-5

There are 2 repo upstream(main repo) and origin(my repo). PR has merge conflict and to resolve it executed below commands

Step 1. On master branch

Step 2. git pull origin master

Step 3.git checkout my_branch

Step 4. git rebase master

Step 5.git status

Your branch and 'my_branch' have diverged, and have 118 and 106 different commits each, respectively. (use "git pull" to merge the remote branch into yours)

please help as the branch is displaying a lot of commits from different developers. If the process is incorrect please guide.

Edric
  • 24,639
  • 13
  • 81
  • 91
  • 2
    This question has nothing to do with java, javascript or selenium. Remove those tags. – S Ahmed May 03 '19 at 20:50
  • Have you tried `git rebase origin/master -i` – chevybow May 03 '19 at 20:59
  • Thanks for the reply. I tried "git pull --rebase" in my_branch and after this command, it displays around 400 commits in my_branch. It gives below message Your branch and 'my_branch' have diverged, and have 118 and 106 different commits each, respectively. (use "git pull" to merge the remote branch into yours) nothing to commit, working tree clean – Amita j May 03 '19 at 21:34

1 Answers1

1

Once you have rebase your PR branch on top of the updated master, all you have to do is push it back.

Since the rebase has rewritten the history of that PR branch, you can simply, ofr the PR branch, force push it

git checkout my_pr_branch
git push --force

That will update the PR.
Since the PR branch has been rebased on top of master, it will be trivial to be integrated by the maintainer of the original repo to the master branch (fast-forward merge)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for the reply.Does this squash the multiple commits into one commit after pushing . – Amita j May 04 '19 at 11:55
  • @Amitaj Only if you have squashed them locally (https://stackoverflow.com/a/2427520/6309). But even if you didn't, the maintainer can still squash them on merge: https://help.github.com/en/articles/about-pull-request-merges#squash-and-merge-your-pull-request-commits – VonC May 04 '19 at 11:59
  • Can we execute the command "git pull --rebase" on the pr branch as when I did this it pulled all the 400 commits in my PR branch and when pushed everything got pushed to the PR because of which I have the decline the PR.hence can we say that git pull --rebase should not be executed on pr branch anytime – Amita j May 04 '19 at 12:19
  • @Amitaj Yes, you should rebase your PR branch on top of upstream/master. – VonC May 04 '19 at 13:39