惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
MyScale Blog
MyScale Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学
Vercel News
Vercel News
D
Docker
博客园 - 聂微东
T
Tailwind CSS Blog
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
D
DataBreaches.Net
B
Blog RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
美团技术团队
F
Fortinet All Blogs
MongoDB | Blog
MongoDB | Blog
T
The Blog of Author Tim Ferriss
GbyAI
GbyAI
N
Netflix TechBlog - Medium
G
Google Developers Blog
腾讯CDC

陈少文的网站

巨变与机遇的未来十年 Kubernetes 平台管理软件压力测试方案 使用镜像部署 Hexo 静态页面 终于等到你 - GitHub 镜像仓库服务(ghcr.io) 一起来学 Go --(6)Interface 一起来学 Go --(5)Goroutine 和 Channel 什么是函数式编程 如何在 Kubernetes 集群集成 Kata 柯里化与偏函数 使用 PyGithub 自动创建 Label 软件产品是团队能力的输出 Helm 2 、Helm 3 比较 IoT 变现 Kubernetes 中的 DNS 服务 国内的 Helm 镜像源 Harbor 使用自签证书支持 Https 访问 DevOps 工具链之 Prow 如何使用 kfctl 安装 Kubeflow VS Code 无法下载 Go 插件的工具包 工程师更应具有服务精神 你不知道的 Docker 使用技巧 使用 Docker 运行 Tensorflow 论中国 什么是左移 如何清空 Git 仓库全部历史记录 一禅小和尚 有风吹过厨房 时间的玫瑰 如何在 CentOS 安装 GPU 驱动 开发 Tips(19)
一个完整的 Git 提交流程
微信公众号 · 2020-05-19 · via 陈少文的网站

这也是一个给开源项目提交 PR 的完整 Git 流程。

1. 本地配置

  • 提交用户信息
1
2
git config --global user.name "username"
git config --global user.email "user@email.com"
  • GPG 配置

参考:GPG 验证提交

2. 克隆代码

  • 首先 fork 原仓库

  • 克隆 fork 的仓库代码

1
git clone https://github.com/yourname/django-xss-cleaner.git
  • 添加原仓库
1
git remote add upstream https://github.com/shaowenchen/django-xss-cleaner.git
  • 查看本地配置的远程源
1
2
3
4
git remote -v

origin xxx
upstream xxx

3. 日常开发

  • 拉取最新代码
  • [可选]非 master 分支集成时操作
1
git checkout -b IntegratedBranch upstream/IntegratedBranch

非 master 分支集成,下面使用 IntegratedBranch 替换 master 即可。

  • 切换集成分支
  • Rebase 更新到自己的仓库
1
git rebase upstream/master
  • 新建一个开发分支
1
git checkout -b feature_1 master
  • 开发

Coding

  • 提交代码
1
2
git add .
git commit -s -m "message"

这里如果忘记加 -s,会缺少签名信息。可以通过 git commit --amend --no-edit -s 进行补救。

  • 提交 PR

选择将自己的 feature_1 分支合并到原仓库的 master 分支

  • 评论、修改,来回切磋,继续提交
1
2
git add .
git commit -s -m "message"
  • Rebase PR 中的 Commit 记录,仅留一条

进入交互模式后,合并之前的两个 Commit 记录,保留第一个 pick,其他改成 f 或 s 。多条 Commit 时,将 2 修改为相应数值。

  • 强制推送

由于远程已经有相关的 commit 记录,这里需要强制推送。

  • PR 合并之后,删除开发分支

如果没有合并直接删除远端开发分支,会导致 PR 关闭。

1
2
3
git checkout master
git branch -D feature_1
git push origin :feature_1