【问题标题】:How can I diff between my repo and a remote repo that's not origin?如何区分我的回购和不是来源的远程回购?
【发布时间】:2015-03-14 19:26:19
【问题描述】:

来自Viewing Unpushed Git Commits 我知道如何在我自己的仓库和本地提交之间做出差异:

git diff origin/master..HEAD

但是,我怎样才能使用 path/to/github/repo.git 而不是 origin 来做同样的事情?

git diff https://github.com/malarres/universal.git/GPII-795..HEAD

正在返回:

fatal: Invalid object name 'https'.

【问题讨论】:

    标签: git github


    【解决方案1】:

    如何使用path/to/github/repo.git 代替origin 做同样的事情?

    git diff https://github.com/malarres/universal.git/GPII-795..HEAD

    git diff 不是这样工作的。如果您想区分本地 repo 和另一个 repo,您​​需要执行以下操作:

    1. 将后者添加为前者的远程。请注意,除了origin,没有什么能阻止您在一个存储库中定义多个遥控器。 (不过,您可能希望选择一个比“其他”更通用的远程名称。)

       git remote add other https://github.com/malarres/universal.git/GPII-795
      
    2. 从远程获取所有内容:

       git fetch other
      
    3. 例如,运行适当的git diff 命令,

       git diff other/master..HEAD
      

    如果您稍后想从存储库中删除该远程,您可以运行

    git remote rm other
    

    【讨论】:

      猜你喜欢
      • 2021-11-05
      • 1970-01-01
      • 2011-03-03
      • 2020-12-14
      • 2015-09-23
      • 2023-02-09
      • 1970-01-01
      • 1970-01-01
      • 2013-07-25
      相关资源
      最近更新 更多