1

I have a remote repo with two branches, one for myself and another for my partner's codes.

To merge the differences, I do git pull origin partnersBranch on my local branch. This automatically merges the differences and mark files with conflict markers where auto merge fails.

The problem is, if there is some code in my branch, which does not exist in my partner's branch, git pull overwrites my codes with my partner's code where it should have merged them.

For example, my branch has a new feature. When I git pull origin partnersBranch, the new feature does not exist anymore.

What I can do to prevent this to happen?

blue112
  • 52,634
  • 3
  • 45
  • 54
PPrasai
  • 1,186
  • 13
  • 36
  • you should create a new local branch example localPartnerBranch then merge to root branch then merge your branch to root branch will merge all diff into. – Mithat Konuk Aug 05 '16 at 08:50
  • 3
    @JadeSync you should not use git pull in your situation. You should do "git merge partnerBranch" while on your current branch. This will merge your partner's branch to your current branch. – Klaus Aug 05 '16 at 08:52
  • @Klaus thanks dude. this added conflict markers on my codes so I could manually merge the branches. – PPrasai Aug 05 '16 at 09:19
  • @JadeSync, that's right. The conflict markers indicate that git cannot automatically merge by itself. It does not know what part to remove and what part to keep. This must be manually resolved by human. – Klaus Aug 05 '16 at 16:51

1 Answers1

0

you can use git merge instead of git pull. and you can also try with git rebase branchname, while using rebase you can easily fix the conflicts. click here to know more about rebase

Community
  • 1
  • 1
karthik
  • 305
  • 1
  • 3
  • 14