- 在github上fork别人的项目。
- 在自己的github帐户上找到这个项目,并clone到本地,进入项目。
- 使用命令
git remote add upstream https://github.com/username/xxx.git将别人的项目源加入远程仓库。 - 输入
git remote -v查看远程仓库,得到:
origin https://github.com/free1/xxx.git (fetch)
origin https://github.com/free1/xxx.git (push)
upstream https://github.com/username/xxx.git (fetch)
upstream https://github.com/username/xxx.git (push)
- 新建分支
git checkout -b 分支名,进行修改。 - 每次 pull requests,切回主分支
git checkout master,看别人的项目是否修改,git pull upstream master更新主分支,切回从分支git checkout 分支名,进行git rebase master合并同步,最后提交到自己clone的项目上(git push origin 分支名)。 - 提交pull requests。
