git多人协作流程
Fork
在github上找到需要参与开发的项目,fork到自己的github仓库中
git clone
初始化
1 | git clone <url> #克隆远程仓库 |
克隆fork来的仓库
git remote
1 | git remote -v #显示所有远程仓库 |
添加对应的github远程仓库
1 | git remote add upstream <url> #添加目标项目的主仓库 |
git branch
1 | git branch #查看本地所有分支 |
新建一个分支
1 | git checkout -b new |
在该分支上进行开发
git add/git commit/git push
1 | git add . #提交全部文件修改到缓存区 |
git add添加新增文件,git commit提交修改到本地仓库,git push提交到自己的远程仓库
1 | git add test.txt |
pull request
github中使用pull request将修改的内容请求合并到主仓库中
git pull
1 | git pull [remote] [branch] #拉取远程仓库的分支与本地当前分支合并 |
在提交到主仓库之前,先拉取主仓库最新的代码
1 | git pull upstream main |
git rm
1 | git rm -r --cached . #移除所有文件 |
将已经提交过的文件加入git忽略文件:
1 | git rm -r --cached . #移除所有文件 |
- 本文标题:git多人协作流程
- 本文作者:灵感胜于汗水
- 创建时间:2022-05-03 18:54:16
- 本文链接:https://cjhsyc.github.io/2022/05/03/git多人协作流程/
- 版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!