git - 新用户尝试拉取并收到一些令人困惑的消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12054223/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git - new user trying to do pull and getting some confusing messages
提问by GeekedOut
I am pretty new to git. I have been primarily checking stuff into a repository, but now I want to get the latest changes from another developer.
我对 git 很陌生。我主要是将东西检查到存储库中,但现在我想从另一个开发人员那里获得最新的更改。
I tried to simply do a command like git pull
something ran, but it came back with a message like this:
我试图简单地执行一个命令,比如git pull
运行的东西,但它返回了一条这样的消息:
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 develop origin/<branch>
So then I did git pull my_branch_name
所以我做了 git pull my_branch_name
and it came back with this:
它回来了:
fatal: 'develop' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
but I had done git checkout my_branch
right before that.
但我git checkout my_branch
在那之前就做了。
Could someone please let me know what I did wrong and how I can simply get the latest files that had been checked in?
有人可以让我知道我做错了什么以及如何简单地获取已签入的最新文件吗?
Thanks!
谢谢!
采纳答案by davids
I think you missed the name of the remote when pulling:
我认为您在拉动时错过了遥控器的名称:
git pull <remote> my_branch_name
Run this command:
运行此命令:
git remote -v
And check what is the name of the remote you want to pull from
并检查您要从中拉出的遥控器的名称是什么
EDIT:
编辑:
If you are new to Git, I would recommend you this book. It covers from basic to advanced topics, is easy to understand and to read
如果您是 Git 新手,我会向您推荐这本书。它涵盖了从基础到高级的主题,易于理解和阅读
回答by bcmcfc
As the first error message indicated, you need to tell git where to look when it pulls for that branch:
正如第一条错误消息所示,您需要告诉 git 在拉取该分支时要查看的位置:
In Git 1.8 and up, ensure you've checked out develop and run:
在 Git 1.8 及更高版本中,确保您已检查开发并运行:
git branch --set-upstream-to origin/develop
git branch --set-upstream-to origin/develop
or the shorter:-
或更短的:-
git branch -u origin/develop
git branch -u origin/develop
In Git prior to version 1.8:
在 1.8 版之前的 Git 中:
git branch --set-upstream develop origin/develop
git branch --set-upstream develop origin/develop
Once you've done that you can git pull
without having to specify the remote or the branch.
完成后,您git pull
无需指定远程或分支即可。
If the remote origin is not yet set up, first run:
如果尚未设置远程源,请先运行:
git remote add origin url
git remote add origin url
回答by navins
try this command:
试试这个命令:
git pull origin master
git push -u origin master
回答by Akash Kandpal
You could specify what branch you want to pull:
您可以指定要拉取的分支:
git pull origin master
Or you could set it up so that your local master branch tracks github master branch as an upstream:
或者您可以设置它,以便您的本地 master 分支将 github master 分支作为上游跟踪:
git branch --set-upstream-to=origin/master master
git pull
This branch tracking is set up for you automatically when you clone a repository (for the default branch only), but if you add a remote to an existing repository you have to set up the tracking yourself. Thankfully, the advice given by git makes that pretty easy to remember how to do.
当您克隆存储库(仅适用于默认分支)时,会自动为您设置此分支跟踪,但是如果您将远程添加到现有存储库,则必须自己设置跟踪。值得庆幸的是,git 给出的建议让你很容易记住该怎么做。
--set-upstream is deprecated in git 1.9.x, apparently. Going forward you'd want to use something like
--set-upstream 显然在 git 1.9.x 中已弃用。展望未来,你会想要使用类似的东西
git branch -u origin/master
assuming you've checked out master already. If not,
git branch -u origin/master master
will work
假设您已经签出 master 。如果没有,
git branch -u origin/master master
将工作
回答by user2493807
What I like to do is...
我喜欢做的是...
$ git checkout master
$ git pull
$ git checkout <remotebranch>
$ git rebase master