Git pull from another repository

后端 未结 2 1440
陌清茗
陌清茗 2020-12-22 15:58

I have a repository called Generic, which is a generic application. I have forked it into a repository called Acme, which just builds upon the appl

相关标签:
2条回答
  • 2020-12-22 16:25

    Issue the following command in your Acme repo. It adds a new remote repository named upstream that points to the Generic repo.

    git remote add upstream https://location/of/generic.git
    

    You can then merge any changes made to Generic into the current branch in Acme with the following command:

    git pull upstream
    

    If you just want it to download the changes without automatically merging, use git fetch instead of git pull.

    If you want to disable pushing to that repository, set the push URL to an invalid URL using something like

    git config remote.upstream.pushurl "NEVER GONNA GIVE YOU UP"
    

    Git will now yell at you about not being able to find a repo if you try to push to upstream (and sorry about the Rickroll, but it was the first random string that popped into my head).

    0 讨论(0)
  • 2020-12-22 16:38

    In order to pull a particular branch from different repo you can use the below git command.

    git pull <git_url> <branch> --allow-unrelated-histories
    
    0 讨论(0)
提交回复
热议问题