Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`git commit -v` by default

Tags:

git

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.

like image 539
Kevin Reid Avatar asked May 03 '11 20:05

Kevin Reid


People also ask

What does the git commit command do by default?

A shortcut command that immediately creates a commit with a passed commit message. By default, git commit will open up the locally configured text editor, and prompt for a commit message to be entered. Passing the -m option will forgo the text editor prompt in-favor of an inline message.

What is default editor in git?

On Windows, if you use Git Bash the default editor will be Vim. Vim is another text editor, like nano or notepad. In order to get started Vim there are only a few commands you must remember.

What do you call initial commit?

Usually the first commit is named "Initial commit". As best practice its include a README file describing the project. The README is usually is a md file. You can put any code you wish as well.

What is conventional commit?

The Conventional Commits specification is a lightweight convention on top of commit messages. It provides an easy set of rules for creating an explicit commit history; which makes it easier to write automated tools on top of.


2 Answers

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).

like image 43
asmeurer Avatar answered Oct 04 '22 04:10

asmeurer


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.

like image 167
Cheng Kai Avatar answered Oct 04 '22 05:10

Cheng Kai