Sridhar Sarnobat
Sridhar Sarnobat

Reputation: 25236

git config diff.name-only?

Is it possible to make git diff show --name-only output by default (i.e. without having to explicitly type --name-only)?

I know you can set defaults on some git options with git config, but I can't figure out how to map between the command line options and the config options. I rely on Googling to see others who've already done it, but I don't see anyone who's wanted this particular default setting.

Upvotes: 1

Views: 188

Answers (2)

romants
romants

Reputation: 3648

According to GitConfig there is no such option among configuration variables, so you can only achieve this using Git Aliases

git config --global alias.diffn 'diff --name-only'

Or setting it manually in .gitconfig under [alias] section:

diffn = diff --name-only

I would also recommend looking at dotfiles repos for more inspiration on aliases and .gitconfig

Upvotes: 2

NIlesh Sharma
NIlesh Sharma

Reputation: 5655

You can use bash alias

echo "alias gitdiffname='git diff --name-only'">>~/.profile

source ~/.profile

gitdiffname

Upvotes: 0

Related Questions