Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Empty patch created using "git format-patch origin/master --stdout"

I was looking into Drill's(open source github project) documentation to create a patch.

I came across this command:

git format-patch origin/master --stdout > DRILL-1234.1.patch.txt

I made some changes. I verified my changes by git status. I modified a .java file. I tried above-mentioned command to create a patch.

I opened DRILL-1234.1.patch.txt & its empty.

Then I tried git add <modified file> & tried the same command, still empty patch file.

What am I missing?

like image 288
Dev Avatar asked Nov 01 '25 17:11

Dev


2 Answers

You must have some content (commits) in order to create path.
Commit your changes and the create a patch

git format-patch HEAD~X // x is the number of commits you need
like image 50
CodeWizard Avatar answered Nov 04 '25 09:11

CodeWizard


Git format-patch creates patches from commits. So you have to perform git commit first.

Also - I don't think --stdout does what you think it does.

From here: https://git-scm.com/docs/git-format-patch

The names of the output files are printed to standard output, unless the --stdout option is specified.

format-patch creates one patch file for each commit you have. It does not output the file itself, but the name of the patches files.

like image 42
Igal S. Avatar answered Nov 04 '25 08:11

Igal S.