github pull request
1. 概念¶
1.1 pull request¶
俗称: pr, 即将别人的项目克隆到本地,然后修改。最后希望作者能接受意见合并代码
2. 操作¶
- fork这个操作的一系列细节;
- 与两个远程仓库分别建立链接;
- 将修改提交到自己的远程仓库;
- Compare需要注意。
2.1 fork clone¶
- 在github上找到对应的项目,对应项目右上角点击fork按钮
- 在自己的github项目上找到fork的项目,然后clone到本地
2.2 增加远程项目¶
查看远程repository地址
my@MacBook ~/File/books git remote -v origin https://github.com/sona201/books.git (fetch) origin https://github.com/sona201/books.git (push)
2.3 关联原作者的repository¶
my@MacBook ~/File/books git remote add upstream https://github.com/caimengzhi/books.git my@MacBook ~/File/books git remote -v origin https://github.com/sona201/books.git (fetch) origin https://github.com/sona201/books.git (push) upstream https://github.com/caimengzhi/books.git (fetch) upstream https://github.com/caimengzhi/books.git (push)
2.4 新建分支¶
建议新建分支,在新分支上修改代码,避免代码混乱
git checkout -b test-branch
2.5 修改提交¶
修改代码,然后提交 推送到远程
git status git add . git push origin test-branch
2.6 创建pr¶
到这里看下就是在自己的github仓库上有了新提交
点击工具栏的pull request
3. 总结¶
- fork
- clone
- git remote add upstream https://githua.com/xxxxxx.git
- git checkout -b new-branch
- "change code"
- git push origin new-branch
- pull request