You are not currently on a branch. Please specify which branch you want to merge with.

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/whm18322394724/article/details/86063806

*前言

  前两天在使用Git提交代码时,我本地显示没什么可提交的了,但其他同事那却看不到我的代码提交记录,于是我就在自己本地再次尝试pull,看能更新下来他们的代码嘛,结果提示我merge,当时也没仔细看merge啥,以往merge那个文件是可以点开的,这次也没有,我再次pull时,pull和push的按钮都变成了灰色,我用命令pull时就提示“You are not currently on a branch. Please specify which branch you want to merge with”,然后百度了一下,其实是我此时本地代码的版本已经不在master主分支上了。如何解决此问题呢,详情请见下文!

*问题

remote: Counting objects: 159, done.
remote: Total 159 (delta 12), reused 115 (delta 12)
Receiving objects: 100% (159/159), 83.11 KiB | 842.00 KiB/s, done.
Resolving deltas: 100% (12/12), done.
From code.aliyun.com:lidabsky/nsbd
   a238209b..29844093  dev        -> origin/dev
You are not currently on a branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

*解决

#1、查看所有变化的文件,把有改动的先删除。
git status

#2、切回master主分支
git checkout master

#3、更新最新的代码
git pull

#4、切回之前使用的dev分支
git checkout dev

参考文章:git错误You are not currently on a branch

没有更多推荐了,返回首页