2

I am trying to generate a patch with only the files that are changed.

If the last 4 commits are A --> B --> C --> D, I want the latest version of the changed files only from all 4 commits.

So if File123.txt was changed in commit A and again in commit C, I want the version from commit C to be moved to a new directory, along with all the other changed files from all 4 commits.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578

2 Answers2

1

I ran git diff HEAD.. but I don't see any kind of output.

That is expected, since git diff HEAD.. would compare two commits, the second being... HEAD itself.

git diff @

That would compare HEAD with its parent commit (unless HEAD is a merge commit, in which case, you need the -m option (By default, git diff-tree --stdin does not show differences for merge commits).

I would also consider the git format-patch (as in here) to generate the patches (to apply with git am)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

If you want to generate a single patch file, which combines the changes of the last four commits, just run :

git diff xx D   # where 'xx' is the parent of A
# equivalent to :
git diff A^ D

# or if D is your active commit (HEAD) :
git diff HEAD~5 HEAD

If you want to list the files that were modified in these commits, just add --name-only to any of the commands above :

git diff --name-only HEAD~5 HEAD
LeGEC
  • 46,477
  • 5
  • 57
  • 104