user496949
user496949

Reputation: 86185

Why do we need to git push first before git pull?

I have both local changes and remote changes.

Someone told me I must do push first, then pull. Any reason behind this?

Upvotes: 16

Views: 11150

Answers (1)

Atropo
Atropo

Reputation: 12561

That person is wrong: the right model is pull-before-you-push and not the reverse.

When you pull, git will fetch commits on origin and will try to fast-forward your local commits on top of them, doing the merge. After that you can push in this way you will not generate conflicts with other updates.

Upvotes: 41

Related Questions