This example is after the octocat example on the github website under ‘step 3: configure remotes’:
git remote add upstream git://github.com/octocat/Spoon-Knife.git
git fetch upstream
As far as I understand after doing these commands the changes the github user octocat has made since I cloned the repo are now implemented in my local repo of the project.
But suppose that after I execute the above commands the user octocat again makes changes in the project.
Q1: Will all changes now be updated automatically to my local folder? (I suspect not)
If the answer to Q1 is no:
Q2.1: In order for me to update the new changes again, do I only need to execute the single command git fetch upstream again to update the new changes?
Q2.2: Can I get a log of only those changes done in that latest fetch?
Q1: No. Git does not poll the remotes for changes. You have to command git to pull down changes with
git fetch(or pull).However, if your branch is tracking the remote branch (and it likely is), then when you issue
git statusgit will tell you whether you branch is ahead or behind the remote. If you’re ahead, then you’ve made commits while nothing has changed on the remote. If you’re behind, then new commits have been added to the remote.Q2: Yes. However, be aware that
git fetchonly pulls the changes down. It does not merge them into your current branch. So until you actually merge them, you won’t “see” the changes. They live in a separate branch – in this case, upstream/master (assuming master is the branch in question).When you’ve examined the changes and you’re ready to merge them in to your local branch, you can do so with:
Q2.2: Yes. This is why doing
git fetchis useful. It makes it easy to see what the changes are, versusgit pull, where it does the fetch and merge in one operation. While you still can get a list of the changes in that case, it’s slightly more difficult.In your case, where you are doing a git fetch, to see the changes made, do
git diff upstream/master.