3

I am trying to rebase but my branch got diverged. It seem to be a common problem. I tried few approaches.

First Approach

I ran these commands

git checkout master
git fetch origin
git reset --hard origin/master

git checkout feature
git pull origin feature
git rebase master

And then I tried to rebase I got the below issue

On branch feature
    Your branch and 'origin/feature' have diverged,
    and have 47 and 42 different commits each, respectively.
      (use "git pull" to merge the remote branch into yours)
    
    nothing to commit, working tree clean

2nd Approach

I also tried to delete the feature and master branch. And fetch the latest of both of the branches still the issue persist

git branch -D master
git branch -D feature
git fetch --all
git checkout master
git checkout feature
git rebase master

once I ran the last command and then check the git status I got the same issue as mentioned above

Any help is appreciated

Aniket Tiwari
  • 3,561
  • 4
  • 21
  • 61
  • You should expect this after rebase: that's what "rebase" *means*. A rebase operation is used when you have some existing commits that you like some aspects of, but dislike others. The rebase takes the existing commits and copies them to new and improved replacements. *Your* repository then abandons the originals in favor of the replacements. *Other* repositories still have the originals (only). – torek Feb 02 '22 at 08:26
  • The fact that you are now using commits that they don't even have, and they are still using the old commits instead, is *why* some people *don't* use rebase ever, and why others are careful about *when* they use rebase. You, with your repository, and they—whoever they are—with their repository or repositories, must coordinate your work with each other so that you and they cooperate rather than compete. – torek Feb 02 '22 at 08:28
  • 2
    It is impossible for us to safely guide you because what you're describing is both normal and benign. It is only a problem if the situation was not expected or you arrived in this situation and you weren't supposed to. There's nothing inherently bad about it. As such, it is impossible for us to tell you how to fix "it" because we don't really know what the actual problem is. Your situation is that your branch has 47 commits that haven't been merged into master, and master has 42 commits that were added after your branch was created. Now, what do you want to do about this? – Lasse V. Karlsen Feb 03 '22 at 07:41

0 Answers0