参与一个项目的开发时,上传代码通常有两种途径:
1、直接从原项目clone,上传代码的时候push上去
2、fork项目到自己的主页,开发完上传代码到自己的主页,再发送pull request到原项目
第二个流程更加严谨一些,而且放在自己目录下也更好管理,接下来简单介绍第二种方法的主要流程。
step 1 fork项目
在项目A页面上单击fork,自己主页的目录(B)中就会出现该项目
step 2 创建本地项目
git clone 自己主页(B)目录下的项目地址
step 3 添加与原项目A的关联
git remote add upstream 项目A的地址
step 4 拉取A上的更新
git pull upstream origin/master
step 5 上传代码改动
git push upstream master
1. 创建分支与upstream分支关联
git branch --set-upstream my_local_branch_name origin/my_remote_branch_name
2. 指定分支与upstream分支关联
git push --set-upstream origin my_remote_branch_name
3.查看各分支的upstream分支
git branch -vv
参考:
https://blog.csdn.net/joelovegreen/article/details/42913163
https://www.dazhuanlan.com/za2ra/topics/1322667