Github贡献项目

fork一个项目到贡献代码流程

Posted by CY on August 4, 2020

fork一个项目到贡献代码流程

1. fork项目

2.clone到本地

$ git clone https://github.com/yourname/project.git

3.更新本地代码,与原项目保持一致

$ git remote add upstream https://github.com/sourcename/project.git

使用 git remote -v 查看 origin 和 upstream 对应的是否正确: origin对应的应该是 yourname/project upstream对应的应该是sourcename/project

4. 拉取最新的代码merge到本地分支上

$ git pull upstream master

每次写代码和提交代码之前要记得先拉取原项目代码,若有冲突,要处理冲突

5.在本地开发时,最好在分支上开发,写完之后合并到主干上

1.本地新建分支
$ git checkout -b new_branch
2.把本地的 nen_branch 分支保存的 github 上
$ git push origin new_branch
3.删除本地 add_sth 分支
$ git branch -D new_branch
4.删除 github 上的 new_branch 分支
$ git push origin :new_branch

6. push到自己的GitHub项目上

git push origin master

7. 将自己的代码pull到原项目

Pull Request


Notice

👇 yytester

如果要在fork的项目里,新建文件夹,以后自己只在此文件夹下开发,整体步骤类似上面,但是提交和更新的话,要在这个新建文件夹当前目录进行,而不能进去新建文件夹里面更新和提交

📕 本地新建分支,开发完成,add -A , commit -am “xx”

📕 切换到主干,合并分支

📕 跳到上级目录,即在fork项目的目录里,add -A , commit -am “xx” , push到自己fork的项目

📕 pull request到原项目