Created
June 5, 2015 05:49
-
-
Save drschwabe/af81af2c32519a78ae2e to your computer and use it in GitHub Desktop.
Git cheatlist
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
git clone | |
git status //< Check to see if git has acknowledged your modifications. | |
git diff //< See what you've changed | |
git add . | |
(or git add -u if you removed files) | |
git commit -m "Your commit message" | |
git log //< Verify your commit is applied. | |
git push | |
git pull //< For later, if someone else pushed commits | |
And if you want to do work without affecting master branch : | |
git checkout -b //< Creates a new branch, and switches to it | |
git checkout master //< Switch back to master | |
git merge someBranch //< Merge your changes/commits in someBranch to master | |
And some handy tricks: | |
git add . | |
git commit --amend | |
Add more changes to your previous commit, this let's you update the commit description too | |
(important: only should be done if you haven't pushed yet) | |
GIT_COMMITTER_DATE="`date`" git commit --amend --date "`date`" | |
Updates your last commit with the current date and time. | |
git reset --hard | |
Resets your directory; wiping any changes you made. | |
git reset --hard HEAD^ | |
Deletes the current commit, effectively rolling back a commit. Use HEAD~5 to roll back 5 commits, or any number. | |
git rebase -i HEAD~3 | |
Let's you interactively "squash" any number (ex: 3) commits into one, or pick and choose which ones to squash or keep separate; useful for consolidating a bunch of commits. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment