I made a 2 lines of change but in git It shows more lines of changes because of whitespace. Its very difficult for us to review the exact code changes.
The below are the
Another way to look at the problem is to be more cautious with the way you stage your changes.
In your above example you're using two very broad sweeping ways to search for changes in your codebase before committing.
git add .
git commit -am "changes"
The .
parameter for add
is already staging all detected changes (not exactly, see the excellent answers here for more details), but on top of that you're using the -a
parameter for commit
, which I'd describe as redundant overkill, since you're staging ALL changes AGAIN.
Your context may make my following advice more or less practical, but you might consider adding your changed files "manually" :
# check your changes (at this point, whitespace differences should not show up)
git status
# let's assume the above line showed changes in 3 files
git add
# then commit without staging parameter
git commit -m "changes"
And if the process seems tedious to you, keep in mind that :
add -i
, which allows you to iteratively look at changes to decide what's to be actually staged.