我克隆了一個github存儲庫,並沒有在本地做任何更改。 Github存儲庫在同一分支上進行提交。克隆和原始遠程存儲庫之間的git diff
- 如何找到我的本地存儲庫和原始github存儲庫之間的區別?
- 如何在我的工作副本和原始github存儲庫之間找到差異?
- 如何在我的本地存儲庫和同一項目的另一個github存儲庫之間找到差異?
我克隆了一個github存儲庫,並沒有在本地做任何更改。 Github存儲庫在同一分支上進行提交。克隆和原始遠程存儲庫之間的git diff
1)添加要比較的任何遠程倉庫:
git remote add foobar git://github.com/user/foobar.git
2)更新您的本地遠程副本:
git fetch foobar
取不會改變你的工作拷貝。
3)從本地存儲庫進行比較的任何分支到任何遠程您添加:
git diff master foobar/master
另一個回答您的問題(假設你是高手和已經做了「混帳取起源」讓你回購知道有關遠程修改):
1)遠程分支提交本地分支產生時,因爲:
git diff HEAD...origin/master
2)我想通過「工作副本」你的意思是ÿ我們的本地分支有一些本地提交,但尚未在遠程。看到你有你的本地分支什麼區別,但這並不對遠程分支機構運行存在:
git diff origin/master...HEAD
3)dbyrne見answer。
感謝您使用'HEAD..origin/master'語法!我們已經得到了起源/ HEAD不存在的錯誤,並且這解決了它。 – Dan 2015-11-06 19:37:34
@ruslan:如果我已經克隆了一個遠程目錄,git diff HEAD ... origin/master'什麼意思,我有權修改? – 2016-07-06 02:07:59
當我使用Windows GUI克隆時發生錯誤,因此我想知道克隆是否完全通過。我看到這些文件夾在我的目錄中,但我想確保它與遠程相同。然而在git shell中,git diff不會返回任何內容。如果我的克隆成功或者不成功,我感到困惑? – 2016-07-06 02:09:14
這個例子可以幫助別人:
注「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)
DIFF這與遠程 - 你的叉: (這經常與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推這些應用到遠程)
我的遠程e分支與遠程主分支不同?
$ git diff origin/mybranch origin/master
我的本地東西與遠程主分支有什麼不同?
$ git diff origin/master
我的東西與別人的fork,同一個回購的master分支有什麼不同?
$git diff mybranch someOtherRepo/master
的[比較遠程分支當地混帳分支?(http://stackoverflow.com/questions/1800783/compare-local-git-branch-with-remote-branch) – 2014-08-30 18:24:26