由于`git fetch`找到更改的地方 [英] Where to find changes due to `git fetch`

查看:283
本文介绍了由于`git fetch`找到更改的地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不希望在 git pull 之后丢失一些信息,因此我之前完成了 git fetch 。我在哪里可以阅读 git fetch 之后的新修改?我去了 FETCH_HEAD 文件,但只有一个大数字。

默认情况下,获取远程名为origin的所有内容,并更新(或创建)所谓的远程跟踪分支远程。假设对于名为master和feature的分支的远程命名origin,运行 git fetch remote 将导致名为origin /主和原点/特征被更新(或创建,如果它们不存在)。你可以在 git branch -a (注意-a)的输出中看到它们。



现在,通常的Git设置是(某些)您的本地分支遵循某些远程分支(通常是同名)。也就是说,你的本地master分支遵循origin / master等。

因此,在获取之后,查看远程master与本地master,你要求Git给你看看这个:

  git log origin / master ^ master 

code>

这意味着«所有可以从origin / master进行的提交,其中不包含可从master访问的提交»
或者,或者

  git log master..origin / master 

具有相同的含义。有关详细信息,请参见gitrevisions手册页面,特别是指定范围部分。另请参阅 git-log手册页中的示例



您可以自由定制 git log 的输出,因为它支持许多影响它的选项。 / p>

请注意,您的本地分支也可能具有匹配的远程分支不包含(尚)的提交。为了得到它们的概述,你必须颠倒传递给 git log 的修订版本(希望)是显而易见的原因。



像往常一样,必须教育 你自己在开始使用工具之前了解底层概念。请做。


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.

解决方案

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").

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.

So, after you fetched, to see what remote "master" has compared to your local "master", you ask Git to show you exactly this:

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 page for more info, especially the "Specifying ranges" part. Also see the examples in the git-log manual page

You're free to customize the output of git log as you see fit as it supports a whole lot of options affecting it.

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.

As usual, it's essential to educate yourself to understand the underlying concepts before starting to use a tool. Please do.

这篇关于由于`git fetch`找到更改的地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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