How to?

Workflow by Gao Tian

Apr 14, 2024
softwares-and-toolsgitworkflow
2 Minutes
329 Words
This article was last updated on May 27, 2026 and some of the information may no longer be applicable due to the passage of time.

Workflow by Gao Tian

ref: https://www.bilibili.com/video/BV19e4y1q7JJ

@zrx_p4ul on bilibili.com

1
1.git clone // 到本地
2
2.git checkout -b xxx 切换至新分支xxx
3
(相当于复制了remote的仓库到本地的xxx分支上
4
3.修改或者添加本地代码(部署在硬盘的源文件上)
5
4.git diff 查看自己对代码做出的改变
6
5.git add 上传更新后的代码至暂存区
7
6.git commit 可以将暂存区里更新后的代码更新到本地git
8
7.git push origin xxx 将本地的xxxgit分支上传至github上的git
9
-----------------------------------------------------------
10
(如果在写自己的代码过程中发现远端GitHub上代码出现改变)
11
1.git checkout main 切换回main分支
12
2.git pull origin master(main) 将远端修改过的代码再更新到本地
13
3.git checkout xxx 回到xxx分支
14
4.git rebase main 我在xxx分支上,先把main移过来,然后根据我的commit来修改成新的内容
15
(中途可能会出现,rebase conflict -----》手动选择保留哪段代码)
7 collapsed lines
16
5.git push -f origin xxx 把rebase后并且更新过的代码再push到远端github上
17
(-f ---》强行)
18
6.原项目主人采用pull request 中的 squash and merge 合并所有不同的commit
19
----------------------------------------------------------------------------------------------
20
远端完成更新后
21
1.git branch -d xxx 删除本地的git分支
22
2.git pull origin master 再把远端的最新代码拉至本地
Article title:Workflow by Gao Tian
Article author:Julyfun
Release time:Apr 14, 2024
Copyright 2026
Sitemap