Search code examples
gitgit-diffgit-config

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.


Solution

  • 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