如何在拉动之前检查本地和github之间的差异 [英] How to check the differences between local and github before the pull
问题描述
在使用pull之前,我想检查一下我的local和github master之间是否有区别。
我该怎么做?
git pull 真的等同于运行
git fetch
然后 git merge
。 git fetch
会更新所谓的远程追踪分支 - 通常这些看起来像 origin / master
, github / experiment
等,你可以看到 git branch -r
。这些就像远程仓库中分支状态的缓存,当你执行 git fetch
(或者成功的 git push $因此,假设你有一个名为
origin
的远程引用了你的GitHub仓库,你会这样做:
git fetch origin
...然后执行:
git diff master origin / master
...为了查看您的 master
和GitHub上的一个。如果你对这些差异感到满意,你可以将它们与 git merge origin / master
合并,假设 master
是您的当前分支。
就我个人而言,我认为做 git fetch
和 git merge
通常分别是一个好主意 a>。
Before using pull, I want to check if there are any differences between my local and github master.
How can I do it?
git pull
is really equivalent to running git fetch
and then git merge
. The git fetch
updates your so-called "remote-tracking branches" - typically these are ones that look like origin/master
, github/experiment
, etc. that you see with git branch -r
. These are like a cache of the state of branches in the remote repository that are updated when you do git fetch
(or a successful git push
).
So, suppose you've got a remote called origin
that refers to your GitHub repository, you would do:
git fetch origin
... and then do:
git diff master origin/master
... in order to see the difference between your master
, and the one on GitHub. If you're happy with those differences, you can merge them in with git merge origin/master
, assuming master
is your current branch.
Personally, I think that doing git fetch
and git merge
separately is generally a good idea.
这篇关于如何在拉动之前检查本地和github之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!