我克隆了一个远程repo,然后进行了git pull。这是有效的。然后我转到我们的开发分支(不是我创建的(
git checkout somebranch/develop
现在我想提取这个分支的最新副本:
$git status
On branch somebranch/develop
nothing to commit, working tree clean
$git pull
并得到:
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
什么?我只想让它获得这个分支的最新版本!
$ git remote -v
origin https://dev.azure.com/org/proj/_git/proj(fetch)
origin https://dev.azure.com/org/proj/_git/proj(push)
我也试过这个:
git pull origin somebranch/develop
但这给出了:
fatal: Couldn't find remote ref somebranch/develop
这毫无意义——我可以在https://dev.azure.com/门户,所有其他开发者都在使用它
我只是做了克隆,切换到一个分支,现在我想获得该分支的最新版本。我没有做过其他命令。
此外,当我刚做"git pull"时,它下载了大量更改。
如果我做"gitbranch-a"我看到:
remotes/origin/somebranch/develop
$ git branch -vv
给出:
somebranch/develop 7b2abd41b [origin/somebranch/develop: behind 92] V1/V2 SitePageData merge
问题是,如何提取此分支的最新版本?从其他开发者更改的azure git repo中获取非master分支的最新版本的命令或命令集是什么?或者总是需要手动进行上游跟踪才能获得分支的最新版本,在这种情况下,git checkout为什么不为您做这件事?
您需要设置上游跟踪:
git branch --set-upstream-to=origin/somebranch/develop somebranch/develop
看起来你的分支没有"远程对应方"——一个通常(默认情况下(看起来像origin/somebranch/develop
的分支
你可能想先检查一下这个假设:
git branch -vv | grep somebranch/develop
如果它有一个远程分支"链接"到它(用git表示的上游分支(,你应该看到类似的东西
somebranch/develop <sha1> [origin/somebranch/develop] <last commit message>
否则它看起来像:
somebranch/develop <sha1> <last commit message>
在这种情况下,您应该"链接"上游跟踪。技术上这样做的问题已经在这里得到了回答
可选地,您可以在实际命令之前运行
git fetch --all # just to make sure you have an information about this branch