Pushing code from one branch of a repo to another branch of another repo

前端 未结 3 621
日久生厌
日久生厌 2021-02-05 06:59

There is a repo say ABC/A. I had forked this repo to my own github say ME/A. I was asked to create a branch on ME/A say x (originally there were develop and master). I had to wr

3条回答
  •  天涯浪人
    2021-02-05 07:43

    The answer by Roman is correct. However, there is an additional step that might not be obvious for some. You will need to first add the remote name and URL of the new repo(Repo you are trying to push to), before pushing to a branch in that repo. This can be done like so;

    git remote add  
    //For example
    git remote add origin2 https://user@github.com/example/new_repo.git
    

    Then you can proceed like in Roman's answer, by pushing to that new repo branch like so

    git push origin2 local_branch:new_repo_branch
    

提交回复
热议问题