git diff between cloned and original remote repository
我克隆了一个Github存储库,没有在本地进行任何更改。Github存储库向前移动,在同一个分支上提交。
1)添加要比较的任何远程存储库:
1 | git remote add foobar git://github.com/user/foobar.git |
2)更新远程服务器的本地副本:
1 | git fetch foobar |
号
提取不会更改您的工作副本。
3)将本地存储库中的任何分支与添加的任何远程分支进行比较:
1 | git diff master foobar/master |
对您的问题的另一个答复(假设您在master上并且已经执行了"git fetch origin"以使您了解远程更改):
1)在创建本地分支后在远程分支上提交:
1 | git diff HEAD...origin/master |
。
2)我假设"工作副本"是指您的本地分支机构,其中一些本地提交尚未远程。要查看本地分支上的内容与远程分支运行上不存在的内容之间的差异,请执行以下操作:
1 | git diff origin/master...HEAD |
3)见dbyrne的答案。
这个例子可能有助于:
注"
我在Github上的远程回购具体是什么?
1 2 3 | $ git remote -v origin https://github.com/flipmcf/Playground.git (fetch) origin https://github.com/flipmcf/Playground.git (push) |
。
添加"其他具有相同代码的Github存储库"——我们称之为fork:
1 2 3 4 5 6 7 | $ 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) |
。
确保我们的本地回购是最新的:
1 | $ git fetch |
在本地更改一些内容。比如说文件/foo/bar.py
1 2 3 4 5 6 | $ git status # On branch mybranch # Changes to be committed: # (use"git reset HEAD <file>..." to unstage) # # modified: foo/bar.py |
。
查看我的未提交更改
1 2 3 4 5 6 7 8 9 | $ 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. |
在本地提交。
1 2 3 | $ git commit foo/bar.py -m"I changed stuff" [myfork 9f31ff7] I changed stuff 1 files changed, 2 insertions(+), 1 deletions(-) |
。
现在,我不同于我的遥控器(在Github上)
1 2 3 4 5 | $ git status # On branch mybranch # Your branch is ahead of 'origin/mybranch' by 1 commit. # nothing to commit (working directory clean) |
号
用遥控器区分这个-你的叉子:(这通常是用
1 2 3 4 5 6 7 8 9 | $ 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 push将这些应用到远程)
我的远程分支与远程主分支有何不同?
1 | $ git diff origin/mybranch origin/master |
号
我的本地资料与远程主分支有什么不同?
1 | $ git diff origin/master |
号
我的东西和别人的叉子,同一回购协议的主分支有什么不同?
1 | $git diff mybranch someOtherRepo/master |
号