git: how to re-syc a fork?

前端 未结 2 947
北恋
北恋 2021-01-29 06:02

the workflow we are required to follow is this:

  1. fork a project on github into your own private githib account.
  2. clone forked project to local machine.
2条回答
  •  萌比男神i
    2021-01-29 06:29

    As the other answer describes, there is nothing wrong in having 2 remotes. Actually, to submit feature branches, you do not have to perform any re-syncing or your fork. You need to follow so-called triangular workflow (search there for "Improved support for triangular workflows").

    tl:dr:

    
    git clone 
    cd clone
    git add upstream 
    
    git fetch upstream
    git checkout -b  upstream/master
    
    git push origin 
    
    

    As you can see, you only update here the branch of your fork, which is up-to-date with upstream - just the one you need to submit a PR. Basically, the whole purpose for the fork to exist is to have that one branch, then there is no reason to maintain other branches in the fork.

    The question Best practice for tracking upstream in fork on github goes beyond that, it needs to "tracking of changes unique to the fork". When such goal arises then there is a task of maintaining those changes up-to-date, but not before.

提交回复
热议问题