- 登录github
- 在github中查找需要需要贡献代码的项目,点击右上角的“fork”,这时即可在github个人项目区看到fork的项目:https://github.com/username(用户名 )
- 打开git客户端,clone 项目到本地
git clone https://github.com/username/projectname
说明:username和projectname为真实的用户名和项目名,例如:https://github.com/mapengbo/incubator-airflow.git
cd projectname
- 添加上游地址,其中upstream名称可以自定义
git remote add upstream https://github.com/apache/incubator-airflow.git
查看上游地址
git remote -v
- 拉取最新代码,从上游地址拉取代码到master
git pull upstream master
- checkout新的分支进行代码修改,不能在master上进行修改,master应该与upstream保持同步
git checkout -b feature/my_modify
- 修改代码
- git add .
- git commit -m"my commit"
- 发布代码,因为在修改过程中上游upstream代码可能已经修改,需要获取最新代码同步到master
git checkout master
git pull upstream master
11.将分支代码加入到maser
git checkout feature/my_modify
git rebase master
12.推送代码,输入git的用户名和密码
git push origin feature/my_modify
13. pull request
登录到https://github.com/username/projectname 刷新,点击“Compare & pull request”
填写提交说明,点击“Create pull request”
视频教程:https://www.codecasts.com/series/use-git-in-your-own-way/episodes/12