You are not currently on a branch

今天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.

这个报错的意思就是你不在分支上,没办法提交。
你需要创建一个临时分支,基于这个临时分支,将你的代码合并到master分支上。合并后删除这个临时分支就行了。

  1. 首先使用git branch命令查看所在的位置
 git branch
 1. (HEAD detached from bdcfe3a8)
 2. master
 3. issue699

当前位置是:HEAD detached from bdcfe3a8上
2. 创建临时分支,合并代码到master

git branch temp bdcfe3a8     #   依据快照bdcfe3a8  创建 temp 分支
git checkout master          #   切换到 master 分支
git merge temp               #   将 temp 分支合并到 master分支

这个时候代码已经合到master了,可以把临时分支temp 删除

git branch -d temp

猜你喜欢

转载自blog.csdn.net/weixin_42648692/article/details/129038917
今日推荐