16

I have both local changes and remote changes.

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

random
  • 9,774
  • 10
  • 66
  • 83
user496949
  • 83,087
  • 147
  • 309
  • 426
  • 14
    This person is wrong. Your changes will not be accepted by the remote. You need to *pull* before pushing, not the other way around. – Nick Tomlin Sep 26 '13 at 15:37

1 Answers1

41

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.

Atropo
  • 12,231
  • 6
  • 49
  • 62