I'm selectively committing parts of a large file and I'd like to see more context around each hunk. Is this possible?
Conclusion. As you work with Git, the status command will be your daily friend. It will help you see exactly what files you've changed, what new files you need to add to source control, and what changes are sitting in the staging area.
Your file is already staged to be committed. You can show it's diff using the --cached option of git. To unstage it, just do what git status suggests in it's output ;) You can check The Git Index For more info.
The git diff command helps you see, compare, and understand changes in your project. You can use it in many different situations, e.g. to look at current changes in your working copy, past changes in commits, or even to compare branches.
Comparing changes with git diffgit diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.
Short answer: no.
git diff
has the -U<n>
option which allows you to customize the number of lines to show around a change. For example, git diff -U5 ...
will show 5 lines of context. As far as I can tell, there is no such option available for the diff display in the interactive mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With