How to make git repo remember all remotes?

前端 未结 3 2061
忘了有多久
忘了有多久 2020-12-29 07:40

I have a git repo that is a fork of another repo. As a rule I will normally add a remote called upstream, which is the original repo I forked from.

$ git rem         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-29 08:34

    This is a slightly modified version of GoZoner's solution.

    You need to capture the info about all the remotes from your repo's .git/config into a file that you could store outside your git repository. You also need to take care of updating this file every time you add a new remote. This can in fact be added to your git repo, so that the next clone or pull brings in this file.

    Starting with git 1.7.10+, git supports including external config files.

    So you can add the following lines to your repo's .git/config to include the external config file containing the remote info:

    [include]
        path            = /dir1/dir2/repo-remotes.gitinfo
    

提交回复
热议问题