我怎样才能区别我的回购和远程回购不是原产地? [英] How can I diff between my repo and a remote repo that's not origin?
问题描述
从查看未压缩的Git提交我知道如何在我自己和我的本地提交回购:
git diff origin / master..HEAD
但是,如何使用路径/ to / github / repo.git
?
git diff https://github.com/malarres/universal.git/GPII-795。 .HEAD
正在返回:
致命:无效的对象名称'https'。
我该怎么办使用
$ b $来代替路径/ to / github / repo.git
?origin
b
git diff https://github.com/malarres/universal.git/GPII-795..HEAD
这不是 git diff
的工作方式。如果您想区分当地回购和其他回购,您需要执行以下操作:
-
将后者添加为前者的 remote 。请注意,在一个存储库中,除了
origin
之外,没有什么能够阻止您定义多个远程。 (但是,您可能希望选择一个不太通用的远程名称)。git remote add other https:/ /github.com/malarres/universal.git/GPII-795
-
remote:
git fetch other
-
运行相应的
git diff
命令,例如,
<$ p $
$ b $ / $>
如果您稍后想要从存储库中删除该远程设备,则可以运行
git remote rm other
From Viewing Unpushed Git Commits I know how to make diff between a repo on my own and my local commits:
git diff origin/master..HEAD
But, How can I do the same instead of origin using a
path/to/github/repo.git
?git diff https://github.com/malarres/universal.git/GPII-795..HEAD
is returning:
fatal: Invalid object name 'https'.
解决方案How can I do the same instead of
origin
using apath/to/github/repo.git
?git diff https://github.com/malarres/universal.git/GPII-795..HEAD
That's not the way
git diff
works. If you want to diff between your local repo and another repo, you need to do the following:Add the latter as a remote of the former. Note that nothing prevents you from defining multiple remotes, in addition to
origin
, within one repository. (You may want to choose a less generic remote name than "other", though.)git remote add other https://github.com/malarres/universal.git/GPII-795
Fetch everything from that remote:
git fetch other
Run the appropriate
git diff
command, for instance,git diff other/master..HEAD
If you later want to remove that remote from your repository, you can run
git remote rm other
这篇关于我怎样才能区别我的回购和远程回购不是原产地?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!