git checkout标记,git pull在分支中失败 [英] git checkout tag, git pull fails in branch

查看:132
本文介绍了git checkout标记,git pull在分支中失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我克隆了一个git仓库,然后签出了一个标签:

I have cloned a git repository and then checked out a tag:

# git checkout 2.4.33 -b my_branch

这是可以的,但是当我尝试运行 git pull 在我的分支中,git吐出这个错误:

This is OK, but when I try to run git pull in my branch, git spits out this error:


当前分支没有跟踪信息。请
指定您想要合并的分支。有关
的详细信息,请参阅git-pull(1)

There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details

git pull <remote> <branch>

如果您希望为这个分支设置跟踪信息,您可以这样做

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream new origin/<branch>


我想 git pull 只更新主分支并保留我当前的分支(无论如何都是标签)。是这样的可能吗?

I want git pull to only update the master branch and leave my current branch alone (it's a tag anyway). Is something like this possible?

我需要这个的原因是我有一个自动脚本,总是git拉仓库,当然因为上面的错误失败..

The reason I need this is that I have a automatic script which always git pulls the repository and of course fails because of the error above..

推荐答案

编辑:对于新版本的Git, - set-上游主人已被弃用,您应该使用 - set-upstream-to 代替:

For newer versions of Git, --set-upstream master has been deprecated, you should use --set-upstream-to instead:

git branch --set-upstream-to=origin/master master






提示时,您可以运行:


As it prompted, you can just run:

git branch --set-upstream master origin/master

之后,您可以简单地运行 git pull 来更新您的代码。

After that, you can simply run git pull to update your code.

这篇关于git checkout标记,git pull在分支中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆