2

we have two remote repositories for same project origin and sandbox.Now i am in origin master branch and trying to pull sandbox feature branch but i am getting conflict issue.

So how should i rebase my sandbox feature branch on origin master branch? and this is a regular thing so what is the best practice to resolve conflicts in this case? Note: i have already checked similar questions like How to rebase one Git repository onto another one? How to rebase one repo to another

Community
  • 1
  • 1
Vivart
  • 14,900
  • 6
  • 36
  • 74

1 Answers1

4

Go to your origin repo. Add a new remote with sandbox URL. Then rebase sandbox/feature branch into origin/master branch. Then if conflict occurs resolve it.

# go into your origin repo
$ git checkout master
$ git remote add sandbox <sanbox-repo-url>
$ git fetch sandbox

$ git rebase sandbox/feature

If Conflict occurs, then better resolve conflicts manually. You can also accept origin or sandbox changes by --theirs or --ours flag.

$ git status        # see the conflicted files (red color)

# resolve conflicts
$ git checkout --theirs <file-name>    # accept origin changes
Or,
$ git checkout --ours <file-name>      # accept sandbox changes   
Sajib Khan
  • 22,878
  • 9
  • 63
  • 73