git commands
Setting git command alias:
$ git config --global alias.co checkout $ git config --global alias.st status $ git config --global alias.br branch
Update git upstream (tracking remote branch)
$ git branch -u origin/master $ git branch -u origin/master <local branch name>
Cleanup git changes
$ git reset HEAD $ git checkout -- . $ git clean -df
How to squash two changes
Cherry-pick two changes $ git rebase -i Replace second change from "pick" to "squash"
How to checkout a tag
$ git tag $ git checkout -b <local branch name> <tag name>
Creating remote branch
$ git checkout -b <new_branch_name> $ git push origin <branch_name> $ git push origin <local_branch_name>:<remote_branch_name> $ git push -u origin <branch_name> $ git push origin --delete <remote_branch_name> $ git push origin :<remote_branch_name>
- create local branch with new name
- if want to assign a different branch name for the remote server, <local_branch_name>:<remote_branch_name> can be used
- if want to set up a upstream branch, -u option can be used
- If want to remove remote branch, –delete option can be used
- a simpler version is using :<remote_branch_name> which is enabled from git version 1.5