Git Repo下如何制作一个patch文件

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文件,非常容易查看的,仔细核对是否是这些改动。

在这里插入图片描述

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文本记录的需求,详见:

虽然,目前上述需求还有一些问题,但是整体上已经非常接近。只要修正一些小问题,相信不久的将来就能赏心悦目了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值