git fetch 在控制台上不显示任何内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17418770/
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 fetch shows nothing on console
提问by Crystal
We are following this model of using git: http://nvie.com/posts/a-successful-git-branching-model/
我们遵循这种使用 git 的模型:http: //nvie.com/posts/a-successful-git-branching-model/
I'm trying to learn to use git fetch and git merge on the specific merge instead of just pulling. For my question, what I did was made changes to a branch and pushed those changes to the branch. I see those changes on github. Then I switch to master to fetch those changes. So I
我正在尝试学习在特定合并上使用 git fetch 和 git merge 而不是拉。对于我的问题,我所做的是对分支进行更改并将这些更改推送到分支。我在 github 上看到了这些变化。然后我切换到 master 来获取这些更改。所以我
git checkout master
git fetch // terminal shows nothing
git fetch origin // terminal shows nothing
Am I using the commands correctly for fetching? I don't see anything on the console. But then when I use a tool like SourceTree, and I fetch, it updates their tree and I can see the changes.
我是否正确使用命令来获取?我在控制台上看不到任何东西。但是当我使用 SourceTree 之类的工具并获取时,它会更新它们的树,我可以看到更改。
Assuming I get this next step to work, and I see the different changes were made, do I just do a git merge <hash of the last commit or commit I want to merge in>
? Thanks!
假设我完成了下一步工作,并且我看到进行了不同的更改,我是否只做一个git merge <hash of the last commit or commit I want to merge in>
?谢谢!
采纳答案by VonC
Regarding the last part, as mentioned in "Fun with FETCH_HEAD", you can do:
关于最后一部分,如“ Fun with FETCH_HEAD”中所述,您可以执行以下操作:
$ git fetch git://repo.or.cz/stranger.git for-junio
$ git log -p ..FETCH_HEAD
$ git merge FETCH_HEAD
Because "
pull
" is "fetch + merge
", we are explicitly decomposing the operation into two steps."
fetch
" leaves the information on the branch it found on the other side inFETCH_HEAD
, which you can use as to name the commit object sitting at the tip of the branch.
"git log -p ..FETCH_HEAD
" (notice the double dots) lets you view the commits he has but not in your branch with their changes in patch form to inspect what he did was sensible.
If you are satisfied, you can useFETCH_HEAD
to merge the commit in to your branch.
因为“
pull
”是“fetch + merge
”,我们明确地将操作分解为两个步骤。"
fetch
" 将它在另一侧找到的分支的信息留在 中FETCH_HEAD
,您可以使用它来命名位于分支尖端的提交对象。
“git log -p ..FETCH_HEAD
”(注意双点)让您可以查看他拥有但不在您的分支中的提交,以及他们以补丁形式进行的更改,以检查他所做的是否合理。
如果您满意,您可以使用FETCH_HEAD
将提交合并到您的分支中。
(See for instance this answer)
(例如参见这个答案)
As detailed in "How Do I 'git fetch
' and 'git merge
' from a Remote Tracking Branch (like 'git pull
')", you don't have to use FETCH_HEAD if you have a upstream branchdefined:
如“我如何从远程跟踪分支(如‘ ’)git fetch
’和‘ git merge
’中git pull
详述,如果您定义了上游分支,则不必使用 FETCH_HEAD :
git fetch origin
git merge origin/an-other-branch
git fetch origin an-other-branch
stores the fetched tip inFETCH_HEAD
, but notorigin/an-other-branch
(i.e. the usual ‘remote tracking branch').
So, one could dogit fetch origin an-other-branch && git merge FETCH_HEAD
.
git fetch origin an-other-branch
将获取的提示存储在FETCH_HEAD
, 但不是origin/an-other-branch
(即通常的“远程跟踪分支”)。
所以,一个人可以做到git fetch origin an-other-branch && git merge FETCH_HEAD
。
For the first part, make sure your branch has an upstream branch setto your remote upstream repo.
对于第一部分,请确保您的分支将上游分支设置为远程上游存储库。
回答by Asenar
git fetch
or git fetch origin
are fine, but if there is nothing to do, nothing is displayed.
git fetch
或git fetch origin
都很好,但如果无事可做,则不显示任何内容。
You can use git fetch -v
to be more verbose and display more informations
您可以使用git fetch -v
更详细并显示更多信息
回答by xtian
I found this because I was having a similar problem. I don't know the whys, but in my case I needed to explicitly name the branch which was updated:
我发现这个是因为我遇到了类似的问题。我不知道为什么,但就我而言,我需要明确命名更新的分支:
$ git fetch [origin] [branch]
Let me explain--I use git for small scripts. I start the repo with master
. After the script is deployed in production, and I still want to work on it, I will make a dev
branch. But most projects just have one branch, or I just don't keep dev
once merged.
让我解释一下——我将 git 用于小脚本。我用master
. 脚本部署到生产中后,我还想继续工作,我会做一个dev
分支。但是大多数项目只有一个分支,或者我只是dev
合并后不保留。
Today, I updated remote master with a few minor changes, and wanted to update my local system with the changes. Out of habit, I just did $ git fetch
. Nothing happened. Then I found your post. First, I added the project name (origin) and did $ git fetch [origin]
. This updated both dev and master to the last time they shared a merge back in January. Then, OH! I ran $ git fetch [origin] master
, and the changes were now downloaded.
今天,我用一些小的改动更新了远程主机,并想用这些改动来更新我的本地系统。出于习惯,我只是这样做了$ git fetch
。什么都没有发生。然后我找到了你的帖子。首先,我添加了项目名称(来源)并执行了$ git fetch [origin]
. 这将 dev 和 master 都更新到了他们在 1 月份共享合并的最后一次。然后,哦!我跑了$ git fetch [origin] master
,现在下载了更改。