Created
September 2, 2012 06:30
-
-
Save yifanz/3595355 to your computer and use it in GitHub Desktop.
Notes on common git operations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Undo last commit and put changes into staging | |
git reset --soft HEAD^ | |
# Change the last commit | |
git commit --amend -m "Oops, forgot to add this to last commit" | |
# Totally undo the last commit | |
git reset --hard HEAD^ | |
# Undo local changes to a file | |
git checkout -- index.html | |
# Add/remove a remote repository | |
git remote add somerepo https://github.com/somerepo.git | |
git remote rm somerepo | |
# show remote repositories | |
git remote -v | |
# Send local changes to remote repo, the -u makes this the default remote next time you can just run git push | |
git push -u somerepo master | |
# Diff the working copy with the index | |
git diff | |
# Diff the index with HEAD | |
git diff --cached | |
# Diff the working copy with HEAD | |
git diff HEAD | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment