Page 1 of 1

What is wrong with 'git pull' to update a local source tree

Posted: Fri Sep 07, 2018 12:38 pm
by oldman
I use git pull origin to update my local source tree, but the wiki (https://reactos.org/wiki/ReactOS_Git_For_Dummies) says "We don’t recommend using pull, but rather to use fetch and rebase."

What is wrong with pull?

Re: What is wrong with 'git pull' to update a local source tree

Posted: Fri Sep 07, 2018 1:42 pm
by Fraizeraust
As per these two links:

https://stackoverflow.com/a/7104747
https://www.git-tower.com/learn/git/faq ... h-git-pull

The point being if you have any uncommitted changes in your directory tree, the recommended option is to fetch and rebase your local repository without breaking your local changes. git pull should be used ONLY when your working directory is clean.

Re: What is wrong with 'git pull' to update a local source tree

Posted: Fri Sep 07, 2018 2:12 pm
by oldman
Thanks Fraizeraust.

So for those of us that only use a local copy of trunk to compile, then git pull is OK.

If I have merged a patch into my local copy and want to preserve the merge, but update from master, then I would need to use fetch and rebase.

Is that correct?

Re: What is wrong with 'git pull' to update a local source tree

Posted: Fri Sep 07, 2018 3:17 pm
by Fraizeraust
oldman wrote:So for those of us that only use a local copy of trunk to compile, then git pull is OK.
In this case yes. You can safely do a pull from the upstream "master branch" repository to your origin (forked/local) repository.
oldman wrote:If I have merged a patch into my local copy and want to preserve the merge, but update from master, then I would need to use fetch and rebase.
You're correct. git apply will result to the specific XYZ file (depending on the patch) being un-staged for the commit thus uncommitted. For this matter you've got to fetch your repository which means it'll download the objects and refs from another repository and then rebase.

After all, git pull is basically a combination of "git fetch" and "git merge". git pull is not bad per se, what does it matter the most is WHEN you use it. And when it comes to un-staged file(s) (the modifications done to the file) you have a high chance of probability to get a merge conflict due to "git merge".

Re: What is wrong with 'git pull' to update a local source tree

Posted: Fri Sep 07, 2018 10:23 pm
by hbelusca
Aside note: we want to have linear history (and not a bush-tree history) when stuff is later committed.