Skip to content

Instantly share code, notes, and snippets.

@seixasfelipe
Last active May 25, 2017 03:07
Show Gist options
  • Save seixasfelipe/5654237 to your computer and use it in GitHub Desktop.
Save seixasfelipe/5654237 to your computer and use it in GitHub Desktop.
Git tips to never forget!
Git
============
To delete a remote branch:
$ git push origin :name_of_remote_branch
To rebase master on another branch and checkout it when action is completed
$ git rebase master :name_of_branch
To add local branch ref on remote
$ git
To Undo commit and redo
$ git commit ... (1)
$ git reset --soft HEAD~1 (2)
<< edit files as necessary >> (3)
$ git add .... (4)
$ git commit -c ORIG_HEAD (5)
To undo modified file to HEAD
$ git checkout -- CONTRIBUTING.md
To untrack changes on file
$ git update-index --assume-unchanged "Source\Infrastructure.Repositories.IntegrationTests\connectionStrings.config"
To edit multiples commits or messages
$ git rebase -i HEAD~6
$ git commit -amend
$ git rebase --continue
http://schacon.github.io/history.html
To view diff between commits
# diff between commits 14b8... and b410...
$ git diff 14b8..b410
# only include diff of specified files
$ git diff 14b8..b410 path/to/file/a path/to/file/b
If you want to get an overview over all the differences that happened from commit to commit, use git log or git whatchanged with the patch option (-p)
# include patch displays in the commit history
$ git log -p
$ git whatchanged -p
# only get history of those commits that touch specified paths
$ git log path/a path/b
$ git whatchanged path/c path/d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment