0

I'm quite new to Git and is trying to learn as much as possible. I tend to end up in this situation where my local branch is behind the origin repo on Github. It seems as I have two options: To merge or to rebase to get in sync. Which should I use?

In the picture below, my local is the pink one.

enter image description here

Michael
  • 199
  • 2
  • 10
  • If your local branch is behind the origin a lot, it could be a symptom of misunderstanding git. Basically, if you are developing *anything*, you should (a) branch off the appropriate spot, (b) develop in that branch (c) update your target branch (be this master or stable or what have you), (d) merge the dev branch, and finally push. Or better, push your dev branch and open a Pull Request – D. Ben Knoble Jan 28 '18 at 13:59
  • Github has a great article on the way you can work with branches: https://guides.github.com/introduction/flow/ – Jess Bowers Feb 14 '18 at 15:21
  • Possible duplicate of [Git workflow and rebase vs merge questions](https://stackoverflow.com/questions/457927/git-workflow-and-rebase-vs-merge-questions) – Jess Bowers Feb 14 '18 at 15:22

1 Answers1

1

Both are good option, but using rebase is preferred as it result in applying each commit one after the other by which you can fix the conflict one after the other rather than fixing all conflict at once while doing merge in which you will be confused if there are many conflicts.

deepak thomas
  • 1,118
  • 9
  • 23