Is there some kind of 'git rebase --dry-run', which would notify me of conflicts in advance?

后端 未结 5 2148
野的像风
野的像风 2020-12-13 23:54

I\'m trying to script rebasing and my script will take different paths depending on if the rebase results in any conflicts.

Is there a way to determine if a rebase w

5条回答
  •  Happy的楠姐
    2020-12-14 00:10

    If you just want to see if the rebase would be successful but then you want to "roll back," you can alway reposition the branch tip back to the original commit. Just tag or make a note of the original SHA.

    Or perhaps easier, create a new temporary branch in which to "stage" the rebase:

    git checkout your-branch
    git checkout -b tmp
    git rebase other-branch
    

    If it was successful but you want to "roll back," your-branch is untouched. Just git branch -D tmp and you're back to where you started from.

    If there were conflicts and you did some work to resolve them and you now you want to keep the rebase, just reposition your-branch tip to tmp (and then git branch -D tmp).

提交回复
热议问题