<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass[onecolumn,letterpaper,11pt]{article}

%===================================================================
\input{common_latex/common_latex_packages}
\input{common_latex/common_latex_definitions}
\input{common_latex/common_latex_help_format}
%===================================================================

\begin{document}

\begin{labcover}
\labtitle{Help Topic: The Git Commit Command}
\vspace{0.1in}
\labdate{Fall 2024}
\vspace{0.1in}
\labauth{Michael Benjamin, mikerb@mit.edu}
\labauth{Oscar Viquez, oviquezr@mit.edu}
\labauth{Department of Mechanical Engineering}
\labauth{MIT, Cambridge MA 02139}
\labline
\end{labcover}

\wikidoc{file=Help.GitCommit}
\wikidoc{auth=mikerb@mit.edu}

%====================================================================
\section*{The Git \cmd{commit} Command}
%====================================================================

The \cmd{git commit} command records changes from your working copy to
the repository. A log message must be provided. The message can be given
on the command line, from a file, or an editor may be launched as the
commit proceeds.  More info on \cmd{git commit} can always be found by
Googling "Git book" and reading the full PDF online free, or just typing
\cmd{git help commit} anytime on the command line.

%---------------------------------------------------------------------
\subsection*{Basic usage of the \cmd{git commit} and \cmd{git push} commands}

The basic syntax for the \cmd{git commit} command is as follows.

\vspace{0.1in}
\begin{consoleverb}
 $ git commit -m "brief commit message"
\end{consoleverb}
\vspace{0.15in}

\noindent
The \cmd{git commit} command does {\em not} require a network connection.
With this command, the changes previously staged with \cmd{git add} and
\cmd{git rm} are now formally recorded in the local copy of the repository's
records. To send the committed changes to the server, an additional
command is needed:

\vspace{0.1in}
\begin{consoleverb}
 $ git push
\end{consoleverb}
\vspace{0.15in}

\noindent
The \cmd{git push} command {\em does} require a network connection
to the server, and you will be prompted for a password (unless you have
something like ssh keys in use).

\vspace{0.1in}
\noindent
The \cmd{-m "brief message"} option is essentially allowing the commit
to proceed without any textual log file comment. This is generally not
recommended for large projects, where more detailed commit documentation
is often preferred. However, for individual repositories with small
incremental changes per commit, the brief messages are often sufficient.

%------------------------------------------------------------------
\subsection*{Collecting the commit message from a file}

In addition to brief one-line comments, Git supports longer commit for
instances where more verbose change tracking is needed. One of the
solutions to manage this is to collect the message from a file, using
the following command:

\vspace{0.1in}
\begin{consoleverb}
 $ git commit -F &lt;file&gt;
\end{consoleverb}
\vspace{0.15in}

%------------------------------------------------------------------
\subsection*{Configuring Git with an editor of your choosing}

Another approach to handling long commit messages is to prompt the
user with a text editor window, where the user can proceed to type
the desired details about the commit. By default, Git uses whatever
the user has set as the default text editor â€“ this can be done via
one of the shell environment variables \var{VISUAL} or \var{EDITOR}.
Otherwise, Git falls back to the vi editor to create and edit your
commit messages. To change that default to something else, you can
use the core.editor setting:

\vspace{0.1in}
\begin{consoleverb}
 $ git config --global core.editor emacs
\end{consoleverb}
\vspace{0.15in}


\pskip
\noindent
If you're a \var{bash} user, you can set the \var{EDITOR} environment
variable by adding the following lines to your \var{.bashrc} file,
with the editor of your choosing:

\vspace{0.1in}
\begin{fileverb}
  export EDITOR=emacs
\end{fileverb}
\vspace{0.15in}

\noindent
To check the prevailing value of an environment variable, e.g., \var{EDITOR}, 
just type this on the command line: \cmd{echo \$EDITOR}.


\end{document}

</pre></body></html>