克隆和原始远程存储库之间的 git diff [英] git diff between cloned and original remote repository

查看:30
本文介绍了克隆和原始远程存储库之间的 git diff的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经克隆了一个 github 存储库并且没有在本地进行任何更改.Github 存储库向前推进,在同一分支上提交.

I have cloned a github repository and made no changes locally. Github repository moved forward with commits on the same branch.

  1. 如何找到本地存储库和原始 github 存储库之间的差异?
  2. 如何找到我的工作副本和原始 github 存储库之间的差异?
  3. 如何找到我的本地存储库和同一项目的另一个 github 存储库之间的差异?

推荐答案

这个例子可能对某人有帮助:

This example might help someone:

注意origin"是我对远程Github 上的内容"的别名
注意mybranch"是我与 github 同步的分支what is local"的别名
-- 如果您没有创建分支,则您的分支名称是master".但是,我使用不同的名称 mybranch 来显示使用分支名称参数的位置.

Note "origin" is my alias for remote "What is on Github"
Note "mybranch" is my alias for my branch "what is local" that I'm syncing with github
--your branch name is 'master' if you didn't create one. However, I'm using the different name mybranch to show where the branch name parameter is used.

我在 github 上的远程仓库究竟是什么?

What exactly are my remote repos on github?

$ git remote -v
origin  https://github.com/flipmcf/Playground.git (fetch)
origin  https://github.com/flipmcf/Playground.git (push)

添加相同代码的其他 github 存储库"——我们称之为 fork:

Add the "other github repository of the same code" - we call this a 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)

确保我们的本地存储库是最新的:

make sure our local repo is up to date:

$ git fetch

在本地更改一些内容.假设文件 ./foo/bar.py

Change some stuff locally. let's say file ./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 上)

Now, I'm different than my remote (on github)

$ git status
# On branch mybranch
# Your branch is ahead of 'origin/mybranch' by 1 commit.
#
nothing to commit (working directory clean)

用遥控器区分这个 - 你的叉子:(这经常用 git diff master origin 完成)

Diff this with remote - your fork: (this is frequently done with 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 push to apply these to remote)

我的远程分支与远程主分支有何不同?

How does my remote branch differ from the remote master branch?

$ git diff origin/mybranch origin/master

我本地的东西与远程 master 分支有什么不同?

How does my local stuff differ from the remote master branch?

$ git diff origin/master

我的东西与其他人的 fork、同一个 repo 的 master 分支有什么不同?

How does my stuff differ from someone else's fork, master branch of the same repo?

$git diff mybranch someOtherRepo/master

这篇关于克隆和原始远程存储库之间的 git diff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆