git pull提示You are not currently on a branch. Please specify which

  在想拉取最新的git代码时提示要输入远端分支。具体提示见以下:

[root@cn-hxh-ope gamecode]# git pull

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>

  

  这里的原因是因为不在master分支,在tag或者其它分支上。使用git branch查看,目前在一个tag上。

  这里解决方式有2种。

1.查看所有变化的文件,把有改动的先删除。
git status
2.切回master主分支
git checkout master
3.更新最新的代码
git pull
4.切回之前使用的tag/分支
git checkout dev

  或者更简单的方式,直接指定分支或者同步的tag名称

git pull origin 1.21.20200820170006_1.21.20200826143407

作者:小家电维修

相见有时,后会无期。

原文地址:https://www.cnblogs.com/lizexiong/p/15432796.html