哪里可以找到由于`git fetch`引起的变化
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10678495/
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
Where to find changes due to `git fetch`
提问by epsilones
I didn't want to lose some information after a git pull
, so I did a git fetch
before. Where can I read the new modifications after a git fetch
? I went to the FETCH_HEAD
file, but there was nothing more than a big number.
我不想在 a 之后丢失一些信息git pull
,所以我git fetch
之前做了一个。之后在哪里可以阅读新的修改git fetch
?我去看了FETCH_HEAD
档案,但没有什么比一个大数字。
回答by kostix
git fetch origin
by default fetches everything from the remote named "origin" and updates (or creates) the so-called "remote-tracking branches" for that remote. Say, for the remote named "origin" which contain branches named "master" and "feature", running git fetch remote
will result in the remote-tracking branches named "origin/master" and "origin/feature" being updated (or created, if they're not exist). You could see them in the output of git branch -a
(notice "-a").
git fetch origin
默认情况下,从名为“origin”的远程获取所有内容并为该远程更新(或创建)所谓的“远程跟踪分支”。例如,对于包含名为“master”和“feature”的git fetch remote
分支的名为“origin”的远程,运行将导致名为“origin/master”和“origin/feature”的远程跟踪分支被更新(或创建,如果它们'不存在)。您可以在git branch -a
(注意“-a”)的输出中看到它们。
Now, the usual Git setup is that (some of) your local branches follow certain remote branches (usually same-named). That is, your local "master" branch follows "origin/master" etc.
现在,通常的 Git 设置是(一些)您的本地分支遵循某些远程分支(通常是同名的)。也就是说,您本地的“master”分支遵循“origin/master”等。
So, after you fetched, to see what remote "master" has compared to your local "master", you ask Git to show you exactly this:
因此,在您获取之后,要查看远程“master”与本地“master”相比的内容,您可以要求 Git 向您显示以下内容:
git log origin/master ^master
which means «all commits reachable from "origin/master" which do not include commits reachable from "master"» or, alternatively
这意味着«所有从“源/主”可达的提交,不包括从“主”可达的提交»或者,或者
git log master..origin/master
which has the same meaning. See the "gitrevisions" manual pagefor more info, especially the "Specifying ranges" part. Also see the examples in the git-log manual page
这具有相同的含义。有关更多信息,请参阅“gitrevisions”手册页,尤其是“指定范围”部分。另请参阅git-log 手册页中的示例
You're free to customize the output of git log
as you see fit as it supports a whole lot of options affecting it.
您可以随意自定义输出,git log
因为它支持大量影响它的选项。
Note that your local branch might also have commits which the matching remote branch does not contain (yet). To get an overview of them you have to reverse the revisions passed to git log
for (hopefully) obvious reasons.
请注意,您的本地分支也可能具有匹配的远程分支不包含(尚未)的提交。要获得对它们的概述,您必须git log
出于(希望)明显的原因反转传递给的修订。
As usual, it's essential to educateyourselfto understand the underlying concepts before starting to use a tool. Please do.
回答by Barend
Try
尝试
git log --oneline --decorate origin/master
This will give you the change log from the master
head of the origin
remote (you can substitute any other remote branch as needed). You'll get an output somewhat like this:
这将为您提供远程master
头部的更改日志origin
(您可以根据需要替换任何其他远程分支)。你会得到一个有点像这样的输出:
234121 (origin/master) Commit message 5
872373 Commit message 4
623748 Commit message 3
235090 (master) Commit message 2
192399 Commit message 1
The commit marked (master)
is the head of your local master
branch. The commit marked (origin/master)
is the head of the remote's master
branch.
标记的提交(master)
是您本地master
分支的负责人。标记的提交(origin/master)
是远程master
分支的头部。
回答by Eliezer Berlin
If you just want to see what files will be modified if you do a GIT PULL, do this:
如果您只想查看执行 GIT PULL 时将修改哪些文件,请执行以下操作:
git fetch && git diff HEAD @{u} --name-only
If you want to see ALL differences between your current version and the incoming version, including uncommited local modifications, type this:
如果要查看当前版本和传入版本之间的所有差异,包括未提交的本地修改,请键入:
git fetch && git diff @{u} --name-only