1

Imagine for 3 files, for each I have made 2 changes. In total 6 changes.

Does git diff have any options to limit git diff to see one change at a time? And then move onto to the next change? i.e. I'd see 6 separate changes?

mfaani
  • 33,269
  • 19
  • 164
  • 293
  • 1
    I doubt it. You can vie individual files as in [this post](https://stackoverflow.com/questions/8048584/see-changes-to-a-specific-file-using-git)., but git doesn't store each individual change only how each file has been changed. – joshmeranda Sep 07 '21 at 21:23
  • @joshmeranda Thanks. Is there a way to see file by file? – mfaani Sep 07 '21 at 21:26
  • 5
    What are you trying to achieve here; what's the state of the repo and what do you mean by 2 changes in each file? If you're looking to review work in progress, maybe `git add -p`? – jonrsharpe Sep 07 '21 at 21:28
  • I think `git add -p` is a great alternative. Can you put that into an answer? I honestly didn't have a certain state in mind. I just wanted it to be interactive. I mean e.g. at line 12 there's a change and at like 52 there's another change in the same file. – mfaani Sep 07 '21 at 21:45
  • 1
    @Honey `git diff `, if you look at the help for [`git-diff`](https://git-scm.com/docs/git-diff) you can read a bit more if you don't go with the `git add -p` route as @johrsharpe suggests although they will provide similar functionality (diff will not allow you to add as you review) – joshmeranda Sep 07 '21 at 23:19

1 Answers1

1

Thanks to JonSharpe's comment, the closest thing to what I asked to do is:

git add -p

With the only note that it works for unstaged changes. There is no such thing as git diff -p. And git diff <path> isn't interactive as you have to manually enter the path yourself.

mfaani
  • 33,269
  • 19
  • 164
  • 293