此示例可能会帮助某人:
注意“ origin
”是我的远程别名“ Github上的内容”
注意“ mybranch
”是我的别名与我正在与github同步的分支“ what is local”
-如果您未创建,则您的分支名称为'master'之一。但是,我正在使用其他名称mybranch
来显示使用分支名称参数的位置。
我在github上的远程仓库到底是什么?
$ git remote -v
origin https://github.com/flipmcf/Playground.git (fetch)
origin https://github.com/flipmcf/Playground.git (push)
添加“具有相同代码的其他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)
确保我们的本地仓库是最新的:
$ 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)
与remote进行比较-您的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 push将其应用于远程)
我的远程分支与远程主分支有什么区别?
$ git diff origin/mybranch origin/master
我的本地内容与远程主分支有什么不同?
$ git diff origin/master
我的东西与其他仓库的分支,同一仓库的master分支有何不同?
$git diff mybranch someOtherRepo/master