今天使用 git pull
和git push
命令,分别报错:
You are not currently on a branch, so I cannot use any
'branch.<branchname>.merge' in your configuration file.
Please specify which remote branch you want to use on the command
line and try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push origin HEAD:<name-of-remote-branch>
这是什么意思呢?
说我当前不是在分支上,因此不能 pull 或者 push
然后利用git branch
查看一下,发现:
git branch
* (HEAD detached from bdcfe3d8)
* master
* issue68
我当前所处的位置是在HEAD detached from bdcfe3d8
上
所以进行如下操作
git branch temp bdcfe3d8
git checkout master
git merge temp
这三行命令的意思是:
- 依据快照bdcfe3d8 创建 temp 分支
- 切换到 master 分支
- 将 temp 分支合并到 master分支
再看一下所有的分支
git branch
* master
* issue68
* temp
这时候就可以进行 git pull
和 git push
了
记得删除 temp 分支哦
git branch -d temp