Created
October 21, 2015 02:28
-
-
Save gigenthomas/1e4a9ab500119ab260d4 to your computer and use it in GitHub Desktop.
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 commit -a -m 'added new benchmarks' | |
automatically stage every file that is already tracked before doing the commit, letting you skip the git add part: | |
Rename a file in git | |
$ git mv file_from file_to | |
Show a history of commits | |
$ git log -p -2 | |
ption displays the same information but with a diff directly following each entry | |
$ git log --stat | |
One of the common undos takes place when you commit too early and possibly forget to add some files, or you mess up your commit message. If you want to try that commit again, you can run commit with the --amend option: | |
$ git commit --amend | |
Unstage a staged file | |
git reset HEAD CONTRIBUTING.md | |
unmodify a modified file | |
git checkout -- CONTRIBUTING.md | |
show remotes | |
git remote -v | |
remote name , branch name | |
$ git push origin master | |
Inspecting a remote | |
$ git remote show origin | |
Tags | |
Lightweight | |
annotated | |
git tag -a v1.4 -m 'my version 1.4' | |
Show tags | |
git show v1.4 | |
By default, the git push command doesn’t transfer tags to remote servers. You will have to explicitly push tags to a shared server after you have created them. This process is just like sharing remote | |
git push origin v1.5 | |
git push origin --tags | |
checking out tags | |
you can’t really check out a tag in Git, since they can’t be moved around. If you want to put a version of your repository in your working directory that looks like a specific tag, you can create a new branch at a specific tag with git checkout -b [branchname] [tagname]: | |
$ git checkout -b version2 v2.0.0 | |
Switched to a new branch 'version2' | |
You can run your tests, make sure the hotfix is what you want, and merge it back into your masterbranch to deploy to production. You do this with the git merge command: | |
Merge hotfix into master | |
$ git checkout master | |
$ git merge hotfix | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment