Search code examples
gitapache-drill

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?


Solution

  • 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.