Git Repo下如何制作一个patch文件
- 1. 源由
- 2. 步骤
- 2.1 本地代码差异
- 2.2 添加修改代码
- 2.3 添加未跟踪代码
- 2.4 确认打包文件
- 2.5 输出打包文件
- 2.6 自查打包文件
- 2.7 恢复工作环境
- 3. 总结
1. 源由
patch
分享,更好的差异化比较,减少时间浪费。同时,也可以作为系统集成的差异化补丁,快速实现本地集成。
2. 步骤
2.1 本地代码差异
daniel@daniel-nvidia:~/Work/jetson-fpv/module/msposd$ git status
On branch main
Your branch is up to date with 'origin/main'.
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: Makefile
modified: README.md
modified: msposd.c
modified: osd.c
Untracked files:
(use "git add <file>..." to include in what will be committed)
osd.h
osd/util/subtitle.c
osd/util/subtitle.h
no changes added to commit (use "git add" and/or "git commit -a")
2.2 添加修改代码
daniel@daniel-nvidia:~/Work/jetson-fpv/module/msposd$ git add Makefile
daniel@daniel-nvidia:~/Work/jetson-fpv/module/msposd$ git add README.md
daniel@daniel-nvidia:~/Work/jetson-fpv/module/msposd$ git add msposd.c
daniel@daniel-nvidia:~/Work/jetson-fpv/module/msposd$ git add osd.
2.3 添加未跟踪代码
daniel@daniel-nvidia:~/Work/jetson-fpv/module/msposd$ git add osd.h
daniel@daniel-nvidia:~/Work/jetson-fpv/module/msposd$ git add osd/util/subtitle.c
daniel@daniel-nvidia:~/Work/jetson-fpv/module/msposd$ git add osd/util/subtitle.h
2.4 确认打包文件
daniel@daniel-nvidia:~/Work/jetson-fpv/module/msposd$ git satus
git: 'satus' is not a git command. See 'git --help'.
The most similar command is
status
daniel@daniel-nvidia:~/Work/jetson-fpv/module/msposd$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: Makefile
modified: README.md
modified: msposd.c
modified: osd.c
new file: osd.h
new file: osd/util/subtitle.c
new file: osd/util/subtitle.h
2.5 输出打包文件
daniel@daniel-nvidia:~/Work/jetson-fpv/module/msposd$ git diff --cached > msposd.srt.53.patch
2.6 自查打包文件
Windows系统下,双击Patch
文件,非常容易查看的,仔细核对是否是这些改动。
- msposd.srt.53.patch
2.7 恢复工作环境
从这里可以看到多了msposd.srt.53.patch
打包文件,其他和2.1一样。
daniel@daniel-nvidia:~/Work/jetson-fpv/module/msposd$ git restore --staged .
daniel@daniel-nvidia:~/Work/jetson-fpv/module/msposd$ git status
On branch main
Your branch is up to date with 'origin/main'.
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: Makefile
modified: README.md
modified: msposd.c
modified: osd.c
Untracked files:
(use "git add <file>..." to include in what will be committed)
msposd.srt.53.patch
osd.h
osd/util/subtitle.c
osd/util/subtitle.h
no changes added to commit (use "git add" and/or "git commit -a")
3. 总结
这份分享代码,就是针对最近在折腾的原始视频+OSD文本记录的需求,详见:
- [Request] OSD info save as sperate files, not in DVR #35
- add osd/srt support #53
虽然,目前上述需求还有一些问题,但是整体上已经非常接近。只要修正一些小问题,相信不久的将来就能赏心悦目了。