且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我怎样才能区别我的回购和远程回购不是原产地?

更新时间:2022-10-15 16:59:17


我该怎么办使用路径/ to / github / repo.git

$ b $来代替 origin b

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


这不是 git diff 的工作方式。如果您想区分当地回购和其他回购,您需要执行以下操作:


  1. 将后者添加为前者的 remote 。请注意,在一个存储库中,除了 origin 之外,没有什么能够阻止您定义多个远程。 (但是,您可能希望选择一个不太通用的远程名称)。

      git remote add other https:/ /github.com/malarres/universal.git/GPII-795 


  2. remote:

      git fetch other 


  3. 运行相应的 git diff 命令,例如,








    $ 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 a path/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:

    1. 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
      

    2. Fetch everything from that remote:

      git fetch other
      

    3. 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