Last active
December 28, 2015 13:51
-
-
Save mitchwongho/b095f31fbce492ed6047 to your computer and use it in GitHub Desktop.
Handy Git commands
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
# Configuration | |
## disable mergetool backup files | |
$ git config --global mergetool.keepBackup false | |
# Branch | |
## Show Tracking Branch | |
$ git remote show origin | |
## Create a new branch | |
$ git checkout -b <branch> <remote>/<branch> | |
## Delete local branch | |
$ git branch -D <branch> | |
## Delete remote branch | |
$ git remote delete <branch> | |
## Push All tags to remote | |
$ git push origin --tags | |
## Rename local and remote branch | |
$ git branch -m <old-branch> <new-branch> | |
$ git push origin :<old-branch> | |
$ git push origin <new-branch> | |
# Add to tracking list | |
$ git add . | |
# Commit | |
$ git commit -a | |
## Commit with commit message | |
$ git commit -a -m "This is your commit message" | |
## Amend previous Commit | |
$ git commit -a --amend | |
# Fetch updates from remote | |
$ git remote update | |
# Merge with remote | |
$ git pull <remote> <branch> // e.g. $ git pull origin master | |
# TAGGING | |
## list Tags | |
$ git tag | |
## Add Tag | |
$ git tag -a <tag> -m <message/annotation> | |
## Show Tag Details | |
$ git show <tag> | |
## Delete local tag | |
$ git tag -d <tag> | |
## Apply Deleted Local tag | |
$ git push origin :refs/tags/<tag> | |
## Untrack files/dirs without deleting them | |
$ git rm --cached <file-to-untrack> | |
$ git rm --cached -r <dir-to-untrack/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment