Skip to main content
nataut
Associate III
June 20, 2023
Solved

only one patch file to patching multiple couples of files

  • June 20, 2023
  • 2 replies
  • 2613 views
Hello all.
I would like clarification about the structure of a patch file made with the "git diff" command.

First question. Are the SHA (Secure Hash Algorithm) codes contained in the file patch important? Let me explain better. Once the patch file is made, if I edit it with a text editor by adding or removing parts, the SHA codes not match with the new file content, is it right? Under these conditions, does the patch file still work correctly?
Second question. To make the patch file "my_file.patch" between two files "my_file1.txt" and "my_file2.txt" I use the command
git diff --no-index my_file1.txt my_file2.txt > ./my_file.patch
Let suppose now to have six files named "my_file1.txt", "my_file2.txt", "my_file3.txt", "my_file4.txt", "my_file5.txt" and "my_file6.txt". What is the way to create ONE ONLY patch file that compare and patches the couples my_file1.txt/my_file2.txt, my_file3.txt/my_file4.txt and my_file5.txt/my_file6.txt?

Many thanks
Regards

 

This topic has been closed for replies.
Best answer by Erwan SZYMANSKI

Hello @nataut ,

On a patch, SHA1 is most of all a unique identifier that can point on a specific commit just by its SHA1 number. In your case, if I well understand, you have to "combine" different commits in one to send it easier. This is more a git question than a ST question and you should be able to find a trick online. I think that a such link can help you.

(Mentioned on the previous link:

git format-patch <SHA1_start>^..<SHA1_end> --stdout > final.patch

Then git am final.patch to apply)

Kind regards,

Erwan.

2 replies

nataut
natautAuthor
Associate III
June 20, 2023

Sorry, I made a mistake copying and pasting the message. I rewrite it.

I would like clarification about the structure of a patch file made with the "git diff" command

First question. Are the SHA (Secure Hash Algorithm) codes contained in the file patch important? Let me explain better. Once the patch file is made, if I edit it with a text editor by adding or removing parts, the SHA codes not match with the new file content, is it right? Under these conditions, does the patch file still work correctly?
Second question. To make the patch file "my_file.patch" between two files "my_file1.txt" and "my_file2.txt" I use the command

git diff --no-index my_file1.txt my_file2.txt > ./my_file.patch

Let suppose now to have six files named "my_file1.txt", "my_file2.txt", "my_file3.txt", "my_file4.txt", "my_file5.txt" and "my_file6.txt". What is the way to create ONE ONLY patch file that compare and patches the couples my_file1.txt/my_file2.txt, my_file3.txt/my_file4.txt and my_file5.txt/my_file6.txt?

Many thanks
Regards

Erwan SZYMANSKI
Erwan SZYMANSKIBest answer
Technical Moderator
June 20, 2023

Hello @nataut ,

On a patch, SHA1 is most of all a unique identifier that can point on a specific commit just by its SHA1 number. In your case, if I well understand, you have to "combine" different commits in one to send it easier. This is more a git question than a ST question and you should be able to find a trick online. I think that a such link can help you.

(Mentioned on the previous link:

git format-patch <SHA1_start>^..<SHA1_end> --stdout > final.patch

Then git am final.patch to apply)

Kind regards,

Erwan.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
nataut
natautAuthor
Associate III
June 20, 2023

Hello @Erwan SZYMANSKI , 

I'll try to read the link you suggested me

Thanks