User Tools

Site Tools


git_commit

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
git_commit [2019/02/20 08:26]
rpjday [git diff]
git_commit [2019/02/28 12:36] (current)
rpjday [-a]
Line 3: Line 3:
 Miscellaneous notes on ''​git commit'',​ using the Linux kernel source as an example. Miscellaneous notes on ''​git commit'',​ using the Linux kernel source as an example.
  
 +===== SYNOPSIS =====
 +
 +<​code>​
 +git commit [-a | --interactive | --patch] [-s] [-v] [-u<​mode>​] [--amend]
 +           ​[--dry-run] [(-c | -C | --fixup | --squash) <​commit>​]
 +           [-F <​file>​ | -m <​msg>​] [--reset-author] [--allow-empty]
 +           ​[--allow-empty-message] [--no-verify] [-e] [--author=<​author>​]
 +           ​[--date=<​date>​] [--cleanup=<​mode>​] [--[no-]status]
 +           [-i | -o] [-S[<​keyid>​]] [--] [<​file>​...]
 +</​code>​
 ===== Examining what is about to be committed ===== ===== Examining what is about to be committed =====
  
Line 58: Line 68:
 ==== git diff --cached --stat ==== ==== git diff --cached --stat ====
  
-For a histogram-style summary:+For a histogram-style summary, add ''​%%--%%stat''​:
  
 <​code>​ <​code>​
Line 67: Line 77:
 $ $
 </​code>​ </​code>​
-===== Template ===== 
  
-This might be worth setting at the system level.+===== Popular commit options ===== 
 + 
 +==== "​-m"​ ====
  
 <​code>​ <​code>​
-$ git config ​--global ​commit.template ~/.gitmessage.txt+-m <​msg>, ​--message=<​msg>​ 
 +    Use the given <msg> as the commit ​messageIf multiple -m 
 +    options are given, their values are concatenated as 
 +    separate paragraphs. 
 + 
 +    The -m option is mutually exclusive with -c, -C, and -F.
 </​code>​ </​code>​
  
-Example ​''​~/​.gitmessage.txt'':​+==== "​-a"​ ==== 
 + 
 +Note how this option accommodates both the modifications and deletions of tracked files: 
 + 
 +<​code>​ 
 +-a, --all 
 +    Tell the command to automatically stage files that have 
 +    been modified and deleted, but new files you have not told 
 +    Git about are not affected. 
 +</​code>​ 
 +===== Defining a commit template ===== 
 + 
 +You can define a more informative commit //​template//​ message, say in a personal ​''​~/​.gitmessage.txt'' ​file:
  
 <​code>​ <​code>​
Line 84: Line 112:
  
 [Ticket: X] [Ticket: X]
 +</​code>​
 +
 +and have it used in one of two ways when committing.
 +
 +First, manually at the command line:
 +
 +<​code>​
 +-t <​file>,​ --template=<​file>​
 +    When editing the commit message, start the editor with the
 +    contents in the given file. The commit.template
 +    configuration variable is often used to give this option
 +    implicitly to the command. This mechanism can be used by
 +    projects that want to guide participants with some hints on
 +    what to write in the message in what order. If the user
 +    exits the editor without editing the message, the commit is
 +    aborted. This has no effect when a message is given by
 +    other means, e.g. with the -m or -F options.
 +</​code>​
 +
 +As a second option, set it once as a configuration setting:
 +
 +<​code>​
 +$ git config --global commit.template ~/​.gitmessage.txt
 </​code>​ </​code>​
git_commit.1550651208.txt.gz · Last modified: 2019/02/20 08:26 by rpjday