Reputation: 681
I have a git log like:
commit: abasued1..
commit: jsdiq7di..
commit: 2348fbvb..
commit: 0123ruhw..
commit: 9chvef87..
commit: 834rhbf3..
I want a diff of changes between commits 834rhbf3..
and abasued1..
without the commits 0123ruhw..
and 2348fbvb..
included in it.
I know how to get the entire diff between the two commits, but is there a way to exclude certain commits from a range?
Upvotes: 2
Views: 2798
Reputation: 2569
An indirect way but serves the purpose:
Now, do a diff for the two branches as follows:
git diff B1..B2
Upvotes: 0
Reputation: 3538
If I understand correctly, you want a diff containing the changes between two points in time, except for changes that occurred as part of a certain two commits.
I don't believe there's a way to do it with a single command; git simply wouldn't be able to construct a meaningful diff if any of your later changes depended on the excluded commits.
If you want to give this a shot without modifying your branch, you can do three separate diffs:
git diff 834rhbf3 9chvef87 # changes made in 9chvef87
git diff 2348fbvb jsdiq7di # changes made in jsdiq7di
git diff jsdiq7di abasued1 # changes made in abasued1
Note that, if changes in abasued1
or jsdiq7di
build on changes in the two excluded commits, you will still see portions of them as context.
Upvotes: 2
Reputation: 4316
I think I finally understand you. you can use this.
$ git revert --no-edit 2348fbvb
$ git revert --no-edit 0123ruhw
$ git diff 834rhbf3 HEAD
ORIGINAL POST
Maybe I misunderstood you, but have you tried git diff 834rhbf3 abasued1
? see here.
Upvotes: 3
Reputation: 96484
Here's an unconventional and brute force approach.
First, for safety, make a copy of the entire project at the root where the .git directory is.
Now, using this copy...
Use the interactive rebase process, e.g. git rebase -i HEAD~10
and actually delete the commits you don't want (by deleting the entire lines that represents those commits) and save your work.
Then you'll be able to do the git diff
of commitA to commitB without the commits between.
Then delete this directory (rm -r
) so you don't accidentally push it anywhere!
Upvotes: -1