tags: - git categories: - informational comments: true

date: 2022-05-28 00:00:00

DESCRIPTION

Create patch files for last X commits in in one git repo and apply them to another repo

ERRORS

VERIFICATION

COMMANDS

mkdir /tmp/dir1
cd /tmp/dir1
git init
echo 'file one' > file1
git add file1
git commit -m file1
git push

echo 'file two' > file2
git add file2
git commit -m file2
git push
git format-patch -2
git format-patch -2 --stdout > file1-file2.patch
mkdir /tmp/dir2
cd /tmp/dir2
git init
cp ../dir1/000* .
ls
0001-file1.patch  0002-file2.patch
git am 0001-file1.patch
Applying: file1
applying to an empty history
git am 0002-file2.patch
Applying: file2
mkdir /tmp/dir3
cd /tmp/dir3
git init
Initialized empty Git repository in /tmp/.git/
cp ../dir/file1-file2.patch .
git am file1-file2.patch
Applying: file1
applying to an empty history
Applying: file2

Reference

https://www.ivankristianto.com/create-patch-files-from-multiple-commits-in-git/