pull request

pull request

Pull requests let you tell others about changes you've pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch.github

"Pull Request 是一种通知机制。你修改了他人的代码,将你的修改通知原来的作者,希望他合并你的修改,这就是 Pull Request。"

步骤

第一步,你需要把别人的代码,克隆到你自己的仓库,Github 的术语叫做 fork。然后就可以clone到自己的本地仓库了

抓取项目更新的部分

git pull

第二步,新建branch

创建新分支的方式

git checkout -b 分支名

切换分支的方式

git checkout 分支名

查看所有的分支

git branch

先切换分支再修改!
先切换分支再修改!
先切换分支再修改!
重要的事情说三遍,鹅鹅鹅~

第三步,修改代码

比如修改了 gdp.Rmd

查看修改

git status

放到本地缓存

git add gdp.Rmd

提交修改信息

git commit -m "add #issue"
git push origin 分支名

合并分支

git fetch origin #同步所有线上分支
git branch #查看有多少本地的分支
git checkout branchA #切换到分支A
git merge branchB#把分支B的commit合并到分支A

按下"New pull request"按钮。

然后进入compare changes页面,有修改的话这里事绿色可点击的button
按下create pull request

添加修改信息,然后create pull request

选上reviewers 和assigineess

ok等待reviewers的review就好了

conflict解决

当多个人同时修改了gdp.Rmd的时候,计算机是无法识别哪个对于当前这个master的是重要的,因此会出现conflict

这个时候要解决conflict了

假如我这里的分支是text_branch

可以选择手动删除,存在冲突的地方,一般就是<<<<<<<<< HEAD =======中间的部分,根据需要删除

$ git status
On branch text_branch
Your branch is ahead of 'origin/text_branch' by 10 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
接下来就可以 push 了。
git push origin text_branch
posted @ 2020-05-02 15:36  高文星星  阅读(707)  评论(0编辑  收藏  举报