Home > Enterprise >  Compare changes from a set of commits to a prior version
Compare changes from a set of commits to a prior version

Time:10-14

I have a branch with commit A with a version of an application with verified working state. Than there are N commits that applied some potentially irrelevant/breaking changes. Followed by M commits which purpose was to implement some feature, but other potentially irrelevant/breaking changes were introduced. I need to select and apply changes that are only relevant to introduced feature and get rid of those that are irrelevant/potentially breaking.
So, it looks like: A -> N... -> M... -> P....
How can I compare changes from a set of M.. to A?


Similar question: Git diff between two commits without some commits in the middle

CodePudding user response:

I would suggest to create a branch, which starts from A, and contains only commits of the M... range.

You can do this using git rebase -i :

# create a new branch from your current branch :
git checkout -b feature

# run :
git rebase -i <A>

# an editor opens : the instructions on what to do with this file are
# explained as comments at the bottom of the file

# in your case : remove all lines mentioning commits in
# the 'N...' and 'P...' ranges

# save and exit

You may have to fix conflicts along the way, but the end result should be : a new branch, with a copy of all M... commits on top of A.

Comparing commits from this branch against A will be more straightforward.

CodePudding user response:

git diff should be able to help you:

git diff commitA commitM
  •  Tags:  
  • git
  • Related