出现下面字样,代表git出现了游离分支:
ubuntu16@ubuntu16-virtual-machine:linux-5.4$ git branch
* (HEAD detached from c58b1a8)
...
方法如下:
- 新建一个临时 temp 分支,把当前提交的代码放到整个分支
git branch temp
git checkout temp
- 换回要回到的那个分支,这里是 master
git checkout master
- 然后 merge 刚才创建的临时分支
git merge temp
Updating cad0be9..2437c6b
Fast-forward
......
- 检查是否有冲突,没有冲突就提交到代码仓
git push origin master
- 删除临时分支
git branch -d temp