- Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git- Make sure that you're on your master branch:
git checkout master- Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:
git fetch upstream- Rewrite your master branch so that any commits of yours that aren't already in upstream/master are replayed on top of that other branch:
git rebase upstream/master or git merge upstream/masterNote: 3 and 4 can be simplified by
git pull upstream master or git pull --rebase upstream master- If your git history has been rewritten, you need
forcepush. Otherwise a normalpushwill do.
git push -f origin master or git push origin master- get the latest from remote
$ git checkout master
$ git pull or git pull --rebase- develop by creating a new branch
$ git checkout -b pr-cool-feature-
DO THE WORK!!!
-
When you are done. get the updates again.
$ git checkout master
$ git pull or git pull --rebaseif open source project or similar nature
$ git fetch upstream
$ git rebase upstream/masterand then push
- rebase from feature branch, you may also resolve any conflict and squash commits
$ git checkout pr-cool-feature
$ git rebase master- rebase from master
$ git checkout master
$ git rebase pr-cool-feature- then push it
$ git push- add tag
git tag <tagname>
git tag -a <tagname> -m '<message>'- push tag/tags
git push origin <tag_name> // single tag
$ git tag # see tag lists
$ git push origin <tag-name> # push a single tag
$ git push --tags # push all local tags $ git push -d <remote_name> <branch_name>
$ git branch -d <branch_name>$ git config --global push.default current
$ git config --global pull.rebase true
$ git push origin pr-cool-feature # push the current branch to orgin
$ git push origin HEAD # push the current branch to orgin