1

For example, let's focus on the latest 4 successive commits. commit1 is the latest while commit4 the earliest:

commit1 HEAD
commit2
commit3
commit4
...

I want get patch file from commit1&2&3. I have tried the following two commands, but they generates different patch files:

git diff commit4 commit1 -- > file.patch
git format-patch -3 commit1 --stadout > file.patch

I want to know if the difference is crucial? Could I use any of them?

Zachary
  • 1,633
  • 2
  • 22
  • 34

2 Answers2

1

git diff only shows changes to the content, but git format-patch includes commit messages as well, making it more appropriate for most scenarios involving exchanging patches with other people (for example, so that you can share them using git send-email, or they can apply them via git am).

Greg Hurrell
  • 5,177
  • 23
  • 27
0

I want get patch file from commit1&2&3 ==> you may use git format-patch commit1..commit3 --stdout > file.patch

Simon
  • 11
  • 2
  • 2
    This question was asked in 2015 and has already been answered, please refrain from bumping old questions unless you actually have something to add. – Havenard Nov 06 '18 at 03:01