我怎样才能比较我的本地分叉存储库与原来可能做出的更改? [英] How can I compare my local forked repository with changes that may have been made to the original?

查看:159
本文介绍了我怎样才能比较我的本地分叉存储库与原来可能做出的更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想比较我与原始/上游存储库分叉的存储库的本地克隆,以查看是否有进一步的提交需要我进行提取/合并。我想从命令行执行此操作。

I want to compare the local clone of a repository I have forked with the original/upstream repository to see if further commits have been made requiring me to pull/merge. I'd like to do this from the command line.

使用此命令将原始存储库添加到远程控制列表中:

I added the original repository to my list of remotes with this command:

git remote add upstream <original repo URL>

概述于 Github自己的分支分支主题

然而,当我运行 git diff upstream git diff upstream / master 这里建议 git diff master master upstream / master 在这里建议,我得到这个:

However, when I run git diff upstream or git diff upstream/master as advised here or git diff master upstream/master as advised here, I get this:

fatal: ambiguous argument 'upstream': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

命令 git diff origin / master 不会返回一个错误(或任何其他的事情)。我错过了什么?

The command git diff origin/master does not return an error (or anything for that matter). Have I missed something?

推荐答案

在运行 git diff 在自己的本地回购与上游之间,必须首先获取上游回购。然后在本地进行比较。

Before one can run a git diff between one's own local repo and the upstream, one must first fetch the upstream repo. The comparison is then made locally.

git fetch upstream

这不会影响您的仓库的工作分支,但它会添加一整串远程分支,您可以通过 git branch -a

This does not affect the working branch of your repo but it does add a whole other bunch of "remote" branches, which you can see with git branch -a.

一旦你有了这些,使用:

Once you've got those, use:

git diff master upstream/master

这会比较本地存储库已经对原始存储库进行了任何更新。此命令的变体将处理您可能对自己的分支进行的更新或与通常一样检查公共祖先(例如, git diff master ... upstream / master ) 。

This will compare the local repository you have with any updates that have been made to the original repository. Variations on this command will deal with updates you may have made to your own branch or check against a common ancestor (e.g., git diff master...upstream/master) as usual.

这篇关于我怎样才能比较我的本地分叉存储库与原来可能做出的更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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