Making Git a little less verbose

Git has some output that can be very helpful to people getting started with it. Once you’ve been using Git for a while, however, you may find that the advice that Git provides to help deal with certain situations just ends up taking up screen real estate. Fortunately, there is a way to turn off a number of these messages.

There are currently six settings to adjust the extra help messages that Git provides by default:

    pushNonFastForward = false
    statusHints        = false
    commitBeforeMerge  = false
    resolveConflict    = false
    implicitIdentity   = false
    detachedHead       = false


pushNonFastForward will turn off the extra help output by git-push(1) when attempting to push a non-fast-forward without using -f, or the +<ref> form of a ref.

Non-fast-forward push with advice

Above, we see the output of attempting to push a non-fast-forward, and below we see the output after setting advice.pushNonFastForward. The difference is only three lines, but the output feels a lot cleaner especially if you already know how to deal with non-fast-forward pushes (merging, or forcing as appropriate).

Non-fast-forward push without advice


statusHints will turn off the hints provided by git-status(1) to help work with changed & new files in the repository.

'git status' with advice

Again, we see the command output above with the advice setting left at the default of true. Below we can see that we save about four lines of output every time we run git status on the command-line.

'git status' without advice


commitBeforeMerge will turn off the reminder to commit, or stash your changes if you have uncommitted changes that conflict with what you are attempting to merge.

'git merge topic-branch' with advice

The difference with advice.commitBeforeMerge doesn’t save us any lines of output, but it does help visually distinguish the error message that includes the list of files, from the line telling us that Git is aborting our attempt to merge (shown below).

'git merge topic-branch' without advice


resolveConflict affects multiple commands, all of which share the scenario of the command aborting due to unresolved conflicts in the work tree/staging-area. The example I will show below is trying to commit before marking all conflicts as resolved.

'git commit' with unresolved conflicts and advice

This is another setting that can save us a couple of lines of output that don’t really help us much after we’ve done this task a couple of times.

'git commit' with unresolved conflicts and advice turned off


implicitIdentity is one that I don’t personally use since I have my name and email set in my ~/.gitconfig, but can come in handy if you rely on Git automatically guessing your name and email from the system you’re on.

Output from 'git commit' when your identity is guessed and advice is enabled

The output after running git commit when Git guesses your name and email is…well…massive. If you rely on having an email generated from the FQDN of the current host, you really should turn off this advice, and save yourself a ton of wasted screen real estate.

Output from 'git commit' when your identity is guessed and advice is disabled


detachedHead is quite handy if you’re comfortable working with Git in a ‘detached HEAD’ state (doubly so, if you have your shell prompt setup to help you remember if you’re currently in a detached head state or not.

Output from 'git checkout HEAD^0' with advice

Turning off the advice when entering a ‘detached HEAD’ state is another one that will end up saving huge amounts of screen real estate once you get comfortable working with this aspect of Git (especially if you have your prompt remind you)..

Output from 'git checkout HEAD^0' without advice