Git

Oh shit, git!

Clear all unstaged changes, including ignored files:

> git clean -dfx

Find removed file:

> git log --all --full-history -- **/thefile.*

Git pull and rebase:

> git pull --rebase

Config Git to do a stash before pull and rebase automatically:

# Once
> git pull --rebase --autostash
# Permanent
> git config pull.rebase true
> git config rebase.autoStash true

Undo latest unpushed commit:

> git commit -m "Something terribly misguided"              (1)
> git reset HEAD~                                           (2)
<< edit files as necessary >>                               (3)
> git add ...                                               (4)
> git commit -c ORIG_HEAD                                   (5)

Find and restore a deleted file:

Remove all local branches that have been merged into the branch currently checked out:

Remove untracked branches (replace -D with -d to only remove fully merged branches:

Staging Patches:

Undo Patches:

Replace remote with local branch:

Modify a specific commit:

Last updated

Was this helpful?