Git rebase a branch onto master failed, how to resolve?

前端 未结 2 1704
半阙折子戏
半阙折子戏 2020-12-30 03:25

I\'ve been working on a local copy of a remote git repo. I created a branch on my local copy, let\'s call it \'my_branch\'. I\'ve committed a few times on my_branch.

相关标签:
2条回答
  • 2020-12-30 03:59

    git rebase has found a .git/rebase-apply directory and so presumes that you might be in the middle of a rebase. This would have happened if there was a conflict during a previous rebase and the rebase was not finished; i.e. you did not run one of git rebase --abort, git rebase --skip or git rebase --continue (the last one after resolving the conflict).

    Anyway, it does not matter how you ended up in this state if you don't think you ran git rebase at all. Simply rm -fr /my_project_directory/.git/rebase-apply as the help suggests and you should be able to do the rebase now.

    But wait. Since you say that you have already published your branch to the remote repository, you should not try to rebase master onto it. In fact, if your remote is set to deny non-fast-forward commits (which seems to be a generally recommended best practice), you'll not even be able to push the rebase'd changes to your remote. In general, it is a bad practice to try to modify a commit (which is what git rebase does) after you have published it to a remote.

    0 讨论(0)
  • 2020-12-30 03:59

    Go to your project directory. Find rebase-apply folder under .git and delete the folder.

    Note : By default .git folder will be hidden.

    0 讨论(0)
提交回复
热议问题