Unhandled Exception
Unhandled Exception

Reputation: 1513

How to view the changes between start and finished in a file that has undergone numerous commits?

Lets say a file undergoes a number of modifications and commits.

Eventually those changed also need to be extracted for another baseline.

Here is the scenario.

 - Start Here.
 - Edit & Commit 1
 - Edit & Commit 2
 - Edit & Commit 3
   :
   :
 - Edit & Commit n
 - Final Commit

Using gitk and it lists each individual commit. Usually this is a decent tool, but in this specific scenario each Edit & Commit may add new code and remove code done from a previous commit. Working in the scenario to extract code is cumbersome as you may find the same code is added/removed/moved/added someplace else......

All I want to see is the Before (Start Here) and After (Final Commit) and not concerned about the various commits.

Is there a tool available that allows me to simply view the changes between "Start HERE" and "Final Commit"?

Upvotes: 0

Views: 57

Answers (2)

Unhandled Exception
Unhandled Exception

Reputation: 1513

Here is what I had to do. Not certain if it is what the above posts mentioned or not.

 - My Final Edit & Commit 
 - My Edit & Commit 2
 - My Initial Edit & Commit 1    <----Don't use this.
 - Someone Else Edit & Commit    <----Use this as the first commit
 - Original File 

Originally I was doing the following diff and it was not showing me all the changes.

 git diff <My Initial Edit & Commit 1> <My Final Edit & Commit> <myFile>

What I had to do :

 git diff <Someone Else Edit & Commit> <My Final Edit & Commit> <myFile>

Once I did the commit prior to my first commit I was able to see all the changes in a single summary.

Not certain if that is what the above responses were actually stating.

Also, if the file only has my 3 changes and no changes prior or commits to reference, I find myself with the original issue of not seeing all the modifications.

Upvotes: 0

LeGEC
LeGEC

Reputation: 51870

gitk has a "Mark this commit" action,

once you have marked the first commit you will see extra actions on a second commit, such as : "Compare with marked commit".


More generally : you are looking for a way to view the diff between two commits ("Start HERE" and "Final Commit").

There are many other ways to do that :

  • in a terminal :

    git diff <commitA> <commitB> -- some/file
    
  • opening a graphical diff tool:

    git difftool <commitA> <commitB> -- some/file
    # look for 'diff.tool' in 'git help config' for details on difftool
    
  • all gui frontends to git (like gitk, but also git gui, git-kraken, git-extensions etc ...) have a way to compare two commits,

    either with a "mark first commit" / "diff with second commit" (as in gitk),
    or by allowing to select two commits (ctrl+Click) and a "diff selected commits" action


To tell gitk to focus on a particular set of files (or a single file) :

you can start gitk with filtering options:

gitk -- some/files

or, once gitk is open, you can execute the "View > New view ..." action,
a dialog will open, with a text field "Enter files and directories to include, one per line" near the bottom.

Upvotes: 1

Related Questions