Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use --relative with git format-patch?

When I use git diff --relative HEAD^..HEAD, I get some nice output for a patch that I strip out the path outside the directory it is in.

I am starting to use git format-patch and I would like to also use --relative but don't see any options for that. How would I get the same effect?

Thanks

like image 765
Elijah Lynn Avatar asked Apr 30 '13 21:04

Elijah Lynn


People also ask

How do I format a patch in git?

In order to create Git patch file for a specific commit, use the “git format-patch” command with the “-1” option and the commit SHA. In order to get the commit SHA, you have to use the “git log” command and look for the corresponding commit SHA.

What is a patch file in git?

Patch is a text file, whose contents are similar to Git diff, but along with code, it also has metadata about commits; e.g., commit ID, date, commit message, etc. We can create a patch from commits and other people can apply them to their repository. Jerry implements the strcat function for his project.


1 Answers

git help format-patch shows

   git format-patch [-k] [(-o|--output-directory) <dir> | --stdout]
   ...
                      **[<common diff options>]**

So, just git format-patch --relative.

like image 188
kan Avatar answered Oct 17 '22 07:10

kan