`git commit -v` by default

Git

Git Problem Overview


How can I configure git commit to act as git commit -v (showing the full diff being committed) by default?

Using an alias is not quite satisfactory, as it does not affect commit message editing during operations which may indirectly commit, such as git rebase.

Git Solutions


Solution 1 - Git

If you are using git 2.9, this can be done with a config.

git config --global commit.verbose true

Git 2.9.0 Release Notes: <https://github.com/git/git/blob/v2.9.0/Documentation/RelNotes/2.9.0.txt> > "git commit" learned to pay attention to the "commit.verbose" configuration variable and act as if the "--verbose" option was given from the command line.

Solution 2 - Git

As far as I can tell, you can not override an already existing git command with an alias (otherwise, there would be no way to do the original command, and a bunch of stuff would break).

So I recommend you do something like git config --global "alias.ci" "commit -v". This will add a line to your ~/.gitconfig file and make it so that git ci does git commit -v. You should then just get into the habit of typing git ci instead of git commit (unless you decide you don't want the -v).

Solution 3 - Git

Well, I use aliases:

alias gc='git commit -v'

There are a bunch of nice aliases like this that I got off the PeepCode git screencasts, I believe.

Solution 4 - Git

I know this is an old question, but I happened to come across it and have an answer. I put the following function in .bash_profile:

#!/bin/bash                                                                            
                                                                                   
git()                                                                                  
{                                                                                      
    case "$1" in                                                                       
        ci|commit)
        gitargs=""
        for i in $@; do
            if [ "$1" != "$i" ]; then                                                  
                gitargs="$gitargs $i"
            fi  
        done
        command git commit -v $gitargs
        ;;  
    *)  
        command git "$@"
        ;;                                                                             
    esac                                                                               
}

This turns git into a bash function that transforms git commit into git commit -v and leaves the rest of the arguments mostly alone. However, it breaks git commit arguments that have whitespace, and it won't let you commit a file named ci or commit.

Solution 5 - Git

I just sent an e-mail to [email protected] and got the following response:

> 05.04.2016 16:47, Pranit Bauva: > On Tue, Apr 5, 2016 at 8:08 PM, Jacek Wielemborek <[email protected]> wrote: >> Hello, >> >> I'm asking for this one because there's quite a lot of interest >> (including me) in this feature and there is no convenient walkaround: >> >> https://stackoverflow.com/questions/5875275/git-commit-v-by-default >> >> Cheers, >> d33tah > > This is currently under progress. I am the one who is working on it. > One of the patches is currently on the pu branch. I am still polishing > it to include some more stuff. You can track its status by reading the > git.git messages by the git maintainer. The latest revision of the > patch is at http://thread.gmane.org/gmane.comp.version-control.git/288820 > > Thanks, > Pranit Bauva

Solution 6 - Git

The following put in .bashrc/.profile seems to do the job:

git() {
	if [[ "$1" = "commit" ]]; then
		shift
		command git commit -v "$@"
	else
		command git "$@"
	fi
}

Solution 7 - Git

Silly workaround: :!git log -1 -u

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKevin ReidView Question on Stackoverflow
Solution 1 - GitCheng KaiView Answer on Stackoverflow
Solution 2 - GitasmeurerView Answer on Stackoverflow
Solution 3 - Gituser122376View Answer on Stackoverflow
Solution 4 - GitboshvarkView Answer on Stackoverflow
Solution 5 - Gitd33tahView Answer on Stackoverflow
Solution 6 - GitArmandView Answer on Stackoverflow
Solution 7 - GitalxndrView Answer on Stackoverflow