克隆和原始远程存储库之间的git diff
我克隆了一个github存储库,并没有在本地进行任何更改。 Github存储库在同一分支上进行提交。
1)添加您想要比较的任何远程存储库:
git remote add foobar git://github.com/user/foobar.git
2)更新您的本地远程副本:
git fetch foobar
取指不会改变你的工作副本。
3)比较本地存储库中的任何分支与您添加的任何远程设备:
git diff master foobar/master
对你的问题的另一个答复(假设你是主人,并且已经做了“git fetch origin”来让你知道远程更改的回购):
1)自从创建本地分支时提交远程分支:
git diff HEAD...origin/master
2)我假设“工作副本”是指你的本地分支有一些本地提交,但尚未提供。 要查看您在本地分支上的差异,但远程分支运行中不存在:
git diff origin/master...HEAD
3)请参阅dbyrne的答案。
这个例子可能有助于某人:
注意“ origin
”是我的远程“Github上的内容”的别名
注意“ mybranch
”是我与github同步的我的分支“什么是本地”的别名
- 如果您没有创建分支名称,则分支名称为“主”。 但是,我使用不同的名称mybranch
来显示分支名称参数的使用位置。
我在github上的远程回购是什么?
$ git remote -v
origin https://github.com/flipmcf/Playground.git (fetch)
origin https://github.com/flipmcf/Playground.git (push)
添加“相同代码的其他github仓库” - 我们称之为分叉:
$ git remote add someOtherRepo https://github.com/otherUser/Playground.git
$git remote -v
origin https://github.com/flipmcf/Playground.git (fetch)
origin https://github.com/flipmcf/Playground.git (push)
someOtherRepo https://github.com/otherUser/Playground.git (push)
someOtherRepo https://github.com/otherUser/Playground.git (fetch)
确保我们的本地回购是最新的:
$ git fetch
在本地更改一些东西。 让我们说文件./foo/bar.py
$ git status
# On branch mybranch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: foo/bar.py
查看我未提交的更改
$ git diff mybranch
diff --git a/playground/foo/bar.py b/playground/foo/bar.py
index b4fb1be..516323b 100655
--- a/playground/foo/bar.py
+++ b/playground/foo/bar.py
@@ -1,27 +1,29 @@
- This line is wrong
+ This line is fixed now - yea!
+ And I added this line too.
本地提交。
$ git commit foo/bar.py -m"I changed stuff"
[myfork 9f31ff7] I changed stuff
1 files changed, 2 insertions(+), 1 deletions(-)
现在,我不同于我的遥控器(在github上)
$ git status
# On branch mybranch
# Your branch is ahead of 'origin/mybranch' by 1 commit.
#
nothing to commit (working directory clean)
用远程来区分这个 - 你的fork:(这通常是用git diff master origin
来完成的)
$ git diff mybranch origin
diff --git a/playground/foo/bar.py b/playground/foo/bar.py
index 516323b..b4fb1be 100655
--- a/playground/foo/bar.py
+++ b/playground/foo/bar.py
@@ -1,27 +1,29 @@
- This line is wrong
+ This line is fixed now - yea!
+ And I added this line too.
(git推这些应用到远程)
我的远程分支与远程主分支有什么不同?
$ git diff origin/mybranch origin/master
我的本地东西与远程主分支有什么不同?
$ git diff origin/master
我的东西与别人的fork,同一个repo的master分支有什么不同?
$git diff mybranch someOtherRepo/master
链接地址: http://www.djcxy.com/p/7559.html
上一篇: git diff between cloned and original remote repository
下一篇: Why "git push helloworld +master:master" instead of just "git push helloworld"?