如何在Github提交pr

如何在Github提交pr

一月 22, 2021

fork

    首先,fork到自己的仓库。之后,仓库显示fork from xxx/xxx,即为fork成功。

git clone (下载至本地)

    在自己的github仓库,点击Code,复制ssh,本地下载。

clone or download

1
git clone git@github.com:ciraos/xxx.git
1
2
3
4
5
6
7
8
$ git clone git@github.com:ciraos/links.git
Cloning into 'links'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 8 (delta 1), reused 8 (delta 1), pack-reused 0
Receiving objects: 100% (8/8), 5.30 KiB | 129.00 KiB/s, done.
Resolving deltas: 100% (1/1), done.

    出现以上,即为clone成功!

git status (查看分支)

1
git status
1
2
3
$ git status
On branch master
Your branch is up to date with 'origin/master'.

    即可看见,分支变成了master

git remote -v

1
git remote -v
1
2
3
$ git remote -v
origin git@github.com:ciraos/links.git (fetch)
origin git@github.com:ciraos/links.git (push)

    可以看见,与远程仓库建立了联系。

git checkout -b newbranchname (新建分支)

1
git checkout -b ciraos
  • 其中,标题中的newbranchname、代码块中的ciraos即为此命令创建的新分支。新分支名称随意。

    然后你会发现,原本的master,变成了新建的分支名。说明,所有修改、提交,都将在这个分支内完成。

修改代码、内容

    不多说了233333!

git status (查看文件状态)

1
git status
1
2
3
4
5
6
$ git status
On branch flink-ciraos
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: Link/link.yml

    直接修改的link.yml文件,出现在了上面,说明本地仓库有改动。

git提交

1
2
3
git add .
git commit -m "xxx"
git push origin branchname
  • git add。将该文件添加到暂存区。git add .,意为:一次性添加所有修改的文件。git add **.**,一次提交一个文件。
  • git commit -m "xxx",将暂存区内容添加到仓库中。
  • git push origin branchname,将暂存区文件提交至分支。

    分别运行以上代码,将修改的文件提交远程仓库(自己创建的分支)。
注意:一定要确认是在自己创建的分支下。

提交pr

Pr.funny

    首先,将仓库分支切换为自己本地新加的分支,例如:我的就是flink-ciraos,然后,会显示2 commits ahead of xxxx,就说明提交仓库成功了!然后点击pull request,提交pr。