-
Notifications
You must be signed in to change notification settings - Fork 5
GIT'n Some Updates
Suppose you already reviewed the GIT'ing Started with git tutorial and have your fork, dev branch, and your many PR branches all happily working together. Now you want to get the latest changes from the upstream fork (mono/MonoGame). How do you do that?
If you followed our advice thus far, then all you need to do is pull a ZIP down of the branch you want from mono/MonoGame and extract that zip onto your pristine fork (yourName/MonoGame). Then you commit those changes and push to your remote repo. That puts your fork'd repo in sync with its upstream fork.
Next, you go to your branches and do a git merge with upstram/MonoGame. Huh?
git merge upstream/MonoGame
You might try the merge tool:
git mergetool upstream/MonoGame
Or if you installed the TortoiseGIT extensions on your Windows machine, you can just use the Tortoise shell interface to merge with the upstream of your branches.
This is by far the easiest way to do things and it is what I've learned to do. You can also try to rebase your fork against the upstream mono/MonoGame fork. I've done that as well, once, and it was not a happy experience. In that regard, you essentially checkout the upstream fork atop your current fork, and then commit/push those changes to your fork.
Just remember that your fork is exactly that, a fork in the road of mono/MonoGame. It's your own repository, not a branch of the main repository. Every commit you make against yourName/MonoGame is just that, your own commits. Don't be afraid to commit there, but be careful to keep the master revision of yourName/MonoGame pristine and in sync with the upstream fork.
Words to remember:
fork : Your own repository
upstream : The parent of your current branch
master : The ROOT of your repository
head : The current revision branch on which you work
detached head : A confusing state where you are trying to move the head revision from one branch to another.
stash : Something you do (git stash) when you want to shelve your changes and revert your branch to the current head revision.
Google is a wealth of information for git. There are countless tutorials on how to use git from the shell, and mostly none that show you how to use it from a UI. Use the shell, know the commands, and keep many copies of your source around. In the svn/cvs world, you usually had one copy of code. Those days are gone. You will need at least 3 copies of your repository: 1 - pristine master, 2 - dirty dev branch, 3+ - PR branch for sharing.
By the way. If you did choose to update your master fork with the upstream fork from mono/MonoGame, then you would need to use:
git fetch
More can be learned at http://www.kernel.org/pub/software/scm/git/docs/git-fetch.html