Git rebase circles back to same place again and again

I am having problem with Git rebase that I have to merge the code again and again but still unsuccessful.

I had cut of my branch (A) from master. I started working on my branch and made more commits. At the same time, master was also changed and underwent bunch of commits. Now I am trying to merge my branch back to master.

So I give,

git co master
git pull 
git co branch-A
git rebase master

Now I get messages like CONFLICT : Merge conflict in

With this, it branches into a new branch with name (no branch, rebasing branch-A) After this I resolve all the conflicts and then I give git add of all those files.

Now I get the status

rebase in progress; onto ad0da3f
You are currently rebasing branch 'branch-A' on 'ad0da3f'.
  (all conflicts fixed: run "git rebase --continue")

After this I run git rebase --continue and all the changes which I did to resolve the conflicts are gone and it goes back to the initial state of merging and throwing a huge bunch of Conflicts as before!

My question is,

  • How can I get back all the conflict resolutions that I have done before issuing git rebase --continue?
  • How can I not get stuck into the same loop requiring to merge again and again to pull the changes from master to my branch?
  • After I successfully merge all the changes from master to my branch, to merge my branch back to master, can I simply use,

    git co master git merge branch-A

  • Or do I need to issue any more commands?

    Any help please...


    To me, it's hard to say what is wrong with you, but follow this steps:

  • First, make a backup of the folder where is your project, just if something goes wrong, you yet have the original local repository.

  • Do a pull with rebase in master:

    git checkout master
    
    git pull --rebase origin master
    
  • Rebase your branch with master:

    git checkout branch-A
    
    git rebase master
    
  • And of course, if there is some conflict, resolve the way you are already doing.

  • When I say rebase a branch with itself, I'd like to say update your branch with remote. Of course if only you use branch-A, you don't need do pull or pull --rebase in your local branch. But in master it is a good practice using rebase to avoid merge commits that result from git pull. Of course do rebase cause some implications, for example when you push commits before do a rebase. So, the ideal, is make everything local, and only after rebase you push your branch or merge it with master. See The Perils of Rebasing.

    In my case what I like to do is: after rebasing my feature branch with master, I checkout to master and do git merge <my-branch> --no-ff . This way my git history has a commit merge branch 'my-branch' . And I like my git history this way.

    More information about merge vs. rebase see this answer for the question What's the difference between 'git merge' and 'git rebase'?

    链接地址: http://www.djcxy.com/p/45096.html

    上一篇: 如何在合并请求中删除其他人的提交

    下一篇: Git rebase一次又一次回到同一个地方