git rebase后发现命令错误,赶紧ctrl + c撤销操作。重新rebase后提交发现失败,然后就发现了如下的问题。
nemo@Cynthia:~/git_work01/lambda$ git status
Not currently on any branch.
nothing to commit, working directory clean
解决方案如下:
切换到该分支
git checkout origin/dev_s17_1
这时候会发现
nemo@Cynthia:~/git_work01/lambda$ git status
HEAD detached at origin/dev_s17_1
nothing to commit, working directory clean
接着切换到该具体分支:
nemo@Cynthia:~/git_work01/lambda$ git checkout dev_s17_1
Warning: you are leaving 1 commit behind, not connected to
any of your branches:
9a76242 xxxxxxxxxxxxxxxxxxx。
If you want to keep it by creating a new branch, this may be a good time
to do so with:
git branch <new-branch-name> 9a76242
Switched to branch 'dev_s17_1'
Your branch and 'origin/dev_s17_1' have diverged,
and have 1 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
再看状态会发现此时已经回到正常的分支状态下了:
nemo@Cynthia:~/git_work01/lambda$ git status
On branch dev_s17_1
Your branch and 'origin/dev_s17_1' have diverged,
and have 1 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working directory clean
这时候再重新执行rebase,重新提交代码即可。