Last active
July 13, 2017 14:21
-
-
Save fracasula/42bfd83369dd10e53a66 to your computer and use it in GitHub Desktop.
Git Vademecum - AKA Cheat Sheet
This file contains hidden or 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
| # Create a branch | |
| cd master/ | |
| git branch branch_name | |
| git checkout branch_name | |
| git push origin branch_name | |
| # Create and switch to a new branch | |
| cd master/ | |
| git checkout -b branch_name | |
| git push origin branch_name | |
| # Delete a branch | |
| cd master/ | |
| git push origin --delete branch_name | |
| # Merge master into branch (updates branch code with the latest master changes) | |
| cd branch/ | |
| git merge origin/master | |
| git push | |
| # Merge branch into master | |
| cd master/ | |
| git merge branch_name | |
| git push | |
| # Switch branch | |
| cd branch/ | |
| git checkout another_branch | |
| git pull | |
| # Force pull with overwrite | |
| git fetch --all | |
| git reset --hard origin/master # OR git reset --hard branch_name | |
| # Creating a tagged branch | |
| cd master/ | |
| git checkout -b v1.0.1 | |
| git push origin v1.0.1 | |
| git tag -a 1.0.1 -m "version 1.0.1" | |
| git push origin 1.0.1 | |
| # Deleting a tag | |
| git tag -d branch_name | |
| git push origin :refs/tags/branch_name | |
| # Forcing a push | |
| git push origin branch_name --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment