Github: Import upstream branch into fork

后端 未结 6 465
攒了一身酷
攒了一身酷 2020-12-07 07:24

I have a fork (origin) from a project (upstream) on github. Now the upstream project has added a new branch, I want to import into my fork. How do

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 07:32

    I had a slightly more complicated scenario where I already had an upstream defined in my fork (from the canonical repo) but needed to checkout a branch from a different fork. To get that done, the process is slightly different. Here's the config I ended up with:

    [remote "origin"]
    url = git@github.com:/.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
    remote = origin
    merge = refs/heads/master
    rebase = true
    [remote "upstream"]
    url = git@github.com:/.git
    fetch = +refs/heads/*:refs/remotes/upstream/*
    [remote "other_user"]
    url = git@github.com:/.git
    fetch = +refs/heads/*:refs/remotes//*
    

    Now you can checkout a branch from fork as well.

    git fetch  
    git checkout -b  /
    

    That will give you a local branch which is derived from the fork.

    To push that local branch I had to be specific with my push command.

    git push origin 
    

提交回复
热议问题