Reputation: 11822
Already checked those questions:
When should I use git pull --rebase?
Git commits are duplicated in the same branch after doing a rebase
When will `git pull --rebase` get me in to trouble?
but what i don't understand is that some people say that you should always git pull --rebase
and also others went to setting it as a default option when pulling and others said it's creating a problem.
I'm facing the duplicate commits issue in git log and i guess it's because of --rebasing
in the wrong time where we should only pull
, I know that the difference between git pull
and git pull --rebase
is that git pull is trying to merge both local and remote while git pull --rebase replicate the commits.
Scenarios:
git pull --rebase
or only git pull
? and why?--rebase or git pull
? and why?git pull
or git pull --rebase
? and why ?Thanks
Upvotes: 3
Views: 434
Reputation: 225282
git pull
does two things - a git fetch
followed by git merge
. If you use git pull --rebase
, it instead does git fetch
followed by git rebase
. To answer your specific questions:
If you haven't committed any changes locally, it doesn't matter. The result will be the same. The implicit git merge
will be a fast-forward.
Normally in this case you'd want to rebase; you'd prefer your changes to be linear history on top of what's going on with the remote.
Normally you'd rebase here too. Again, you want your local work to be added on top of the remote's history, not adding merge commits to it.
All of this mess can be avoided by just not working on the remote tracking branch.
Upvotes: 2