4

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?

Dev
  • 13,492
  • 19
  • 81
  • 174
  • Note: [Git 2.41 Q2 2023 `git format-patch` does manage empty commits](https://stackoverflow.com/a/34692447/6309). – VonC Apr 24 '23 at 18:49

2 Answers2

3

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
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
2

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.

Igal S.
  • 13,146
  • 5
  • 30
  • 48