简介
git可用于patch补丁的制作,下面是使用git命令的制作patch的过程
制作patch命令详解
#配置邮箱名和作者名
[root@localhost anaconda-21.48.21]# git config --global user.email "xxx@163.com"
[root@localhost anaconda-21.48.21]# git config --global user.name "xxx"
#查看配置
[root@localhost /]# git config --list
user.email=xxx@163.com
user.name=xxx
#初始化git仓库
root@localhost anaconda-21.48.21]# git init
初始化空的 Git 版本库于 /root/rpmbuild/BUILD/anaconda-21.48.21/.git/
#记录当前分支文件初始状态
root@localhost anaconda-21.48.21]# git add .
#制作初始状态标签
[root@localhost anaconda-21.48.21]# git commit -a -q -m "$1 first commit"
#查看提交记录
[root@localhost anaconda-21.48.21]# git log
commit 88cc5244c5e7c5d37514fb535a6623884ad8d1eb
Author: xxx <xxx@163.com>
Date: Sun Feb 21 16:23:35 2021 +0800
first commit
[root@localhost anaconda-21.48.21]# git commit -a -q -m " first commit"
位于分支 master
无文件要提交,干净的工作区
#新建patch分支
[root@localhost anaconda-21.48.21]# git branch patch
#切换到patch分支
[root@localhost anaconda-21.48.21]# git checkout patch
切换到分支 'patch'
#直接修改源码
[root@localhost anaconda-21.48.21]# vim anaconda
#若新增文件需要执行git add filename
[root@localhost anaconda-21.48.21]# touch test.c
[root@localhost anaconda-21.48.21]# git add test.c
#修改文件后重新制作标签
[root@localhost anaconda-21.48.21]# git commit -a -m "Test"
[patch 95e6fc5] Test
1 file changed, 1 insertion(+)
#生成0001-Test.patch文件,在文件中已经记录了所修改的内容
[root@localhost anaconda-21.48.21]# git format-patch -M master
0001-Test.patch