setup git credentials store
$ git config credential.helper store $ git config credential.helper store --file=github
merge and rebase
Atlassian Merge vs Rebase tutorial.
Rename local and remote branch
Taken from here.
### Rename local branch $ git branch -m new-name ### Rename local branch if you are on a different branch $ git branch -m old-name new-name # Remove old remote and push new local branch $ git push origin :old-name new-name ### Reset upstream branch for thew name, switch to the new local $ git push origin -u new-name
REMOVE LOCAL AND REMOTE BRANCHES
### Remote
$ git push --delete <remote_name> <branch_name>
### Or
$ git branch -rd <branch_name>
### Local
$ git branch -d <branch_name>
merge
### Squash merge $ git checkout develop $ git merge --squash feature/branch
Revert
### Revert to a specific commit $ git checkout -f COMMITID -- . $ git commit -a ### Revert a specific commit $ git revert --no-commit COMMITID
git flow
Nice git flow cheatsheet.
git stash
Good tutorial from Atlassian.
git submodules
Good tutorial from Jon Cairns.
Export existing git project to Github/Bitbucket
More details see on How can I export the project in Eclipse to a GitHub repository:
# github $ git remote add origin git@github.com:<username>/<reponame>.git # bitbucket $ git remote add origin https://<username>@bitbucket.org/<username>/<reponame>.git $ git push -u origin master
Find branch point
Taken from stackoverflow:
$ git log --pretty=oneline master > 1 $ git log --pretty=oneline branch_A > 2 $ git rev-parse `diff 1 2 | tail -1 | cut -c 3-42`^