Gem*_*ker 166 git version-control github
我克隆了一个github存储库,并没有在本地进行任何更改.Github存储库在同一分支上提交了提交.
dby*_*rne 158
1)添加要比较的任何远程存储库:
git remote add foobar git://github.com/user/foobar.git
Run Code Online (Sandbox Code Playgroud)
2)更新远程的本地副本:
git fetch foobar
Run Code Online (Sandbox Code Playgroud)
获取不会更改您的工作副本.
3)将本地存储库中的任何分支与您添加的任何远程数据进行比较:
git diff master foobar/master
Run Code Online (Sandbox Code Playgroud)
Rus*_*lin 46
对你的问题的另一个回复(假设你是主人并且已经做了"git fetch origin"让你回复了解远程更改):
1)在创建本地分支时提交远程分支:
git diff HEAD...origin/master
Run Code Online (Sandbox Code Playgroud)
2)我假设"工作副本"你的意思是你的本地分支与一些尚未远程的本地提交.要查看您在本地分支上的内容的差异,但在远程分支上运行时不存在:
git diff origin/master...HEAD
Run Code Online (Sandbox Code Playgroud)
3)请参阅dbyrne 的答案.
Fli*_*McF 19
这个例子可能会帮助某人:
注意" origin
"是我的远程别名"Github上的内容"
注意" mybranch
"是我的分支"我是什么本地"的别名我正在与github同步
- 如果你没有创建,你的分支名称是'master'一.但是,我使用不同的名称mybranch
来显示分支名称参数的使用位置.
我的远程回购在github上究竟是什么?
$ git remote -v
origin https://github.com/flipmcf/Playground.git (fetch)
origin https://github.com/flipmcf/Playground.git (push)
Run Code Online (Sandbox Code Playgroud)
添加"相同代码的其他github存储库" - 我们将其称为fork:
$ 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)
Run Code Online (Sandbox Code Playgroud)
确保我们的本地回购是最新的:
$ git fetch
Run Code Online (Sandbox Code Playgroud)
在本地改变一些东西.让我们说文件./foo/bar.py
$ git status
# On branch mybranch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: foo/bar.py
Run Code Online (Sandbox Code Playgroud)
查看我未提交的更改
$ 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.
Run Code Online (Sandbox Code Playgroud)
在本地提交.
$ git commit foo/bar.py -m"I changed stuff"
[myfork 9f31ff7] I changed stuff
1 files changed, 2 insertions(+), 1 deletions(-)
Run Code Online (Sandbox Code Playgroud)
现在,我和我的遥控器不同(在github上)
$ git status
# On branch mybranch
# Your branch is ahead of 'origin/mybranch' by 1 commit.
#
nothing to commit (working directory clean)
Run Code Online (Sandbox Code Playgroud)
用远程扩展这个 - 你的分叉:(经常这样做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.
Run Code Online (Sandbox Code Playgroud)
(git push将这些应用到远程)
我的远程分支与远程主分支有何不同?
$ git diff origin/mybranch origin/master
Run Code Online (Sandbox Code Playgroud)
我的本地东西与远程主分支有何不同?
$ git diff origin/master
Run Code Online (Sandbox Code Playgroud)
我的东西与其他人的叉子,同一个仓库的主分支有什么不同?
$git diff mybranch someOtherRepo/master
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
145072 次 |
最近记录: |