Skip to content

Instantly share code, notes, and snippets.

@nikku
Last active December 30, 2015 03:38
Show Gist options
  • Save nikku/7770279 to your computer and use it in GitHub Desktop.
Save nikku/7770279 to your computer and use it in GitHub Desktop.
Git awesome hacker shortcuts

Pull

Pull changes into the local repository.

  • Pull upstream changes from <remote name>/<branch name> and perform a rebase on current branch instead of merging it (via). Useful to update+merge pull requests.

    git pull --rebase <remote name> <branch name>
    

Tags

  • Remove remote tag <tag name> (via)

    git tag -d <tag name>
    git push origin :refs/tags/<tag name>
    

Cherry Pick

Grab a number of commits and put them on top of your current working tree.

Secrets

  • last <n> commits from branch <branch name>

    git cherry-pick B~<n>..~<branch name>
    

Notes

There may be merge conflicts that need to be resolved. Resolve them and continue the cherry picking via

git cherry-pick --continue

Cleanup

Cleanup all local, non-ignored files (that could otherwise be added via git add).

git clean -df .

No more Merges

Use rebase to origin/master or clean master branch instead of merge for less merge commit noise in commit logs and happier contributors.

Instead of merging (during pull)

git commit -m "work done"
git pull

merge conflicts foo
...

git commit -m "merged changes from upstream"

perform a rebase

git commit -m "work done"
git fetch origin
git rebase origin/master

merge conflicts foo
...

git rebase --continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment