git:从主仓库更新代码到fork的仓库

1、在git 上fork 主仓库的项目

2、在本地 下载自己fork的项目:

      $ git clone [email protected]:wangyy/TestProject.git    -b dev

3、查看远程仓库地址:

     $ git remote -v

origin  [email protected]:wangyy/TestProject.git (fetch)
origin  [email protected]:wangyy/TestProject.git (push)

4、添加主仓库地址

     $ git remote add test [email protected]:test/TestProject.git

5、再次查看远程仓库地址:

    origin  [email protected]:wangyy/TestProject.git (fetch)
    origin  [email protected]:wangyy/TestProject.git (push)

    test  [email protected]:test/TestProject.git (fetch)
    test  [email protected]:test/TestProject.git (push)


6、本地修改代码实现功能,通过git add、git commit 提交修改到本地仓库

7、从主仓库更新最新代码,和本地代码合并,解决冲突

    $git pull test dev

     有时候不会自动合并,使用git fetch、git merge

    $git fetch test dev

    $git merge test/dev         # 当前在origin/dev 分支

8、将本地代码提交到fork项目的分支上

    $git push origin dev

9、向主仓库发起pull request请求

10、主仓库管理员合并Pull request

你可能感兴趣的:(git:从主仓库更新代码到fork的仓库)