Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: show more context when using git add -i or git add -e?

Tags:

git

I'm selectively committing parts of a large file and I'd like to see more context around each hunk. Is this possible?

like image 812
Shawn J. Goff Avatar asked Jul 15 '11 18:07

Shawn J. Goff


People also ask

How do I see changes after git add?

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.

Why git diff does not show changes?

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.

In which situation should you use git diff?

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.

Does git diff use diff?

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.


1 Answers

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.

like image 157
hammar Avatar answered Oct 18 '22 10:10

hammar