diff options
Diffstat (limited to 'devdocs/git')
202 files changed, 8253 insertions, 0 deletions
diff --git a/devdocs/git/api-index.html b/devdocs/git/api-index.html new file mode 100644 index 00000000..ac1ad68d --- /dev/null +++ b/devdocs/git/api-index.html @@ -0,0 +1,6 @@ +<h1>Reference</h1> <p> Quick reference guides: <a href="https://github.github.com/training-kit/">GitHub Cheat Sheet</a> | <a href="https://ndpsoftware.com/git-cheatsheet.html">Visual Git Cheat Sheet</a> </p> <a href="git#_git_commands">Complete list of all commands</a> <div class="two-column"> <div class="column-left"> <h3 class="setup">Setup and Config</h3> <ul class="unstyled"> <li><a href="git">git</a></li> <li><a href="git-config">config</a></li> <li><a href="git-help">help</a></li> <li><a href="git-bugreport">bugreport</a></li> <a href="https://git-scm.com/doc/credential-helpers">Credential helpers</a> </ul> <h3 class="projects">Getting and Creating Projects</h3> <ul class="unstyled"> <li><a href="git-init">init</a></li> <li><a href="git-clone">clone</a></li> </ul> <h3 class="snapshotting">Basic Snapshotting</h3> <ul class="unstyled"> <li><a href="git-add">add</a></li> <li><a href="git-status">status</a></li> <li><a href="git-diff">diff</a></li> <li><a href="git-commit">commit</a></li> <li><a href="git-notes">notes</a></li> <li><a href="git-restore">restore</a></li> <li><a href="git-reset">reset</a></li> <li><a href="git-rm">rm</a></li> <li><a href="git-mv">mv</a></li> </ul> <h3 class="branching">Branching and Merging</h3> <ul class="unstyled"> <li><a href="git-branch">branch</a></li> <li><a href="git-checkout">checkout</a></li> <li><a href="git-switch">switch</a></li> <li><a href="git-merge">merge</a></li> <li><a href="git-mergetool">mergetool</a></li> <li><a href="git-log">log</a></li> <li><a href="git-stash">stash</a></li> <li><a href="git-tag">tag</a></li> <li><a href="git-worktree">worktree</a></li> </ul> <h3 class="sharing">Sharing and Updating Projects</h3> <ul class="unstyled"> <li><a href="git-fetch">fetch</a></li> <li><a href="git-pull">pull</a></li> <li><a href="git-push">push</a></li> <li><a href="git-remote">remote</a></li> <li><a href="git-submodule">submodule</a></li> </ul> <h3 class="inspection">Inspection and Comparison</h3> <ul class="unstyled"> <li><a href="git-show">show</a></li> <li><a href="git-log">log</a></li> <li><a href="git-diff">diff</a></li> <li><a href="git-difftool">difftool</a></li> <li><a href="git-range-diff">range-diff</a></li> <li><a href="git-shortlog">shortlog</a></li> <li><a href="git-describe">describe</a></li> </ul> <h3 class="patching">Patching</h3> <ul class="unstyled"> <li><a href="git-apply">apply</a></li> <li><a href="git-cherry-pick">cherry-pick</a></li> <li><a href="git-diff">diff</a></li> <li><a href="git-rebase">rebase</a></li> <li><a href="git-revert">revert</a></li> </ul> <h3 class="debugging">Debugging</h3> <ul class="unstyled"> <li><a href="git-bisect">bisect</a></li> <li><a href="git-blame">blame</a></li> <li><a href="git-grep">grep</a></li> </ul> </div> <div class="column-right"> <h3 class="guides">Guides</h3> <ul class="unstyled"> <li><a href="gitattributes">gitattributes</a></li> <li><a href="gitcli">Command-line interface conventions</a></li> <li><a href="giteveryday">Everyday Git</a></li> <li><a href="gitfaq">Frequently Asked Questions (FAQ)</a></li> <li><a href="gitglossary">Glossary</a></li> <li><a href="githooks">Hooks</a></li> <li><a href="gitignore">gitignore</a></li> <li><a href="gitmodules">gitmodules</a></li> <li><a href="gitrevisions">Revisions</a></li> <li><a href="gitsubmodules">Submodules</a></li> <li><a href="gittutorial">Tutorial</a></li> <li><a href="gitworkflows">Workflows</a></li> <li><a href="git#_guides">All guides...</a></li> </ul> <h3 class="email">Email</h3> <ul class="unstyled"> <li><a href="git-am">am</a></li> <li><a href="git-apply">apply</a></li> <li><a href="git-format-patch">format-patch</a></li> <li><a href="git-send-email">send-email</a></li> <li><a href="git-request-pull">request-pull</a></li> </ul> <h3 class="external">External Systems</h3> <ul class="unstyled"> <li><a href="git-svn">svn</a></li> <li><a href="git-fast-import">fast-import</a></li> </ul> <h3 class="admin">Administration</h3> <ul class="unstyled"> <li><a href="git-clean">clean</a></li> <li><a href="git-gc">gc</a></li> <li><a href="git-fsck">fsck</a></li> <li><a href="git-reflog">reflog</a></li> <li><a href="git-filter-branch">filter-branch</a></li> <li><a href="git-instaweb">instaweb</a></li> <li><a href="git-archive">archive</a></li> <li><a href="git-bundle">bundle</a></li> </ul> <h3 class="server-admin">Server Admin</h3> <ul class="unstyled"> <li><a href="git-daemon">daemon</a></li> <li><a href="git-update-server-info">update-server-info</a></li> </ul> <h3 class="plumbing">Plumbing Commands</h3> <ul class="unstyled"> <li><a href="git-cat-file">cat-file</a></li> <li><a href="git-check-ignore">check-ignore</a></li> <li><a href="git-checkout-index">checkout-index</a></li> <li><a href="git-commit-tree">commit-tree</a></li> <li><a href="git-count-objects">count-objects</a></li> <li><a href="git-diff-index">diff-index</a></li> <li><a href="git-for-each-ref">for-each-ref</a></li> <li><a href="git-hash-object">hash-object</a></li> <li><a href="git-ls-files">ls-files</a></li> <li><a href="git-ls-tree">ls-tree</a></li> <li><a href="git-merge-base">merge-base</a></li> <li><a href="git-read-tree">read-tree</a></li> <li><a href="git-rev-list">rev-list</a></li> <li><a href="git-rev-parse">rev-parse</a></li> <li><a href="git-show-ref">show-ref</a></li> <li><a href="git-symbolic-ref">symbolic-ref</a></li> <li><a href="git-update-index">update-index</a></li> <li><a href="git-update-ref">update-ref</a></li> <li><a href="git-verify-pack">verify-pack</a></li> <li><a href="git-write-tree">write-tree</a></li> </ul> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/api-index" class="_attribution-link">https://git-scm.com/docs/api-index</a> + </p> +</div> diff --git a/devdocs/git/api-simple-ipc.html b/devdocs/git/api-simple-ipc.html new file mode 100644 index 00000000..d915e95e --- /dev/null +++ b/devdocs/git/api-simple-ipc.html @@ -0,0 +1,6 @@ +<h1>api-simple-ipc</h1> <div class="sectionbody"> <p>The Simple-IPC API is a collection of <code>ipc_</code> prefixed library routines and a basic communication protocol that allows an IPC-client process to send an application-specific IPC-request message to an IPC-server process and receive an application-specific IPC-response message.</p> <p>Communication occurs over a named pipe on Windows and a Unix domain socket on other platforms. IPC-clients and IPC-servers rendezvous at a previously agreed-to application-specific pathname (which is outside the scope of this design) that is local to the computer system.</p> <p>The IPC-server routines within the server application process create a thread pool to listen for connections and receive request messages from multiple concurrent IPC-clients. When received, these messages are dispatched up to the server application callbacks for handling. IPC-server routines then incrementally relay responses back to the IPC-client.</p> <p>The IPC-client routines within a client application process connect to the IPC-server and send a request message and wait for a response. When received, the response is returned back to the caller.</p> <p>For example, the <code>fsmonitor--daemon</code> feature will be built as a server application on top of the IPC-server library routines. It will have threads watching for file system events and a thread pool waiting for client connections. Clients, such as <code>git status</code>, will request a list of file system events since a point in time and the server will respond with a list of changed files and directories. The formats of the request and response are application-specific; the IPC-client and IPC-server routines treat them as opaque byte streams.</p> </div> <h2 id="_comparison_with_sub_process_model">Comparison with sub-process model</h2> <div class="sectionbody"> <p>The Simple-IPC mechanism differs from the existing <code>sub-process.c</code> model (Documentation/technical/long-running-process-protocol.txt) and used by applications like Git-LFS. In the LFS-style sub-process model, the helper is started by the foreground process, communication happens via a pair of file descriptors bound to the stdin/stdout of the sub-process, the sub-process only serves the current foreground process, and the sub-process exits when the foreground process terminates.</p> <p>In the Simple-IPC model the server is a very long-running service. It can service many clients at the same time and has a private socket or named pipe connection to each active client. It might be started (on-demand) by the current client process or it might have been started by a previous client or by the OS at boot time. The server process is not associated with a terminal and it persists after clients terminate. Clients do not have access to the stdin/stdout of the server process and therefore must communicate over sockets or named pipes.</p> </div> <h2 id="_server_startup_and_shutdown">Server startup and shutdown</h2> <div class="sectionbody"> <p>How an application server based upon IPC-server is started is also outside the scope of the Simple-IPC design and is a property of the application using it. For example, the server might be started or restarted during routine maintenance operations, or it might be started as a system service during the system boot-up sequence, or it might be started on-demand by a foreground Git command when needed.</p> <p>Similarly, server shutdown is a property of the application using the simple-ipc routines. For example, the server might decide to shutdown when idle or only upon explicit request.</p> </div> <h2 id="_simple_ipc_protocol">Simple-ipc protocol</h2> <div class="sectionbody"> <p>The Simple-IPC protocol consists of a single request message from the client and an optional response message from the server. Both the client and server messages are unlimited in length and are terminated with a flush packet.</p> <p>The pkt-line routines (<a href="gitprotocol-common">gitprotocol-common[5]</a>) are used to simplify buffer management during message generation, transmission, and reception. A flush packet is used to mark the end of the message. This allows the sender to incrementally generate and transmit the message. It allows the receiver to incrementally receive the message in chunks and to know when they have received the entire message.</p> <p>The actual byte format of the client request and server response messages are application specific. The IPC layer transmits and receives them as opaque byte buffers without any concern for the content within. It is the job of the calling application layer to understand the contents of the request and response messages.</p> </div> <h2 id="_summary">Summary</h2> <div class="sectionbody"> <p>Conceptually, the Simple-IPC protocol is similar to an HTTP REST request. Clients connect, make an application-specific and stateless request, receive an application-specific response, and disconnect. It is a one round trip facility for querying the server. The Simple-IPC routines hide the socket, named pipe, and thread pool details and allow the application layer to focus on the task at hand.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/api-simple-ipc" class="_attribution-link">https://git-scm.com/docs/api-simple-ipc</a> + </p> +</div> diff --git a/devdocs/git/api-trace2.html b/devdocs/git/api-trace2.html new file mode 100644 index 00000000..204d4047 --- /dev/null +++ b/devdocs/git/api-trace2.html @@ -0,0 +1,547 @@ +<h1>api-trace2</h1> <div class="sectionbody"> <p>The Trace2 API can be used to print debug, performance, and telemetry information to stderr or a file. The Trace2 feature is inactive unless explicitly enabled by enabling one or more Trace2 Targets.</p> <p>The Trace2 API is intended to replace the existing (Trace1) <code>printf()</code>-style tracing provided by the existing <code>GIT_TRACE</code> and <code>GIT_TRACE_PERFORMANCE</code> facilities. During initial implementation, Trace2 and Trace1 may operate in parallel.</p> <p>The Trace2 API defines a set of high-level messages with known fields, such as (<code>start</code>: <code>argv</code>) and (<code>exit</code>: {<code>exit-code</code>, <code>elapsed-time</code>}).</p> <p>Trace2 instrumentation throughout the Git code base sends Trace2 messages to the enabled Trace2 Targets. Targets transform these messages content into purpose-specific formats and write events to their data streams. In this manner, the Trace2 API can drive many different types of analysis.</p> <p>Targets are defined using a VTable allowing easy extension to other formats in the future. This might be used to define a binary format, for example.</p> <p>Trace2 is controlled using <code>trace2.*</code> config values in the system and global config files and <code>GIT_TRACE2*</code> environment variables. Trace2 does not read from repo local or worktree config files, nor does it respect <code>-c</code> command line config settings.</p> </div> <h2 id="_trace2_targets">Trace2 targets</h2> <div class="sectionbody"> <p>Trace2 defines the following set of Trace2 Targets. Format details are given in a later section.</p> <div class="sect2"> <h3 id="_the_normal_format_target"> +The Normal Format Target</h3> <p>The normal format target is a traditional <code>printf()</code> format and similar to the <code>GIT_TRACE</code> format. This format is enabled with the <code>GIT_TRACE2</code> environment variable or the <code>trace2.normalTarget</code> system or global config setting.</p> <p>For example</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ export GIT_TRACE2=~/log.normal +$ git version +git version 2.20.1.155.g426c96fcdb</pre> </div> </div> <p>or</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config --global trace2.normalTarget ~/log.normal +$ git version +git version 2.20.1.155.g426c96fcdb</pre> </div> </div> <p>yields</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat ~/log.normal +12:28:42.620009 common-main.c:38 version 2.20.1.155.g426c96fcdb +12:28:42.620989 common-main.c:39 start git version +12:28:42.621101 git.c:432 cmd_name version (version) +12:28:42.621215 git.c:662 exit elapsed:0.001227 code:0 +12:28:42.621250 trace2/tr2_tgt_normal.c:124 atexit elapsed:0.001265 code:0</pre> </div> </div> </div> <div class="sect2"> <h3 id="_the_performance_format_target"> +The Performance Format Target</h3> <p>The performance format target (PERF) is a column-based format to replace <code>GIT_TRACE_PERFORMANCE</code> and is suitable for development and testing, possibly to complement tools like <code>gprof</code>. This format is enabled with the <code>GIT_TRACE2_PERF</code> environment variable or the <code>trace2.perfTarget</code> system or global config setting.</p> <p>For example</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ export GIT_TRACE2_PERF=~/log.perf +$ git version +git version 2.20.1.155.g426c96fcdb</pre> </div> </div> <p>or</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config --global trace2.perfTarget ~/log.perf +$ git version +git version 2.20.1.155.g426c96fcdb</pre> </div> </div> <p>yields</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat ~/log.perf +12:28:42.620675 common-main.c:38 | d0 | main | version | | | | | 2.20.1.155.g426c96fcdb +12:28:42.621001 common-main.c:39 | d0 | main | start | | 0.001173 | | | git version +12:28:42.621111 git.c:432 | d0 | main | cmd_name | | | | | version (version) +12:28:42.621225 git.c:662 | d0 | main | exit | | 0.001227 | | | code:0 +12:28:42.621259 trace2/tr2_tgt_perf.c:211 | d0 | main | atexit | | 0.001265 | | | code:0</pre> </div> </div> </div> <div class="sect2"> <h3 id="_the_event_format_target"> +The Event Format Target</h3> <p>The event format target is a JSON-based format of event data suitable for telemetry analysis. This format is enabled with the <code>GIT_TRACE2_EVENT</code> environment variable or the <code>trace2.eventTarget</code> system or global config setting.</p> <p>For example</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ export GIT_TRACE2_EVENT=~/log.event +$ git version +git version 2.20.1.155.g426c96fcdb</pre> </div> </div> <p>or</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config --global trace2.eventTarget ~/log.event +$ git version +git version 2.20.1.155.g426c96fcdb</pre> </div> </div> <p>yields</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat ~/log.event +{"event":"version","sid":"20190408T191610.507018Z-H9b68c35f-P000059a8","thread":"main","time":"2019-01-16T17:28:42.620713Z","file":"common-main.c","line":38,"evt":"3","exe":"2.20.1.155.g426c96fcdb"} +{"event":"start","sid":"20190408T191610.507018Z-H9b68c35f-P000059a8","thread":"main","time":"2019-01-16T17:28:42.621027Z","file":"common-main.c","line":39,"t_abs":0.001173,"argv":["git","version"]} +{"event":"cmd_name","sid":"20190408T191610.507018Z-H9b68c35f-P000059a8","thread":"main","time":"2019-01-16T17:28:42.621122Z","file":"git.c","line":432,"name":"version","hierarchy":"version"} +{"event":"exit","sid":"20190408T191610.507018Z-H9b68c35f-P000059a8","thread":"main","time":"2019-01-16T17:28:42.621236Z","file":"git.c","line":662,"t_abs":0.001227,"code":0} +{"event":"atexit","sid":"20190408T191610.507018Z-H9b68c35f-P000059a8","thread":"main","time":"2019-01-16T17:28:42.621268Z","file":"trace2/tr2_tgt_event.c","line":163,"t_abs":0.001265,"code":0}</pre> </div> </div> </div> <div class="sect2"> <h3 id="_enabling_a_target"> +Enabling a Target</h3> <p>To enable a target, set the corresponding environment variable or system or global config value to one of the following:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>0</code> or <code>false</code> - Disables the target.</p> </li> <li> <p><code>1</code> or <code>true</code> - Writes to <code>STDERR</code>.</p> </li> <li> <p><code>[2-9]</code> - Writes to the already opened file descriptor.</p> </li> <li> <p><code><absolute-pathname></code> - Writes to the file in append mode. If the target already exists and is a directory, the traces will be written to files (one per process) underneath the given directory.</p> </li> <li> <p><code>af_unix:[<socket_type>:]<absolute-pathname></code> - Write to a Unix DomainSocket (on platforms that support them). Socket type can be either <code>stream</code> or <code>dgram</code>; if omitted Git will try both.</p> </li> </ul> </div> </div> </div> <p>When trace files are written to a target directory, they will be named according to the last component of the SID (optionally followed by a counter to avoid filename collisions).</p> </div> </div> <h2 id="_trace2_api">Trace2 api</h2> <div class="sectionbody"> <p>The Trace2 public API is defined and documented in <code>trace2.h</code>; refer to it for more information. All public functions and macros are prefixed with <code>trace2_</code> and are implemented in <code>trace2.c</code>.</p> <p>There are no public Trace2 data structures.</p> <p>The Trace2 code also defines a set of private functions and data types in the <code>trace2/</code> directory. These symbols are prefixed with <code>tr2_</code> and should only be used by functions in <code>trace2.c</code> (or other private source files in <code>trace2/</code>).</p> <div class="sect2"> <h3 id="_conventions_for_public_functions_and_macros"> +Conventions for Public Functions and Macros</h3> <p>Some functions have a <code>_fl()</code> suffix to indicate that they take <code>file</code> and <code>line-number</code> arguments.</p> <p>Some functions have a <code>_va_fl()</code> suffix to indicate that they also take a <code>va_list</code> argument.</p> <p>Some functions have a <code>_printf_fl()</code> suffix to indicate that they also take a <code>printf()</code> style format with a variable number of arguments.</p> <p>CPP wrapper macros are defined to hide most of these details.</p> </div> </div> <h2 id="_trace2_target_formats">Trace2 target formats</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_normal_format"> +NORMAL Format</h3> <p>Events are written as lines of the form:</p> <div class="listingblock"> <div class="content"> <pre>[<time> SP <filename>:<line> SP+] <event-name> [[SP] <event-message>] LF</pre> </div> </div> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codeltevent-namegtcode"> <code><event-name></code> </dt> <dd> <p>is the event name.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codeltevent-messagegtcode"> <code><event-message></code> </dt> <dd> <p>is a free-form <code>printf()</code> message intended for human consumption.</p> <p>Note that this may contain embedded LF or CRLF characters that are not escaped, so the event may spill across multiple lines.</p> </dd> </dl> </div> <p>If <code>GIT_TRACE2_BRIEF</code> or <code>trace2.normalBrief</code> is true, the <code>time</code>, <code>filename</code>, and <code>line</code> fields are omitted.</p> <p>This target is intended to be more of a summary (like GIT_TRACE) and less detailed than the other targets. It ignores thread, region, and data messages, for example.</p> </div> <div class="sect2"> <h3 id="_perf_format"> +PERF Format</h3> <p>Events are written as lines of the form:</p> <div class="listingblock"> <div class="content"> <pre>[<time> SP <filename>:<line> SP+ + BAR SP] d<depth> SP + BAR SP <thread-name> SP+ + BAR SP <event-name> SP+ + BAR SP [r<repo-id>] SP+ + BAR SP [<t_abs>] SP+ + BAR SP [<t_rel>] SP+ + BAR SP [<category>] SP+ + BAR SP DOTS* <perf-event-message> + LF</pre> </div> </div> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codeltdepthgtcode"> <code><depth></code> </dt> <dd> <p>is the git process depth. This is the number of parent git processes. A top-level git command has depth value "d0". A child of it has depth value "d1". A second level child has depth value "d2" and so on.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codeltthread-namegtcode"> <code><thread-name></code> </dt> <dd> <p>is a unique name for the thread. The primary thread is called "main". Other thread names are of the form "th%d:%s" and include a unique number and the name of the thread-proc.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codeltevent-namegtcode-1"> <code><event-name></code> </dt> <dd> <p>is the event name.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codeltrepo-idgtcode"> <code><repo-id></code> </dt> <dd> <p>when present, is a number indicating the repository in use. A <code>def_repo</code> event is emitted when a repository is opened. This defines the repo-id and associated worktree. Subsequent repo-specific events will reference this repo-id.</p> <p>Currently, this is always "r1" for the main repository. This field is in anticipation of in-proc submodules in the future.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codelttabsgtcode"> <code><t_abs></code> </dt> <dd> <p>when present, is the absolute time in seconds since the program started.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codelttrelgtcode"> <code><t_rel></code> </dt> <dd> <p>when present, is time in seconds relative to the start of the current region. For a thread-exit event, it is the elapsed time of the thread.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codeltcategorygtcode"> <code><category></code> </dt> <dd> <p>is present on region and data events and is used to indicate a broad category, such as "index" or "status".</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codeltperf-event-messagegtcode"> <code><perf-event-message></code> </dt> <dd> <p>is a free-form <code>printf()</code> message intended for human consumption.</p> </dd> </dl> </div> <div class="listingblock"> <div class="content"> <pre>15:33:33.532712 wt-status.c:2310 | d0 | main | region_enter | r1 | 0.126064 | | status | label:print +15:33:33.532712 wt-status.c:2331 | d0 | main | region_leave | r1 | 0.127568 | 0.001504 | status | label:print</pre> </div> </div> <p>If <code>GIT_TRACE2_PERF_BRIEF</code> or <code>trace2.perfBrief</code> is true, the <code>time</code>, <code>file</code>, and <code>line</code> fields are omitted.</p> <div class="listingblock"> <div class="content"> <pre>d0 | main | region_leave | r1 | 0.011717 | 0.009122 | index | label:preload</pre> </div> </div> <p>The PERF target is intended for interactive performance analysis during development and is quite noisy.</p> </div> <div class="sect2"> <h3 id="_event_format"> +EVENT Format</h3> <p>Each event is a JSON-object containing multiple key/value pairs written as a single line and followed by a LF.</p> <div class="listingblock"> <div class="content"> <pre>'{' <key> ':' <value> [',' <key> ':' <value>]* '}' LF</pre> </div> </div> <p>Some key/value pairs are common to all events and some are event-specific.</p> <div class="sect3"> <h4 id="_common_keyvalue_pairs"> +Common Key/Value Pairs</h4> <p>The following key/value pairs are common to all events:</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"version", + "sid":"20190408T191827.272759Z-H9b68c35f-P00003510", + "thread":"main", + "time":"2019-04-08T19:18:27.282761Z", + "file":"common-main.c", + "line":42, + ... +}</pre> </div> </div> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codeeventlteventgtcode"> <code>"event":<event></code> </dt> <dd> <p>is the event name.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codesidltsidgtcode"> <code>"sid":<sid></code> </dt> <dd> <p>is the session-id. This is a unique string to identify the process instance to allow all events emitted by a process to be identified. A session-id is used instead of a PID because PIDs are recycled by the OS. For child git processes, the session-id is prepended with the session-id of the parent git process to allow parent-child relationships to be identified during post-processing.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codethreadltthreadgtcode"> <code>"thread":<thread></code> </dt> <dd> <p>is the thread name.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codetimelttimegtcode"> <code>"time":<time></code> </dt> <dd> <p>is the UTC time of the event.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codefileltfilenamegtcode"> <code>"file":<filename></code> </dt> <dd> <p>is source file generating the event.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codelineltline-numbergtcode"> <code>"line":<line-number></code> </dt> <dd> <p>is the integer source line number generating the event.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-coderepoltrepo-idgtcode"> <code>"repo":<repo-id></code> </dt> <dd> <p>when present, is the integer repo-id as described previously.</p> </dd> </dl> </div> <p>If <code>GIT_TRACE2_EVENT_BRIEF</code> or <code>trace2.eventBrief</code> is true, the <code>file</code> and <code>line</code> fields are omitted from all events and the <code>time</code> field is only present on the "start" and "atexit" events.</p> </div> <div class="sect3"> <h4 id="_event_specific_keyvalue_pairs"> +Event-Specific Key/Value Pairs</h4> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codeversioncode"> <code>"version"</code> </dt> <dd> <p>This event gives the version of the executable and the EVENT format. It should always be the first event in a trace session. The EVENT format version will be incremented if new event types are added, if existing fields are removed, or if there are significant changes in interpretation of existing events or fields. Smaller changes, such as adding a new field to an existing event, will not require an increment to the EVENT format version.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"version", + ... + "evt":"3", # EVENT format version + "exe":"2.20.1.155.g426c96fcdb" # git version +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codetoomanyfilescode"> <code>"too_many_files"</code> </dt> <dd> <p>This event is written to the git-trace2-discard sentinel file if there are too many files in the target trace directory (see the trace2.maxFiles config option).</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"too_many_files", + ... +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codestartcode"> <code>"start"</code> </dt> <dd> <p>This event contains the complete argv received by main().</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"start", + ... + "t_abs":0.001227, # elapsed time in seconds + "argv":["git","version"] +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codeexitcode"> <code>"exit"</code> </dt> <dd> <p>This event is emitted when git calls <code>exit()</code>.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"exit", + ... + "t_abs":0.001227, # elapsed time in seconds + "code":0 # exit code +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codeatexitcode"> <code>"atexit"</code> </dt> <dd> <p>This event is emitted by the Trace2 <code>atexit</code> routine during final shutdown. It should be the last event emitted by the process.</p> <p>(The elapsed time reported here is greater than the time reported in the "exit" event because it runs after all other atexit tasks have completed.)</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"atexit", + ... + "t_abs":0.001227, # elapsed time in seconds + "code":0 # exit code +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codesignalcode"> <code>"signal"</code> </dt> <dd> <p>This event is emitted when the program is terminated by a user signal. Depending on the platform, the signal event may prevent the "atexit" event from being generated.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"signal", + ... + "t_abs":0.001227, # elapsed time in seconds + "signo":13 # SIGTERM, SIGINT, etc. +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codeerrorcode"> <code>"error"</code> </dt> <dd> <p>This event is emitted when one of the <code>BUG()</code>, <code>bug()</code>, <code>error()</code>, <code>die()</code>, <code>warning()</code>, or <code>usage()</code> functions are called.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"error", + ... + "msg":"invalid option: --cahced", # formatted error message + "fmt":"invalid option: %s" # error format string +}</pre> </div> </div> <p>The error event may be emitted more than once. The format string allows post-processors to group errors by type without worrying about specific error arguments.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codecmdpathcode"> <code>"cmd_path"</code> </dt> <dd> <p>This event contains the discovered full path of the git executable (on platforms that are configured to resolve it).</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"cmd_path", + ... + "path":"C:/work/gfw/git.exe" +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codecmdancestrycode"> <code>"cmd_ancestry"</code> </dt> <dd> <p>This event contains the text command name for the parent (and earlier generations of parents) of the current process, in an array ordered from nearest parent to furthest great-grandparent. It may not be implemented on all platforms.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"cmd_ancestry", + ... + "ancestry":["bash","tmux: server","systemd"] +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codecmdnamecode"> <code>"cmd_name"</code> </dt> <dd> <p>This event contains the command name for this git process and the hierarchy of commands from parent git processes.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"cmd_name", + ... + "name":"pack-objects", + "hierarchy":"push/pack-objects" +}</pre> </div> </div> <p>Normally, the "name" field contains the canonical name of the command. When a canonical name is not available, one of these special values are used:</p> <div class="listingblock"> <div class="content"> <pre>"_query_" # "git --html-path" +"_run_dashed_" # when "git foo" tries to run "git-foo" +"_run_shell_alias_" # alias expansion to a shell command +"_run_git_alias_" # alias expansion to a git command +"_usage_" # usage error</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codecmdmodecode"> <code>"cmd_mode"</code> </dt> <dd> <p>This event, when present, describes the command variant. This event may be emitted more than once.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"cmd_mode", + ... + "name":"branch" +}</pre> </div> </div> <p>The "name" field is an arbitrary string to describe the command mode. For example, checkout can checkout a branch or an individual file. And these variations typically have different performance characteristics that are not comparable.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codealiascode"> <code>"alias"</code> </dt> <dd> <p>This event is present when an alias is expanded.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"alias", + ... + "alias":"l", # registered alias + "argv":["log","--graph"] # alias expansion +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codechildstartcode"> <code>"child_start"</code> </dt> <dd> <p>This event describes a child process that is about to be spawned.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"child_start", + ... + "child_id":2, + "child_class":"?", + "use_shell":false, + "argv":["git","rev-list","--objects","--stdin","--not","--all","--quiet"] + + "hook_name":"<hook_name>" # present when child_class is "hook" + "cd":"<path>" # present when cd is required +}</pre> </div> </div> <p>The "child_id" field can be used to match this child_start with the corresponding child_exit event.</p> <p>The "child_class" field is a rough classification, such as "editor", "pager", "transport/*", and "hook". Unclassified children are classified with "?".</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codechildexitcode"> <code>"child_exit"</code> </dt> <dd> <p>This event is generated after the current process has returned from the <code>waitpid()</code> and collected the exit information from the child.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"child_exit", + ... + "child_id":2, + "pid":14708, # child PID + "code":0, # child exit-code + "t_rel":0.110605 # observed run-time of child process +}</pre> </div> </div> <p>Note that the session-id of the child process is not available to the current/spawning process, so the child’s PID is reported here as a hint for post-processing. (But it is only a hint because the child process may be a shell script which doesn’t have a session-id.)</p> <p>Note that the <code>t_rel</code> field contains the observed run time in seconds for the child process (starting before the fork/exec/spawn and stopping after the <code>waitpid()</code> and includes OS process creation overhead). So this time will be slightly larger than the atexit time reported by the child process itself.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codechildreadycode"> <code>"child_ready"</code> </dt> <dd> <p>This event is generated after the current process has started a background process and released all handles to it.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"child_ready", + ... + "child_id":2, + "pid":14708, # child PID + "ready":"ready", # child ready state + "t_rel":0.110605 # observed run-time of child process +}</pre> </div> </div> <p>Note that the session-id of the child process is not available to the current/spawning process, so the child’s PID is reported here as a hint for post-processing. (But it is only a hint because the child process may be a shell script which doesn’t have a session-id.)</p> <p>This event is generated after the child is started in the background and given a little time to boot up and start working. If the child starts up normally while the parent is still waiting, the "ready" field will have the value "ready". If the child is too slow to start and the parent times out, the field will have the value "timeout". If the child starts but the parent is unable to probe it, the field will have the value "error".</p> <p>After the parent process emits this event, it will release all of its handles to the child process and treat the child as a background daemon. So even if the child does eventually finish booting up, the parent will not emit an updated event.</p> <p>Note that the <code>t_rel</code> field contains the observed run time in seconds when the parent released the child process into the background. The child is assumed to be a long-running daemon process and may outlive the parent process. So the parent’s child event times should not be compared to the child’s atexit times.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codeexeccode"> <code>"exec"</code> </dt> <dd> <p>This event is generated before git attempts to <code>exec()</code> another command rather than starting a child process.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"exec", + ... + "exec_id":0, + "exe":"git", + "argv":["foo", "bar"] +}</pre> </div> </div> <p>The "exec_id" field is a command-unique id and is only useful if the <code>exec()</code> fails and a corresponding exec_result event is generated.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codeexecresultcode"> <code>"exec_result"</code> </dt> <dd> <p>This event is generated if the <code>exec()</code> fails and control returns to the current git command.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"exec_result", + ... + "exec_id":0, + "code":1 # error code (errno) from exec() +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codethreadstartcode"> <code>"thread_start"</code> </dt> <dd> <p>This event is generated when a thread is started. It is generated from <strong>within</strong> the new thread’s thread-proc (because it needs to access data in the thread’s thread-local storage).</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"thread_start", + ... + "thread":"th02:preload_thread" # thread name +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codethreadexitcode"> <code>"thread_exit"</code> </dt> <dd> <p>This event is generated when a thread exits. It is generated from <strong>within</strong> the thread’s thread-proc.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"thread_exit", + ... + "thread":"th02:preload_thread", # thread name + "t_rel":0.007328 # thread elapsed time +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codedefparamcode"> <code>"def_param"</code> </dt> <dd> <p>This event is generated to log a global parameter, such as a config setting, command-line flag, or environment variable.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"def_param", + ... + "scope":"global", + "param":"core.abbrev", + "value":"7" +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codedefrepocode"> <code>"def_repo"</code> </dt> <dd> <p>This event defines a repo-id and associates it with the root of the worktree.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"def_repo", + ... + "repo":1, + "worktree":"/Users/jeffhost/work/gfw" +}</pre> </div> </div> <p>As stated earlier, the repo-id is currently always 1, so there will only be one def_repo event. Later, if in-proc submodules are supported, a def_repo event should be emitted for each submodule visited.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-coderegionentercode"> <code>"region_enter"</code> </dt> <dd> <p>This event is generated when entering a region.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"region_enter", + ... + "repo":1, # optional + "nesting":1, # current region stack depth + "category":"index", # optional + "label":"do_read_index", # optional + "msg":".git/index" # optional +}</pre> </div> </div> <p>The <code>category</code> field may be used in a future enhancement to do category-based filtering.</p> <p><code>GIT_TRACE2_EVENT_NESTING</code> or <code>trace2.eventNesting</code> can be used to filter deeply nested regions and data events. It defaults to "2".</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-coderegionleavecode"> <code>"region_leave"</code> </dt> <dd> <p>This event is generated when leaving a region.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"region_leave", + ... + "repo":1, # optional + "t_rel":0.002876, # time spent in region in seconds + "nesting":1, # region stack depth + "category":"index", # optional + "label":"do_read_index", # optional + "msg":".git/index" # optional +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codedatacode"> <code>"data"</code> </dt> <dd> <p>This event is generated to log a thread- and region-local key/value pair.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"data", + ... + "repo":1, # optional + "t_abs":0.024107, # absolute elapsed time + "t_rel":0.001031, # elapsed time in region/thread + "nesting":2, # region stack depth + "category":"index", + "key":"read/cache_nr", + "value":"3552" +}</pre> </div> </div> <p>The "value" field may be an integer or a string.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codedata-jsoncode"> <code>"data-json"</code> </dt> <dd> <p>This event is generated to log a pre-formatted JSON string containing structured data.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"data_json", + ... + "repo":1, # optional + "t_abs":0.015905, + "t_rel":0.015905, + "nesting":1, + "category":"process", + "key":"windows/ancestry", + "value":["bash.exe","bash.exe"] +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codethtimercode"> <code>"th_timer"</code> </dt> <dd> <p>This event logs the amount of time that a stopwatch timer was running in the thread. This event is generated when a thread exits for timers that requested per-thread events.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"th_timer", + ... + "category":"my_category", + "name":"my_timer", + "intervals":5, # number of time it was started/stopped + "t_total":0.052741, # total time in seconds it was running + "t_min":0.010061, # shortest interval + "t_max":0.011648 # longest interval +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codetimercode"> <code>"timer"</code> </dt> <dd> <p>This event logs the amount of time that a stopwatch timer was running aggregated across all threads. This event is generated when the process exits.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"timer", + ... + "category":"my_category", + "name":"my_timer", + "intervals":5, # number of time it was started/stopped + "t_total":0.052741, # total time in seconds it was running + "t_min":0.010061, # shortest interval + "t_max":0.011648 # longest interval +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codethcountercode"> <code>"th_counter"</code> </dt> <dd> <p>This event logs the value of a counter variable in a thread. This event is generated when a thread exits for counters that requested per-thread events.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"th_counter", + ... + "category":"my_category", + "name":"my_counter", + "count":23 +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-codecountercode"> <code>"counter"</code> </dt> <dd> <p>This event logs the value of a counter variable across all threads. This event is generated when the process exits. The total value reported here is the sum across all threads.</p> <div class="listingblock"> <div class="content"> <pre>{ + "event":"counter", + ... + "category":"my_category", + "name":"my_counter", + "count":23 +}</pre> </div> </div> </dd> </dl> </div> </div> </div> </div> <h2 id="_example_trace2_api_usage">Example trace2 api usage</h2> <div class="sectionbody"> <p>Here is a hypothetical usage of the Trace2 API showing the intended usage (without worrying about the actual Git details).</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-Initialization"> Initialization </dt> <dd> <p>Initialization happens in <code>main()</code>. Behind the scenes, an <code>atexit</code> and <code>signal</code> handler are registered.</p> <div class="listingblock"> <div class="content"> <pre>int main(int argc, const char **argv) +{ + int exit_code; + + trace2_initialize(); + trace2_cmd_start(argv); + + exit_code = cmd_main(argc, argv); + + trace2_cmd_exit(exit_code); + + return exit_code; +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-CommandDetails"> Command Details </dt> <dd> <p>After the basics are established, additional command information can be sent to Trace2 as it is discovered.</p> <div class="listingblock"> <div class="content"> <pre>int cmd_checkout(int argc, const char **argv) +{ + trace2_cmd_name("checkout"); + trace2_cmd_mode("branch"); + trace2_def_repo(the_repository); + + // emit "def_param" messages for "interesting" config settings. + trace2_cmd_list_config(); + + if (do_something()) + trace2_cmd_error("Path '%s': cannot do something", path); + + return 0; +}</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-ChildProcesses"> Child Processes </dt> <dd> <p>Wrap code spawning child processes.</p> <div class="listingblock"> <div class="content"> <pre>void run_child(...) +{ + int child_exit_code; + struct child_process cmd = CHILD_PROCESS_INIT; + ... + cmd.trace2_child_class = "editor"; + + trace2_child_start(&cmd); + child_exit_code = spawn_child_and_wait_for_it(); + trace2_child_exit(&cmd, child_exit_code); +}</pre> </div> </div> <p>For example, the following fetch command spawned ssh, index-pack, rev-list, and gc. This example also shows that fetch took 5.199 seconds and of that 4.932 was in ssh.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ export GIT_TRACE2_BRIEF=1 +$ export GIT_TRACE2=~/log.normal +$ git fetch origin +...</pre> </div> </div> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat ~/log.normal +version 2.20.1.vfs.1.1.47.g534dbe1ad1 +start git fetch origin +worktree /Users/jeffhost/work/gfw +cmd_name fetch (fetch) +child_start[0] ssh git@github.com ... +child_start[1] git index-pack ... +... (Trace2 events from child processes omitted) +child_exit[1] pid:14707 code:0 elapsed:0.076353 +child_exit[0] pid:14706 code:0 elapsed:4.931869 +child_start[2] git rev-list ... +... (Trace2 events from child process omitted) +child_exit[2] pid:14708 code:0 elapsed:0.110605 +child_start[3] git gc --auto +... (Trace2 events from child process omitted) +child_exit[3] pid:14709 code:0 elapsed:0.006240 +exit elapsed:5.198503 code:0 +atexit elapsed:5.198541 code:0</pre> </div> </div> <p>When a git process is a (direct or indirect) child of another git process, it inherits Trace2 context information. This allows the child to print the command hierarchy. This example shows gc as child[3] of fetch. When the gc process reports its name as "gc", it also reports the hierarchy as "fetch/gc". (In this example, trace2 messages from the child process is indented for clarity.)</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ export GIT_TRACE2_BRIEF=1 +$ export GIT_TRACE2=~/log.normal +$ git fetch origin +...</pre> </div> </div> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat ~/log.normal +version 2.20.1.160.g5676107ecd.dirty +start git fetch official +worktree /Users/jeffhost/work/gfw +cmd_name fetch (fetch) +... +child_start[3] git gc --auto + version 2.20.1.160.g5676107ecd.dirty + start /Users/jeffhost/work/gfw/git gc --auto + worktree /Users/jeffhost/work/gfw + cmd_name gc (fetch/gc) + exit elapsed:0.001959 code:0 + atexit elapsed:0.001997 code:0 +child_exit[3] pid:20303 code:0 elapsed:0.007564 +exit elapsed:3.868938 code:0 +atexit elapsed:3.868970 code:0</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-Regions"> Regions </dt> <dd> <p>Regions can be used to time an interesting section of code.</p> <div class="listingblock"> <div class="content"> <pre>void wt_status_collect(struct wt_status *s) +{ + trace2_region_enter("status", "worktrees", s->repo); + wt_status_collect_changes_worktree(s); + trace2_region_leave("status", "worktrees", s->repo); + + trace2_region_enter("status", "index", s->repo); + wt_status_collect_changes_index(s); + trace2_region_leave("status", "index", s->repo); + + trace2_region_enter("status", "untracked", s->repo); + wt_status_collect_untracked(s); + trace2_region_leave("status", "untracked", s->repo); +} + +void wt_status_print(struct wt_status *s) +{ + trace2_region_enter("status", "print", s->repo); + switch (s->status_format) { + ... + } + trace2_region_leave("status", "print", s->repo); +}</pre> </div> </div> <p>In this example, scanning for untracked files ran from +0.012568 to +0.027149 (since the process started) and took 0.014581 seconds.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ export GIT_TRACE2_PERF_BRIEF=1 +$ export GIT_TRACE2_PERF=~/log.perf +$ git status +... + +$ cat ~/log.perf +d0 | main | version | | | | | 2.20.1.160.g5676107ecd.dirty +d0 | main | start | | 0.001173 | | | git status +d0 | main | def_repo | r1 | | | | worktree:/Users/jeffhost/work/gfw +d0 | main | cmd_name | | | | | status (status) +... +d0 | main | region_enter | r1 | 0.010988 | | status | label:worktrees +d0 | main | region_leave | r1 | 0.011236 | 0.000248 | status | label:worktrees +d0 | main | region_enter | r1 | 0.011260 | | status | label:index +d0 | main | region_leave | r1 | 0.012542 | 0.001282 | status | label:index +d0 | main | region_enter | r1 | 0.012568 | | status | label:untracked +d0 | main | region_leave | r1 | 0.027149 | 0.014581 | status | label:untracked +d0 | main | region_enter | r1 | 0.027411 | | status | label:print +d0 | main | region_leave | r1 | 0.028741 | 0.001330 | status | label:print +d0 | main | exit | | 0.028778 | | | code:0 +d0 | main | atexit | | 0.028809 | | | code:0</pre> </div> </div> <p>Regions may be nested. This causes messages to be indented in the PERF target, for example. Elapsed times are relative to the start of the corresponding nesting level as expected. For example, if we add region message to:</p> <div class="listingblock"> <div class="content"> <pre>static enum path_treatment read_directory_recursive(struct dir_struct *dir, + struct index_state *istate, const char *base, int baselen, + struct untracked_cache_dir *untracked, int check_only, + int stop_at_first_file, const struct pathspec *pathspec) +{ + enum path_treatment state, subdir_state, dir_state = path_none; + + trace2_region_enter_printf("dir", "read_recursive", NULL, "%.*s", baselen, base); + ... + trace2_region_leave_printf("dir", "read_recursive", NULL, "%.*s", baselen, base); + return dir_state; +}</pre> </div> </div> <p>We can further investigate the time spent scanning for untracked files.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ export GIT_TRACE2_PERF_BRIEF=1 +$ export GIT_TRACE2_PERF=~/log.perf +$ git status +... +$ cat ~/log.perf +d0 | main | version | | | | | 2.20.1.162.gb4ccea44db.dirty +d0 | main | start | | 0.001173 | | | git status +d0 | main | def_repo | r1 | | | | worktree:/Users/jeffhost/work/gfw +d0 | main | cmd_name | | | | | status (status) +... +d0 | main | region_enter | r1 | 0.015047 | | status | label:untracked +d0 | main | region_enter | | 0.015132 | | dir | ..label:read_recursive +d0 | main | region_enter | | 0.016341 | | dir | ....label:read_recursive vcs-svn/ +d0 | main | region_leave | | 0.016422 | 0.000081 | dir | ....label:read_recursive vcs-svn/ +d0 | main | region_enter | | 0.016446 | | dir | ....label:read_recursive xdiff/ +d0 | main | region_leave | | 0.016522 | 0.000076 | dir | ....label:read_recursive xdiff/ +d0 | main | region_enter | | 0.016612 | | dir | ....label:read_recursive git-gui/ +d0 | main | region_enter | | 0.016698 | | dir | ......label:read_recursive git-gui/po/ +d0 | main | region_enter | | 0.016810 | | dir | ........label:read_recursive git-gui/po/glossary/ +d0 | main | region_leave | | 0.016863 | 0.000053 | dir | ........label:read_recursive git-gui/po/glossary/ +... +d0 | main | region_enter | | 0.031876 | | dir | ....label:read_recursive builtin/ +d0 | main | region_leave | | 0.032270 | 0.000394 | dir | ....label:read_recursive builtin/ +d0 | main | region_leave | | 0.032414 | 0.017282 | dir | ..label:read_recursive +d0 | main | region_leave | r1 | 0.032454 | 0.017407 | status | label:untracked +... +d0 | main | exit | | 0.034279 | | | code:0 +d0 | main | atexit | | 0.034322 | | | code:0</pre> </div> </div> <p>Trace2 regions are similar to the existing trace_performance_enter() and trace_performance_leave() routines, but are thread safe and maintain per-thread stacks of timers.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-DataMessages"> Data Messages </dt> <dd> <p>Data messages added to a region.</p> <div class="listingblock"> <div class="content"> <pre>int read_index_from(struct index_state *istate, const char *path, + const char *gitdir) +{ + trace2_region_enter_printf("index", "do_read_index", the_repository, "%s", path); + + ... + + trace2_data_intmax("index", the_repository, "read/version", istate->version); + trace2_data_intmax("index", the_repository, "read/cache_nr", istate->cache_nr); + + trace2_region_leave_printf("index", "do_read_index", the_repository, "%s", path); +}</pre> </div> </div> <p>This example shows that the index contained 3552 entries.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ export GIT_TRACE2_PERF_BRIEF=1 +$ export GIT_TRACE2_PERF=~/log.perf +$ git status +... +$ cat ~/log.perf +d0 | main | version | | | | | 2.20.1.156.gf9916ae094.dirty +d0 | main | start | | 0.001173 | | | git status +d0 | main | def_repo | r1 | | | | worktree:/Users/jeffhost/work/gfw +d0 | main | cmd_name | | | | | status (status) +d0 | main | region_enter | r1 | 0.001791 | | index | label:do_read_index .git/index +d0 | main | data | r1 | 0.002494 | 0.000703 | index | ..read/version:2 +d0 | main | data | r1 | 0.002520 | 0.000729 | index | ..read/cache_nr:3552 +d0 | main | region_leave | r1 | 0.002539 | 0.000748 | index | label:do_read_index .git/index +...</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-ThreadEvents"> Thread Events </dt> <dd> <p>Thread messages added to a thread-proc.</p> <p>For example, the multi-threaded preload-index code can be instrumented with a region around the thread pool and then per-thread start and exit events within the thread-proc.</p> <div class="listingblock"> <div class="content"> <pre>static void *preload_thread(void *_data) +{ + // start the per-thread clock and emit a message. + trace2_thread_start("preload_thread"); + + // report which chunk of the array this thread was assigned. + trace2_data_intmax("index", the_repository, "offset", p->offset); + trace2_data_intmax("index", the_repository, "count", nr); + + do { + ... + } while (--nr > 0); + ... + + // report elapsed time taken by this thread. + trace2_thread_exit(); + return NULL; +} + +void preload_index(struct index_state *index, + const struct pathspec *pathspec, + unsigned int refresh_flags) +{ + trace2_region_enter("index", "preload", the_repository); + + for (i = 0; i < threads; i++) { + ... /* create thread */ + } + + for (i = 0; i < threads; i++) { + ... /* join thread */ + } + + trace2_region_leave("index", "preload", the_repository); +}</pre> </div> </div> <p>In this example preload_index() was executed by the <code>main</code> thread and started the <code>preload</code> region. Seven threads, named <code>th01:preload_thread</code> through <code>th07:preload_thread</code>, were started. Events from each thread are atomically appended to the shared target stream as they occur so they may appear in random order with respect other threads. Finally, the main thread waits for the threads to finish and leaves the region.</p> <p>Data events are tagged with the active thread name. They are used to report the per-thread parameters.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ export GIT_TRACE2_PERF_BRIEF=1 +$ export GIT_TRACE2_PERF=~/log.perf +$ git status +... +$ cat ~/log.perf +... +d0 | main | region_enter | r1 | 0.002595 | | index | label:preload +d0 | th01:preload_thread | thread_start | | 0.002699 | | | +d0 | th02:preload_thread | thread_start | | 0.002721 | | | +d0 | th01:preload_thread | data | r1 | 0.002736 | 0.000037 | index | offset:0 +d0 | th02:preload_thread | data | r1 | 0.002751 | 0.000030 | index | offset:2032 +d0 | th03:preload_thread | thread_start | | 0.002711 | | | +d0 | th06:preload_thread | thread_start | | 0.002739 | | | +d0 | th01:preload_thread | data | r1 | 0.002766 | 0.000067 | index | count:508 +d0 | th06:preload_thread | data | r1 | 0.002856 | 0.000117 | index | offset:2540 +d0 | th03:preload_thread | data | r1 | 0.002824 | 0.000113 | index | offset:1016 +d0 | th04:preload_thread | thread_start | | 0.002710 | | | +d0 | th02:preload_thread | data | r1 | 0.002779 | 0.000058 | index | count:508 +d0 | th06:preload_thread | data | r1 | 0.002966 | 0.000227 | index | count:508 +d0 | th07:preload_thread | thread_start | | 0.002741 | | | +d0 | th07:preload_thread | data | r1 | 0.003017 | 0.000276 | index | offset:3048 +d0 | th05:preload_thread | thread_start | | 0.002712 | | | +d0 | th05:preload_thread | data | r1 | 0.003067 | 0.000355 | index | offset:1524 +d0 | th05:preload_thread | data | r1 | 0.003090 | 0.000378 | index | count:508 +d0 | th07:preload_thread | data | r1 | 0.003037 | 0.000296 | index | count:504 +d0 | th03:preload_thread | data | r1 | 0.002971 | 0.000260 | index | count:508 +d0 | th04:preload_thread | data | r1 | 0.002983 | 0.000273 | index | offset:508 +d0 | th04:preload_thread | data | r1 | 0.007311 | 0.004601 | index | count:508 +d0 | th05:preload_thread | thread_exit | | 0.008781 | 0.006069 | | +d0 | th01:preload_thread | thread_exit | | 0.009561 | 0.006862 | | +d0 | th03:preload_thread | thread_exit | | 0.009742 | 0.007031 | | +d0 | th06:preload_thread | thread_exit | | 0.009820 | 0.007081 | | +d0 | th02:preload_thread | thread_exit | | 0.010274 | 0.007553 | | +d0 | th07:preload_thread | thread_exit | | 0.010477 | 0.007736 | | +d0 | th04:preload_thread | thread_exit | | 0.011657 | 0.008947 | | +d0 | main | region_leave | r1 | 0.011717 | 0.009122 | index | label:preload +... +d0 | main | exit | | 0.029996 | | | code:0 +d0 | main | atexit | | 0.030027 | | | code:0</pre> </div> </div> <p>In this example, the preload region took 0.009122 seconds. The 7 threads took between 0.006069 and 0.008947 seconds to work on their portion of the index. Thread "th01" worked on 508 items at offset 0. Thread "th02" worked on 508 items at offset 2032. Thread "th04" worked on 508 items at offset 508.</p> <p>This example also shows that thread names are assigned in a racy manner as each thread starts.</p> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-ConfigdefparamEvents"> Config (def param) Events </dt> <dd> <p>Dump "interesting" config values to trace2 log.</p> <p>We can optionally emit configuration events, see <code>trace2.configparams</code> in <a href="git-config">git-config[1]</a> for how to enable it.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config --system color.ui never +$ git config --global color.ui always +$ git config --local color.ui auto +$ git config --list --show-scope | grep 'color.ui' +system color.ui=never +global color.ui=always +local color.ui=auto</pre> </div> </div> <p>Then, mark the config <code>color.ui</code> as "interesting" config with <code>GIT_TRACE2_CONFIG_PARAMS</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ export GIT_TRACE2_PERF_BRIEF=1 +$ export GIT_TRACE2_PERF=~/log.perf +$ export GIT_TRACE2_CONFIG_PARAMS=color.ui +$ git version +... +$ cat ~/log.perf +d0 | main | version | | | | | ... +d0 | main | start | | 0.001642 | | | /usr/local/bin/git version +d0 | main | cmd_name | | | | | version (version) +d0 | main | def_param | | | | scope:system | color.ui:never +d0 | main | def_param | | | | scope:global | color.ui:always +d0 | main | def_param | | | | scope:local | color.ui:auto +d0 | main | data | r0 | 0.002100 | 0.002100 | fsync | fsync/writeout-only:0 +d0 | main | data | r0 | 0.002126 | 0.002126 | fsync | fsync/hardware-flush:0 +d0 | main | exit | | 0.000470 | | | code:0 +d0 | main | atexit | | 0.000477 | | | code:0</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/technical/api-trace2.txt-StopwatchTimerEvents"> Stopwatch Timer Events </dt> <dd> <p>Measure the time spent in a function call or span of code that might be called from many places within the code throughout the life of the process.</p> <div class="listingblock"> <div class="content"> <pre>static void expensive_function(void) +{ + trace2_timer_start(TRACE2_TIMER_ID_TEST1); + ... + sleep_millisec(1000); // Do something expensive + ... + trace2_timer_stop(TRACE2_TIMER_ID_TEST1); +} + +static int ut_100timer(int argc, const char **argv) +{ + ... + + expensive_function(); + + // Do something else 1... + + expensive_function(); + + // Do something else 2... + + expensive_function(); + + return 0; +}</pre> </div> </div> <p>In this example, we measure the total time spent in <code>expensive_function()</code> regardless of when it is called in the overall flow of the program.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ export GIT_TRACE2_PERF_BRIEF=1 +$ export GIT_TRACE2_PERF=~/log.perf +$ t/helper/test-tool trace2 100timer 3 1000 +... +$ cat ~/log.perf +d0 | main | version | | | | | ... +d0 | main | start | | 0.001453 | | | t/helper/test-tool trace2 100timer 3 1000 +d0 | main | cmd_name | | | | | trace2 (trace2) +d0 | main | exit | | 3.003667 | | | code:0 +d0 | main | timer | | | | test | name:test1 intervals:3 total:3.001686 min:1.000254 max:1.000929 +d0 | main | atexit | | 3.003796 | | | code:0</pre> </div> </div> </dd> </dl> </div> </div> <h2 id="_future_work">Future work</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_relationship_to_the_existing_trace_api_api_trace_txt"> +Relationship to the Existing Trace Api (api-trace.txt)</h3> <p>There are a few issues to resolve before we can completely switch to Trace2.</p> <div class="ulist"> <ul> <li> <p>Updating existing tests that assume <code>GIT_TRACE</code> format messages.</p> </li> <li> <p>How to best handle custom <code>GIT_TRACE_<key></code> messages?</p> <div class="ulist"> <ul> <li> <p>The <code>GIT_TRACE_<key></code> mechanism allows each <key> to write to a different file (in addition to just stderr).</p> </li> <li> <p>Do we want to maintain that ability or simply write to the existing Trace2 targets (and convert <key> to a "category").</p> </li> </ul> </div> </li> </ul> </div> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/api-trace2" class="_attribution-link">https://git-scm.com/docs/api-trace2</a> + </p> +</div> diff --git a/devdocs/git/bundle-uri.html b/devdocs/git/bundle-uri.html new file mode 100644 index 00000000..568e27c0 --- /dev/null +++ b/devdocs/git/bundle-uri.html @@ -0,0 +1,34 @@ +<h1>bundle-uri</h1> <div class="sectionbody"> <p>Git bundles are files that store a pack-file along with some extra metadata, including a set of refs and a (possibly empty) set of necessary commits. See <a href="git-bundle">git-bundle[1]</a> and <a href="gitformat-bundle">gitformat-bundle[5]</a> for more information.</p> <p>Bundle URIs are locations where Git can download one or more bundles in order to bootstrap the object database in advance of fetching the remaining objects from a remote.</p> <p>One goal is to speed up clones and fetches for users with poor network connectivity to the origin server. Another benefit is to allow heavy users, such as CI build farms, to use local resources for the majority of Git data and thereby reducing the load on the origin server.</p> <p>To enable the bundle URI feature, users can specify a bundle URI using command-line options or the origin server can advertise one or more URIs via a protocol v2 capability.</p> </div> <h2 id="_design_goals">Design goals</h2> <div class="sectionbody"> <p>The bundle URI standard aims to be flexible enough to satisfy multiple workloads. The bundle provider and the Git client have several choices in how they create and consume bundle URIs.</p> <div class="ulist"> <ul> <li> <p>Bundles can have whatever name the server desires. This name could refer to immutable data by using a hash of the bundle contents. However, this means that a new URI will be needed after every update of the content. This might be acceptable if the server is advertising the URI (and the server is aware of new bundles being generated) but would not be ergonomic for users using the command line option.</p> </li> <li> <p>The bundles could be organized specifically for bootstrapping full clones, but could also be organized with the intention of bootstrapping incremental fetches. The bundle provider must decide on one of several organization schemes to minimize client downloads during incremental fetches, but the Git client can also choose whether to use bundles for either of these operations.</p> </li> <li> <p>The bundle provider can choose to support full clones, partial clones, or both. The client can detect which bundles are appropriate for the repository’s partial clone filter, if any.</p> </li> <li> <p>The bundle provider can use a single bundle (for clones only), or a list of bundles. When using a list of bundles, the provider can specify whether or not the client needs <code>all</code> of the bundle URIs for a full clone, or if <code>any</code> one of the bundle URIs is sufficient. This allows the bundle provider to use different URIs for different geographies.</p> </li> <li> <p>The bundle provider can organize the bundles using heuristics, such as creation tokens, to help the client prevent downloading bundles it does not need. When the bundle provider does not provide these heuristics, the client can use optimizations to minimize how much of the data is downloaded.</p> </li> <li> <p>The bundle provider does not need to be associated with the Git server. The client can choose to use the bundle provider without it being advertised by the Git server.</p> </li> <li> <p>The client can choose to discover bundle providers that are advertised by the Git server. This could happen during <code>git clone</code>, during <code>git fetch</code>, both, or neither. The user can choose which combination works best for them.</p> </li> <li> <p>The client can choose to configure a bundle provider manually at any time. The client can also choose to specify a bundle provider manually as a command-line option to <code>git clone</code>.</p> </li> </ul> </div> <p>Each repository is different and every Git server has different needs. Hopefully the bundle URI feature is flexible enough to satisfy all needs. If not, then the feature can be extended through its versioning mechanism.</p> </div> <h2 id="_server_requirements">Server requirements</h2> <div class="sectionbody"> <p>To provide a server-side implementation of bundle servers, no other parts of the Git protocol are required. This allows server maintainers to use static content solutions such as CDNs in order to serve the bundle files.</p> <p>At the current scope of the bundle URI feature, all URIs are expected to be HTTP(S) URLs where content is downloaded to a local file using a <code>GET</code> request to that URL. The server could include authentication requirements to those requests with the aim of triggering the configured credential helper for secure access. (Future extensions could use "file://" URIs or SSH URIs.)</p> <p>Assuming a <code>200 OK</code> response from the server, the content at the URL is inspected. First, Git attempts to parse the file as a bundle file of version 2 or higher. If the file is not a bundle, then the file is parsed as a plain-text file using Git’s config parser. The key-value pairs in that config file are expected to describe a list of bundle URIs. If neither of these parse attempts succeed, then Git will report an error to the user that the bundle URI provided erroneous data.</p> <p>Any other data provided by the server is considered erroneous.</p> </div> <h2 id="_bundle_lists">Bundle lists</h2> <div class="sectionbody"> <p>The Git server can advertise bundle URIs using a set of <code>key=value</code> pairs. A bundle URI can also serve a plain-text file in the Git config format containing these same <code>key=value</code> pairs. In both cases, we consider this to be a <code>bundle list</code>. The pairs specify information about the bundles that the client can use to make decisions for which bundles to download and which to ignore.</p> <p>A few keys focus on properties of the list itself.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/technical/bundle-uri.txt-bundleversion"> bundle.version </dt> <dd> <p>(Required) This value provides a version number for the bundle list. If a future Git change enables a feature that needs the Git client to react to a new key in the bundle list file, then this version will increment. The only current version number is 1, and if any other value is specified then Git will fail to use this file.</p> </dd> <dt class="hdlist1" id="Documentation/technical/bundle-uri.txt-bundlemode"> bundle.mode </dt> <dd> <p>(Required) This value has one of two values: <code>all</code> and <code>any</code>. When <code>all</code> is specified, then the client should expect to need all of the listed bundle URIs that match their repository’s requirements. When <code>any</code> is specified, then the client should expect that any one of the bundle URIs that match their repository’s requirements will suffice. Typically, the <code>any</code> option is used to list a number of different bundle servers located in different geographies.</p> </dd> <dt class="hdlist1" id="Documentation/technical/bundle-uri.txt-bundleheuristic"> bundle.heuristic </dt> <dd> <p>If this string-valued key exists, then the bundle list is designed to work well with incremental <code>git fetch</code> commands. The heuristic signals that there are additional keys available for each bundle that help determine which subset of bundles the client should download. The only heuristic currently planned is <code>creationToken</code>.</p> </dd> </dl> </div> <p>The remaining keys include an <code><id></code> segment which is a server-designated name for each available bundle. The <code><id></code> must contain only alphanumeric and <code>-</code> characters.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/technical/bundle-uri.txt-bundleltidgturi"> bundle.<id>.uri </dt> <dd> <p>(Required) This string value is the URI for downloading bundle <code><id></code>. If the URI begins with a protocol (<code>http://</code> or <code>https://</code>) then the URI is absolute. Otherwise, the URI is interpreted as relative to the URI used for the bundle list. If the URI begins with <code>/</code>, then that relative path is relative to the domain name used for the bundle list. (This use of relative paths is intended to make it easier to distribute a set of bundles across a large number of servers or CDNs with different domain names.)</p> </dd> <dt class="hdlist1" id="Documentation/technical/bundle-uri.txt-bundleltidgtfilter"> bundle.<id>.filter </dt> <dd> <p>This string value represents an object filter that should also appear in the header of this bundle. The server uses this value to differentiate different kinds of bundles from which the client can choose those that match their object filters.</p> </dd> <dt class="hdlist1" id="Documentation/technical/bundle-uri.txt-bundleltidgtcreationToken"> bundle.<id>.creationToken </dt> <dd> <p>This value is a nonnegative 64-bit integer used for sorting the bundles list. This is used to download a subset of bundles during a fetch when <code>bundle.heuristic=creationToken</code>.</p> </dd> <dt class="hdlist1" id="Documentation/technical/bundle-uri.txt-bundleltidgtlocation"> bundle.<id>.location </dt> <dd> <p>This string value advertises a real-world location from where the bundle URI is served. This can be used to present the user with an option for which bundle URI to use or simply as an informative indicator of which bundle URI was selected by Git. This is only valuable when <code>bundle.mode</code> is <code>any</code>.</p> </dd> </dl> </div> <p>Here is an example bundle list using the Git config format:</p> <div class="literalblock"> <div class="content"> <pre>[bundle] + version = 1 + mode = all + heuristic = creationToken</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>[bundle "2022-02-09-1644442601-daily"] + uri = https://bundles.example.com/git/git/2022-02-09-1644442601-daily.bundle + creationToken = 1644442601</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>[bundle "2022-02-02-1643842562"] + uri = https://bundles.example.com/git/git/2022-02-02-1643842562.bundle + creationToken = 1643842562</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>[bundle "2022-02-09-1644442631-daily-blobless"] + uri = 2022-02-09-1644442631-daily-blobless.bundle + creationToken = 1644442631 + filter = blob:none</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>[bundle "2022-02-02-1643842568-blobless"] + uri = /git/git/2022-02-02-1643842568-blobless.bundle + creationToken = 1643842568 + filter = blob:none</pre> </div> </div> <p>This example uses <code>bundle.mode=all</code> as well as the <code>bundle.<id>.creationToken</code> heuristic. It also uses the <code>bundle.<id>.filter</code> options to present two parallel sets of bundles: one for full clones and another for blobless partial clones.</p> <p>Suppose that this bundle list was found at the URI <code>https://bundles.example.com/git/git/</code> and so the two blobless bundles have the following fully-expanded URIs:</p> <div class="ulist"> <ul> <li> <p><code>https://bundles.example.com/git/git/2022-02-09-1644442631-daily-blobless.bundle</code></p> </li> <li> <p><code>https://bundles.example.com/git/git/2022-02-02-1643842568-blobless.bundle</code></p> </li> </ul> </div> </div> <h2 id="_advertising_bundle_uris">Advertising bundle uris</h2> <div class="sectionbody"> <p>If a user knows a bundle URI for the repository they are cloning, then they can specify that URI manually through a command-line option. However, a Git host may want to advertise bundle URIs during the clone operation, helping users unaware of the feature.</p> <p>The only thing required for this feature is that the server can advertise one or more bundle URIs. This advertisement takes the form of a new protocol v2 capability specifically for discovering bundle URIs.</p> <p>The client could choose an arbitrary bundle URI as an option <code>or</code> select the URI with best performance by some exploratory checks. It is up to the bundle provider to decide if having multiple URIs is preferable to a single URI that is geodistributed through server-side infrastructure.</p> </div> <h2 id="_cloning_with_bundle_uris">Cloning with bundle uris</h2> <div class="sectionbody"> <p>The primary need for bundle URIs is to speed up clones. The Git client will interact with bundle URIs according to the following flow:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>The user specifies a bundle URI with the <code>--bundle-uri</code> command-line option <code>or</code> the client discovers a bundle list advertised by the Git server.</p> </li> <li> <p>If the downloaded data from a bundle URI is a bundle, then the client inspects the bundle headers to check that the prerequisite commit OIDs are present in the client repository. If some are missing, then the client delays unbundling until other bundles have been unbundled, making those OIDs present. When all required OIDs are present, the client unbundles that data using a refspec. The default refspec is <code>+refs/heads/*:refs/bundles/*</code>, but this can be configured. These refs are stored so that later <code>git fetch</code> negotiations can communicate each bundled ref as a <code>have</code>, reducing the size of the fetch over the Git protocol. To allow pruning refs from this ref namespace, Git may introduce a numbered namespace (such as <code>refs/bundles/<i>/*</code>) such that stale bundle refs can be deleted.</p> </li> <li> <p>If the file is instead a bundle list, then the client inspects the <code>bundle.mode</code> to see if the list is of the <code>all</code> or <code>any</code> form.</p> <div class="olist loweralpha"> <ol class="loweralpha"> <li> <p>If <code>bundle.mode=all</code>, then the client considers all bundle URIs. The list is reduced based on the <code>bundle.<id>.filter</code> options matching the client repository’s partial clone filter. Then, all bundle URIs are requested. If the <code>bundle.<id>.creationToken</code> heuristic is provided, then the bundles are downloaded in decreasing order by the creation token, stopping when a bundle has all required OIDs. The bundles can then be unbundled in increasing creation token order. The client stores the latest creation token as a heuristic for avoiding future downloads if the bundle list does not advertise bundles with larger creation tokens.</p> </li> <li> <p>If <code>bundle.mode=any</code>, then the client can choose any one of the bundle URIs to inspect. The client can use a variety of ways to choose among these URIs. The client can also fallback to another URI if the initial choice fails to return a result.</p> </li> </ol> </div> </li> </ol> </div> <p>Note that during a clone we expect that all bundles will be required, and heuristics such as <code>bundle.<uri>.creationToken</code> can be used to download bundles in chronological order or in parallel.</p> <p>If a given bundle URI is a bundle list with a <code>bundle.heuristic</code> value, then the client can choose to store that URI as its chosen bundle URI. The client can then navigate directly to that URI during later <code>git +fetch</code> calls.</p> <p>When downloading bundle URIs, the client can choose to inspect the initial content before committing to downloading the entire content. This may provide enough information to determine if the URI is a bundle list or a bundle. In the case of a bundle, the client may inspect the bundle header to determine that all advertised tips are already in the client repository and cancel the remaining download.</p> </div> <h2 id="_fetching_with_bundle_uris">Fetching with bundle uris</h2> <div class="sectionbody"> <p>When the client fetches new data, it can decide to fetch from bundle servers before fetching from the origin remote. This could be done via a command-line option, but it is more likely useful to use a config value such as the one specified during the clone.</p> <p>The fetch operation follows the same procedure to download bundles from a bundle list (although we do <code>not</code> want to use parallel downloads here). We expect that the process will end when all prerequisite commit OIDs in a thin bundle are already in the object database.</p> <p>When using the <code>creationToken</code> heuristic, the client can avoid downloading any bundles if their creation tokens are not larger than the stored creation token. After fetching new bundles, Git updates this local creation token.</p> <p>If the bundle provider does not provide a heuristic, then the client should attempt to inspect the bundle headers before downloading the full bundle data in case the bundle tips already exist in the client repository.</p> </div> <h2 id="_error_conditions">Error conditions</h2> <div class="sectionbody"> <p>If the Git client discovers something unexpected while downloading information according to a bundle URI or the bundle list found at that location, then Git can ignore that data and continue as if it was not given a bundle URI. The remote Git server is the ultimate source of truth, not the bundle URI.</p> <p>Here are a few example error conditions:</p> <div class="ulist"> <ul> <li> <p>The client fails to connect with a server at the given URI or a connection is lost without any chance to recover.</p> </li> <li> <p>The client receives a 400-level response (such as <code>404 Not Found</code> or <code>401 Not Authorized</code>). The client should use the credential helper to find and provide a credential for the URI, but match the semantics of Git’s other HTTP protocols in terms of handling specific 400-level errors.</p> </li> <li> <p>The server reports any other failure response.</p> </li> <li> <p>The client receives data that is not parsable as a bundle or bundle list.</p> </li> <li> <p>A bundle includes a filter that does not match expectations.</p> </li> <li> <p>The client cannot unbundle the bundles because the prerequisite commit OIDs are not in the object database and there are no more bundles to download.</p> </li> </ul> </div> <p>There are also situations that could be seen as wasteful, but are not error conditions:</p> <div class="ulist"> <ul> <li> <p>The downloaded bundles contain more information than is requested by the clone or fetch request. A primary example is if the user requests a clone with <code>--single-branch</code> but downloads bundles that store every reachable commit from all <code>refs/heads/*</code> references. This might be initially wasteful, but perhaps these objects will become reachable by a later ref update that the client cares about.</p> </li> <li> <p>A bundle download during a <code>git fetch</code> contains objects already in the object database. This is probably unavoidable if we are using bundles for fetches, since the client will almost always be slightly ahead of the bundle servers after performing its "catch-up" fetch to the remote server. This extra work is most wasteful when the client is fetching much more frequently than the server is computing bundles, such as if the client is using hourly prefetches with background maintenance, but the server is computing bundles weekly. For this reason, the client should not use bundle URIs for fetch unless the server has explicitly recommended it through a <code>bundle.heuristic</code> value.</p> </li> </ul> </div> </div> <h2 id="_example_bundle_provider_organization">Example bundle provider organization</h2> <div class="sectionbody"> <p>The bundle URI feature is intentionally designed to be flexible to different ways a bundle provider wants to organize the object data. However, it can be helpful to have a complete organization model described here so providers can start from that base.</p> <p>This example organization is a simplified model of what is used by the GVFS Cache Servers (see section near the end of this document) which have been beneficial in speeding up clones and fetches for very large repositories, although using extra software outside of Git.</p> <p>The bundle provider deploys servers across multiple geographies. Each server manages its own bundle set. The server can track a number of Git repositories, but provides a bundle list for each based on a pattern. For example, when mirroring a repository at <code>https://<domain>/<org>/<repo></code> the bundle server could have its bundle list available at <code>https://<server-url>/<domain>/<org>/<repo></code>. The origin Git server can list all of these servers under the "any" mode:</p> <div class="literalblock"> <div class="content"> <pre>[bundle] + version = 1 + mode = any</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>[bundle "eastus"] + uri = https://eastus.example.com/<domain>/<org>/<repo></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>[bundle "europe"] + uri = https://europe.example.com/<domain>/<org>/<repo></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>[bundle "apac"] + uri = https://apac.example.com/<domain>/<org>/<repo></pre> </div> </div> <p>This "list of lists" is static and only changes if a bundle server is added or removed.</p> <p>Each bundle server manages its own set of bundles. The initial bundle list contains only a single bundle, containing all of the objects received from cloning the repository from the origin server. The list uses the <code>creationToken</code> heuristic and a <code>creationToken</code> is made for the bundle based on the server’s timestamp.</p> <p>The bundle server runs regularly-scheduled updates for the bundle list, such as once a day. During this task, the server fetches the latest contents from the origin server and generates a bundle containing the objects reachable from the latest origin refs, but not contained in a previously-computed bundle. This bundle is added to the list, with care that the <code>creationToken</code> is strictly greater than the previous maximum <code>creationToken</code>.</p> <p>When the bundle list grows too large, say more than 30 bundles, then the oldest "<code>N</code> minus 30" bundles are combined into a single bundle. This bundle’s <code>creationToken</code> is equal to the maximum <code>creationToken</code> among the merged bundles.</p> <p>An example bundle list is provided here, although it only has two daily bundles and not a full list of 30:</p> <div class="literalblock"> <div class="content"> <pre>[bundle] + version = 1 + mode = all + heuristic = creationToken</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>[bundle "2022-02-13-1644770820-daily"] + uri = https://eastus.example.com/<domain>/<org>/<repo>/2022-02-09-1644770820-daily.bundle + creationToken = 1644770820</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>[bundle "2022-02-09-1644442601-daily"] + uri = https://eastus.example.com/<domain>/<org>/<repo>/2022-02-09-1644442601-daily.bundle + creationToken = 1644442601</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>[bundle "2022-02-02-1643842562"] + uri = https://eastus.example.com/<domain>/<org>/<repo>/2022-02-02-1643842562.bundle + creationToken = 1643842562</pre> </div> </div> <p>To avoid storing and serving object data in perpetuity despite becoming unreachable in the origin server, this bundle merge can be more careful. Instead of taking an absolute union of the old bundles, instead the bundle can be created by looking at the newer bundles and ensuring that their necessary commits are all available in this merged bundle (or in another one of the newer bundles). This allows "expiring" object data that is not being used by new commits in this window of time. That data could be reintroduced by a later push.</p> <p>The intention of this data organization has two main goals. First, initial clones of the repository become faster by downloading precomputed object data from a closer source. Second, <code>git fetch</code> commands can be faster, especially if the client has not fetched for a few days. However, if a client does not fetch for 30 days, then the bundle list organization would cause redownloading a large amount of object data.</p> <p>One way to make this organization more useful to users who fetch frequently is to have more frequent bundle creation. For example, bundles could be created every hour, and then once a day those "hourly" bundles could be merged into a "daily" bundle. The daily bundles are merged into the oldest bundle after 30 days.</p> <p>It is recommended that this bundle strategy is repeated with the <code>blob:none</code> filter if clients of this repository are expecting to use blobless partial clones. This list of blobless bundles stays in the same list as the full bundles, but uses the <code>bundle.<id>.filter</code> key to separate the two groups. For very large repositories, the bundle provider may want to <code>only</code> provide blobless bundles.</p> </div> <h2 id="_implementation_plan">Implementation plan</h2> <div class="sectionbody"> <p>This design document is being submitted on its own as an aspirational document, with the goal of implementing all of the mentioned client features over the course of several patch series. Here is a potential outline for submitting these features:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Integrate bundle URIs into <code>git clone</code> with a <code>--bundle-uri</code> option. This will include a new <code>git fetch --bundle-uri</code> mode for use as the implementation underneath <code>git clone</code>. The initial version here will expect a single bundle at the given URI.</p> </li> <li> <p>Implement the ability to parse a bundle list from a bundle URI and update the <code>git fetch --bundle-uri</code> logic to properly distinguish between <code>bundle.mode</code> options. Specifically design the feature so that the config format parsing feeds a list of key-value pairs into the bundle list logic.</p> </li> <li> <p>Create the <code>bundle-uri</code> protocol v2 command so Git servers can advertise bundle URIs using the key-value pairs. Plug into the existing key-value input to the bundle list logic. Allow <code>git clone</code> to discover these bundle URIs and bootstrap the client repository from the bundle data. (This choice is an opt-in via a config option and a command-line option.)</p> </li> <li> <p>Allow the client to understand the <code>bundle.heuristic</code> configuration key and the <code>bundle.<id>.creationToken</code> heuristic. When <code>git clone</code> discovers a bundle URI with <code>bundle.heuristic</code>, it configures the client repository to check that bundle URI during later <code>git fetch <remote></code> commands.</p> </li> <li> <p>Allow clients to discover bundle URIs during <code>git fetch</code> and configure a bundle URI for later fetches if <code>bundle.heuristic</code> is set.</p> </li> <li> <p>Implement the "inspect headers" heuristic to reduce data downloads when the <code>bundle.<id>.creationToken</code> heuristic is not available.</p> </li> </ol> </div> <p>As these features are reviewed, this plan might be updated. We also expect that new designs will be discovered and implemented as this feature matures and becomes used in real-world scenarios.</p> </div> <h2 id="_related_work_packfile_uris">Related work: packfile uris</h2> <div class="sectionbody"> <p>The Git protocol already has a capability where the Git server can list a set of URLs along with the packfile response when serving a client request. The client is then expected to download the packfiles at those locations in order to have a complete understanding of the response.</p> <p>This mechanism is used by the Gerrit server (implemented with JGit) and has been effective at reducing CPU load and improving user performance for clones.</p> <p>A major downside to this mechanism is that the origin server needs to know <code>exactly</code> what is in those packfiles, and the packfiles need to be available to the user for some time after the server has responded. This coupling between the origin and the packfile data is difficult to manage.</p> <p>Further, this implementation is extremely hard to make work with fetches.</p> </div> <h2 id="_related_work_gvfs_cache_servers">Related work: gvfs cache servers</h2> <div class="sectionbody"> <p>The GVFS Protocol [2] is a set of HTTP endpoints designed independently of the Git project before Git’s partial clone was created. One feature of this protocol is the idea of a "cache server" which can be colocated with build machines or developer offices to transfer Git data without overloading the central server.</p> <p>The endpoint that VFS for Git is famous for is the <code>GET /gvfs/objects/{oid}</code> endpoint, which allows downloading an object on-demand. This is a critical piece of the filesystem virtualization of that product.</p> <p>However, a more subtle need is the <code>GET /gvfs/prefetch?lastPackTimestamp=<t></code> endpoint. Given an optional timestamp, the cache server responds with a list of precomputed packfiles containing the commits and trees that were introduced in those time intervals.</p> <p>The cache server computes these "prefetch" packfiles using the following strategy:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Every hour, an "hourly" pack is generated with a given timestamp.</p> </li> <li> <p>Nightly, the previous 24 hourly packs are rolled up into a "daily" pack.</p> </li> <li> <p>Nightly, all prefetch packs more than 30 days old are rolled up into one pack.</p> </li> </ol> </div> <p>When a user runs <code>gvfs clone</code> or <code>scalar clone</code> against a repo with cache servers, the client requests all prefetch packfiles, which is at most <code>24 + 30 + 1</code> packfiles downloading only commits and trees. The client then follows with a request to the origin server for the references, and attempts to checkout that tip reference. (There is an extra endpoint that helps get all reachable trees from a given commit, in case that commit was not already in a prefetch packfile.)</p> <p>During a <code>git fetch</code>, a hook requests the prefetch endpoint using the most-recent timestamp from a previously-downloaded prefetch packfile. Only the list of packfiles with later timestamps are downloaded. Most users fetch hourly, so they get at most one hourly prefetch pack. Users whose machines have been off or otherwise have not fetched in over 30 days might redownload all prefetch packfiles. This is rare.</p> <p>It is important to note that the clients always contact the origin server for the refs advertisement, so the refs are frequently "ahead" of the prefetched pack data. The missing objects are downloaded on-demand using the <code>GET gvfs/objects/{oid}</code> requests, when needed by a command such as <code>git checkout</code> or <code>git log</code>. Some Git optimizations disable checks that would cause these on-demand downloads to be too aggressive.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p>[1] <a href="https://lore.kernel.org/git/RFC-cover-00.13-0000000000-20210805T150534Z-avarab@gmail.com/" class="bare">https://lore.kernel.org/git/RFC-cover-00.13-0000000000-20210805T150534Z-avarab@gmail.com/</a> An earlier RFC for a bundle URI feature.</p> <p>[2] <a href="https://github.com/microsoft/VFSForGit/blob/master/Protocol.md" class="bare">https://github.com/microsoft/VFSForGit/blob/master/Protocol.md</a> The GVFS Protocol</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/bundle-uri" class="_attribution-link">https://git-scm.com/docs/bundle-uri</a> + </p> +</div> diff --git a/devdocs/git/git-add.html b/devdocs/git/git-add.html new file mode 100644 index 00000000..119e8a7d --- /dev/null +++ b/devdocs/git/git-add.html @@ -0,0 +1,31 @@ +<h1>git-add</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-add - Add file contents to the index</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p] + [--edit | -e] [--[no-]all | -A | --[no-]ignore-removal | [--update | -u]] [--sparse] + [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing] [--renormalize] + [--chmod=(+|-)x] [--pathspec-from-file=<file> [--pathspec-file-nul]] + [--] [<pathspec>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit. It typically adds the current content of existing paths as a whole, but with some options it can also be used to add content with only part of the changes made to the working tree files applied, or remove paths that do not exist in the working tree anymore.</p> <p>The "index" holds a snapshot of the content of the working tree, and it is this snapshot that is taken as the contents of the next commit. Thus after making any changes to the working tree, and before running the commit command, you must use the <code>add</code> command to add any new or modified files to the index.</p> <p>This command can be performed multiple times before a commit. It only adds the content of the specified file(s) at the time the add command is run; if you want subsequent changes included in the next commit, then you must run <code>git add</code> again to add the new content to the index.</p> <p>The <code>git status</code> command can be used to obtain a summary of which files have changes that are staged for the next commit.</p> <p>The <code>git add</code> command will not add ignored files by default. If any ignored files were explicitly specified on the command line, <code>git add</code> will fail with a list of ignored files. Ignored files reached by directory recursion or filename globbing performed by Git (quote your globs before the shell) will be silently ignored. The <code>git add</code> command can be used to add ignored files with the <code>-f</code> (force) option.</p> <p>Please see <a href="git-commit">git-commit[1]</a> for alternative ways to add content to a commit.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-add.txt-ltpathspecgt82308203"> <pathspec>… </dt> <dd> <p>Files to add content from. Fileglobs (e.g. <code>*.c</code>) can be given to add all matching files. Also a leading directory name (e.g. <code>dir</code> to add <code>dir/file1</code> and <code>dir/file2</code>) can be given to update the index to match the current state of the directory as a whole (e.g. specifying <code>dir</code> will record not just a file <code>dir/file1</code> modified in the working tree, a file <code>dir/file2</code> added to the working tree, but also a file <code>dir/file3</code> removed from the working tree). Note that older versions of Git used to ignore removed files; use <code>--no-all</code> option if you want to add modified or new files but ignore removed ones.</p> <p>For more details about the <pathspec> syntax, see the <code>pathspec</code> entry in <a href="gitglossary">gitglossary[7]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-add.txt---dry-run"> --dry-run </dt> <dd> <p>Don’t actually add the file(s), just show if they exist and/or will be ignored.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-add.txt---verbose"> --verbose </dt> <dd> <p>Be verbose.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-add.txt---force"> --force </dt> <dd> <p>Allow adding otherwise ignored files.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt---sparse"> --sparse </dt> <dd> <p>Allow updating index entries outside of the sparse-checkout cone. Normally, <code>git add</code> refuses to update index entries whose paths do not fit within the sparse-checkout cone, since those files might be removed from the working tree without warning. See <a href="git-sparse-checkout">git-sparse-checkout[1]</a> for more details.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt--i"> -i </dt> <dt class="hdlist1" id="Documentation/git-add.txt---interactive"> --interactive </dt> <dd> <p>Add modified contents in the working tree interactively to the index. Optional path arguments may be supplied to limit operation to a subset of the working tree. See “Interactive mode” for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-add.txt---patch"> --patch </dt> <dd> <p>Interactively choose hunks of patch between the index and the work tree and add them to the index. This gives the user a chance to review the difference before adding modified contents to the index.</p> <p>This effectively runs <code>add --interactive</code>, but bypasses the initial command menu and directly jumps to the <code>patch</code> subcommand. See “Interactive mode” for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt--e"> -e </dt> <dt class="hdlist1" id="Documentation/git-add.txt---edit"> --edit </dt> <dd> <p>Open the diff vs. the index in an editor and let the user edit it. After the editor was closed, adjust the hunk headers and apply the patch to the index.</p> <p>The intent of this option is to pick and choose lines of the patch to apply, or even to modify the contents of lines to be staged. This can be quicker and more flexible than using the interactive hunk selector. However, it is easy to confuse oneself and create a patch that does not apply to the index. See EDITING PATCHES below.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt--u"> -u </dt> <dt class="hdlist1" id="Documentation/git-add.txt---update"> --update </dt> <dd> <p>Update the index just where it already has an entry matching <pathspec>. This removes as well as modifies index entries to match the working tree, but adds no new files.</p> <p>If no <pathspec> is given when <code>-u</code> option is used, all tracked files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt--A"> -A </dt> <dt class="hdlist1" id="Documentation/git-add.txt---all"> --all </dt> <dt class="hdlist1" id="Documentation/git-add.txt---no-ignore-removal"> --no-ignore-removal </dt> <dd> <p>Update the index not only where the working tree has a file matching <pathspec> but also where the index already has an entry. This adds, modifies, and removes index entries to match the working tree.</p> <p>If no <pathspec> is given when <code>-A</code> option is used, all files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt---no-all"> --no-all </dt> <dt class="hdlist1" id="Documentation/git-add.txt---ignore-removal"> --ignore-removal </dt> <dd> <p>Update the index by adding new files that are unknown to the index and files modified in the working tree, but ignore files that have been removed from the working tree. This option is a no-op when no <pathspec> is used.</p> <p>This option is primarily to help users who are used to older versions of Git, whose "git add <pathspec>…" was a synonym for "git add --no-all <pathspec>…", i.e. ignored removed files.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt--N"> -N </dt> <dt class="hdlist1" id="Documentation/git-add.txt---intent-to-add"> --intent-to-add </dt> <dd> <p>Record only the fact that the path will be added later. An entry for the path is placed in the index with no content. This is useful for, among other things, showing the unstaged content of such files with <code>git diff</code> and committing them with <code>git commit +-a</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt---refresh"> --refresh </dt> <dd> <p>Don’t add the file(s), but only refresh their stat() information in the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt---ignore-errors"> --ignore-errors </dt> <dd> <p>If some files could not be added because of errors indexing them, do not abort the operation, but continue adding the others. The command shall still exit with non-zero status. The configuration variable <code>add.ignoreErrors</code> can be set to true to make this the default behaviour.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt---ignore-missing"> --ignore-missing </dt> <dd> <p>This option can only be used together with --dry-run. By using this option the user can check if any of the given files would be ignored, no matter if they are already present in the work tree or not.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt---no-warn-embedded-repo"> --no-warn-embedded-repo </dt> <dd> <p>By default, <code>git add</code> will warn when adding an embedded repository to the index without using <code>git submodule add</code> to create an entry in <code>.gitmodules</code>. This option will suppress the warning (e.g., if you are manually performing operations on submodules).</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt---renormalize"> --renormalize </dt> <dd> <p>Apply the "clean" process freshly to all tracked files to forcibly add them again to the index. This is useful after changing <code>core.autocrlf</code> configuration or the <code>text</code> attribute in order to correct files added with wrong CRLF/LF line endings. This option implies <code>-u</code>. Lone CR characters are untouched, thus while a CRLF cleans to LF, a CRCRLF sequence is only partially cleaned to CRLF.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt---chmod-x"> --chmod=(+|-)x </dt> <dd> <p>Override the executable bit of the added files. The executable bit is only changed in the index, the files on disk are left unchanged.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt---pathspec-from-fileltfilegt"> --pathspec-from-file=<file> </dt> <dd> <p>Pathspec is passed in <code><file></code> instead of commandline args. If <code><file></code> is exactly <code>-</code> then standard input is used. Pathspec elements are separated by LF or CR/LF. Pathspec elements can be quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>). See also <code>--pathspec-file-nul</code> and global <code>--literal-pathspecs</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt---pathspec-file-nul"> --pathspec-file-nul </dt> <dd> <p>Only meaningful with <code>--pathspec-from-file</code>. Pathspec elements are separated with NUL character and all other characters are taken literally (including newlines and quotes).</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt---"> -- </dt> <dd> <p>This option can be used to separate command-line options from the list of files, (useful when filenames might be mistaken for command-line options).</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Adds content from all <code>*.txt</code> files under <code>Documentation</code> directory and its subdirectories:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git add Documentation/\*.txt</pre> </div> </div> <p>Note that the asterisk <code>*</code> is quoted from the shell in this example; this lets the command include the files from subdirectories of <code>Documentation/</code> directory.</p> </li> <li> <p>Considers adding content from all git-*.sh scripts:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git add git-*.sh</pre> </div> </div> <p>Because this example lets the shell expand the asterisk (i.e. you are listing the files explicitly), it does not consider <code>subdir/git-foo.sh</code>.</p> </li> </ul> </div> </div> <h2 id="_interactive_mode">Interactive mode</h2> <div class="sectionbody"> <p>When the command enters the interactive mode, it shows the output of the <code>status</code> subcommand, and then goes into its interactive command loop.</p> <p>The command loop shows the list of subcommands available, and gives a prompt "What now> ". In general, when the prompt ends with a single <code>></code>, you can pick only one of the choices given and type return, like this:</p> <div class="listingblock"> <div class="content"> <pre> *** Commands *** + 1: status 2: update 3: revert 4: add untracked + 5: patch 6: diff 7: quit 8: help + What now> 1</pre> </div> </div> <p>You also could say <code>s</code> or <code>sta</code> or <code>status</code> above as long as the choice is unique.</p> <p>The main command loop has 6 subcommands (plus help and quit).</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-add.txt-status"> status </dt> <dd> <p>This shows the change between HEAD and index (i.e. what will be committed if you say <code>git commit</code>), and between index and working tree files (i.e. what you could stage further before <code>git commit</code> using <code>git add</code>) for each path. A sample output looks like this:</p> <div class="listingblock"> <div class="content"> <pre> staged unstaged path + 1: binary nothing foo.png + 2: +403/-35 +1/-1 add-interactive.c</pre> </div> </div> <p>It shows that foo.png has differences from HEAD (but that is binary so line count cannot be shown) and there is no difference between indexed copy and the working tree version (if the working tree version were also different, <code>binary</code> would have been shown in place of <code>nothing</code>). The other file, add-interactive.c, has 403 lines added and 35 lines deleted if you commit what is in the index, but working tree file has further modifications (one addition and one deletion).</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt-update"> update </dt> <dd> <p>This shows the status information and issues an "Update>>" prompt. When the prompt ends with double <code>>></code>, you can make more than one selection, concatenated with whitespace or comma. Also you can say ranges. E.g. "2-5 7,9" to choose 2,3,4,5,7,9 from the list. If the second number in a range is omitted, all remaining patches are taken. E.g. "7-" to choose 7,8,9 from the list. You can say <code>*</code> to choose everything.</p> <p>What you chose are then highlighted with <code>*</code>, like this:</p> <div class="listingblock"> <div class="content"> <pre> staged unstaged path + 1: binary nothing foo.png +* 2: +403/-35 +1/-1 add-interactive.c</pre> </div> </div> <p>To remove selection, prefix the input with <code>-</code> like this:</p> <div class="listingblock"> <div class="content"> <pre>Update>> -2</pre> </div> </div> <p>After making the selection, answer with an empty line to stage the contents of working tree files for selected paths in the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt-revert"> revert </dt> <dd> <p>This has a very similar UI to <code>update</code>, and the staged information for selected paths are reverted to that of the HEAD version. Reverting new paths makes them untracked.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt-adduntracked"> add untracked </dt> <dd> <p>This has a very similar UI to <code>update</code> and <code>revert</code>, and lets you add untracked paths to the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt-patch"> patch </dt> <dd> <p>This lets you choose one path out of a <code>status</code> like selection. After choosing the path, it presents the diff between the index and the working tree file and asks you if you want to stage the change of each hunk. You can select one of the following options and type return:</p> <div class="literalblock"> <div class="content"> <pre>y - stage this hunk +n - do not stage this hunk +q - quit; do not stage this hunk or any of the remaining ones +a - stage this hunk and all later hunks in the file +d - do not stage this hunk or any of the later hunks in the file +g - select a hunk to go to +/ - search for a hunk matching the given regex +j - leave this hunk undecided, see next undecided hunk +J - leave this hunk undecided, see next hunk +k - leave this hunk undecided, see previous undecided hunk +K - leave this hunk undecided, see previous hunk +s - split the current hunk into smaller hunks +e - manually edit the current hunk +? - print help</pre> </div> </div> <p>After deciding the fate for all hunks, if there is any hunk that was chosen, the index is updated with the selected hunks.</p> <p>You can omit having to type return here, by setting the configuration variable <code>interactive.singleKey</code> to <code>true</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt-diff"> diff </dt> <dd> <p>This lets you review what will be committed (i.e. between HEAD and index).</p> </dd> </dl> </div> </div> <h2 id="_editing_patches">Editing patches</h2> <div class="sectionbody"> <p>Invoking <code>git add -e</code> or selecting <code>e</code> from the interactive hunk selector will open a patch in your editor; after the editor exits, the result is applied to the index. You are free to make arbitrary changes to the patch, but note that some changes may have confusing results, or even result in a patch that cannot be applied. If you want to abort the operation entirely (i.e., stage nothing new in the index), simply delete all lines of the patch. The list below describes some common things you may see in a patch, and which editing operations make sense on them.</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-add.txt-addedcontent"> added content </dt> <dd> <p>Added content is represented by lines beginning with "+". You can prevent staging any addition lines by deleting them.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt-removedcontent"> removed content </dt> <dd> <p>Removed content is represented by lines beginning with "-". You can prevent staging their removal by converting the "-" to a " " (space).</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt-modifiedcontent"> modified content </dt> <dd> <p>Modified content is represented by "-" lines (removing the old content) followed by "+" lines (adding the replacement content). You can prevent staging the modification by converting "-" lines to " ", and removing "+" lines. Beware that modifying only half of the pair is likely to introduce confusing changes to the index.</p> </dd> </dl> </div> </div> </div> <p>There are also more complex operations that can be performed. But beware that because the patch is applied only to the index and not the working tree, the working tree will appear to "undo" the change in the index. For example, introducing a new line into the index that is in neither the HEAD nor the working tree will stage the new line for commit, but the line will appear to be reverted in the working tree.</p> <p>Avoid using these constructs, or do so with extreme caution.</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-add.txt-removinguntouchedcontent"> removing untouched content </dt> <dd> <p>Content which does not differ between the index and working tree may be shown on context lines, beginning with a " " (space). You can stage context lines for removal by converting the space to a "-". The resulting working tree file will appear to re-add the content.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt-modifyingexistingcontent"> modifying existing content </dt> <dd> <p>One can also modify context lines by staging them for removal (by converting " " to "-") and adding a "+" line with the new content. Similarly, one can modify "+" lines for existing additions or modifications. In all cases, the new modification will appear reverted in the working tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt-newcontent"> new content </dt> <dd> <p>You may also add new content that does not exist in the patch; simply add new lines, each starting with "+". The addition will appear reverted in the working tree.</p> </dd> </dl> </div> </div> </div> <p>There are also several operations which should be avoided entirely, as they will make the patch impossible to apply:</p> <div class="ulist"> <ul> <li> <p>adding context (" ") or removal ("-") lines</p> </li> <li> <p>deleting context or removal lines</p> </li> <li> <p>modifying the contents of context or removal lines</p> </li> </ul> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-add.txt-addignoreErrors"> add.ignoreErrors </dt> <dt class="hdlist1" id="Documentation/git-add.txt-addignore-errorsdeprecated"> add.ignore-errors (deprecated) </dt> <dd> <p>Tells <code>git add</code> to continue adding files when some files cannot be added due to indexing errors. Equivalent to the <code>--ignore-errors</code> option of <a href="git-add">git-add[1]</a>. <code>add.ignore-errors</code> is deprecated, as it does not follow the usual naming convention for configuration variables.</p> </dd> <dt class="hdlist1" id="Documentation/git-add.txt-addinteractiveuseBuiltin"> add.interactive.useBuiltin </dt> <dd> <p>Unused configuration variable. Used in Git versions v2.25.0 to v2.36.0 to enable the built-in version of <a href="git-add">git-add[1]</a>'s interactive mode, which then became the default in Git versions v2.37.0 to v2.39.0.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-status">git-status[1]</a> <a href="git-rm">git-rm[1]</a> <a href="git-reset">git-reset[1]</a> <a href="git-mv">git-mv[1]</a> <a href="git-commit">git-commit[1]</a> <a href="git-update-index">git-update-index[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-add" class="_attribution-link">https://git-scm.com/docs/git-add</a> + </p> +</div> diff --git a/devdocs/git/git-am.html b/devdocs/git/git-am.html new file mode 100644 index 00000000..fb45e943 --- /dev/null +++ b/devdocs/git/git-am.html @@ -0,0 +1,15 @@ +<h1>git-am</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-am - Apply a series of patches from a mailbox</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git am [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8] [--no-verify] + [--[no-]3way] [--interactive] [--committer-date-is-author-date] + [--ignore-date] [--ignore-space-change | --ignore-whitespace] + [--whitespace=<action>] [-C<n>] [-p<n>] [--directory=<dir>] + [--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet] + [--[no-]scissors] [-S[<keyid>]] [--patch-format=<format>] + [--quoted-cr=<action>] + [--empty=(stop|drop|keep)] + [(<mbox> | <Maildir>)…] +git am (--continue | --skip | --abort | --quit | --show-current-patch[=(diff|raw)] | --allow-empty)</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Splits mail messages in a mailbox into commit log messages, authorship information, and patches, and applies them to the current branch. You could think of it as a reverse operation of <a href="git-format-patch">git-format-patch[1]</a> run on a branch with a straight history without merges.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-am.txt-ltmboxgtltMaildirgt82308203"> (<mbox>|<Maildir>)… </dt> <dd> <p>The list of mailbox files to read patches from. If you do not supply this argument, the command reads from the standard input. If you supply directories, they will be treated as Maildirs.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-am.txt---signoff"> --signoff </dt> <dd> <p>Add a <code>Signed-off-by</code> trailer to the commit message, using the committer identity of yourself. See the signoff option in <a href="git-commit">git-commit[1]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt--k"> -k </dt> <dt class="hdlist1" id="Documentation/git-am.txt---keep"> --keep </dt> <dd> <p>Pass <code>-k</code> flag to <code>git mailinfo</code> (see <a href="git-mailinfo">git-mailinfo[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---keep-non-patch"> --keep-non-patch </dt> <dd> <p>Pass <code>-b</code> flag to <code>git mailinfo</code> (see <a href="git-mailinfo">git-mailinfo[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---no-keep-cr"> --[no-]keep-cr </dt> <dd> <p>With <code>--keep-cr</code>, call <code>git mailsplit</code> (see <a href="git-mailsplit">git-mailsplit[1]</a>) with the same option, to prevent it from stripping CR at the end of lines. <code>am.keepcr</code> configuration variable can be used to specify the default behaviour. <code>--no-keep-cr</code> is useful to override <code>am.keepcr</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt--c"> -c </dt> <dt class="hdlist1" id="Documentation/git-am.txt---scissors"> --scissors </dt> <dd> <p>Remove everything in body before a scissors line (see <a href="git-mailinfo">git-mailinfo[1]</a>). Can be activated by default using the <code>mailinfo.scissors</code> configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---no-scissors"> --no-scissors </dt> <dd> <p>Ignore scissors lines (see <a href="git-mailinfo">git-mailinfo[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---quoted-crltactiongt"> --quoted-cr=<action> </dt> <dd> <p>This flag will be passed down to <code>git mailinfo</code> (see <a href="git-mailinfo">git-mailinfo[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---emptystopdropkeep"> --empty=(stop|drop|keep) </dt> <dd> <p>By default, or when the option is set to <code>stop</code>, the command errors out on an input e-mail message lacking a patch and stops in the middle of the current am session. When this option is set to <code>drop</code>, skip such an e-mail message instead. When this option is set to <code>keep</code>, create an empty commit, recording the contents of the e-mail message as its log.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt--m"> -m </dt> <dt class="hdlist1" id="Documentation/git-am.txt---message-id"> --message-id </dt> <dd> <p>Pass the <code>-m</code> flag to <code>git mailinfo</code> (see <a href="git-mailinfo">git-mailinfo[1]</a>), so that the Message-ID header is added to the commit message. The <code>am.messageid</code> configuration variable can be used to specify the default behaviour.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---no-message-id"> --no-message-id </dt> <dd> <p>Do not add the Message-ID header to the commit message. <code>no-message-id</code> is useful to override <code>am.messageid</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-am.txt---quiet"> --quiet </dt> <dd> <p>Be quiet. Only print error messages.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt--u"> -u </dt> <dt class="hdlist1" id="Documentation/git-am.txt---utf8"> --utf8 </dt> <dd> <p>Pass <code>-u</code> flag to <code>git mailinfo</code> (see <a href="git-mailinfo">git-mailinfo[1]</a>). The proposed commit log message taken from the e-mail is re-coded into UTF-8 encoding (configuration variable <code>i18n.commitEncoding</code> can be used to specify the project’s preferred encoding if it is not UTF-8).</p> <p>This was optional in prior versions of git, but now it is the default. You can use <code>--no-utf8</code> to override this.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---no-utf8"> --no-utf8 </dt> <dd> <p>Pass <code>-n</code> flag to <code>git mailinfo</code> (see <a href="git-mailinfo">git-mailinfo[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt--3"> -3 </dt> <dt class="hdlist1" id="Documentation/git-am.txt---3way"> --3way </dt> <dt class="hdlist1" id="Documentation/git-am.txt---no-3way"> --no-3way </dt> <dd> <p>When the patch does not apply cleanly, fall back on 3-way merge if the patch records the identity of blobs it is supposed to apply to and we have those blobs available locally. <code>--no-3way</code> can be used to override am.threeWay configuration variable. For more information, see am.threeWay in <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---rerere-autoupdate"> --rerere-autoupdate </dt> <dt class="hdlist1" id="Documentation/git-am.txt---no-rerere-autoupdate"> --no-rerere-autoupdate </dt> <dd> <p>After the rerere mechanism reuses a recorded resolution on the current conflict to update the files in the working tree, allow it to also update the index with the result of resolution. <code>--no-rerere-autoupdate</code> is a good way to double-check what <code>rerere</code> did and catch potential mismerges, before committing the result to the index with a separate <code>git add</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---ignore-space-change"> --ignore-space-change </dt> <dt class="hdlist1" id="Documentation/git-am.txt---ignore-whitespace"> --ignore-whitespace </dt> <dt class="hdlist1" id="Documentation/git-am.txt---whitespaceltactiongt"> --whitespace=<action> </dt> <dt class="hdlist1" id="Documentation/git-am.txt--Cltngt"> -C<n> </dt> <dt class="hdlist1" id="Documentation/git-am.txt--pltngt"> -p<n> </dt> <dt class="hdlist1" id="Documentation/git-am.txt---directoryltdirgt"> --directory=<dir> </dt> <dt class="hdlist1" id="Documentation/git-am.txt---excludeltpathgt"> --exclude=<path> </dt> <dt class="hdlist1" id="Documentation/git-am.txt---includeltpathgt"> --include=<path> </dt> <dt class="hdlist1" id="Documentation/git-am.txt---reject"> --reject </dt> <dd> <p>These flags are passed to the <code>git apply</code> (see <a href="git-apply">git-apply[1]</a>) program that applies the patch.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---patch-format"> --patch-format </dt> <dd> <p>By default the command will try to detect the patch format automatically. This option allows the user to bypass the automatic detection and specify the patch format that the patch(es) should be interpreted as. Valid formats are mbox, mboxrd, stgit, stgit-series, and hg.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt--i"> -i </dt> <dt class="hdlist1" id="Documentation/git-am.txt---interactive"> --interactive </dt> <dd> <p>Run interactively.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-am.txt---no-verify"> --no-verify </dt> <dd> <p>By default, the pre-applypatch and applypatch-msg hooks are run. When any of <code>--no-verify</code> or <code>-n</code> is given, these are bypassed. See also <a href="githooks">githooks[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---committer-date-is-author-date"> --committer-date-is-author-date </dt> <dd> <p>By default the command records the date from the e-mail message as the commit author date, and uses the time of commit creation as the committer date. This allows the user to lie about the committer date by using the same value as the author date.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---ignore-date"> --ignore-date </dt> <dd> <p>By default the command records the date from the e-mail message as the commit author date, and uses the time of commit creation as the committer date. This allows the user to lie about the author date by using the same value as the committer date.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---skip"> --skip </dt> <dd> <p>Skip the current patch. This is only meaningful when restarting an aborted patch.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt--Sltkeyidgt"> -S[<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-am.txt---gpg-signltkeyidgt"> --gpg-sign[=<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-am.txt---no-gpg-sign"> --no-gpg-sign </dt> <dd> <p>GPG-sign commits. The <code>keyid</code> argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space. <code>--no-gpg-sign</code> is useful to countermand both <code>commit.gpgSign</code> configuration variable, and earlier <code>--gpg-sign</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---continue"> --continue </dt> <dt class="hdlist1" id="Documentation/git-am.txt--r"> -r </dt> <dt class="hdlist1" id="Documentation/git-am.txt---resolved"> --resolved </dt> <dd> <p>After a patch failure (e.g. attempting to apply conflicting patch), the user has applied it by hand and the index file stores the result of the application. Make a commit using the authorship and commit log extracted from the e-mail message and the current index file, and continue.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---resolvemsgltmsggt"> --resolvemsg=<msg> </dt> <dd> <p>When a patch failure occurs, <msg> will be printed to the screen before exiting. This overrides the standard message informing you to use <code>--continue</code> or <code>--skip</code> to handle the failure. This is solely for internal use between <code>git rebase</code> and <code>git am</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---abort"> --abort </dt> <dd> <p>Restore the original branch and abort the patching operation. Revert the contents of files involved in the am operation to their pre-am state.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---quit"> --quit </dt> <dd> <p>Abort the patching operation but keep HEAD and the index untouched.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---show-current-patchdiffraw"> --show-current-patch[=(diff|raw)] </dt> <dd> <p>Show the message at which <code>git am</code> has stopped due to conflicts. If <code>raw</code> is specified, show the raw contents of the e-mail message; if <code>diff</code>, show the diff portion only. Defaults to <code>raw</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt---allow-empty"> --allow-empty </dt> <dd> <p>After a patch failure on an input e-mail message lacking a patch, create an empty commit with the contents of the e-mail message as its log message.</p> </dd> </dl> </div> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>The commit author name is taken from the "From: " line of the message, and commit author date is taken from the "Date: " line of the message. The "Subject: " line is used as the title of the commit, after stripping common prefix "[PATCH <anything>]". The "Subject: " line is supposed to concisely describe what the commit is about in one line of text.</p> <p>"From: ", "Date: ", and "Subject: " lines starting the body override the respective commit author name and title values taken from the headers.</p> <p>The commit message is formed by the title taken from the "Subject: ", a blank line and the body of the message up to where the patch begins. Excess whitespace at the end of each line is automatically stripped.</p> <p>The patch is expected to be inline, directly following the message. Any line that is of the form:</p> <div class="ulist"> <ul> <li> <p>three-dashes and end-of-line, or</p> </li> <li> <p>a line that begins with "diff -", or</p> </li> <li> <p>a line that begins with "Index: "</p> </li> </ul> </div> <p>is taken as the beginning of a patch, and the commit log message is terminated before the first occurrence of such a line.</p> <p>When initially invoking <code>git am</code>, you give it the names of the mailboxes to process. Upon seeing the first patch that does not apply, it aborts in the middle. You can recover from this in one of two ways:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>skip the current patch by re-running the command with the <code>--skip</code> option.</p> </li> <li> <p>hand resolve the conflict in the working directory, and update the index file to bring it into a state that the patch should have produced. Then run the command with the <code>--continue</code> option.</p> </li> </ol> </div> <p>The command refuses to process new mailboxes until the current operation is finished, so if you decide to start over from scratch, run <code>git am --abort</code> before running the command with mailbox names.</p> <p>Before any patches are applied, ORIG_HEAD is set to the tip of the current branch. This is useful if you have problems with multiple commits, like running <code>git am</code> on the wrong branch or an error in the commits that is more easily fixed by changing the mailbox (e.g. errors in the "From:" lines).</p> </div> <h2 id="_hooks">Hooks</h2> <div class="sectionbody"> <p>This command can run <code>applypatch-msg</code>, <code>pre-applypatch</code>, and <code>post-applypatch</code> hooks. See <a href="githooks">githooks[5]</a> for more information.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-am.txt-amkeepcr"> am.keepcr </dt> <dd> <p>If true, git-am will call git-mailsplit for patches in mbox format with parameter <code>--keep-cr</code>. In this case git-mailsplit will not remove <code>\r</code> from lines ending with <code>\r\n</code>. Can be overridden by giving <code>--no-keep-cr</code> from the command line. See <a href="git-am">git-am[1]</a>, <a href="git-mailsplit">git-mailsplit[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-am.txt-amthreeWay"> am.threeWay </dt> <dd> <p>By default, <code>git am</code> will fail if the patch does not apply cleanly. When set to true, this setting tells <code>git am</code> to fall back on 3-way merge if the patch records the identity of blobs it is supposed to apply to and we have those blobs available locally (equivalent to giving the <code>--3way</code> option from the command line). Defaults to <code>false</code>. See <a href="git-am">git-am[1]</a>.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-apply">git-apply[1]</a>, <a href="git-format-patch">git-format-patch[1]</a>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-am" class="_attribution-link">https://git-scm.com/docs/git-am</a> + </p> +</div> diff --git a/devdocs/git/git-annotate.html b/devdocs/git/git-annotate.html new file mode 100644 index 00000000..899b6969 --- /dev/null +++ b/devdocs/git/git-annotate.html @@ -0,0 +1,7 @@ +<h1>git-annotate</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-annotate - Annotate file lines with commit information</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git annotate [<options>] [<rev-opts>] [<rev>] [--] <file></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Annotates each line in the given file with information from the commit which introduced the line. Optionally annotates from a given revision.</p> <p>The only difference between this command and <a href="git-blame">git-blame[1]</a> is that they use slightly different output formats, and this command exists only for backward compatibility to support existing scripts, and provide a more familiar command name for people coming from other SCM systems.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-annotate.txt--b"> -b </dt> <dd> <p>Show blank SHA-1 for boundary commits. This can also be controlled via the <code>blame.blankBoundary</code> config option.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt---root"> --root </dt> <dd> <p>Do not treat root commits as boundaries. This can also be controlled via the <code>blame.showRoot</code> config option.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt---show-stats"> --show-stats </dt> <dd> <p>Include additional statistics at the end of blame output.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt--Lltstartgtltendgt"> -L <start>,<end> </dt> <dt class="hdlist1" id="Documentation/git-annotate.txt--Lltfuncnamegt"> -L :<funcname> </dt> <dd> <p>Annotate only the line range given by <code><start>,<end></code>, or by the function name regex <code><funcname></code>. May be specified multiple times. Overlapping ranges are allowed.</p> <p><code><start></code> and <code><end></code> are optional. <code>-L <start></code> or <code>-L <start>,</code> spans from <code><start></code> to end of file. <code>-L ,<end></code> spans from start of file to <code><end></code>.</p> <p><code><start></code> and <code><end></code> can take one of these forms:</p> <div class="ulist"> <ul> <li> <p>number</p> <p>If <code><start></code> or <code><end></code> is a number, it specifies an absolute line number (lines count from 1).</p> </li> <li> <p><code>/regex/</code></p> <p>This form will use the first line matching the given POSIX regex. If <code><start></code> is a regex, it will search from the end of the previous <code>-L</code> range, if any, otherwise from the start of file. If <code><start></code> is <code>^/regex/</code>, it will search from the start of file. If <code><end></code> is a regex, it will search starting at the line given by <code><start></code>.</p> </li> <li> <p>+offset or -offset</p> <p>This is only valid for <code><end></code> and will specify a number of lines before or after the line given by <code><start></code>.</p> </li> </ul> </div> <p>If <code>:<funcname></code> is given in place of <code><start></code> and <code><end></code>, it is a regular expression that denotes the range from the first funcname line that matches <code><funcname></code>, up to the next funcname line. <code>:<funcname></code> searches from the end of the previous <code>-L</code> range, if any, otherwise from the start of file. <code>^:<funcname></code> searches from the start of file. The function names are determined in the same way as <code>git diff</code> works out patch hunk headers (see <code>Defining a custom hunk-header</code> in <a href="gitattributes">gitattributes[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt--l"> -l </dt> <dd> <p>Show long rev (Default: off).</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt--t"> -t </dt> <dd> <p>Show raw timestamp (Default: off).</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt--Sltrevs-filegt"> -S <revs-file> </dt> <dd> <p>Use revisions from revs-file instead of calling <a href="git-rev-list">git-rev-list[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt---reverseltrevgtltrevgt"> --reverse <rev>..<rev> </dt> <dd> <p>Walk history forward instead of backward. Instead of showing the revision in which a line appeared, this shows the last revision in which a line has existed. This requires a range of revision like START..END where the path to blame exists in START. <code>git blame --reverse START</code> is taken as <code>git blame +--reverse START..HEAD</code> for convenience.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt---first-parent"> --first-parent </dt> <dd> <p>Follow only the first parent commit upon seeing a merge commit. This option can be used to determine when a line was introduced to a particular integration branch, rather than when it was introduced to the history overall.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-annotate.txt---porcelain"> --porcelain </dt> <dd> <p>Show in a format designed for machine consumption.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt---line-porcelain"> --line-porcelain </dt> <dd> <p>Show the porcelain format, but output commit information for each line, not just the first time a commit is referenced. Implies --porcelain.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt---incremental"> --incremental </dt> <dd> <p>Show the result incrementally in a format designed for machine consumption.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt---encodingltencodinggt"> --encoding=<encoding> </dt> <dd> <p>Specifies the encoding used to output author names and commit summaries. Setting it to <code>none</code> makes blame output unconverted data. For more information see the discussion about encoding in the <a href="git-log">git-log[1]</a> manual page.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt---contentsltfilegt"> --contents <file> </dt> <dd> <p>Annotate using the contents from the named file, starting from <rev> if it is specified, and HEAD otherwise. You may specify <code>-</code> to make the command read from the standard input for the file contents.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt---dateltformatgt"> --date <format> </dt> <dd> <p>Specifies the format used to output dates. If --date is not provided, the value of the blame.date config variable is used. If the blame.date config variable is also not set, the iso format is used. For supported values, see the discussion of the --date option at <a href="git-log">git-log[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt---no-progress"> --[no-]progress </dt> <dd> <p>Progress status is reported on the standard error stream by default when it is attached to a terminal. This flag enables progress reporting even if not attached to a terminal. Can’t use <code>--progress</code> together with <code>--porcelain</code> or <code>--incremental</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt--Mltnumgt"> -M[<num>] </dt> <dd> <p>Detect moved or copied lines within a file. When a commit moves or copies a block of lines (e.g. the original file has A and then B, and the commit changes it to B and then A), the traditional <code>blame</code> algorithm notices only half of the movement and typically blames the lines that were moved up (i.e. B) to the parent and assigns blame to the lines that were moved down (i.e. A) to the child commit. With this option, both groups of lines are blamed on the parent by running extra passes of inspection.</p> <p><num> is optional but it is the lower bound on the number of alphanumeric characters that Git must detect as moving/copying within a file for it to associate those lines with the parent commit. The default value is 20.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt--Cltnumgt"> -C[<num>] </dt> <dd> <p>In addition to <code>-M</code>, detect lines moved or copied from other files that were modified in the same commit. This is useful when you reorganize your program and move code around across files. When this option is given twice, the command additionally looks for copies from other files in the commit that creates the file. When this option is given three times, the command additionally looks for copies from other files in any commit.</p> <p><num> is optional but it is the lower bound on the number of alphanumeric characters that Git must detect as moving/copying between files for it to associate those lines with the parent commit. And the default value is 40. If there are more than one <code>-C</code> options given, the <num> argument of the last <code>-C</code> will take effect.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt---ignore-revltrevgt"> --ignore-rev <rev> </dt> <dd> <p>Ignore changes made by the revision when assigning blame, as if the change never happened. Lines that were changed or added by an ignored commit will be blamed on the previous commit that changed that line or nearby lines. This option may be specified multiple times to ignore more than one revision. If the <code>blame.markIgnoredLines</code> config option is set, then lines that were changed by an ignored commit and attributed to another commit will be marked with a <code>?</code> in the blame output. If the <code>blame.markUnblamableLines</code> config option is set, then those lines touched by an ignored commit that we could not attribute to another revision are marked with a <code>*</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt---ignore-revs-fileltfilegt"> --ignore-revs-file <file> </dt> <dd> <p>Ignore revisions listed in <code>file</code>, which must be in the same format as an <code>fsck.skipList</code>. This option may be repeated, and these files will be processed after any files specified with the <code>blame.ignoreRevsFile</code> config option. An empty file name, <code>""</code>, will clear the list of revs from previously processed files.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt---color-lines"> --color-lines </dt> <dd> <p>Color line annotations in the default format differently if they come from the same commit as the preceding line. This makes it easier to distinguish code blocks introduced by different commits. The color defaults to cyan and can be adjusted using the <code>color.blame.repeatedLines</code> config option.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt---color-by-age"> --color-by-age </dt> <dd> <p>Color line annotations depending on the age of the line in the default format. The <code>color.blame.highlightRecent</code> config option controls what color is used for each range of age.</p> </dd> <dt class="hdlist1" id="Documentation/git-annotate.txt--h"> -h </dt> <dd> <p>Show help message.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-blame">git-blame[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-annotate" class="_attribution-link">https://git-scm.com/docs/git-annotate</a> + </p> +</div> diff --git a/devdocs/git/git-apply.html b/devdocs/git/git-apply.html new file mode 100644 index 00000000..1da3a539 --- /dev/null +++ b/devdocs/git/git-apply.html @@ -0,0 +1,13 @@ +<h1>git-apply</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-apply - Apply a patch to files and/or to the index</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git apply [--stat] [--numstat] [--summary] [--check] [--index | --intent-to-add] [--3way] + [--apply] [--no-add] [--build-fake-ancestor=<file>] [-R | --reverse] + [--allow-binary-replacement | --binary] [--reject] [-z] + [-p<n>] [-C<n>] [--inaccurate-eof] [--recount] [--cached] + [--ignore-space-change | --ignore-whitespace] + [--whitespace=(nowarn|warn|fix|error|error-all)] + [--exclude=<path>] [--include=<path>] [--directory=<root>] + [--verbose | --quiet] [--unsafe-paths] [--allow-empty] [<patch>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Reads the supplied diff output (i.e. "a patch") and applies it to files. When running from a subdirectory in a repository, patched paths outside the directory are ignored. With the <code>--index</code> option, the patch is also applied to the index, and with the <code>--cached</code> option, the patch is only applied to the index. Without these options, the command applies the patch only to files, and does not require them to be in a Git repository.</p> <p>This command applies the patch but does not create a commit. Use <a href="git-am">git-am[1]</a> to create commits from patches generated by <a href="git-format-patch">git-format-patch[1]</a> and/or received by email.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-apply.txt-ltpatchgt82308203"> <patch>… </dt> <dd> <p>The files to read the patch from. <code>-</code> can be used to read from the standard input.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---stat"> --stat </dt> <dd> <p>Instead of applying the patch, output diffstat for the input. Turns off "apply".</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---numstat"> --numstat </dt> <dd> <p>Similar to <code>--stat</code>, but shows the number of added and deleted lines in decimal notation and the pathname without abbreviation, to make it more machine friendly. For binary files, outputs two <code>-</code> instead of saying <code>0 0</code>. Turns off "apply".</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---summary"> --summary </dt> <dd> <p>Instead of applying the patch, output a condensed summary of information obtained from git diff extended headers, such as creations, renames, and mode changes. Turns off "apply".</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---check"> --check </dt> <dd> <p>Instead of applying the patch, see if the patch is applicable to the current working tree and/or the index file and detects errors. Turns off "apply".</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---index"> --index </dt> <dd> <p>Apply the patch to both the index and the working tree (or merely check that it would apply cleanly to both if <code>--check</code> is in effect). Note that <code>--index</code> expects index entries and working tree copies for relevant paths to be identical (their contents and metadata such as file mode must match), and will raise an error if they are not, even if the patch would apply cleanly to both the index and the working tree in isolation.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---cached"> --cached </dt> <dd> <p>Apply the patch to just the index, without touching the working tree. If <code>--check</code> is in effect, merely check that it would apply cleanly to the index entry.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---intent-to-add"> --intent-to-add </dt> <dd> <p>When applying the patch only to the working tree, mark new files to be added to the index later (see <code>--intent-to-add</code> option in <a href="git-add">git-add[1]</a>). This option is ignored unless running in a Git repository and <code>--index</code> is not specified. Note that <code>--index</code> could be implied by other options such as <code>--cached</code> or <code>--3way</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt--3"> -3 </dt> <dt class="hdlist1" id="Documentation/git-apply.txt---3way"> --3way </dt> <dd> <p>Attempt 3-way merge if the patch records the identity of blobs it is supposed to apply to and we have those blobs available locally, possibly leaving the conflict markers in the files in the working tree for the user to resolve. This option implies the <code>--index</code> option unless the <code>--cached</code> option is used, and is incompatible with the <code>--reject</code> option. When used with the <code>--cached</code> option, any conflicts are left at higher stages in the cache.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---build-fake-ancestorltfilegt"> --build-fake-ancestor=<file> </dt> <dd> <p>Newer <code>git diff</code> output has embedded <code>index information</code> for each blob to help identify the original version that the patch applies to. When this flag is given, and if the original versions of the blobs are available locally, builds a temporary index containing those blobs.</p> <p>When a pure mode change is encountered (which has no index information), the information is read from the current index instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt--R"> -R </dt> <dt class="hdlist1" id="Documentation/git-apply.txt---reverse"> --reverse </dt> <dd> <p>Apply the patch in reverse.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---reject"> --reject </dt> <dd> <p>For atomicity, <code>git apply</code> by default fails the whole patch and does not touch the working tree when some of the hunks do not apply. This option makes it apply the parts of the patch that are applicable, and leave the rejected hunks in corresponding *.rej files.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt--z"> -z </dt> <dd> <p>When <code>--numstat</code> has been given, do not munge pathnames, but use a NUL-terminated machine-readable format.</p> <p>Without this option, pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt--pltngt"> -p<n> </dt> <dd> <p>Remove <n> leading path components (separated by slashes) from traditional diff paths. E.g., with <code>-p2</code>, a patch against <code>a/dir/file</code> will be applied directly to <code>file</code>. The default is 1.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt--Cltngt"> -C<n> </dt> <dd> <p>Ensure at least <n> lines of surrounding context match before and after each change. When fewer lines of surrounding context exist they all must match. By default no context is ever ignored.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---unidiff-zero"> --unidiff-zero </dt> <dd> <p>By default, <code>git apply</code> expects that the patch being applied is a unified diff with at least one line of context. This provides good safety measures, but breaks down when applying a diff generated with <code>--unified=0</code>. To bypass these checks use <code>--unidiff-zero</code>.</p> <p>Note, for the reasons stated above, the usage of context-free patches is discouraged.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---apply"> --apply </dt> <dd> <p>If you use any of the options marked "Turns off <code>apply</code>" above, <code>git apply</code> reads and outputs the requested information without actually applying the patch. Give this flag after those flags to also apply the patch.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---no-add"> --no-add </dt> <dd> <p>When applying a patch, ignore additions made by the patch. This can be used to extract the common part between two files by first running <code>diff</code> on them and applying the result with this option, which would apply the deletion part but not the addition part.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---allow-binary-replacement"> --allow-binary-replacement </dt> <dt class="hdlist1" id="Documentation/git-apply.txt---binary"> --binary </dt> <dd> <p>Historically we did not allow binary patch application without an explicit permission from the user, and this flag was the way to do so. Currently, we always allow binary patch application, so this is a no-op.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---excludeltpath-patterngt"> --exclude=<path-pattern> </dt> <dd> <p>Don’t apply changes to files matching the given path pattern. This can be useful when importing patchsets, where you want to exclude certain files or directories.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---includeltpath-patterngt"> --include=<path-pattern> </dt> <dd> <p>Apply changes to files matching the given path pattern. This can be useful when importing patchsets, where you want to include certain files or directories.</p> <p>When <code>--exclude</code> and <code>--include</code> patterns are used, they are examined in the order they appear on the command line, and the first match determines if a patch to each path is used. A patch to a path that does not match any include/exclude pattern is used by default if there is no include pattern on the command line, and ignored if there is any include pattern.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---ignore-space-change"> --ignore-space-change </dt> <dt class="hdlist1" id="Documentation/git-apply.txt---ignore-whitespace"> --ignore-whitespace </dt> <dd> <p>When applying a patch, ignore changes in whitespace in context lines if necessary. Context lines will preserve their whitespace, and they will not undergo whitespace fixing regardless of the value of the <code>--whitespace</code> option. New lines will still be fixed, though.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---whitespaceltactiongt"> --whitespace=<action> </dt> <dd> <p>When applying a patch, detect a new or modified line that has whitespace errors. What are considered whitespace errors is controlled by <code>core.whitespace</code> configuration. By default, trailing whitespaces (including lines that solely consist of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors.</p> <p>By default, the command outputs warning messages but applies the patch. When <code>git-apply</code> is used for statistics and not applying a patch, it defaults to <code>nowarn</code>.</p> <p>You can use different <code><action></code> values to control this behavior:</p> <div class="ulist"> <ul> <li> <p><code>nowarn</code> turns off the trailing whitespace warning.</p> </li> <li> <p><code>warn</code> outputs warnings for a few such errors, but applies the patch as-is (default).</p> </li> <li> <p><code>fix</code> outputs warnings for a few such errors, and applies the patch after fixing them (<code>strip</code> is a synonym — the tool used to consider only trailing whitespace characters as errors, and the fix involved <code>stripping</code> them, but modern Gits do more).</p> </li> <li> <p><code>error</code> outputs warnings for a few such errors, and refuses to apply the patch.</p> </li> <li> <p><code>error-all</code> is similar to <code>error</code> but shows all errors.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---inaccurate-eof"> --inaccurate-eof </dt> <dd> <p>Under certain circumstances, some versions of <code>diff</code> do not correctly detect a missing new-line at the end of the file. As a result, patches created by such <code>diff</code> programs do not record incomplete lines correctly. This option adds support for applying such patches by working around this bug.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-apply.txt---verbose"> --verbose </dt> <dd> <p>Report progress to stderr. By default, only a message about the current patch being applied will be printed. This option will cause additional information to be reported.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-apply.txt---quiet"> --quiet </dt> <dd> <p>Suppress stderr output. Messages about patch status and progress will not be printed.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---recount"> --recount </dt> <dd> <p>Do not trust the line counts in the hunk headers, but infer them by inspecting the patch (e.g. after editing the patch without adjusting the hunk headers appropriately).</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---directoryltrootgt"> --directory=<root> </dt> <dd> <p>Prepend <root> to all filenames. If a "-p" argument was also passed, it is applied before prepending the new root.</p> <p>For example, a patch that talks about updating <code>a/git-gui.sh</code> to <code>b/git-gui.sh</code> can be applied to the file in the working tree <code>modules/git-gui/git-gui.sh</code> by running <code>git apply --directory=modules/git-gui</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---unsafe-paths"> --unsafe-paths </dt> <dd> <p>By default, a patch that affects outside the working area (either a Git controlled working tree, or the current working directory when "git apply" is used as a replacement of GNU patch) is rejected as a mistake (or a mischief).</p> <p>When <code>git apply</code> is used as a "better GNU patch", the user can pass the <code>--unsafe-paths</code> option to override this safety check. This option has no effect when <code>--index</code> or <code>--cached</code> is in use.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt---allow-empty"> --allow-empty </dt> <dd> <p>Don’t return an error for patches containing no diff. This includes empty patches and patches with commit text only.</p> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-apply.txt-applyignoreWhitespace"> apply.ignoreWhitespace </dt> <dd> <p>When set to <code>change</code>, tells <code>git apply</code> to ignore changes in whitespace, in the same way as the <code>--ignore-space-change</code> option. When set to one of: no, none, never, false, it tells <code>git apply</code> to respect all whitespace differences. See <a href="git-apply">git-apply[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-apply.txt-applywhitespace"> apply.whitespace </dt> <dd> <p>Tells <code>git apply</code> how to handle whitespace, in the same way as the <code>--whitespace</code> option. See <a href="git-apply">git-apply[1]</a>.</p> </dd> </dl> </div> </div> <h2 id="_submodules">Submodules</h2> <div class="sectionbody"> <p>If the patch contains any changes to submodules then <code>git apply</code> treats these changes as follows.</p> <p>If <code>--index</code> is specified (explicitly or implicitly), then the submodule commits must match the index exactly for the patch to apply. If any of the submodules are checked-out, then these check-outs are completely ignored, i.e., they are not required to be up to date or clean and they are not updated.</p> <p>If <code>--index</code> is not specified, then the submodule commits in the patch are ignored and only the absence or presence of the corresponding subdirectory is checked and (if possible) updated.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-am">git-am[1]</a>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-apply" class="_attribution-link">https://git-scm.com/docs/git-apply</a> + </p> +</div> diff --git a/devdocs/git/git-archimport.html b/devdocs/git/git-archimport.html new file mode 100644 index 00000000..3a2d1230 --- /dev/null +++ b/devdocs/git/git-archimport.html @@ -0,0 +1,7 @@ +<h1>git-archimport</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-archimport - Import a GNU Arch repository into Git</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git archimport [-h] [-v] [-o] [-a] [-f] [-T] [-D <depth>] [-t <tempdir>] + <archive>/<branch>[:<git-branch>]…</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Imports a project from one or more GNU Arch repositories. It will follow branches and repositories within the namespaces defined by the <archive>/<branch> parameters supplied. If it cannot find the remote branch a merge comes from it will just import it as a regular commit. If it can find it, it will mark it as a merge whenever possible (see discussion below).</p> <p>The script expects you to provide the key roots where it can start the import from an <code>initial import</code> or <code>tag</code> type of Arch commit. It will follow and import new branches within the provided roots.</p> <p>It expects to be dealing with one project only. If it sees branches that have different roots, it will refuse to run. In that case, edit your <archive>/<branch> parameters to define clearly the scope of the import.</p> <p><code>git archimport</code> uses <code>tla</code> extensively in the background to access the Arch repository. Make sure you have a recent version of <code>tla</code> available in the path. <code>tla</code> must know about the repositories you pass to <code>git archimport</code>.</p> <p>For the initial import, <code>git archimport</code> expects to find itself in an empty directory. To follow the development of a project that uses Arch, rerun <code>git archimport</code> with the same parameters as the initial import to perform incremental imports.</p> <p>While <code>git archimport</code> will try to create sensible branch names for the archives that it imports, it is also possible to specify Git branch names manually. To do so, write a Git branch name after each <archive>/<branch> parameter, separated by a colon. This way, you can shorten the Arch branch names and convert Arch jargon to Git jargon, for example mapping a "PROJECT--devo--VERSION" branch to "master".</p> <p>Associating multiple Arch branches to one Git branch is possible; the result will make the most sense only if no commits are made to the first branch, after the second branch is created. Still, this is useful to convert Arch repositories that had been rotated periodically.</p> </div> <h2 id="_merges">Merges</h2> <div class="sectionbody"> <p>Patch merge data from Arch is used to mark merges in Git as well. Git does not care much about tracking patches, and only considers a merge when a branch incorporates all the commits since the point they forked. The end result is that Git will have a good idea of how far branches have diverged. So the import process does lose some patch-trading metadata.</p> <p>Fortunately, when you try and merge branches imported from Arch, Git will find a good merge base, and it has a good chance of identifying patches that have been traded out-of-sequence between the branches.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-archimport.txt--h"> -h </dt> <dd> <p>Display usage.</p> </dd> <dt class="hdlist1" id="Documentation/git-archimport.txt--v"> -v </dt> <dd> <p>Verbose output.</p> </dd> <dt class="hdlist1" id="Documentation/git-archimport.txt--T"> -T </dt> <dd> <p>Many tags. Will create a tag for every commit, reflecting the commit name in the Arch repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-archimport.txt--f"> -f </dt> <dd> <p>Use the fast patchset import strategy. This can be significantly faster for large trees, but cannot handle directory renames or permissions changes. The default strategy is slow and safe.</p> </dd> <dt class="hdlist1" id="Documentation/git-archimport.txt--o"> -o </dt> <dd> <p>Use this for compatibility with old-style branch names used by earlier versions of <code>git archimport</code>. Old-style branch names were category--branch, whereas new-style branch names are archive,category--branch--version. In both cases, names given on the command-line will override the automatically-generated ones.</p> </dd> <dt class="hdlist1" id="Documentation/git-archimport.txt--Dltdepthgt"> -D <depth> </dt> <dd> <p>Follow merge ancestry and attempt to import trees that have been merged from. Specify a depth greater than 1 if patch logs have been pruned.</p> </dd> <dt class="hdlist1" id="Documentation/git-archimport.txt--a"> -a </dt> <dd> <p>Attempt to auto-register archives at <code>http://mirrors.sourcecontrol.net</code> This is particularly useful with the -D option.</p> </dd> <dt class="hdlist1" id="Documentation/git-archimport.txt--tlttmpdirgt"> -t <tmpdir> </dt> <dd> <p>Override the default tempdir.</p> </dd> <dt class="hdlist1" id="Documentation/git-archimport.txt-ltarchivegtltbranchgt"> <archive>/<branch> </dt> <dd> <p><archive>/<branch> identifier in a format that <code>tla log</code> understands.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-archimport" class="_attribution-link">https://git-scm.com/docs/git-archimport</a> + </p> +</div> diff --git a/devdocs/git/git-archive.html b/devdocs/git/git-archive.html new file mode 100644 index 00000000..deb581bf --- /dev/null +++ b/devdocs/git/git-archive.html @@ -0,0 +1,11 @@ +<h1>git-archive</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-archive - Create an archive of files from a named tree</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git archive [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>] + [-o <file> | --output=<file>] [--worktree-attributes] + [--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish> + [<path>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Creates an archive of the specified format containing the tree structure for the named tree, and writes it out to the standard output. If <prefix> is specified it is prepended to the filenames in the archive.</p> <p><code>git archive</code> behaves differently when given a tree ID as opposed to a commit ID or tag ID. When a tree ID is provided, the current time is used as the modification time of each file in the archive. On the other hand, when a commit ID or tag ID is provided, the commit time as recorded in the referenced commit object is used instead. Additionally the commit ID is stored in a global extended pax header if the tar format is used; it can be extracted using <code>git get-tar-commit-id</code>. In ZIP files it is stored as a file comment.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-archive.txt---formatltfmtgt"> --format=<fmt> </dt> <dd> <p>Format of the resulting archive. Possible values are <code>tar</code>, <code>zip</code>, <code>tar.gz</code>, <code>tgz</code>, and any format defined using the configuration option <code>tar.<format>.command</code>. If <code>--format</code> is not given, and the output file is specified, the format is inferred from the filename if possible (e.g. writing to <code>foo.zip</code> makes the output to be in the <code>zip</code> format). Otherwise the output format is <code>tar</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt--l"> -l </dt> <dt class="hdlist1" id="Documentation/git-archive.txt---list"> --list </dt> <dd> <p>Show all available formats.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-archive.txt---verbose"> --verbose </dt> <dd> <p>Report progress to stderr.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt---prefixltprefixgt"> --prefix=<prefix>/ </dt> <dd> <p>Prepend <prefix>/ to paths in the archive. Can be repeated; its rightmost value is used for all tracked files. See below which value gets used by <code>--add-file</code> and <code>--add-virtual-file</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt--oltfilegt"> -o <file> </dt> <dt class="hdlist1" id="Documentation/git-archive.txt---outputltfilegt"> --output=<file> </dt> <dd> <p>Write the archive to <file> instead of stdout.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt---add-fileltfilegt"> --add-file=<file> </dt> <dd> <p>Add a non-tracked file to the archive. Can be repeated to add multiple files. The path of the file in the archive is built by concatenating the value of the last <code>--prefix</code> option (if any) before this <code>--add-file</code> and the basename of <file>.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt---add-virtual-fileltpathgtltcontentgt"> --add-virtual-file=<path>:<content> </dt> <dd> <p>Add the specified contents to the archive. Can be repeated to add multiple files. The path of the file in the archive is built by concatenating the value of the last <code>--prefix</code> option (if any) before this <code>--add-virtual-file</code> and <code><path></code>.</p> <p>The <code><path></code> argument can start and end with a literal double-quote character; the contained file name is interpreted as a C-style string, i.e. the backslash is interpreted as escape character. The path must be quoted if it contains a colon, to avoid the colon from being misinterpreted as the separator between the path and the contents, or if the path begins or ends with a double-quote character.</p> <p>The file mode is limited to a regular file, and the option may be subject to platform-dependent command-line limits. For non-trivial cases, write an untracked file and use <code>--add-file</code> instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt---worktree-attributes"> --worktree-attributes </dt> <dd> <p>Look for attributes in .gitattributes files in the working tree as well (see <a href="#ATTRIBUTES">ATTRIBUTES</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt---mtimelttimegt"> --mtime=<time> </dt> <dd> <p>Set modification time of archive entries. Without this option the committer time is used if <code><tree-ish></code> is a commit or tag, and the current time if it is a tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt-ltextragt"> <extra> </dt> <dd> <p>This can be any options that the archiver backend understands. See next section.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt---remoteltrepogt"> --remote=<repo> </dt> <dd> <p>Instead of making a tar archive from the local repository, retrieve a tar archive from a remote repository. Note that the remote repository may place restrictions on which sha1 expressions may be allowed in <code><tree-ish></code>. See <a href="git-upload-archive">git-upload-archive[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt---execltgit-upload-archivegt"> --exec=<git-upload-archive> </dt> <dd> <p>Used with --remote to specify the path to the <code>git-upload-archive</code> on the remote side.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt-lttree-ishgt"> <tree-ish> </dt> <dd> <p>The tree or commit to produce an archive for.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt-ltpathgt"> <path> </dt> <dd> <p>Without an optional path parameter, all files and subdirectories of the current working directory are included in the archive. If one or more paths are specified, only these are included.</p> </dd> </dl> </div> </div> <h2 id="_backend_extra_options">Backend extra options</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_zip"> +zip</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-archive.txt--ltdigitgt"> -<digit> </dt> <dd> <p>Specify compression level. Larger values allow the command to spend more time to compress to smaller size. Supported values are from <code>-0</code> (store-only) to <code>-9</code> (best ratio). Default is <code>-6</code> if not given.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_tar"> +tar</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-archive.txt--ltnumbergt"> -<number> </dt> <dd> <p>Specify compression level. The value will be passed to the compression command configured in <code>tar.<format>.command</code>. See manual page of the configured command for the list of supported levels and the default level if this option isn’t specified.</p> </dd> </dl> </div> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-archive.txt-tarumask"> tar.umask </dt> <dd> <p>This variable can be used to restrict the permission bits of tar archive entries. The default is 0002, which turns off the world write bit. The special value "user" indicates that the archiving user’s umask will be used instead. See umask(2) for details. If <code>--remote</code> is used then only the configuration of the remote repository takes effect.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt-tarltformatgtcommand"> tar.<format>.command </dt> <dd> <p>This variable specifies a shell command through which the tar output generated by <code>git archive</code> should be piped. The command is executed using the shell with the generated tar file on its standard input, and should produce the final output on its standard output. Any compression-level options will be passed to the command (e.g., <code>-9</code>).</p> <p>The <code>tar.gz</code> and <code>tgz</code> formats are defined automatically and use the magic command <code>git archive gzip</code> by default, which invokes an internal implementation of gzip.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt-tarltformatgtremote"> tar.<format>.remote </dt> <dd> <p>If true, enable the format for use by remote clients via <a href="git-upload-archive">git-upload-archive[1]</a>. Defaults to false for user-defined formats, but true for the <code>tar.gz</code> and <code>tgz</code> formats.</p> </dd> </dl> </div> </div> <h2 id="ATTRIBUTES">Attributes</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-archive.txt-export-ignore"> export-ignore </dt> <dd> <p>Files and directories with the attribute export-ignore won’t be added to archive files. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt-export-subst"> export-subst </dt> <dd> <p>If the attribute export-subst is set for a file then Git will expand several placeholders when adding this file to an archive. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> </dl> </div> <p>Note that attributes are by default taken from the <code>.gitattributes</code> files in the tree that is being archived. If you want to tweak the way the output is generated after the fact (e.g. you committed without adding an appropriate export-ignore in its <code>.gitattributes</code>), adjust the checked out <code>.gitattributes</code> file as necessary and use <code>--worktree-attributes</code> option. Alternatively you can keep necessary attributes that should apply while archiving any tree in your <code>$GIT_DIR/info/attributes</code> file.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-archive.txt-codegitarchive--formattar--prefixjunkHEADcdvartmpampamptarxf-code"> <code>git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)</code> </dt> <dd> <p>Create a tar archive that contains the contents of the latest commit on the current branch, and extract it in the <code>/var/tmp/junk</code> directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt-codegitarchive--formattar--prefixgit-140v140gzipgtgit-140targzcode"> <code>git archive --format=tar --prefix=git-1.4.0/ v1.4.0 | gzip >git-1.4.0.tar.gz</code> </dt> <dd> <p>Create a compressed tarball for v1.4.0 release.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt-codegitarchive--formattargz--prefixgit-140v140gtgit-140targzcode"> <code>git archive --format=tar.gz --prefix=git-1.4.0/ v1.4.0 >git-1.4.0.tar.gz</code> </dt> <dd> <p>Same as above, but using the builtin tar.gz handling.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt-codegitarchive--prefixgit-140-ogit-140targzv140code"> <code>git archive --prefix=git-1.4.0/ -o git-1.4.0.tar.gz v1.4.0</code> </dt> <dd> <p>Same as above, but the format is inferred from the output file.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt-codegitarchive--formattar--prefixgit-140v140treegzipgtgit-140targzcode"> <code>git archive --format=tar --prefix=git-1.4.0/ v1.4.0^{tree} | gzip >git-1.4.0.tar.gz</code> </dt> <dd> <p>Create a compressed tarball for v1.4.0 release, but without a global extended pax header.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt-codegitarchive--formatzip--prefixgit-docsHEADDocumentationgtgit-140-docszipcode"> <code>git archive --format=zip --prefix=git-docs/ HEAD:Documentation/ > git-1.4.0-docs.zip</code> </dt> <dd> <p>Put everything in the current head’s Documentation/ directory into <code>git-1.4.0-docs.zip</code>, with the prefix <code>git-docs/</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt-codegitarchive-olatestzipHEADcode"> <code>git archive -o latest.zip HEAD</code> </dt> <dd> <p>Create a Zip archive that contains the contents of the latest commit on the current branch. Note that the output format is inferred by the extension of the output file.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt-codegitarchive-olatesttar--prefixbuild--add-fileconfigure--prefixHEADcode"> <code>git archive -o latest.tar --prefix=build/ --add-file=configure --prefix= HEAD</code> </dt> <dd> <p>Creates a tar archive that contains the contents of the latest commit on the current branch with no prefix and the untracked file <code>configure</code> with the prefix <code>build/</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-archive.txt-codegitconfigtartarxzcommandxz-ccode"> <code>git config tar.tar.xz.command "xz -c"</code> </dt> <dd> <p>Configure a "tar.xz" format for making LZMA-compressed tarfiles. You can use it specifying <code>--format=tar.xz</code>, or by creating an output file like <code>-o foo.tar.xz</code>.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gitattributes">gitattributes[5]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-archive" class="_attribution-link">https://git-scm.com/docs/git-archive</a> + </p> +</div> diff --git a/devdocs/git/git-bisect-lk2009.html b/devdocs/git/git-bisect-lk2009.html new file mode 100644 index 00000000..f6bd3209 --- /dev/null +++ b/devdocs/git/git-bisect-lk2009.html @@ -0,0 +1,185 @@ +<h1>git-bisect-lk2009</h1> <h2 id="_abstract">Abstract</h2> <div class="sectionbody"> <p>"git bisect" enables software users and developers to easily find the commit that introduced a regression. We show why it is important to have good tools to fight regressions. We describe how "git bisect" works from the outside and the algorithms it uses inside. Then we explain how to take advantage of "git bisect" to improve current practices. And we discuss how "git bisect" could improve in the future.</p> </div> <h2 id="_introduction_to_git_bisect">Introduction to "git bisect"</h2> <div class="sectionbody"> <p>Git is a Distributed Version Control system (DVCS) created by Linus Torvalds and maintained by Junio Hamano.</p> <p>In Git like in many other Version Control Systems (VCS), the different states of the data that is managed by the system are called commits. And, as VCS are mostly used to manage software source code, sometimes "interesting" changes of behavior in the software are introduced in some commits.</p> <p>In fact people are specially interested in commits that introduce a "bad" behavior, called a bug or a regression. They are interested in these commits because a commit (hopefully) contains a very small set of source code changes. And it’s much easier to understand and properly fix a problem when you only need to check a very small set of changes, than when you don’t know where look in the first place.</p> <p>So to help people find commits that introduce a "bad" behavior, the "git bisect" set of commands was invented. And it follows of course that in "git bisect" parlance, commits where the "interesting behavior" is present are called "bad" commits, while other commits are called "good" commits. And a commit that introduce the behavior we are interested in is called a "first bad commit". Note that there could be more than one "first bad commit" in the commit space we are searching.</p> <p>So "git bisect" is designed to help find a "first bad commit". And to be as efficient as possible, it tries to perform a binary search.</p> </div> <h2 id="_fighting_regressions_overview">Fighting regressions overview</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_regressions_a_big_problem"> +Regressions: a big problem</h3> <p>Regressions are a big problem in the software industry. But it’s difficult to put some real numbers behind that claim.</p> <p>There are some numbers about bugs in general, like a NIST study in 2002 <a href="#1">[1]</a> that said:</p> <div class="quoteblock"> <blockquote> <p>Software bugs, or errors, are so prevalent and so detrimental that they cost the U.S. economy an estimated $59.5 billion annually, or about 0.6 percent of the gross domestic product, according to a newly released study commissioned by the Department of Commerce’s National Institute of Standards and Technology (NIST). At the national level, over half of the costs are borne by software users and the remainder by software developers/vendors. The study also found that, although all errors cannot be removed, more than a third of these costs, or an estimated $22.2 billion, could be eliminated by an improved testing infrastructure that enables earlier and more effective identification and removal of software defects. These are the savings associated with finding an increased percentage (but not 100 percent) of errors closer to the development stages in which they are introduced. Currently, over half of all errors are not found until "downstream" in the development process or during post-sale software use.</p> </blockquote> </div> <p>And then:</p> <div class="quoteblock"> <blockquote> <p>Software developers already spend approximately 80 percent of development costs on identifying and correcting defects, and yet few products of any type other than software are shipped with such high levels of errors.</p> </blockquote> </div> <p>Eventually the conclusion started with:</p> <div class="quoteblock"> <blockquote> <p>The path to higher software quality is significantly improved software testing.</p> </blockquote> </div> <p>There are other estimates saying that 80% of the cost related to software is about maintenance <a href="#2">[2]</a>.</p> <p>Though, according to Wikipedia <a href="#3">[3]</a>:</p> <div class="quoteblock"> <blockquote> <p>A common perception of maintenance is that it is merely fixing bugs. However, studies and surveys over the years have indicated that the majority, over 80%, of the maintenance effort is used for non-corrective actions (Pigosky 1997). This perception is perpetuated by users submitting problem reports that in reality are functionality enhancements to the system.</p> </blockquote> </div> <p>But we can guess that improving on existing software is very costly because you have to watch out for regressions. At least this would make the above studies consistent among themselves.</p> <p>Of course some kind of software is developed, then used during some time without being improved on much, and then finally thrown away. In this case, of course, regressions may not be a big problem. But on the other hand, there is a lot of big software that is continually developed and maintained during years or even tens of years by a lot of people. And as there are often many people who depend (sometimes critically) on such software, regressions are a really big problem.</p> <p>One such software is the Linux kernel. And if we look at the Linux kernel, we can see that a lot of time and effort is spent to fight regressions. The release cycle start with a 2 weeks long merge window. Then the first release candidate (rc) version is tagged. And after that about 7 or 8 more rc versions will appear with around one week between each of them, before the final release.</p> <p>The time between the first rc release and the final release is supposed to be used to test rc versions and fight bugs and especially regressions. And this time is more than 80% of the release cycle time. But this is not the end of the fight yet, as of course it continues after the release.</p> <p>And then this is what Ingo Molnar (a well known Linux kernel developer) says about his use of git bisect:</p> <div class="quoteblock"> <blockquote> <p>I most actively use it during the merge window (when a lot of trees get merged upstream and when the influx of bugs is the highest) - and yes, there have been cases that i used it multiple times a day. My average is roughly once a day.</p> </blockquote> </div> <p>So regressions are fought all the time by developers, and indeed it is well known that bugs should be fixed as soon as possible, so as soon as they are found. That’s why it is interesting to have good tools for this purpose.</p> </div> <div class="sect2"> <h3 id="_other_tools_to_fight_regressions"> +Other tools to fight regressions</h3> <p>So what are the tools used to fight regressions? They are nearly the same as those used to fight regular bugs. The only specific tools are test suites and tools similar as "git bisect".</p> <p>Test suites are very nice. But when they are used alone, they are supposed to be used so that all the tests are checked after each commit. This means that they are not very efficient, because many tests are run for no interesting result, and they suffer from combinatorial explosion.</p> <p>In fact the problem is that big software often has many different configuration options and that each test case should pass for each configuration after each commit. So if you have for each release: N configurations, M commits and T test cases, you should perform:</p> <div class="listingblock"> <div class="content"> <pre>N * M * T tests</pre> </div> </div> <p>where N, M and T are all growing with the size your software.</p> <p>So very soon it will not be possible to completely test everything.</p> <p>And if some bugs slip through your test suite, then you can add a test to your test suite. But if you want to use your new improved test suite to find where the bug slipped in, then you will either have to emulate a bisection process or you will perhaps bluntly test each commit backward starting from the "bad" commit you have which may be very wasteful.</p> </div> </div> <h2 id="_git_bisect_overview">"git bisect" overview</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_starting_a_bisection"> +Starting a bisection</h3> <p>The first "git bisect" subcommand to use is "git bisect start" to start the search. Then bounds must be set to limit the commit space. This is done usually by giving one "bad" and at least one "good" commit. They can be passed in the initial call to "git bisect start" like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start [BAD [GOOD...]]</pre> </div> </div> <p>or they can be set using:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect bad [COMMIT]</pre> </div> </div> <p>and:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect good [COMMIT...]</pre> </div> </div> <p>where BAD, GOOD and COMMIT are all names that can be resolved to a commit.</p> <p>Then "git bisect" will checkout a commit of its choosing and ask the user to test it, like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start v2.6.27 v2.6.25 +Bisecting: 10928 revisions left to test after this (roughly 14 steps) +[2ec65f8b89ea003c27ff7723525a2ee335a2b393] x86: clean up using max_low_pfn on 32-bit</pre> </div> </div> <p>Note that the example that we will use is really a toy example, we will be looking for the first commit that has a version like "2.6.26-something", that is the commit that has a "SUBLEVEL = 26" line in the top level Makefile. This is a toy example because there are better ways to find this commit with Git than using "git bisect" (for example "git blame" or "git log -S<string>").</p> </div> <div class="sect2"> <h3 id="_driving_a_bisection_manually"> +Driving a bisection manually</h3> <p>At this point there are basically 2 ways to drive the search. It can be driven manually by the user or it can be driven automatically by a script or a command.</p> <p>If the user is driving it, then at each step of the search, the user will have to test the current commit and say if it is "good" or "bad" using the "git bisect good" or "git bisect bad" commands respectively that have been described above. For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect bad +Bisecting: 5480 revisions left to test after this (roughly 13 steps) +[66c0b394f08fd89236515c1c84485ea712a157be] KVM: kill file->f_count abuse in kvm</pre> </div> </div> <p>And after a few more steps like that, "git bisect" will eventually find a first bad commit:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect bad +2ddcca36c8bcfa251724fe342c8327451988be0d is the first bad commit +commit 2ddcca36c8bcfa251724fe342c8327451988be0d +Author: Linus Torvalds <torvalds@linux-foundation.org> +Date: Sat May 3 11:59:44 2008 -0700 + + Linux 2.6.26-rc1 + +:100644 100644 5cf82581... 4492984e... M Makefile</pre> </div> </div> <p>At this point we can see what the commit does, check it out (if it’s not already checked out) or tinker with it, for example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show HEAD +commit 2ddcca36c8bcfa251724fe342c8327451988be0d +Author: Linus Torvalds <torvalds@linux-foundation.org> +Date: Sat May 3 11:59:44 2008 -0700 + + Linux 2.6.26-rc1 + +diff --git a/Makefile b/Makefile +index 5cf8258..4492984 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,7 @@ + VERSION = 2 + PATCHLEVEL = 6 +-SUBLEVEL = 25 +-EXTRAVERSION = ++SUBLEVEL = 26 ++EXTRAVERSION = -rc1 + NAME = Funky Weasel is Jiggy wit it + + # *DOCUMENTATION*</pre> </div> </div> <p>And when we are finished we can use "git bisect reset" to go back to the branch we were in before we started bisecting:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect reset +Checking out files: 100% (21549/21549), done. +Previous HEAD position was 2ddcca3... Linux 2.6.26-rc1 +Switched to branch 'master'</pre> </div> </div> </div> <div class="sect2"> <h3 id="_driving_a_bisection_automatically"> +Driving a bisection automatically</h3> <p>The other way to drive the bisection process is to tell "git bisect" to launch a script or command at each bisection step to know if the current commit is "good" or "bad". To do that, we use the "git bisect run" command. For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start v2.6.27 v2.6.25 +Bisecting: 10928 revisions left to test after this (roughly 14 steps) +[2ec65f8b89ea003c27ff7723525a2ee335a2b393] x86: clean up using max_low_pfn on 32-bit +$ +$ git bisect run grep '^SUBLEVEL = 25' Makefile +running grep ^SUBLEVEL = 25 Makefile +Bisecting: 5480 revisions left to test after this (roughly 13 steps) +[66c0b394f08fd89236515c1c84485ea712a157be] KVM: kill file->f_count abuse in kvm +running grep ^SUBLEVEL = 25 Makefile +SUBLEVEL = 25 +Bisecting: 2740 revisions left to test after this (roughly 12 steps) +[671294719628f1671faefd4882764886f8ad08cb] V4L/DVB(7879): Adding cx18 Support for mxl5005s +... +... +running grep ^SUBLEVEL = 25 Makefile +Bisecting: 0 revisions left to test after this (roughly 0 steps) +[2ddcca36c8bcfa251724fe342c8327451988be0d] Linux 2.6.26-rc1 +running grep ^SUBLEVEL = 25 Makefile +2ddcca36c8bcfa251724fe342c8327451988be0d is the first bad commit +commit 2ddcca36c8bcfa251724fe342c8327451988be0d +Author: Linus Torvalds <torvalds@linux-foundation.org> +Date: Sat May 3 11:59:44 2008 -0700 + + Linux 2.6.26-rc1 + +:100644 100644 5cf82581... 4492984e... M Makefile +bisect run success</pre> </div> </div> <p>In this example, we passed "grep <code>^SUBLEVEL = 25</code> Makefile" as parameter to "git bisect run". This means that at each step, the grep command we passed will be launched. And if it exits with code 0 (that means success) then git bisect will mark the current state as "good". If it exits with code 1 (or any code between 1 and 127 included, except the special code 125), then the current state will be marked as "bad".</p> <p>Exit code between 128 and 255 are special to "git bisect run". They make it stop immediately the bisection process. This is useful for example if the command passed takes too long to complete, because you can kill it with a signal and it will stop the bisection process.</p> <p>It can also be useful in scripts passed to "git bisect run" to "exit 255" if some very abnormal situation is detected.</p> </div> <div class="sect2"> <h3 id="_avoiding_untestable_commits"> +Avoiding untestable commits</h3> <p>Sometimes it happens that the current state cannot be tested, for example if it does not compile because there was a bug preventing it at that time. This is what the special exit code 125 is for. It tells "git bisect run" that the current commit should be marked as untestable and that another one should be chosen and checked out.</p> <p>If the bisection process is driven manually, you can use "git bisect skip" to do the same thing. (In fact the special exit code 125 makes "git bisect run" use "git bisect skip" in the background.)</p> <p>Or if you want more control, you can inspect the current state using for example "git bisect visualize". It will launch gitk (or "git log" if the <code>DISPLAY</code> environment variable is not set) to help you find a better bisection point.</p> <p>Either way, if you have a string of untestable commits, it might happen that the regression you are looking for has been introduced by one of these untestable commits. In this case it’s not possible to tell for sure which commit introduced the regression.</p> <p>So if you used "git bisect skip" (or the run script exited with special code 125) you could get a result like this:</p> <div class="listingblock"> <div class="content"> <pre>There are only 'skip'ped commits left to test. +The first bad commit could be any of: +15722f2fa328eaba97022898a305ffc8172db6b1 +78e86cf3e850bd755bb71831f42e200626fbd1e0 +e15b73ad3db9b48d7d1ade32f8cd23a751fe0ace +070eab2303024706f2924822bfec8b9847e4ac1b +We cannot bisect more!</pre> </div> </div> </div> <div class="sect2"> <h3 id="_saving_a_log_and_replaying_it"> +Saving a log and replaying it</h3> <p>If you want to show other people your bisection process, you can get a log using for example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect log > bisect_log.txt</pre> </div> </div> <p>And it is possible to replay it using:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect replay bisect_log.txt</pre> </div> </div> </div> </div> <h2 id="_git_bisect_details">"git bisect" details</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_bisection_algorithm"> +Bisection algorithm</h3> <p>As the Git commits form a directed acyclic graph (DAG), finding the best bisection commit to test at each step is not so simple. Anyway Linus found and implemented a "truly stupid" algorithm, later improved by Junio Hamano, that works quite well.</p> <p>So the algorithm used by "git bisect" to find the best bisection commit when there are no skipped commits is the following:</p> <p>1) keep only the commits that:</p> <p>a) are ancestor of the "bad" commit (including the "bad" commit itself), b) are not ancestor of a "good" commit (excluding the "good" commits).</p> <p>This means that we get rid of the uninteresting commits in the DAG.</p> <p>For example if we start with a graph like this:</p> <div class="listingblock"> <div class="content"> <pre>G-Y-G-W-W-W-X-X-X-X + \ / + W-W-B + / +Y---G-W---W + \ / \ +Y-Y X-X-X-X + +-> time goes this way -></pre> </div> </div> <p>where B is the "bad" commit, "G" are "good" commits and W, X, and Y are other commits, we will get the following graph after this first step:</p> <div class="listingblock"> <div class="content"> <pre>W-W-W + \ + W-W-B + / +W---W</pre> </div> </div> <p>So only the W and B commits will be kept. Because commits X and Y will have been removed by rules a) and b) respectively, and because commits G are removed by rule b) too.</p> <p>Note for Git users, that it is equivalent as keeping only the commit given by:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git rev-list BAD --not GOOD1 GOOD2...</pre> </div> </div> <p>Also note that we don’t require the commits that are kept to be descendants of a "good" commit. So in the following example, commits W and Z will be kept:</p> <div class="listingblock"> <div class="content"> <pre>G-W-W-W-B + / +Z-Z</pre> </div> </div> <p>2) starting from the "good" ends of the graph, associate to each commit the number of ancestors it has plus one</p> <p>For example with the following graph where H is the "bad" commit and A and D are some parents of some "good" commits:</p> <div class="listingblock"> <div class="content"> <pre>A-B-C + \ + F-G-H + / +D---E</pre> </div> </div> <p>this will give:</p> <div class="listingblock"> <div class="content"> <pre>1 2 3 +A-B-C + \6 7 8 + F-G-H +1 2/ +D---E</pre> </div> </div> <p>3) associate to each commit: min(X, N - X)</p> <p>where X is the value associated to the commit in step 2) and N is the total number of commits in the graph.</p> <p>In the above example we have N = 8, so this will give:</p> <div class="listingblock"> <div class="content"> <pre>1 2 3 +A-B-C + \2 1 0 + F-G-H +1 2/ +D---E</pre> </div> </div> <p>4) the best bisection point is the commit with the highest associated number</p> <p>So in the above example the best bisection point is commit C.</p> <p>5) note that some shortcuts are implemented to speed up the algorithm</p> <p>As we know N from the beginning, we know that min(X, N - X) can’t be greater than N/2. So during steps 2) and 3), if we would associate N/2 to a commit, then we know this is the best bisection point. So in this case we can just stop processing any other commit and return the current commit.</p> </div> <div class="sect2"> <h3 id="_bisection_algorithm_debugging"> +Bisection algorithm debugging</h3> <p>For any commit graph, you can see the number associated with each commit using "git rev-list --bisect-all".</p> <p>For example, for the above graph, a command like:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rev-list --bisect-all BAD --not GOOD1 GOOD2</pre> </div> </div> <p>would output something like:</p> <div class="listingblock"> <div class="content"> <pre>e15b73ad3db9b48d7d1ade32f8cd23a751fe0ace (dist=3) +15722f2fa328eaba97022898a305ffc8172db6b1 (dist=2) +78e86cf3e850bd755bb71831f42e200626fbd1e0 (dist=2) +a1939d9a142de972094af4dde9a544e577ddef0e (dist=2) +070eab2303024706f2924822bfec8b9847e4ac1b (dist=1) +a3864d4f32a3bf5ed177ddef598490a08760b70d (dist=1) +a41baa717dd74f1180abf55e9341bc7a0bb9d556 (dist=1) +9e622a6dad403b71c40979743bb9d5be17b16bd6 (dist=0)</pre> </div> </div> </div> <div class="sect2"> <h3 id="_bisection_algorithm_discussed"> +Bisection algorithm discussed</h3> <p>First let’s define "best bisection point". We will say that a commit X is a best bisection point or a best bisection commit if knowing its state ("good" or "bad") gives as much information as possible whether the state of the commit happens to be "good" or "bad".</p> <p>This means that the best bisection commits are the commits where the following function is maximum:</p> <div class="listingblock"> <div class="content"> <pre>f(X) = min(information_if_good(X), information_if_bad(X))</pre> </div> </div> <p>where information_if_good(X) is the information we get if X is good and information_if_bad(X) is the information we get if X is bad.</p> <p>Now we will suppose that there is only one "first bad commit". This means that all its descendants are "bad" and all the other commits are "good". And we will suppose that all commits have an equal probability of being good or bad, or of being the first bad commit, so knowing the state of c commits gives always the same amount of information wherever these c commits are on the graph and whatever c is. (So we suppose that these commits being for example on a branch or near a good or a bad commit does not give more or less information).</p> <p>Let’s also suppose that we have a cleaned up graph like one after step 1) in the bisection algorithm above. This means that we can measure the information we get in terms of number of commit we can remove from the graph..</p> <p>And let’s take a commit X in the graph.</p> <p>If X is found to be "good", then we know that its ancestors are all "good", so we want to say that:</p> <div class="listingblock"> <div class="content"> <pre>information_if_good(X) = number_of_ancestors(X) (TRUE)</pre> </div> </div> <p>And this is true because at step 1) b) we remove the ancestors of the "good" commits.</p> <p>If X is found to be "bad", then we know that its descendants are all "bad", so we want to say that:</p> <div class="listingblock"> <div class="content"> <pre>information_if_bad(X) = number_of_descendants(X) (WRONG)</pre> </div> </div> <p>But this is wrong because at step 1) a) we keep only the ancestors of the bad commit. So we get more information when a commit is marked as "bad", because we also know that the ancestors of the previous "bad" commit that are not ancestors of the new "bad" commit are not the first bad commit. We don’t know if they are good or bad, but we know that they are not the first bad commit because they are not ancestor of the new "bad" commit.</p> <p>So when a commit is marked as "bad" we know we can remove all the commits in the graph except those that are ancestors of the new "bad" commit. This means that:</p> <div class="listingblock"> <div class="content"> <pre>information_if_bad(X) = N - number_of_ancestors(X) (TRUE)</pre> </div> </div> <p>where N is the number of commits in the (cleaned up) graph.</p> <p>So in the end this means that to find the best bisection commits we should maximize the function:</p> <div class="listingblock"> <div class="content"> <pre>f(X) = min(number_of_ancestors(X), N - number_of_ancestors(X))</pre> </div> </div> <p>And this is nice because at step 2) we compute number_of_ancestors(X) and so at step 3) we compute f(X).</p> <p>Let’s take the following graph as an example:</p> <div class="listingblock"> <div class="content"> <pre> G-H-I-J + / \ +A-B-C-D-E-F O + \ / + K-L-M-N</pre> </div> </div> <p>If we compute the following non optimal function on it:</p> <div class="listingblock"> <div class="content"> <pre>g(X) = min(number_of_ancestors(X), number_of_descendants(X))</pre> </div> </div> <p>we get:</p> <div class="listingblock"> <div class="content"> <pre> 4 3 2 1 + G-H-I-J +1 2 3 4 5 6/ \0 +A-B-C-D-E-F O + \ / + K-L-M-N + 4 3 2 1</pre> </div> </div> <p>but with the algorithm used by git bisect we get:</p> <div class="listingblock"> <div class="content"> <pre> 7 7 6 5 + G-H-I-J +1 2 3 4 5 6/ \0 +A-B-C-D-E-F O + \ / + K-L-M-N + 7 7 6 5</pre> </div> </div> <p>So we chose G, H, K or L as the best bisection point, which is better than F. Because if for example L is bad, then we will know not only that L, M and N are bad but also that G, H, I and J are not the first bad commit (since we suppose that there is only one first bad commit and it must be an ancestor of L).</p> <p>So the current algorithm seems to be the best possible given what we initially supposed.</p> </div> <div class="sect2"> <h3 id="_skip_algorithm"> +Skip algorithm</h3> <p>When some commits have been skipped (using "git bisect skip"), then the bisection algorithm is the same for step 1) to 3). But then we use roughly the following steps:</p> <p>6) sort the commit by decreasing associated value</p> <p>7) if the first commit has not been skipped, we can return it and stop here</p> <p>8) otherwise filter out all the skipped commits in the sorted list</p> <p>9) use a pseudo random number generator (PRNG) to generate a random number between 0 and 1</p> <p>10) multiply this random number with its square root to bias it toward 0</p> <p>11) multiply the result by the number of commits in the filtered list to get an index into this list</p> <p>12) return the commit at the computed index</p> </div> <div class="sect2"> <h3 id="_skip_algorithm_discussed"> +Skip algorithm discussed</h3> <p>After step 7) (in the skip algorithm), we could check if the second commit has been skipped and return it if it is not the case. And in fact that was the algorithm we used from when "git bisect skip" was developed in Git version 1.5.4 (released on February 1st 2008) until Git version 1.6.4 (released July 29th 2009).</p> <p>But Ingo Molnar and H. Peter Anvin (another well known linux kernel developer) both complained that sometimes the best bisection points all happened to be in an area where all the commits are untestable. And in this case the user was asked to test many untestable commits, which could be very inefficient.</p> <p>Indeed untestable commits are often untestable because a breakage was introduced at one time, and that breakage was fixed only after many other commits were introduced.</p> <p>This breakage is of course most of the time unrelated to the breakage we are trying to locate in the commit graph. But it prevents us to know if the interesting "bad behavior" is present or not.</p> <p>So it is a fact that commits near an untestable commit have a high probability of being untestable themselves. And the best bisection commits are often found together too (due to the bisection algorithm).</p> <p>This is why it is a bad idea to just chose the next best unskipped bisection commit when the first one has been skipped.</p> <p>We found that most commits on the graph may give quite a lot of information when they are tested. And the commits that will not on average give a lot of information are the one near the good and bad commits.</p> <p>So using a PRNG with a bias to favor commits away from the good and bad commits looked like a good choice.</p> <p>One obvious improvement to this algorithm would be to look for a commit that has an associated value near the one of the best bisection commit, and that is on another branch, before using the PRNG. Because if such a commit exists, then it is not very likely to be untestable too, so it will probably give more information than a nearly randomly chosen one.</p> </div> <div class="sect2"> <h3 id="_checking_merge_bases"> +Checking merge bases</h3> <p>There is another tweak in the bisection algorithm that has not been described in the "bisection algorithm" above.</p> <p>We supposed in the previous examples that the "good" commits were ancestors of the "bad" commit. But this is not a requirement of "git bisect".</p> <p>Of course the "bad" commit cannot be an ancestor of a "good" commit, because the ancestors of the good commits are supposed to be "good". And all the "good" commits must be related to the bad commit. They cannot be on a branch that has no link with the branch of the "bad" commit. But it is possible for a good commit to be related to a bad commit and yet not be neither one of its ancestor nor one of its descendants.</p> <p>For example, there can be a "main" branch, and a "dev" branch that was forked of the main branch at a commit named "D" like this:</p> <div class="listingblock"> <div class="content"> <pre>A-B-C-D-E-F-G <--main + \ + H-I-J <--dev</pre> </div> </div> <p>The commit "D" is called a "merge base" for branch "main" and "dev" because it’s the best common ancestor for these branches for a merge.</p> <p>Now let’s suppose that commit J is bad and commit G is good and that we apply the bisection algorithm like it has been previously described.</p> <p>As described in step 1) b) of the bisection algorithm, we remove all the ancestors of the good commits because they are supposed to be good too.</p> <p>So we would be left with only:</p> <div class="listingblock"> <div class="content"> <pre>H-I-J</pre> </div> </div> <p>But what happens if the first bad commit is "B" and if it has been fixed in the "main" branch by commit "F"?</p> <p>The result of such a bisection would be that we would find that H is the first bad commit, when in fact it’s B. So that would be wrong!</p> <p>And yes it can happen in practice that people working on one branch are not aware that people working on another branch fixed a bug! It could also happen that F fixed more than one bug or that it is a revert of some big development effort that was not ready to be released.</p> <p>In fact development teams often maintain both a development branch and a maintenance branch, and it would be quite easy for them if "git bisect" just worked when they want to bisect a regression on the development branch that is not on the maintenance branch. They should be able to start bisecting using:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start dev main</pre> </div> </div> <p>To enable that additional nice feature, when a bisection is started and when some good commits are not ancestors of the bad commit, we first compute the merge bases between the bad and the good commits and we chose these merge bases as the first commits that will be checked out and tested.</p> <p>If it happens that one merge base is bad, then the bisection process is stopped with a message like:</p> <div class="listingblock"> <div class="content"> <pre>The merge base BBBBBB is bad. +This means the bug has been fixed between BBBBBB and [GGGGGG,...].</pre> </div> </div> <p>where BBBBBB is the sha1 hash of the bad merge base and [GGGGGG,…] is a comma separated list of the sha1 of the good commits.</p> <p>If some of the merge bases are skipped, then the bisection process continues, but the following message is printed for each skipped merge base:</p> <div class="listingblock"> <div class="content"> <pre>Warning: the merge base between BBBBBB and [GGGGGG,...] must be skipped. +So we cannot be sure the first bad commit is between MMMMMM and BBBBBB. +We continue anyway.</pre> </div> </div> <p>where BBBBBB is the sha1 hash of the bad commit, MMMMMM is the sha1 hash of the merge base that is skipped and [GGGGGG,…] is a comma separated list of the sha1 of the good commits.</p> <p>So if there is no bad merge base, the bisection process continues as usual after this step.</p> </div> </div> <h2 id="_best_bisecting_practices">Best bisecting practices</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_using_test_suites_and_git_bisect_together"> +Using test suites and git bisect together</h3> <p>If you both have a test suite and use git bisect, then it becomes less important to check that all tests pass after each commit. Though of course it is probably a good idea to have some checks to avoid breaking too many things because it could make bisecting other bugs more difficult.</p> <p>You can focus your efforts to check at a few points (for example rc and beta releases) that all the T test cases pass for all the N configurations. And when some tests don’t pass you can use "git bisect" (or better "git bisect run"). So you should perform roughly:</p> <div class="listingblock"> <div class="content"> <pre>c * N * T + b * M * log2(M) tests</pre> </div> </div> <p>where c is the number of rounds of test (so a small constant) and b is the ratio of bug per commit (hopefully a small constant too).</p> <p>So of course it’s much better as it’s O(N * T) vs O(N * T * M) if you would test everything after each commit.</p> <p>This means that test suites are good to prevent some bugs from being committed and they are also quite good to tell you that you have some bugs. But they are not so good to tell you where some bugs have been introduced. To tell you that efficiently, git bisect is needed.</p> <p>The other nice thing with test suites, is that when you have one, you already know how to test for bad behavior. So you can use this knowledge to create a new test case for "git bisect" when it appears that there is a regression. So it will be easier to bisect the bug and fix it. And then you can add the test case you just created to your test suite.</p> <p>So if you know how to create test cases and how to bisect, you will be subject to a virtuous circle:</p> <p>more tests ⇒ easier to create tests ⇒ easier to bisect ⇒ more tests</p> <p>So test suites and "git bisect" are complementary tools that are very powerful and efficient when used together.</p> </div> <div class="sect2"> <h3 id="_bisecting_build_failures"> +Bisecting build failures</h3> <p>You can very easily automatically bisect broken builds using something like:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start BAD GOOD +$ git bisect run make</pre> </div> </div> </div> <div class="sect2"> <h3 id="_passing_sh_c_some_commands_to_git_bisect_run"> +Passing sh -c "some commands" to "git bisect run"</h3> <p>For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect run sh -c "make || exit 125; ./my_app | grep 'good output'"</pre> </div> </div> <p>On the other hand if you do this often, then it can be worth having scripts to avoid too much typing.</p> </div> <div class="sect2"> <h3 id="_finding_performance_regressions"> +Finding performance regressions</h3> <p>Here is an example script that comes slightly modified from a real world script used by Junio Hamano <a href="#4">[4]</a>.</p> <p>This script can be passed to "git bisect run" to find the commit that introduced a performance regression:</p> <div class="listingblock"> <div class="content"> <pre>#!/bin/sh + +# Build errors are not what I am interested in. +make my_app || exit 255 + +# We are checking if it stops in a reasonable amount of time, so +# let it run in the background... + +./my_app >log 2>&1 & + +# ... and grab its process ID. +pid=$! + +# ... and then wait for sufficiently long. +sleep $NORMAL_TIME + +# ... and then see if the process is still there. +if kill -0 $pid +then + # It is still running -- that is bad. + kill $pid; sleep 1; kill $pid; + exit 1 +else + # It has already finished (the $pid process was no more), + # and we are happy. + exit 0 +fi</pre> </div> </div> </div> <div class="sect2"> <h3 id="_following_general_best_practices"> +Following general best practices</h3> <p>It is obviously a good idea not to have commits with changes that knowingly break things, even if some other commits later fix the breakage.</p> <p>It is also a good idea when using any VCS to have only one small logical change in each commit.</p> <p>The smaller the changes in your commit, the most effective "git bisect" will be. And you will probably need "git bisect" less in the first place, as small changes are easier to review even if they are only reviewed by the committer.</p> <p>Another good idea is to have good commit messages. They can be very helpful to understand why some changes were made.</p> <p>These general best practices are very helpful if you bisect often.</p> </div> <div class="sect2"> <h3 id="_avoiding_bug_prone_merges"> +Avoiding bug prone merges</h3> <p>First merges by themselves can introduce some regressions even when the merge needs no source code conflict resolution. This is because a semantic change can happen in one branch while the other branch is not aware of it.</p> <p>For example one branch can change the semantic of a function while the other branch add more calls to the same function.</p> <p>This is made much worse if many files have to be fixed to resolve conflicts. That’s why such merges are called "evil merges". They can make regressions very difficult to track down. It can even be misleading to know the first bad commit if it happens to be such a merge, because people might think that the bug comes from bad conflict resolution when it comes from a semantic change in one branch.</p> <p>Anyway "git rebase" can be used to linearize history. This can be used either to avoid merging in the first place. Or it can be used to bisect on a linear history instead of the non linear one, as this should give more information in case of a semantic change in one branch.</p> <p>Merges can be also made simpler by using smaller branches or by using many topic branches instead of only long version related branches.</p> <p>And testing can be done more often in special integration branches like linux-next for the linux kernel.</p> </div> <div class="sect2"> <h3 id="_adapting_your_work_flow"> +Adapting your work-flow</h3> <p>A special work-flow to process regressions can give great results.</p> <p>Here is an example of a work-flow used by Andreas Ericsson:</p> <div class="ulist"> <ul> <li> <p>write, in the test suite, a test script that exposes the regression</p> </li> <li> <p>use "git bisect run" to find the commit that introduced it</p> </li> <li> <p>fix the bug that is often made obvious by the previous step</p> </li> <li> <p>commit both the fix and the test script (and if needed more tests)</p> </li> </ul> </div> <p>And here is what Andreas said about this work-flow <a href="#5">[5]</a>:</p> <div class="quoteblock"> <blockquote> <p>To give some hard figures, we used to have an average report-to-fix cycle of 142.6 hours (according to our somewhat weird bug-tracker which just measures wall-clock time). Since we moved to Git, we’ve lowered that to 16.2 hours. Primarily because we can stay on top of the bug fixing now, and because everyone’s jockeying to get to fix bugs (we’re quite proud of how lazy we are to let Git find the bugs for us). Each new release results in ~40% fewer bugs (almost certainly due to how we now feel about writing tests).</p> </blockquote> </div> <p>Clearly this work-flow uses the virtuous circle between test suites and "git bisect". In fact it makes it the standard procedure to deal with regression.</p> <p>In other messages Andreas says that they also use the "best practices" described above: small logical commits, topic branches, no evil merge,… These practices all improve the bisectability of the commit graph, by making it easier and more useful to bisect.</p> <p>So a good work-flow should be designed around the above points. That is making bisecting easier, more useful and standard.</p> </div> <div class="sect2"> <h3 id="_involving_qa_people_and_if_possible_end_users"> +Involving QA people and if possible end users</h3> <p>One nice about "git bisect" is that it is not only a developer tool. It can effectively be used by QA people or even end users (if they have access to the source code or if they can get access to all the builds).</p> <p>There was a discussion at one point on the linux kernel mailing list of whether it was ok to always ask end user to bisect, and very good points were made to support the point of view that it is ok.</p> <p>For example David Miller wrote <a href="#6">[6]</a>:</p> <div class="quoteblock"> <blockquote> <p>What people don’t get is that this is a situation where the "end node principle" applies. When you have limited resources (here: developers) you don’t push the bulk of the burden upon them. Instead you push things out to the resource you have a lot of, the end nodes (here: users), so that the situation actually scales.</p> </blockquote> </div> <p>This means that it is often "cheaper" if QA people or end users can do it.</p> <p>What is interesting too is that end users that are reporting bugs (or QA people that reproduced a bug) have access to the environment where the bug happens. So they can often more easily reproduce a regression. And if they can bisect, then more information will be extracted from the environment where the bug happens, which means that it will be easier to understand and then fix the bug.</p> <p>For open source projects it can be a good way to get more useful contributions from end users, and to introduce them to QA and development activities.</p> </div> <div class="sect2"> <h3 id="_using_complex_scripts"> +Using complex scripts</h3> <p>In some cases like for kernel development it can be worth developing complex scripts to be able to fully automate bisecting.</p> <p>Here is what Ingo Molnar says about that <a href="#7">[7]</a>:</p> <div class="quoteblock"> <blockquote> <p>i have a fully automated bootup-hang bisection script. It is based on "git-bisect run". I run the script, it builds and boots kernels fully automatically, and when the bootup fails (the script notices that via the serial log, which it continuously watches - or via a timeout, if the system does not come up within 10 minutes it’s a "bad" kernel), the script raises my attention via a beep and i power cycle the test box. (yeah, i should make use of a managed power outlet to 100% automate it)</p> </blockquote> </div> </div> <div class="sect2"> <h3 id="_combining_test_suites_git_bisect_and_other_systems_together"> +Combining test suites, git bisect and other systems together</h3> <p>We have seen that test suites and git bisect are very powerful when used together. It can be even more powerful if you can combine them with other systems.</p> <p>For example some test suites could be run automatically at night with some unusual (or even random) configurations. And if a regression is found by a test suite, then "git bisect" can be automatically launched, and its result can be emailed to the author of the first bad commit found by "git bisect", and perhaps other people too. And a new entry in the bug tracking system could be automatically created too.</p> </div> </div> <h2 id="_the_future_of_bisecting">The future of bisecting</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_git_replace"> +"git replace"</h3> <p>We saw earlier that "git bisect skip" is now using a PRNG to try to avoid areas in the commit graph where commits are untestable. The problem is that sometimes the first bad commit will be in an untestable area.</p> <p>To simplify the discussion we will suppose that the untestable area is a simple string of commits and that it was created by a breakage introduced by one commit (let’s call it BBC for bisect breaking commit) and later fixed by another one (let’s call it BFC for bisect fixing commit).</p> <p>For example:</p> <div class="listingblock"> <div class="content"> <pre>...-Y-BBC-X1-X2-X3-X4-X5-X6-BFC-Z-...</pre> </div> </div> <p>where we know that Y is good and BFC is bad, and where BBC and X1 to X6 are untestable.</p> <p>In this case if you are bisecting manually, what you can do is create a special branch that starts just before the BBC. The first commit in this branch should be the BBC with the BFC squashed into it. And the other commits in the branch should be the commits between BBC and BFC rebased on the first commit of the branch and then the commit after BFC also rebased on.</p> <p>For example:</p> <div class="listingblock"> <div class="content"> <pre> (BBC+BFC)-X1'-X2'-X3'-X4'-X5'-X6'-Z' + / +...-Y-BBC-X1-X2-X3-X4-X5-X6-BFC-Z-...</pre> </div> </div> <p>where commits quoted with ' have been rebased.</p> <p>You can easily create such a branch with Git using interactive rebase.</p> <p>For example using:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rebase -i Y Z</pre> </div> </div> <p>and then moving BFC after BBC and squashing it.</p> <p>After that you can start bisecting as usual in the new branch and you should eventually find the first bad commit.</p> <p>For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start Z' Y</pre> </div> </div> <p>If you are using "git bisect run", you can use the same manual fix up as above, and then start another "git bisect run" in the special branch. Or as the "git bisect" man page says, the script passed to "git bisect run" can apply a patch before it compiles and test the software <a href="#8">[8]</a>. The patch should turn a current untestable commits into a testable one. So the testing will result in "good" or "bad" and "git bisect" will be able to find the first bad commit. And the script should not forget to remove the patch once the testing is done before exiting from the script.</p> <p>(Note that instead of a patch you can use "git cherry-pick BFC" to apply the fix, and in this case you should use "git reset --hard HEAD^" to revert the cherry-pick after testing and before returning from the script.)</p> <p>But the above ways to work around untestable areas are a little bit clunky. Using special branches is nice because these branches can be shared by developers like usual branches, but the risk is that people will get many such branches. And it disrupts the normal "git bisect" work-flow. So, if you want to use "git bisect run" completely automatically, you have to add special code in your script to restart bisection in the special branches.</p> <p>Anyway one can notice in the above special branch example that the Z' and Z commits should point to the same source code state (the same "tree" in git parlance). That’s because Z' result from applying the same changes as Z just in a slightly different order.</p> <p>So if we could just "replace" Z by Z' when we bisect, then we would not need to add anything to a script. It would just work for anyone in the project sharing the special branches and the replacements.</p> <p>With the example above that would give:</p> <div class="listingblock"> <div class="content"> <pre> (BBC+BFC)-X1'-X2'-X3'-X4'-X5'-X6'-Z'-... + / +...-Y-BBC-X1-X2-X3-X4-X5-X6-BFC-Z</pre> </div> </div> <p>That’s why the "git replace" command was created. Technically it stores replacements "refs" in the "refs/replace/" hierarchy. These "refs" are like branches (that are stored in "refs/heads/") or tags (that are stored in "refs/tags"), and that means that they can automatically be shared like branches or tags among developers.</p> <p>"git replace" is a very powerful mechanism. It can be used to fix commits in already released history, for example to change the commit message or the author. And it can also be used instead of git "grafts" to link a repository with another old repository.</p> <p>In fact it’s this last feature that "sold" it to the Git community, so it is now in the "master" branch of Git’s Git repository and it should be released in Git 1.6.5 in October or November 2009.</p> <p>One problem with "git replace" is that currently it stores all the replacements refs in "refs/replace/", but it would be perhaps better if the replacement refs that are useful only for bisecting would be in "refs/replace/bisect/". This way the replacement refs could be used only for bisecting, while other refs directly in "refs/replace/" would be used nearly all the time.</p> </div> <div class="sect2"> <h3 id="_bisecting_sporadic_bugs"> +Bisecting sporadic bugs</h3> <p>Another possible improvement to "git bisect" would be to optionally add some redundancy to the tests performed so that it would be more reliable when tracking sporadic bugs.</p> <p>This has been requested by some kernel developers because some bugs called sporadic bugs do not appear in all the kernel builds because they are very dependent on the compiler output.</p> <p>The idea is that every 3 test for example, "git bisect" could ask the user to test a commit that has already been found to be "good" or "bad" (because one of its descendants or one of its ancestors has been found to be "good" or "bad" respectively). If it happens that a commit has been previously incorrectly classified then the bisection can be aborted early, hopefully before too many mistakes have been made. Then the user will have to look at what happened and then restart the bisection using a fixed bisect log.</p> <p>There is already a project called BBChop created by Ealdwulf Wuffinga on Github that does something like that using Bayesian Search Theory <a href="#9">[9]</a>:</p> <div class="quoteblock"> <blockquote> <p>BBChop is like <code>git bisect</code> (or equivalent), but works when your bug is intermittent. That is, it works in the presence of false negatives (when a version happens to work this time even though it contains the bug). It assumes that there are no false positives (in principle, the same approach would work, but adding it may be non-trivial).</p> </blockquote> </div> <p>But BBChop is independent of any VCS and it would be easier for Git users to have something integrated in Git.</p> </div> </div> <h2 id="_conclusion">Conclusion</h2> <div class="sectionbody"> <p>We have seen that regressions are an important problem, and that "git bisect" has nice features that complement very well practices and other tools, especially test suites, that are generally used to fight regressions. But it might be needed to change some work-flows and (bad) habits to get the most out of it.</p> <p>Some improvements to the algorithms inside "git bisect" are possible and some new features could help in some cases, but overall "git bisect" works already very well, is used a lot, and is already very useful. To back up that last claim, let’s give the final word to Ingo Molnar when he was asked by the author how much time does he think "git bisect" saves him when he uses it:</p> <div class="quoteblock"> <blockquote> <p>a <code>lot</code>.</p> <p>About ten years ago did i do my first <code>bisection</code> of a Linux patch queue. That was prior the Git (and even prior the BitKeeper) days. I literally days spent sorting out patches, creating what in essence were standalone commits that i guessed to be related to that bug.</p> <p>It was a tool of absolute last resort. I’d rather spend days looking at printk output than do a manual <code>patch bisection</code>.</p> <p>With Git bisect it’s a breeze: in the best case i can get a ~15 step kernel bisection done in 20-30 minutes, in an automated way. Even with manual help or when bisecting multiple, overlapping bugs, it’s rarely more than an hour.</p> <p>In fact it’s invaluable because there are bugs i would never even <code>try</code> to debug if it wasn’t for git bisect. In the past there were bug patterns that were immediately hopeless for me to debug - at best i could send the crash/bug signature to lkml and hope that someone else can think of something.</p> <p>And even if a bisection fails today it tells us something valuable about the bug: that it’s non-deterministic - timing or kernel image layout dependent.</p> <p>So git bisect is unconditional goodness - and feel free to quote that ;-)</p> </blockquote> </div> </div> <h2 id="_acknowledgments">Acknowledgments</h2> <div class="sectionbody"> <p>Many thanks to Junio Hamano for his help in reviewing this paper, for reviewing the patches I sent to the Git mailing list, for discussing some ideas and helping me improve them, for improving "git bisect" a lot and for his awesome work in maintaining and developing Git.</p> <p>Many thanks to Ingo Molnar for giving me very useful information that appears in this paper, for commenting on this paper, for his suggestions to improve "git bisect" and for evangelizing "git bisect" on the linux kernel mailing lists.</p> <p>Many thanks to Linus Torvalds for inventing, developing and evangelizing "git bisect", Git and Linux.</p> <p>Many thanks to the many other great people who helped one way or another when I worked on Git, especially to Andreas Ericsson, Johannes Schindelin, H. Peter Anvin, Daniel Barkalow, Bill Lear, John Hawley, Shawn O. Pierce, Jeff King, Sam Vilain, Jon Seymour.</p> <p>Many thanks to the Linux-Kongress program committee for choosing the author to given a talk and for publishing this paper.</p> </div> <h2 id="_references">References</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>[[[1]]] <a href="https://web.archive.org/web/20091206032101/http://www.nist.gov/public_affairs/releases/n02-10.htm"><em>Software Errors Cost U.S. Economy $59.5 Billion Annually</em>. Nist News Release.</a> See also <a href="https://www.nist.gov/system/files/documents/director/planning/report02-3.pdf"><em>The Economic Impacts of Inadequate Infratructure for Software Testing</em>. Nist Planning Report 02-3</a>, Executive Summary and Chapter 8.</p> </li> <li> <p>[[[2]]] <a href="https://www.oracle.com/java/technologies/javase/codeconventions-introduction.html"><em>Code Conventions for the Java Programming Language: 1. Introduction</em>. Sun Microsystems.</a></p> </li> <li> <p>[[[3]]] <a href="https://en.wikipedia.org/wiki/Software_maintenance"><em>Software maintenance</em>. Wikipedia.</a></p> </li> <li> <p>[[[4]]] <a href="https://lore.kernel.org/git/7vps5xsbwp.fsf_-_@assigned-by-dhcp.cox.net/">Junio C Hamano. <em>Automated bisect success story</em>.</a></p> </li> <li> <p>[[[5]]] <a href="https://lwn.net/Articles/317154/">Christian Couder. <em>Fully automated bisecting with "git bisect run"</em>. LWN.net.</a></p> </li> <li> <p>[[[6]]] <a href="https://lwn.net/Articles/277872/">Jonathan Corbet. <em>Bisection divides users and developers</em>. LWN.net.</a></p> </li> <li> <p>[[[7]]] <a href="https://lore.kernel.org/lkml/20071207113734.GA14598@elte.hu/">Ingo Molnar. <em>Re: BUG 2.6.23-rc3 can’t see sd partitions on Alpha</em>. Linux-kernel mailing list.</a></p> </li> <li> <p>[[[8]]] <a href="https://www.kernel.org/pub/software/scm/git/docs/git-bisect.html">Junio C Hamano and the git-list. <em>git-bisect(1) Manual Page</em>. Linux Kernel Archives.</a></p> </li> <li> <p>[[[9]]] <a href="https://github.com/Ealdwulf/bbchop">Ealdwulf. <em>bbchop</em>. GitHub.</a></p> </li> </ul> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-bisect-lk2009" class="_attribution-link">https://git-scm.com/docs/git-bisect-lk2009</a> + </p> +</div> diff --git a/devdocs/git/git-bisect.html b/devdocs/git/git-bisect.html new file mode 100644 index 00000000..63e658e7 --- /dev/null +++ b/devdocs/git/git-bisect.html @@ -0,0 +1,86 @@ +<h1>git-bisect</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-bisect - Use binary search to find the commit that introduced a bug</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git bisect <subcommand> <options></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>The command takes various subcommands, and different options depending on the subcommand:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git bisect start [--term-(new|bad)=<term-new> --term-(old|good)=<term-old>] + [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<paths>...] +git bisect (bad|new|<term-new>) [<rev>] +git bisect (good|old|<term-old>) [<rev>...] +git bisect terms [--term-good | --term-bad] +git bisect skip [(<rev>|<range>)...] +git bisect reset [<commit>] +git bisect (visualize|view) +git bisect replay <logfile> +git bisect log +git bisect run <cmd> [<arg>...] +git bisect help</pre> </div> </div> <p>This command uses a binary search algorithm to find which commit in your project’s history introduced a bug. You use it by first telling it a "bad" commit that is known to contain the bug, and a "good" commit that is known to be before the bug was introduced. Then <code>git +bisect</code> picks a commit between those two endpoints and asks you whether the selected commit is "good" or "bad". It continues narrowing down the range until it finds the exact commit that introduced the change.</p> <p>In fact, <code>git bisect</code> can be used to find the commit that changed <strong>any</strong> property of your project; e.g., the commit that fixed a bug, or the commit that caused a benchmark’s performance to improve. To support this more general usage, the terms "old" and "new" can be used in place of "good" and "bad", or you can choose your own terms. See section "Alternate terms" below for more information.</p> <div class="sect2"> <h3 id="_basic_bisect_commands_start_bad_good"> +Basic bisect commands: start, bad, good</h3> <p>As an example, suppose you are trying to find the commit that broke a feature that was known to work in version <code>v2.6.13-rc2</code> of your project. You start a bisect session as follows:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start +$ git bisect bad # Current version is bad +$ git bisect good v2.6.13-rc2 # v2.6.13-rc2 is known to be good</pre> </div> </div> <p>Once you have specified at least one bad and one good commit, <code>git +bisect</code> selects a commit in the middle of that range of history, checks it out, and outputs something similar to the following:</p> <div class="listingblock"> <div class="content"> <pre>Bisecting: 675 revisions left to test after this (roughly 10 steps)</pre> </div> </div> <p>You should now compile the checked-out version and test it. If that version works correctly, type</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect good</pre> </div> </div> <p>If that version is broken, type</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect bad</pre> </div> </div> <p>Then <code>git bisect</code> will respond with something like</p> <div class="listingblock"> <div class="content"> <pre>Bisecting: 337 revisions left to test after this (roughly 9 steps)</pre> </div> </div> <p>Keep repeating the process: compile the tree, test it, and depending on whether it is good or bad run <code>git bisect good</code> or <code>git bisect bad</code> to ask for the next commit that needs testing.</p> <p>Eventually there will be no more revisions left to inspect, and the command will print out a description of the first bad commit. The reference <code>refs/bisect/bad</code> will be left pointing at that commit.</p> </div> <div class="sect2"> <h3 id="_bisect_reset"> +Bisect reset</h3> <p>After a bisect session, to clean up the bisection state and return to the original HEAD, issue the following command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect reset</pre> </div> </div> <p>By default, this will return your tree to the commit that was checked out before <code>git bisect start</code>. (A new <code>git bisect start</code> will also do that, as it cleans up the old bisection state.)</p> <p>With an optional argument, you can return to a different commit instead:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect reset <commit></pre> </div> </div> <p>For example, <code>git bisect reset bisect/bad</code> will check out the first bad revision, while <code>git bisect reset HEAD</code> will leave you on the current bisection commit and avoid switching commits at all.</p> </div> <div class="sect2"> <h3 id="_alternate_terms"> +Alternate terms</h3> <p>Sometimes you are not looking for the commit that introduced a breakage, but rather for a commit that caused a change between some other "old" state and "new" state. For example, you might be looking for the commit that introduced a particular fix. Or you might be looking for the first commit in which the source-code filenames were finally all converted to your company’s naming standard. Or whatever.</p> <p>In such cases it can be very confusing to use the terms "good" and "bad" to refer to "the state before the change" and "the state after the change". So instead, you can use the terms "old" and "new", respectively, in place of "good" and "bad". (But note that you cannot mix "good" and "bad" with "old" and "new" in a single session.)</p> <p>In this more general usage, you provide <code>git bisect</code> with a "new" commit that has some property and an "old" commit that doesn’t have that property. Each time <code>git bisect</code> checks out a commit, you test if that commit has the property. If it does, mark the commit as "new"; otherwise, mark it as "old". When the bisection is done, <code>git bisect</code> will report which commit introduced the property.</p> <p>To use "old" and "new" instead of "good" and bad, you must run <code>git +bisect start</code> without commits as argument and then run the following commands to add the commits:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git bisect old [<rev>]</pre> </div> </div> <p>to indicate that a commit was before the sought change, or</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git bisect new [<rev>...]</pre> </div> </div> <p>to indicate that it was after.</p> <p>To get a reminder of the currently used terms, use</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git bisect terms</pre> </div> </div> <p>You can get just the old (respectively new) term with <code>git bisect terms +--term-old</code> or <code>git bisect terms --term-good</code>.</p> <p>If you would like to use your own terms instead of "bad"/"good" or "new"/"old", you can choose any names you like (except existing bisect subcommands like <code>reset</code>, <code>start</code>, …) by starting the bisection using</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git bisect start --term-old <term-old> --term-new <term-new></pre> </div> </div> <p>For example, if you are looking for a commit that introduced a performance regression, you might use</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git bisect start --term-old fast --term-new slow</pre> </div> </div> <p>Or if you are looking for the commit that fixed a bug, you might use</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git bisect start --term-new fixed --term-old broken</pre> </div> </div> <p>Then, use <code>git bisect <term-old></code> and <code>git bisect <term-new></code> instead of <code>git bisect good</code> and <code>git bisect bad</code> to mark commits.</p> </div> <div class="sect2"> <h3 id="_bisect_visualizeview"> +Bisect visualize/view</h3> <p>To see the currently remaining suspects in <code>gitk</code>, issue the following command during the bisection process (the subcommand <code>view</code> can be used as an alternative to <code>visualize</code>):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect visualize</pre> </div> </div> <p>Git detects a graphical environment through various environment variables: <code>DISPLAY</code>, which is set in X Window System environments on Unix systems. <code>SESSIONNAME</code>, which is set under Cygwin in interactive desktop sessions. <code>MSYSTEM</code>, which is set under Msys2 and Git for Windows. <code>SECURITYSESSIONID</code>, which may be set on macOS in interactive desktop sessions.</p> <p>If none of these environment variables is set, <code>git log</code> is used instead. You can also give command-line options such as <code>-p</code> and <code>--stat</code>.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect visualize --stat</pre> </div> </div> </div> <div class="sect2"> <h3 id="_bisect_log_and_bisect_replay"> +Bisect log and bisect replay</h3> <p>After having marked revisions as good or bad, issue the following command to show what has been done so far:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect log</pre> </div> </div> <p>If you discover that you made a mistake in specifying the status of a revision, you can save the output of this command to a file, edit it to remove the incorrect entries, and then issue the following commands to return to a corrected state:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect reset +$ git bisect replay that-file</pre> </div> </div> </div> <div class="sect2"> <h3 id="_avoiding_testing_a_commit"> +Avoiding testing a commit</h3> <p>If, in the middle of a bisect session, you know that the suggested revision is not a good one to test (e.g. it fails to build and you know that the failure does not have anything to do with the bug you are chasing), you can manually select a nearby commit and test that one instead.</p> <p>For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect good/bad # previous round was good or bad. +Bisecting: 337 revisions left to test after this (roughly 9 steps) +$ git bisect visualize # oops, that is uninteresting. +$ git reset --hard HEAD~3 # try 3 revisions before what + # was suggested</pre> </div> </div> <p>Then compile and test the chosen revision, and afterwards mark the revision as good or bad in the usual manner.</p> </div> <div class="sect2"> <h3 id="_bisect_skip"> +Bisect skip</h3> <p>Instead of choosing a nearby commit by yourself, you can ask Git to do it for you by issuing the command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect skip # Current version cannot be tested</pre> </div> </div> <p>However, if you skip a commit adjacent to the one you are looking for, Git will be unable to tell exactly which of those commits was the first bad one.</p> <p>You can also skip a range of commits, instead of just one commit, using range notation. For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect skip v2.5..v2.6</pre> </div> </div> <p>This tells the bisect process that no commit after <code>v2.5</code>, up to and including <code>v2.6</code>, should be tested.</p> <p>Note that if you also want to skip the first commit of the range you would issue the command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect skip v2.5 v2.5..v2.6</pre> </div> </div> <p>This tells the bisect process that the commits between <code>v2.5</code> and <code>v2.6</code> (inclusive) should be skipped.</p> </div> <div class="sect2"> <h3 id="_cutting_down_bisection_by_giving_more_parameters_to_bisect_start"> +Cutting down bisection by giving more parameters to bisect start</h3> <p>You can further cut down the number of trials, if you know what part of the tree is involved in the problem you are tracking down, by specifying path parameters when issuing the <code>bisect start</code> command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start -- arch/i386 include/asm-i386</pre> </div> </div> <p>If you know beforehand more than one good commit, you can narrow the bisect space down by specifying all of the good commits immediately after the bad commit when issuing the <code>bisect start</code> command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start v2.6.20-rc6 v2.6.20-rc4 v2.6.20-rc1 -- + # v2.6.20-rc6 is bad + # v2.6.20-rc4 and v2.6.20-rc1 are good</pre> </div> </div> </div> <div class="sect2"> <h3 id="_bisect_run"> +Bisect run</h3> <p>If you have a script that can tell if the current source code is good or bad, you can bisect by issuing the command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect run my_script arguments</pre> </div> </div> <p>Note that the script (<code>my_script</code> in the above example) should exit with code 0 if the current source code is good/old, and exit with a code between 1 and 127 (inclusive), except 125, if the current source code is bad/new.</p> <p>Any other exit code will abort the bisect process. It should be noted that a program that terminates via <code>exit(-1)</code> leaves $? = 255, (see the exit(3) manual page), as the value is chopped with <code>& 0377</code>.</p> <p>The special exit code 125 should be used when the current source code cannot be tested. If the script exits with this code, the current revision will be skipped (see <code>git bisect skip</code> above). 125 was chosen as the highest sensible value to use for this purpose, because 126 and 127 are used by POSIX shells to signal specific error status (127 is for command not found, 126 is for command found but not executable—these details do not matter, as they are normal errors in the script, as far as <code>bisect run</code> is concerned).</p> <p>You may often find that during a bisect session you want to have temporary modifications (e.g. s/#define DEBUG 0/#define DEBUG 1/ in a header file, or "revision that does not have this commit needs this patch applied to work around another problem this bisection is not interested in") applied to the revision being tested.</p> <p>To cope with such a situation, after the inner <code>git bisect</code> finds the next revision to test, the script can apply the patch before compiling, run the real test, and afterwards decide if the revision (possibly with the needed patch) passed the test and then rewind the tree to the pristine state. Finally the script should exit with the status of the real test to let the <code>git bisect run</code> command loop determine the eventual outcome of the bisect session.</p> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-bisect.txt---no-checkout"> --no-checkout </dt> <dd> <p>Do not checkout the new working tree at each iteration of the bisection process. Instead just update the reference named <code>BISECT_HEAD</code> to make it point to the commit that should be tested.</p> <p>This option may be useful when the test you would perform in each step does not require a checked out tree.</p> <p>If the repository is bare, <code>--no-checkout</code> is assumed.</p> </dd> <dt class="hdlist1" id="Documentation/git-bisect.txt---first-parent"> --first-parent </dt> <dd> <p>Follow only the first parent commit upon seeing a merge commit.</p> <p>In detecting regressions introduced through the merging of a branch, the merge commit will be identified as introduction of the bug and its ancestors will be ignored.</p> <p>This option is particularly useful in avoiding false positives when a merged branch contained broken or non-buildable commits, but the merge itself was OK.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Automatically bisect a broken build between v1.2 and HEAD:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start HEAD v1.2 -- # HEAD is bad, v1.2 is good +$ git bisect run make # "make" builds the app +$ git bisect reset # quit the bisect session</pre> </div> </div> </li> <li> <p>Automatically bisect a test failure between origin and HEAD:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start HEAD origin -- # HEAD is bad, origin is good +$ git bisect run make test # "make test" builds and tests +$ git bisect reset # quit the bisect session</pre> </div> </div> </li> <li> <p>Automatically bisect a broken test case:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat ~/test.sh +#!/bin/sh +make || exit 125 # this skips broken builds +~/check_test_case.sh # does the test case pass? +$ git bisect start HEAD HEAD~10 -- # culprit is among the last 10 +$ git bisect run ~/test.sh +$ git bisect reset # quit the bisect session</pre> </div> </div> <p>Here we use a <code>test.sh</code> custom script. In this script, if <code>make</code> fails, we skip the current commit. <code>check_test_case.sh</code> should <code>exit 0</code> if the test case passes, and <code>exit 1</code> otherwise.</p> <p>It is safer if both <code>test.sh</code> and <code>check_test_case.sh</code> are outside the repository to prevent interactions between the bisect, make and test processes and the scripts.</p> </li> <li> <p>Automatically bisect with temporary modifications (hot-fix):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat ~/test.sh +#!/bin/sh + +# tweak the working tree by merging the hot-fix branch +# and then attempt a build +if git merge --no-commit --no-ff hot-fix && + make +then + # run project specific test and report its status + ~/check_test_case.sh + status=$? +else + # tell the caller this is untestable + status=125 +fi + +# undo the tweak to allow clean flipping to the next commit +git reset --hard + +# return control +exit $status</pre> </div> </div> <p>This applies modifications from a hot-fix branch before each test run, e.g. in case your build or test environment changed so that older revisions may need a fix which newer ones have already. (Make sure the hot-fix branch is based off a commit which is contained in all revisions which you are bisecting, so that the merge does not pull in too much, or use <code>git cherry-pick</code> instead of <code>git merge</code>.)</p> </li> <li> <p>Automatically bisect a broken test case:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start HEAD HEAD~10 -- # culprit is among the last 10 +$ git bisect run sh -c "make || exit 125; ~/check_test_case.sh" +$ git bisect reset # quit the bisect session</pre> </div> </div> <p>This shows that you can do without a run script if you write the test on a single line.</p> </li> <li> <p>Locate a good region of the object graph in a damaged repository</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start HEAD <known-good-commit> [ <boundary-commit> ... ] --no-checkout +$ git bisect run sh -c ' + GOOD=$(git for-each-ref "--format=%(objectname)" refs/bisect/good-*) && + git rev-list --objects BISECT_HEAD --not $GOOD >tmp.$$ && + git pack-objects --stdout >/dev/null <tmp.$$ + rc=$? + rm -f tmp.$$ + test $rc = 0' + +$ git bisect reset # quit the bisect session</pre> </div> </div> <p>In this case, when <code>git bisect run</code> finishes, bisect/bad will refer to a commit that has at least one parent whose reachable graph is fully traversable in the sense required by <code>git pack objects</code>.</p> </li> <li> <p>Look for a fix instead of a regression in the code</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start +$ git bisect new HEAD # current commit is marked as new +$ git bisect old HEAD~10 # the tenth commit from now is marked as old</pre> </div> </div> <p>or:</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start --term-old broken --term-new fixed +$ git bisect fixed +$ git bisect broken HEAD~10</pre> </div> </div> <div class="sect2"> <h3 id="_getting_help"> +Getting help</h3> <p>Use <code>git bisect</code> to get a short usage description, and <code>git bisect +help</code> or <code>git bisect -h</code> to get a long usage description.</p> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-bisect-lk2009">Fighting regressions with git bisect</a>, <a href="git-blame">git-blame[1]</a>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-bisect" class="_attribution-link">https://git-scm.com/docs/git-bisect</a> + </p> +</div> diff --git a/devdocs/git/git-blame.html b/devdocs/git/git-blame.html new file mode 100644 index 00000000..1212804c --- /dev/null +++ b/devdocs/git/git-blame.html @@ -0,0 +1,18 @@ +<h1>git-blame</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-blame - Show what revision and author last modified each line of a file</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git blame [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-e] [-p] [-w] [--incremental] + [-L <range>] [-S <revs-file>] [-M] [-C] [-C] [-C] [--since=<date>] + [--ignore-rev <rev>] [--ignore-revs-file <file>] + [--color-lines] [--color-by-age] [--progress] [--abbrev=<n>] + [ --contents <file> ] [<rev> | --reverse <rev>..<rev>] [--] <file></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Annotates each line in the given file with information from the revision which last modified the line. Optionally, start annotating from the given revision.</p> <p>When specified one or more times, <code>-L</code> restricts annotation to the requested lines.</p> <p>The origin of lines is automatically followed across whole-file renames (currently there is no option to turn the rename-following off). To follow lines moved from one file to another, or to follow lines that were copied and pasted from another file, etc., see the <code>-C</code> and <code>-M</code> options.</p> <p>The report does not tell you anything about lines which have been deleted or replaced; you need to use a tool such as <code>git diff</code> or the "pickaxe" interface briefly mentioned in the following paragraph.</p> <p>Apart from supporting file annotation, Git also supports searching the development history for when a code snippet occurred in a change. This makes it possible to track when a code snippet was added to a file, moved or copied between files, and eventually deleted or replaced. It works by searching for a text string in the diff. A small example of the pickaxe interface that searches for <code>blame_usage</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log --pretty=oneline -S'blame_usage' +5040f17eba15504bad66b14a645bddd9b015ebb7 blame -S <ancestry-file> +ea4c7f9bf69e781dd0cd88d2bccb2bf5cc15c9a7 git-blame: Make the output</pre> </div> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-blame.txt--b"> -b </dt> <dd> <p>Show blank SHA-1 for boundary commits. This can also be controlled via the <code>blame.blankBoundary</code> config option.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---root"> --root </dt> <dd> <p>Do not treat root commits as boundaries. This can also be controlled via the <code>blame.showRoot</code> config option.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---show-stats"> --show-stats </dt> <dd> <p>Include additional statistics at the end of blame output.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt--Lltstartgtltendgt"> -L <start>,<end> </dt> <dt class="hdlist1" id="Documentation/git-blame.txt--Lltfuncnamegt"> -L :<funcname> </dt> <dd> <p>Annotate only the line range given by <code><start>,<end></code>, or by the function name regex <code><funcname></code>. May be specified multiple times. Overlapping ranges are allowed.</p> <p><code><start></code> and <code><end></code> are optional. <code>-L <start></code> or <code>-L <start>,</code> spans from <code><start></code> to end of file. <code>-L ,<end></code> spans from start of file to <code><end></code>.</p> <p><code><start></code> and <code><end></code> can take one of these forms:</p> <div class="ulist"> <ul> <li> <p>number</p> <p>If <code><start></code> or <code><end></code> is a number, it specifies an absolute line number (lines count from 1).</p> </li> <li> <p><code>/regex/</code></p> <p>This form will use the first line matching the given POSIX regex. If <code><start></code> is a regex, it will search from the end of the previous <code>-L</code> range, if any, otherwise from the start of file. If <code><start></code> is <code>^/regex/</code>, it will search from the start of file. If <code><end></code> is a regex, it will search starting at the line given by <code><start></code>.</p> </li> <li> <p>+offset or -offset</p> <p>This is only valid for <code><end></code> and will specify a number of lines before or after the line given by <code><start></code>.</p> </li> </ul> </div> <p>If <code>:<funcname></code> is given in place of <code><start></code> and <code><end></code>, it is a regular expression that denotes the range from the first funcname line that matches <code><funcname></code>, up to the next funcname line. <code>:<funcname></code> searches from the end of the previous <code>-L</code> range, if any, otherwise from the start of file. <code>^:<funcname></code> searches from the start of file. The function names are determined in the same way as <code>git diff</code> works out patch hunk headers (see <code>Defining a custom hunk-header</code> in <a href="gitattributes">gitattributes[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt--l"> -l </dt> <dd> <p>Show long rev (Default: off).</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt--t"> -t </dt> <dd> <p>Show raw timestamp (Default: off).</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt--Sltrevs-filegt"> -S <revs-file> </dt> <dd> <p>Use revisions from revs-file instead of calling <a href="git-rev-list">git-rev-list[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---reverseltrevgtltrevgt"> --reverse <rev>..<rev> </dt> <dd> <p>Walk history forward instead of backward. Instead of showing the revision in which a line appeared, this shows the last revision in which a line has existed. This requires a range of revision like START..END where the path to blame exists in START. <code>git blame --reverse START</code> is taken as <code>git blame +--reverse START..HEAD</code> for convenience.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---first-parent"> --first-parent </dt> <dd> <p>Follow only the first parent commit upon seeing a merge commit. This option can be used to determine when a line was introduced to a particular integration branch, rather than when it was introduced to the history overall.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-blame.txt---porcelain"> --porcelain </dt> <dd> <p>Show in a format designed for machine consumption.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---line-porcelain"> --line-porcelain </dt> <dd> <p>Show the porcelain format, but output commit information for each line, not just the first time a commit is referenced. Implies --porcelain.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---incremental"> --incremental </dt> <dd> <p>Show the result incrementally in a format designed for machine consumption.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---encodingltencodinggt"> --encoding=<encoding> </dt> <dd> <p>Specifies the encoding used to output author names and commit summaries. Setting it to <code>none</code> makes blame output unconverted data. For more information see the discussion about encoding in the <a href="git-log">git-log[1]</a> manual page.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---contentsltfilegt"> --contents <file> </dt> <dd> <p>Annotate using the contents from the named file, starting from <rev> if it is specified, and HEAD otherwise. You may specify <code>-</code> to make the command read from the standard input for the file contents.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---dateltformatgt"> --date <format> </dt> <dd> <p>Specifies the format used to output dates. If --date is not provided, the value of the blame.date config variable is used. If the blame.date config variable is also not set, the iso format is used. For supported values, see the discussion of the --date option at <a href="git-log">git-log[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---no-progress"> --[no-]progress </dt> <dd> <p>Progress status is reported on the standard error stream by default when it is attached to a terminal. This flag enables progress reporting even if not attached to a terminal. Can’t use <code>--progress</code> together with <code>--porcelain</code> or <code>--incremental</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt--Mltnumgt"> -M[<num>] </dt> <dd> <p>Detect moved or copied lines within a file. When a commit moves or copies a block of lines (e.g. the original file has A and then B, and the commit changes it to B and then A), the traditional <code>blame</code> algorithm notices only half of the movement and typically blames the lines that were moved up (i.e. B) to the parent and assigns blame to the lines that were moved down (i.e. A) to the child commit. With this option, both groups of lines are blamed on the parent by running extra passes of inspection.</p> <p><num> is optional but it is the lower bound on the number of alphanumeric characters that Git must detect as moving/copying within a file for it to associate those lines with the parent commit. The default value is 20.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt--Cltnumgt"> -C[<num>] </dt> <dd> <p>In addition to <code>-M</code>, detect lines moved or copied from other files that were modified in the same commit. This is useful when you reorganize your program and move code around across files. When this option is given twice, the command additionally looks for copies from other files in the commit that creates the file. When this option is given three times, the command additionally looks for copies from other files in any commit.</p> <p><num> is optional but it is the lower bound on the number of alphanumeric characters that Git must detect as moving/copying between files for it to associate those lines with the parent commit. And the default value is 40. If there are more than one <code>-C</code> options given, the <num> argument of the last <code>-C</code> will take effect.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---ignore-revltrevgt"> --ignore-rev <rev> </dt> <dd> <p>Ignore changes made by the revision when assigning blame, as if the change never happened. Lines that were changed or added by an ignored commit will be blamed on the previous commit that changed that line or nearby lines. This option may be specified multiple times to ignore more than one revision. If the <code>blame.markIgnoredLines</code> config option is set, then lines that were changed by an ignored commit and attributed to another commit will be marked with a <code>?</code> in the blame output. If the <code>blame.markUnblamableLines</code> config option is set, then those lines touched by an ignored commit that we could not attribute to another revision are marked with a <code>*</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---ignore-revs-fileltfilegt"> --ignore-revs-file <file> </dt> <dd> <p>Ignore revisions listed in <code>file</code>, which must be in the same format as an <code>fsck.skipList</code>. This option may be repeated, and these files will be processed after any files specified with the <code>blame.ignoreRevsFile</code> config option. An empty file name, <code>""</code>, will clear the list of revs from previously processed files.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---color-lines"> --color-lines </dt> <dd> <p>Color line annotations in the default format differently if they come from the same commit as the preceding line. This makes it easier to distinguish code blocks introduced by different commits. The color defaults to cyan and can be adjusted using the <code>color.blame.repeatedLines</code> config option.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---color-by-age"> --color-by-age </dt> <dd> <p>Color line annotations depending on the age of the line in the default format. The <code>color.blame.highlightRecent</code> config option controls what color is used for each range of age.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt--h"> -h </dt> <dd> <p>Show help message.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt--c"> -c </dt> <dd> <p>Use the same output mode as <a href="git-annotate">git-annotate[1]</a> (Default: off).</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---score-debug"> --score-debug </dt> <dd> <p>Include debugging information related to the movement of lines between files (see <code>-C</code>) and lines moved within a file (see <code>-M</code>). The first number listed is the score. This is the number of alphanumeric characters detected as having been moved between or within files. This must be above a certain threshold for <code>git blame</code> to consider those lines of code to have been moved.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-blame.txt---show-name"> --show-name </dt> <dd> <p>Show the filename in the original commit. By default the filename is shown if there is any line that came from a file with a different name, due to rename detection.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-blame.txt---show-number"> --show-number </dt> <dd> <p>Show the line number in the original commit (Default: off).</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt--s"> -s </dt> <dd> <p>Suppress the author name and timestamp from the output.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt--e"> -e </dt> <dt class="hdlist1" id="Documentation/git-blame.txt---show-email"> --show-email </dt> <dd> <p>Show the author email instead of the author name (Default: off). This can also be controlled via the <code>blame.showEmail</code> config option.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt--w"> -w </dt> <dd> <p>Ignore whitespace when comparing the parent’s version and the child’s to find where the lines came from.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt---abbrevltngt"> --abbrev=<n> </dt> <dd> <p>Instead of using the default 7+1 hexadecimal digits as the abbreviated object name, use <m>+1 digits, where <m> is at least <n> but ensures the commit object names are unique. Note that 1 column is used for a caret to mark the boundary commit.</p> </dd> </dl> </div> </div> <h2 id="_the_default_format">The default format</h2> <div class="sectionbody"> <p>When neither <code>--porcelain</code> nor <code>--incremental</code> option is specified, <code>git blame</code> will output annotation for each line with:</p> <div class="ulist"> <ul> <li> <p>abbreviated object name for the commit the line came from;</p> </li> <li> <p>author ident (by default the author name and date, unless <code>-s</code> or <code>-e</code> is specified); and</p> </li> <li> <p>line number</p> </li> </ul> </div> <p>before the line contents.</p> </div> <h2 id="_the_porcelain_format">The porcelain format</h2> <div class="sectionbody"> <p>In this format, each line is output after a header; the header at the minimum has the first line which has:</p> <div class="ulist"> <ul> <li> <p>40-byte SHA-1 of the commit the line is attributed to;</p> </li> <li> <p>the line number of the line in the original file;</p> </li> <li> <p>the line number of the line in the final file;</p> </li> <li> <p>on a line that starts a group of lines from a different commit than the previous one, the number of lines in this group. On subsequent lines this field is absent.</p> </li> </ul> </div> <p>This header line is followed by the following information at least once for each commit:</p> <div class="ulist"> <ul> <li> <p>the author name ("author"), email ("author-mail"), time ("author-time"), and time zone ("author-tz"); similarly for committer.</p> </li> <li> <p>the filename in the commit that the line is attributed to.</p> </li> <li> <p>the first line of the commit log message ("summary").</p> </li> </ul> </div> <p>The contents of the actual line are output after the above header, prefixed by a TAB. This is to allow adding more header elements later.</p> <p>The porcelain format generally suppresses commit information that has already been seen. For example, two lines that are blamed to the same commit will both be shown, but the details for that commit will be shown only once. This is more efficient, but may require more state be kept by the reader. The <code>--line-porcelain</code> option can be used to output full commit information for each line, allowing simpler (but less efficient) usage like:</p> <div class="literalblock"> <div class="content"> <pre># count the number of lines attributed to each author +git blame --line-porcelain file | +sed -n 's/^author //p' | +sort | uniq -c | sort -rn</pre> </div> </div> </div> <h2 id="_specifying_ranges">Specifying ranges</h2> <div class="sectionbody"> <p>Unlike <code>git blame</code> and <code>git annotate</code> in older versions of git, the extent of the annotation can be limited to both line ranges and revision ranges. The <code>-L</code> option, which limits annotation to a range of lines, may be specified multiple times.</p> <p>When you are interested in finding the origin for lines 40-60 for file <code>foo</code>, you can use the <code>-L</code> option like so (they mean the same thing — both ask for 21 lines starting at line 40):</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git blame -L 40,60 foo +git blame -L 40,+21 foo</pre> </div> </div> <p>Also you can use a regular expression to specify the line range:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git blame -L '/^sub hello {/,/^}$/' foo</pre> </div> </div> <p>which limits the annotation to the body of the <code>hello</code> subroutine.</p> <p>When you are not interested in changes older than version v2.6.18, or changes older than 3 weeks, you can use revision range specifiers similar to <code>git rev-list</code>:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git blame v2.6.18.. -- foo +git blame --since=3.weeks -- foo</pre> </div> </div> <p>When revision range specifiers are used to limit the annotation, lines that have not changed since the range boundary (either the commit v2.6.18 or the most recent commit that is more than 3 weeks old in the above example) are blamed for that range boundary commit.</p> <p>A particularly useful way is to see if an added file has lines created by copy-and-paste from existing files. Sometimes this indicates that the developer was being sloppy and did not refactor the code properly. You can first find the commit that introduced the file with:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git log --diff-filter=A --pretty=short -- foo</pre> </div> </div> <p>and then annotate the change between the commit and its parents, using <code>commit^!</code> notation:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git blame -C -C -f $commit^! -- foo</pre> </div> </div> </div> <h2 id="_incremental_output">Incremental output</h2> <div class="sectionbody"> <p>When called with <code>--incremental</code> option, the command outputs the result as it is built. The output generally will talk about lines touched by more recent commits first (i.e. the lines will be annotated out of order) and is meant to be used by interactive viewers.</p> <p>The output format is similar to the Porcelain format, but it does not contain the actual lines from the file that is being annotated.</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Each blame entry always starts with a line of:</p> <div class="literalblock"> <div class="content"> <pre><40-byte hex sha1> <sourceline> <resultline> <num_lines></pre> </div> </div> <p>Line numbers count from 1.</p> </li> <li> <p>The first time that a commit shows up in the stream, it has various other information about it printed out with a one-word tag at the beginning of each line describing the extra commit information (author, email, committer, dates, summary, etc.).</p> </li> <li> <p>Unlike the Porcelain format, the filename information is always given and terminates the entry:</p> <div class="literalblock"> <div class="content"> <pre>"filename" <whitespace-quoted-filename-goes-here></pre> </div> </div> <p>and thus it is really quite easy to parse for some line- and word-oriented parser (which should be quite natural for most scripting languages).</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> For people who do parsing: to make it more robust, just ignore any lines between the first and last one ("<sha1>" and "filename" lines) where you do not recognize the tag words (or care about that particular one) at the beginning of the "extended information" lines. That way, if there is ever added information (like the commit encoding or extended commit commentary), a blame viewer will not care. </td> </tr> </table> </div> </li> </ol> </div> </div> <h2 id="_mapping_authors">Mapping authors</h2> <div class="sectionbody"> <p>See <a href="gitmailmap">gitmailmap[5]</a>.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-blame.txt-blameblankBoundary"> blame.blankBoundary </dt> <dd> <p>Show blank commit object name for boundary commits in <a href="git-blame">git-blame[1]</a>. This option defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt-blamecoloring"> blame.coloring </dt> <dd> <p>This determines the coloring scheme to be applied to blame output. It can be <code>repeatedLines</code>, <code>highlightRecent</code>, or <code>none</code> which is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt-blamedate"> blame.date </dt> <dd> <p>Specifies the format used to output dates in <a href="git-blame">git-blame[1]</a>. If unset the iso format is used. For supported values, see the discussion of the <code>--date</code> option at <a href="git-log">git-log[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt-blameshowEmail"> blame.showEmail </dt> <dd> <p>Show the author email instead of author name in <a href="git-blame">git-blame[1]</a>. This option defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt-blameshowRoot"> blame.showRoot </dt> <dd> <p>Do not treat root commits as boundaries in <a href="git-blame">git-blame[1]</a>. This option defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt-blameignoreRevsFile"> blame.ignoreRevsFile </dt> <dd> <p>Ignore revisions listed in the file, one unabbreviated object name per line, in <a href="git-blame">git-blame[1]</a>. Whitespace and comments beginning with <code>#</code> are ignored. This option may be repeated multiple times. Empty file names will reset the list of ignored revisions. This option will be handled before the command line option <code>--ignore-revs-file</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt-blamemarkUnblamableLines"> blame.markUnblamableLines </dt> <dd> <p>Mark lines that were changed by an ignored revision that we could not attribute to another commit with a <code>*</code> in the output of <a href="git-blame">git-blame[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-blame.txt-blamemarkIgnoredLines"> blame.markIgnoredLines </dt> <dd> <p>Mark lines that were changed by an ignored revision that we attributed to another commit with a <code>?</code> in the output of <a href="git-blame">git-blame[1]</a>.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-annotate">git-annotate[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-blame" class="_attribution-link">https://git-scm.com/docs/git-blame</a> + </p> +</div> diff --git a/devdocs/git/git-branch.html b/devdocs/git/git-branch.html new file mode 100644 index 00000000..55b8eb41 --- /dev/null +++ b/devdocs/git/git-branch.html @@ -0,0 +1,30 @@ +<h1>git-branch</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-branch - List, create, or delete branches</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git branch [--color[=<when>] | --no-color] [--show-current] + [-v [--abbrev=<n> | --no-abbrev]] + [--column[=<options>] | --no-column] [--sort=<key>] + [--merged [<commit>]] [--no-merged [<commit>]] + [--contains [<commit>]] [--no-contains [<commit>]] + [--points-at <object>] [--format=<format>] + [(-r | --remotes) | (-a | --all)] + [--list] [<pattern>…] +git branch [--track[=(direct|inherit)] | --no-track] [-f] + [--recurse-submodules] <branchname> [<start-point>] +git branch (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>] +git branch --unset-upstream [<branchname>] +git branch (-m | -M) [<oldbranch>] <newbranch> +git branch (-c | -C) [<oldbranch>] <newbranch> +git branch (-d | -D) [-r] <branchname>… +git branch --edit-description [<branchname>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>If <code>--list</code> is given, or if there are no non-option arguments, existing branches are listed; the current branch will be highlighted in green and marked with an asterisk. Any branches checked out in linked worktrees will be highlighted in cyan and marked with a plus sign. Option <code>-r</code> causes the remote-tracking branches to be listed, and option <code>-a</code> shows both local and remote branches.</p> <p>If a <code><pattern></code> is given, it is used as a shell wildcard to restrict the output to matching branches. If multiple patterns are given, a branch is shown if it matches any of the patterns.</p> <p>Note that when providing a <code><pattern></code>, you must use <code>--list</code>; otherwise the command may be interpreted as branch creation.</p> <p>With <code>--contains</code>, shows only the branches that contain the named commit (in other words, the branches whose tip commits are descendants of the named commit), <code>--no-contains</code> inverts it. With <code>--merged</code>, only branches merged into the named commit (i.e. the branches whose tip commits are reachable from the named commit) will be listed. With <code>--no-merged</code> only branches not merged into the named commit will be listed. If the <commit> argument is missing it defaults to <code>HEAD</code> (i.e. the tip of the current branch).</p> <p>The command’s second form creates a new branch head named <branchname> which points to the current <code>HEAD</code>, or <start-point> if given. As a special case, for <start-point>, you may use <code>"A...B"</code> as a shortcut for the merge base of <code>A</code> and <code>B</code> if there is exactly one merge base. You can leave out at most one of <code>A</code> and <code>B</code>, in which case it defaults to <code>HEAD</code>.</p> <p>Note that this will create the new branch, but it will not switch the working tree to it; use "git switch <newbranch>" to switch to the new branch.</p> <p>When a local branch is started off a remote-tracking branch, Git sets up the branch (specifically the <code>branch.<name>.remote</code> and <code>branch.<name>.merge</code> configuration entries) so that <code>git pull</code> will appropriately merge from the remote-tracking branch. This behavior may be changed via the global <code>branch.autoSetupMerge</code> configuration flag. That setting can be overridden by using the <code>--track</code> and <code>--no-track</code> options, and changed later using <code>git branch --set-upstream-to</code>.</p> <p>With a <code>-m</code> or <code>-M</code> option, <oldbranch> will be renamed to <newbranch>. If <oldbranch> had a corresponding reflog, it is renamed to match <newbranch>, and a reflog entry is created to remember the branch renaming. If <newbranch> exists, -M must be used to force the rename to happen.</p> <p>The <code>-c</code> and <code>-C</code> options have the exact same semantics as <code>-m</code> and <code>-M</code>, except instead of the branch being renamed, it will be copied to a new name, along with its config and reflog.</p> <p>With a <code>-d</code> or <code>-D</code> option, <code><branchname></code> will be deleted. You may specify more than one branch for deletion. If the branch currently has a reflog then the reflog will also be deleted.</p> <p>Use <code>-r</code> together with <code>-d</code> to delete remote-tracking branches. Note, that it only makes sense to delete remote-tracking branches if they no longer exist in the remote repository or if <code>git fetch</code> was configured not to fetch them again. See also the <code>prune</code> subcommand of <a href="git-remote">git-remote[1]</a> for a way to clean up all obsolete remote-tracking branches.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-branch.txt--d"> -d </dt> <dt class="hdlist1" id="Documentation/git-branch.txt---delete"> --delete </dt> <dd> <p>Delete a branch. The branch must be fully merged in its upstream branch, or in <code>HEAD</code> if no upstream was set with <code>--track</code> or <code>--set-upstream-to</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt--D"> -D </dt> <dd> <p>Shortcut for <code>--delete --force</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---create-reflog"> --create-reflog </dt> <dd> <p>Create the branch’s reflog. This activates recording of all changes made to the branch ref, enabling use of date based sha1 expressions such as "<branchname>@{yesterday}". Note that in non-bare repositories, reflogs are usually enabled by default by the <code>core.logAllRefUpdates</code> config option. The negated form <code>--no-create-reflog</code> only overrides an earlier <code>--create-reflog</code>, but currently does not negate the setting of <code>core.logAllRefUpdates</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-branch.txt---force"> --force </dt> <dd> <p>Reset <branchname> to <start-point>, even if <branchname> exists already. Without <code>-f</code>, <code>git branch</code> refuses to change an existing branch. In combination with <code>-d</code> (or <code>--delete</code>), allow deleting the branch irrespective of its merged status, or whether it even points to a valid commit. In combination with <code>-m</code> (or <code>--move</code>), allow renaming the branch even if the new branch name already exists, the same applies for <code>-c</code> (or <code>--copy</code>).</p> <p>Note that <code>git branch -f <branchname> [<start-point>]</code>, even with <code>-f</code>, refuses to change an existing branch <code><branchname></code> that is checked out in another worktree linked to the same repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt--m"> -m </dt> <dt class="hdlist1" id="Documentation/git-branch.txt---move"> --move </dt> <dd> <p>Move/rename a branch, together with its config and reflog.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt--M"> -M </dt> <dd> <p>Shortcut for <code>--move --force</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt--c"> -c </dt> <dt class="hdlist1" id="Documentation/git-branch.txt---copy"> --copy </dt> <dd> <p>Copy a branch, together with its config and reflog.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt--C"> -C </dt> <dd> <p>Shortcut for <code>--copy --force</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---colorltwhengt"> --color[=<when>] </dt> <dd> <p>Color branches to highlight current, local, and remote-tracking branches. The value must be always (the default), never, or auto.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---no-color"> --no-color </dt> <dd> <p>Turn off branch colors, even when the configuration file gives the default to color output. Same as <code>--color=never</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt--i"> -i </dt> <dt class="hdlist1" id="Documentation/git-branch.txt---ignore-case"> --ignore-case </dt> <dd> <p>Sorting and filtering branches are case insensitive.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---omit-empty"> --omit-empty </dt> <dd> <p>Do not print a newline after formatted refs where the format expands to the empty string.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---columnltoptionsgt"> --column[=<options>] </dt> <dt class="hdlist1" id="Documentation/git-branch.txt---no-column"> --no-column </dt> <dd> <p>Display branch listing in columns. See configuration variable <code>column.branch</code> for option syntax. <code>--column</code> and <code>--no-column</code> without options are equivalent to <code>always</code> and <code>never</code> respectively.</p> <p>This option is only applicable in non-verbose mode.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt--r"> -r </dt> <dt class="hdlist1" id="Documentation/git-branch.txt---remotes"> --remotes </dt> <dd> <p>List or delete (if used with -d) the remote-tracking branches. Combine with <code>--list</code> to match the optional pattern(s).</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-branch.txt---all"> --all </dt> <dd> <p>List both remote-tracking branches and local branches. Combine with <code>--list</code> to match optional pattern(s).</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt--l"> -l </dt> <dt class="hdlist1" id="Documentation/git-branch.txt---list"> --list </dt> <dd> <p>List branches. With optional <code><pattern>...</code>, e.g. <code>git +branch --list 'maint-*'</code>, list only the branches that match the pattern(s).</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---show-current"> --show-current </dt> <dd> <p>Print the name of the current branch. In detached HEAD state, nothing is printed.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-branch.txt--vv"> -vv </dt> <dt class="hdlist1" id="Documentation/git-branch.txt---verbose"> --verbose </dt> <dd> <p>When in list mode, show sha1 and commit subject line for each head, along with relationship to upstream branch (if any). If given twice, print the path of the linked worktree (if any) and the name of the upstream branch, as well (see also <code>git remote show <remote></code>). Note that the current worktree’s HEAD will not have its path printed (it will always be your current directory).</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-branch.txt---quiet"> --quiet </dt> <dd> <p>Be more quiet when creating or deleting a branch, suppressing non-error messages.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---abbrevltngt"> --abbrev=<n> </dt> <dd> <p>In the verbose listing that show the commit object name, show the shortest prefix that is at least <code><n></code> hexdigits long that uniquely refers the object. The default value is 7 and can be overridden by the <code>core.abbrev</code> config option.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---no-abbrev"> --no-abbrev </dt> <dd> <p>Display the full sha1s in the output listing rather than abbreviating them.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt--t"> -t </dt> <dt class="hdlist1" id="Documentation/git-branch.txt---trackdirectinherit"> --track[=(direct|inherit)] </dt> <dd> <p>When creating a new branch, set up <code>branch.<name>.remote</code> and <code>branch.<name>.merge</code> configuration entries to set "upstream" tracking configuration for the new branch. This configuration will tell git to show the relationship between the two branches in <code>git status</code> and <code>git branch -v</code>. Furthermore, it directs <code>git pull</code> without arguments to pull from the upstream when the new branch is checked out.</p> <p>The exact upstream branch is chosen depending on the optional argument: <code>-t</code>, <code>--track</code>, or <code>--track=direct</code> means to use the start-point branch itself as the upstream; <code>--track=inherit</code> means to copy the upstream configuration of the start-point branch.</p> <p>The branch.autoSetupMerge configuration variable specifies how <code>git switch</code>, <code>git checkout</code> and <code>git branch</code> should behave when neither <code>--track</code> nor <code>--no-track</code> are specified:</p> <p>The default option, <code>true</code>, behaves as though <code>--track=direct</code> were given whenever the start-point is a remote-tracking branch. <code>false</code> behaves as if <code>--no-track</code> were given. <code>always</code> behaves as though <code>--track=direct</code> were given. <code>inherit</code> behaves as though <code>--track=inherit</code> were given. <code>simple</code> behaves as though <code>--track=direct</code> were given only when the start-point is a remote-tracking branch and the new branch has the same name as the remote branch.</p> <p>See <a href="git-pull">git-pull[1]</a> and <a href="git-config">git-config[1]</a> for additional discussion on how the <code>branch.<name>.remote</code> and <code>branch.<name>.merge</code> options are used.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---no-track"> --no-track </dt> <dd> <p>Do not set up "upstream" configuration, even if the branch.autoSetupMerge configuration variable is set.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---recurse-submodules"> --recurse-submodules </dt> <dd> <p>THIS OPTION IS EXPERIMENTAL! Causes the current command to recurse into submodules if <code>submodule.propagateBranches</code> is enabled. See <code>submodule.propagateBranches</code> in <a href="git-config">git-config[1]</a>. Currently, only branch creation is supported.</p> <p>When used in branch creation, a new branch <branchname> will be created in the superproject and all of the submodules in the superproject’s <start-point>. In submodules, the branch will point to the submodule commit in the superproject’s <start-point> but the branch’s tracking information will be set up based on the submodule’s branches and remotes e.g. <code>git branch --recurse-submodules topic origin/main</code> will create the submodule branch "topic" that points to the submodule commit in the superproject’s "origin/main", but tracks the submodule’s "origin/main".</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---set-upstream"> --set-upstream </dt> <dd> <p>As this option had confusing syntax, it is no longer supported. Please use <code>--track</code> or <code>--set-upstream-to</code> instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt--ultupstreamgt"> -u <upstream> </dt> <dt class="hdlist1" id="Documentation/git-branch.txt---set-upstream-toltupstreamgt"> --set-upstream-to=<upstream> </dt> <dd> <p>Set up <branchname>'s tracking information so <upstream> is considered <branchname>'s upstream branch. If no <branchname> is specified, then it defaults to the current branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---unset-upstream"> --unset-upstream </dt> <dd> <p>Remove the upstream information for <branchname>. If no branch is specified it defaults to the current branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---edit-description"> --edit-description </dt> <dd> <p>Open an editor and edit the text to explain what the branch is for, to be used by various other commands (e.g. <code>format-patch</code>, <code>request-pull</code>, and <code>merge</code> (if enabled)). Multi-line explanations may be used.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---containsltcommitgt"> --contains [<commit>] </dt> <dd> <p>Only list branches which contain the specified commit (HEAD if not specified). Implies <code>--list</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---no-containsltcommitgt"> --no-contains [<commit>] </dt> <dd> <p>Only list branches which don’t contain the specified commit (HEAD if not specified). Implies <code>--list</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---mergedltcommitgt"> --merged [<commit>] </dt> <dd> <p>Only list branches whose tips are reachable from the specified commit (HEAD if not specified). Implies <code>--list</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---no-mergedltcommitgt"> --no-merged [<commit>] </dt> <dd> <p>Only list branches whose tips are not reachable from the specified commit (HEAD if not specified). Implies <code>--list</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt-ltbranchnamegt"> <branchname> </dt> <dd> <p>The name of the branch to create or delete. The new branch name must pass all checks defined by <a href="git-check-ref-format">git-check-ref-format[1]</a>. Some of these checks may restrict the characters allowed in a branch name.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt-ltstart-pointgt"> <start-point> </dt> <dd> <p>The new branch head will point to this commit. It may be given as a branch name, a commit-id, or a tag. If this option is omitted, the current HEAD will be used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt-ltoldbranchgt"> <oldbranch> </dt> <dd> <p>The name of an existing branch to rename.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt-ltnewbranchgt"> <newbranch> </dt> <dd> <p>The new name for an existing branch. The same restrictions as for <branchname> apply.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---sortltkeygt"> --sort=<key> </dt> <dd> <p>Sort based on the key given. Prefix <code>-</code> to sort in descending order of the value. You may use the --sort=<key> option multiple times, in which case the last key becomes the primary key. The keys supported are the same as those in <code>git +for-each-ref</code>. Sort order defaults to the value configured for the <code>branch.sort</code> variable if it exists, or to sorting based on the full refname (including <code>refs/...</code> prefix). This lists detached HEAD (if present) first, then local branches and finally remote-tracking branches. See <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---points-atltobjectgt"> --points-at <object> </dt> <dd> <p>Only list branches of the given object.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt---formatltformatgt"> --format <format> </dt> <dd> <p>A string that interpolates <code>%(fieldname)</code> from a branch ref being shown and the object it points at. The format is the same as that of <a href="git-for-each-ref">git-for-each-ref[1]</a>.</p> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p><code>pager.branch</code> is only respected when listing branches, i.e., when <code>--list</code> is used or implied. The default is to use a pager. See <a href="git-config">git-config[1]</a>.</p> <p>Everything above this line in this section isn’t included from the <a href="git-config">git-config[1]</a> documentation. The content that follows is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-branch.txt-branchautoSetupMerge"> branch.autoSetupMerge </dt> <dd> <p>Tells <code>git branch</code>, <code>git switch</code> and <code>git checkout</code> to set up new branches so that <a href="git-pull">git-pull[1]</a> will appropriately merge from the starting point branch. Note that even if this option is not set, this behavior can be chosen per-branch using the <code>--track</code> and <code>--no-track</code> options. The valid settings are: <code>false</code> — no automatic setup is done; <code>true</code> — automatic setup is done when the starting point is a remote-tracking branch; <code>always</code> — automatic setup is done when the starting point is either a local branch or remote-tracking branch; <code>inherit</code> — if the starting point has a tracking configuration, it is copied to the new branch; <code>simple</code> — automatic setup is done only when the starting point is a remote-tracking branch and the new branch has the same name as the remote branch. This option defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt-branchautoSetupRebase"> branch.autoSetupRebase </dt> <dd> <p>When a new branch is created with <code>git branch</code>, <code>git switch</code> or <code>git checkout</code> that tracks another branch, this variable tells Git to set up pull to rebase instead of merge (see "branch.<name>.rebase"). When <code>never</code>, rebase is never automatically set to true. When <code>local</code>, rebase is set to true for tracked branches of other local branches. When <code>remote</code>, rebase is set to true for tracked branches of remote-tracking branches. When <code>always</code>, rebase will be set to true for all tracking branches. See "branch.autoSetupMerge" for details on how to set up a branch to track another branch. This option defaults to never.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt-branchsort"> branch.sort </dt> <dd> <p>This variable controls the sort ordering of branches when displayed by <a href="git-branch">git-branch[1]</a>. Without the "--sort=<value>" option provided, the value of this variable will be used as the default. See <a href="git-for-each-ref">git-for-each-ref[1]</a> field names for valid values.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt-branchltnamegtremote"> branch.<name>.remote </dt> <dd> <p>When on branch <name>, it tells <code>git fetch</code> and <code>git push</code> which remote to fetch from or push to. The remote to push to may be overridden with <code>remote.pushDefault</code> (for all branches). The remote to push to, for the current branch, may be further overridden by <code>branch.<name>.pushRemote</code>. If no remote is configured, or if you are not on any branch and there is more than one remote defined in the repository, it defaults to <code>origin</code> for fetching and <code>remote.pushDefault</code> for pushing. Additionally, <code>.</code> (a period) is the current local repository (a dot-repository), see <code>branch.<name>.merge</code>'s final note below.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt-branchltnamegtpushRemote"> branch.<name>.pushRemote </dt> <dd> <p>When on branch <name>, it overrides <code>branch.<name>.remote</code> for pushing. It also overrides <code>remote.pushDefault</code> for pushing from branch <name>. When you pull from one place (e.g. your upstream) and push to another place (e.g. your own publishing repository), you would want to set <code>remote.pushDefault</code> to specify the remote to push to for all branches, and use this option to override it for a specific branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt-branchltnamegtmerge"> branch.<name>.merge </dt> <dd> <p>Defines, together with branch.<name>.remote, the upstream branch for the given branch. It tells <code>git fetch</code>/<code>git pull</code>/<code>git rebase</code> which branch to merge and can also affect <code>git push</code> (see push.default). When in branch <name>, it tells <code>git fetch</code> the default refspec to be marked for merging in FETCH_HEAD. The value is handled like the remote part of a refspec, and must match a ref which is fetched from the remote given by "branch.<name>.remote". The merge information is used by <code>git pull</code> (which first calls <code>git fetch</code>) to lookup the default branch for merging. Without this option, <code>git pull</code> defaults to merge the first refspec fetched. Specify multiple values to get an octopus merge. If you wish to setup <code>git pull</code> so that it merges into <name> from another branch in the local repository, you can point branch.<name>.merge to the desired branch, and use the relative path setting <code>.</code> (a period) for branch.<name>.remote.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt-branchltnamegtmergeOptions"> branch.<name>.mergeOptions </dt> <dd> <p>Sets default options for merging into branch <name>. The syntax and supported options are the same as those of <a href="git-merge">git-merge[1]</a>, but option values containing whitespace characters are currently not supported.</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt-branchltnamegtrebase"> branch.<name>.rebase </dt> <dd> <p>When true, rebase the branch <name> on top of the fetched branch, instead of merging the default branch from the default remote when "git pull" is run. See "pull.rebase" for doing this in a non branch-specific manner.</p> <p>When <code>merges</code> (or just <code>m</code>), pass the <code>--rebase-merges</code> option to <code>git rebase</code> so that the local merge commits are included in the rebase (see <a href="git-rebase">git-rebase[1]</a> for details).</p> <p>When the value is <code>interactive</code> (or just <code>i</code>), the rebase is run in interactive mode.</p> <p><strong>NOTE</strong>: this is a possibly dangerous operation; do <strong>not</strong> use it unless you understand the implications (see <a href="git-rebase">git-rebase[1]</a> for details).</p> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt-branchltnamegtdescription"> branch.<name>.description </dt> <dd> <p>Branch description, can be edited with <code>git branch --edit-description</code>. Branch description is automatically added to the format-patch cover letter or request-pull summary.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-branch.txt-Startdevelopmentfromaknowntag"> Start development from a known tag </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6 +$ cd my2.6 +$ git branch my2.6.14 v2.6.14 (1) +$ git switch my2.6.14</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>This step and the next one could be combined into a single step with "checkout -b my2.6.14 v2.6.14".</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt-Deleteanunneededbranch"> Delete an unneeded branch </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git clone git://git.kernel.org/.../git.git my.git +$ cd my.git +$ git branch -d -r origin/todo origin/html origin/man (1) +$ git branch -D test (2)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>Delete the remote-tracking branches "todo", "html" and "man". The next <code>fetch</code> or <code>pull</code> will create them again unless you configure them not to. See <a href="git-fetch">git-fetch[1]</a>.</p> </li> <li> <p>Delete the "test" branch even if the "master" branch (or whichever branch is currently checked out) does not have all commits from the test branch.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/git-branch.txt-Listingbranchesfromaspecificremote"> Listing branches from a specific remote </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch -r -l '<remote>/<pattern>' (1) +$ git for-each-ref 'refs/remotes/<remote>/<pattern>' (2)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>Using <code>-a</code> would conflate <remote> with any local branches you happen to have been prefixed with the same <remote> pattern.</p> </li> <li> <p><code>for-each-ref</code> can take a wide range of options. See <a href="git-for-each-ref">git-for-each-ref[1]</a></p> </li> </ol> </div> </dd> </dl> </div> <p>Patterns will normally need quoting.</p> </div> <h2 id="_notes">Notes</h2> <div class="sectionbody"> <p>If you are creating a branch that you want to switch to immediately, it is easier to use the "git switch" command with its <code>-c</code> option to do the same thing with a single command.</p> <p>The options <code>--contains</code>, <code>--no-contains</code>, <code>--merged</code> and <code>--no-merged</code> serve four related but different purposes:</p> <div class="ulist"> <ul> <li> <p><code>--contains <commit></code> is used to find all branches which will need special attention if <commit> were to be rebased or amended, since those branches contain the specified <commit>.</p> </li> <li> <p><code>--no-contains <commit></code> is the inverse of that, i.e. branches that don’t contain the specified <commit>.</p> </li> <li> <p><code>--merged</code> is used to find all branches which can be safely deleted, since those branches are fully contained by HEAD.</p> </li> <li> <p><code>--no-merged</code> is used to find branches which are candidates for merging into HEAD, since those branches are not fully contained by HEAD.</p> </li> </ul> </div> <p>When combining multiple <code>--contains</code> and <code>--no-contains</code> filters, only references that contain at least one of the <code>--contains</code> commits and contain none of the <code>--no-contains</code> commits are shown.</p> <p>When combining multiple <code>--merged</code> and <code>--no-merged</code> filters, only references that are reachable from at least one of the <code>--merged</code> commits and from none of the <code>--no-merged</code> commits are shown.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-check-ref-format">git-check-ref-format[1]</a>, <a href="git-fetch">git-fetch[1]</a>, <a href="git-remote">git-remote[1]</a>, <a href="user-manual#what-is-a-branch">“Understanding history: What is a branch?”</a> in the Git User’s Manual.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-branch" class="_attribution-link">https://git-scm.com/docs/git-branch</a> + </p> +</div> diff --git a/devdocs/git/git-bugreport.html b/devdocs/git/git-bugreport.html new file mode 100644 index 00000000..bb2a1c96 --- /dev/null +++ b/devdocs/git/git-bugreport.html @@ -0,0 +1,7 @@ +<h1>git-bugreport</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-bugreport - Collect information for user to file a bug report</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git bugreport [(-o | --output-directory) <path>] [(-s | --suffix) <format>] + [--diagnose[=<mode>]]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Collects information about the user’s machine, Git client, and repository state, in addition to a form requesting information about the behavior the user observed, and stores it in a single text file which the user can then share, for example to the Git mailing list, in order to report an observed bug.</p> <p>The following information is requested from the user:</p> <div class="ulist"> <ul> <li> <p>Reproduction steps</p> </li> <li> <p>Expected behavior</p> </li> <li> <p>Actual behavior</p> </li> </ul> </div> <p>The following information is captured automatically:</p> <div class="ulist"> <ul> <li> <p><code>git version --build-options</code></p> </li> <li> <p>uname sysname, release, version, and machine strings</p> </li> <li> <p>Compiler-specific info string</p> </li> <li> <p>A list of enabled hooks</p> </li> <li> <p>$SHELL</p> </li> </ul> </div> <p>Additional information may be gathered into a separate zip archive using the <code>--diagnose</code> option, and can be attached alongside the bugreport document to provide additional context to readers.</p> <p>This tool is invoked via the typical Git setup process, which means that in some cases, it might not be able to launch - for example, if a relevant config file is unreadable. In this kind of scenario, it may be helpful to manually gather the kind of information listed above when manually asking for help.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-bugreport.txt--oltpathgt"> -o <path> </dt> <dt class="hdlist1" id="Documentation/git-bugreport.txt---output-directoryltpathgt"> --output-directory <path> </dt> <dd> <p>Place the resulting bug report file in <code><path></code> instead of the current directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-bugreport.txt--sltformatgt"> -s <format> </dt> <dt class="hdlist1" id="Documentation/git-bugreport.txt---suffixltformatgt"> --suffix <format> </dt> <dd> <p>Specify an alternate suffix for the bugreport name, to create a file named <code>git-bugreport-<formatted suffix></code>. This should take the form of a strftime(3) format string; the current local time will be used.</p> </dd> <dt class="hdlist1" id="Documentation/git-bugreport.txt---no-diagnose"> --no-diagnose </dt> <dt class="hdlist1" id="Documentation/git-bugreport.txt---diagnoseltmodegt"> --diagnose[=<mode>] </dt> <dd> <p>Create a zip archive of supplemental information about the user’s machine, Git client, and repository state. The archive is written to the same output directory as the bug report and is named <code>git-diagnostics-<formatted suffix></code>.</p> <p>Without <code>mode</code> specified, the diagnostic archive will contain the default set of statistics reported by <code>git diagnose</code>. An optional <code>mode</code> value may be specified to change which information is included in the archive. See <a href="git-diagnose">git-diagnose[1]</a> for the list of valid values for <code>mode</code> and details about their usage.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-bugreport" class="_attribution-link">https://git-scm.com/docs/git-bugreport</a> + </p> +</div> diff --git a/devdocs/git/git-bundle.html b/devdocs/git/git-bundle.html new file mode 100644 index 00000000..aed79026 --- /dev/null +++ b/devdocs/git/git-bundle.html @@ -0,0 +1,24 @@ +<h1>git-bundle</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-bundle - Move objects and refs by archive</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git bundle create [-q | --quiet | --progress] + [--version=<version>] <file> <git-rev-list-args> +git bundle verify [-q | --quiet] <file> +git bundle list-heads <file> [<refname>…] +git bundle unbundle [--progress] <file> [<refname>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Create, unpack, and manipulate "bundle" files. Bundles are used for the "offline" transfer of Git objects without an active "server" sitting on the other side of the network connection.</p> <p>They can be used to create both incremental and full backups of a repository, and to relay the state of the references in one repository to another.</p> <p>Git commands that fetch or otherwise "read" via protocols such as <code>ssh://</code> and <code>https://</code> can also operate on bundle files. It is possible <a href="git-clone">git-clone[1]</a> a new repository from a bundle, to use <a href="git-fetch">git-fetch[1]</a> to fetch from one, and to list the references contained within it with <a href="git-ls-remote">git-ls-remote[1]</a>. There’s no corresponding "write" support, i.e.a <code>git push</code> into a bundle is not supported.</p> <p>See the "EXAMPLES" section below for examples of how to use bundles.</p> </div> <h2 id="_bundle_format">Bundle format</h2> <div class="sectionbody"> <p>Bundles are <code>.pack</code> files (see <a href="git-pack-objects">git-pack-objects[1]</a>) with a header indicating what references are contained within the bundle.</p> <p>Like the packed archive format itself bundles can either be self-contained, or be created using exclusions. See the "OBJECT PREREQUISITES" section below.</p> <p>Bundles created using revision exclusions are "thin packs" created using the <code>--thin</code> option to <a href="git-pack-objects">git-pack-objects[1]</a>, and unbundled using the <code>--fix-thin</code> option to <a href="git-index-pack">git-index-pack[1]</a>.</p> <p>There is no option to create a "thick pack" when using revision exclusions, and users should not be concerned about the difference. By using "thin packs", bundles created using exclusions are smaller in size. That they’re "thin" under the hood is merely noted here as a curiosity, and as a reference to other documentation.</p> <p>See <a href="gitformat-bundle">gitformat-bundle[5]</a> for more details and the discussion of "thin pack" in <a href="gitformat-pack">gitformat-pack[5]</a> for further details.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-bundle.txt-createoptionsltfilegtltgit-rev-list-argsgt"> create [options] <file> <git-rev-list-args> </dt> <dd> <p>Used to create a bundle named <code>file</code>. This requires the <code><git-rev-list-args></code> arguments to define the bundle contents. <code>options</code> contains the options specific to the <code>git bundle create</code> subcommand. If <code>file</code> is <code>-</code>, the bundle is written to stdout.</p> </dd> <dt class="hdlist1" id="Documentation/git-bundle.txt-verifyltfilegt"> verify <file> </dt> <dd> <p>Used to check that a bundle file is valid and will apply cleanly to the current repository. This includes checks on the bundle format itself as well as checking that the prerequisite commits exist and are fully linked in the current repository. Then, <code>git bundle</code> prints a list of missing commits, if any. Finally, information about additional capabilities, such as "object filter", is printed. See "Capabilities" in <a href="gitformat-bundle">gitformat-bundle[5]</a> for more information. The exit code is zero for success, but will be nonzero if the bundle file is invalid. If <code>file</code> is <code>-</code>, the bundle is read from stdin.</p> </dd> <dt class="hdlist1" id="Documentation/git-bundle.txt-list-headsltfilegt"> list-heads <file> </dt> <dd> <p>Lists the references defined in the bundle. If followed by a list of references, only references matching those given are printed out. If <code>file</code> is <code>-</code>, the bundle is read from stdin.</p> </dd> <dt class="hdlist1" id="Documentation/git-bundle.txt-unbundleltfilegt"> unbundle <file> </dt> <dd> <p>Passes the objects in the bundle to <code>git index-pack</code> for storage in the repository, then prints the names of all defined references. If a list of references is given, only references matching those in the list are printed. This command is really plumbing, intended to be called only by <code>git fetch</code>. If <code>file</code> is <code>-</code>, the bundle is read from stdin.</p> </dd> <dt class="hdlist1" id="Documentation/git-bundle.txt-ltgit-rev-list-argsgt"> <git-rev-list-args> </dt> <dd> <p>A list of arguments, acceptable to <code>git rev-parse</code> and <code>git rev-list</code> (and containing a named ref, see SPECIFYING REFERENCES below), that specifies the specific objects and references to transport. For example, <code>master~10..master</code> causes the current master reference to be packaged along with all objects added since its 10th ancestor commit. There is no explicit limit to the number of references and objects that may be packaged.</p> </dd> <dt class="hdlist1" id="Documentation/git-bundle.txt-ltrefnamegt82308203"> [<refname>…] </dt> <dd> <p>A list of references used to limit the references reported as available. This is principally of use to <code>git fetch</code>, which expects to receive only those references asked for and not necessarily everything in the pack (in this case, <code>git bundle</code> acts like <code>git fetch-pack</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-bundle.txt---progress"> --progress </dt> <dd> <p>Progress status is reported on the standard error stream by default when it is attached to a terminal, unless -q is specified. This flag forces progress status even if the standard error stream is not directed to a terminal.</p> </dd> <dt class="hdlist1" id="Documentation/git-bundle.txt---versionltversiongt"> --version=<version> </dt> <dd> <p>Specify the bundle version. Version 2 is the older format and can only be used with SHA-1 repositories; the newer version 3 contains capabilities that permit extensions. The default is the oldest supported format, based on the hash algorithm in use.</p> </dd> <dt class="hdlist1" id="Documentation/git-bundle.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-bundle.txt---quiet"> --quiet </dt> <dd> <p>This flag makes the command not to report its progress on the standard error stream.</p> </dd> </dl> </div> </div> <h2 id="_specifying_references">Specifying references</h2> <div class="sectionbody"> <p>Revisions must be accompanied by reference names to be packaged in a bundle.</p> <p>More than one reference may be packaged, and more than one set of prerequisite objects can be specified. The objects packaged are those not contained in the union of the prerequisites.</p> <p>The <code>git bundle create</code> command resolves the reference names for you using the same rules as <code>git rev-parse --abbrev-ref=loose</code>. Each prerequisite can be specified explicitly (e.g. <code>^master~10</code>), or implicitly (e.g. <code>master~10..master</code>, <code>--since=10.days.ago master</code>).</p> <p>All of these simple cases are OK (assuming we have a "master" and "next" branch):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bundle create master.bundle master +$ echo master | git bundle create master.bundle --stdin +$ git bundle create master-and-next.bundle master next +$ (echo master; echo next) | git bundle create master-and-next.bundle --stdin</pre> </div> </div> <p>And so are these (and the same but omitted <code>--stdin</code> examples):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bundle create recent-master.bundle master~10..master +$ git bundle create recent-updates.bundle master~10..master next~5..next</pre> </div> </div> <p>A revision name or a range whose right-hand-side cannot be resolved to a reference is not accepted:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bundle create HEAD.bundle $(git rev-parse HEAD) +fatal: Refusing to create empty bundle. +$ git bundle create master-yesterday.bundle master~10..master~5 +fatal: Refusing to create empty bundle.</pre> </div> </div> </div> <h2 id="_object_prerequisites">Object prerequisites</h2> <div class="sectionbody"> <p>When creating bundles it is possible to create a self-contained bundle that can be unbundled in a repository with no common history, as well as providing negative revisions to exclude objects needed in the earlier parts of the history.</p> <p>Feeding a revision such as <code>new</code> to <code>git bundle create</code> will create a bundle file that contains all the objects reachable from the revision <code>new</code>. That bundle can be unbundled in any repository to obtain a full history that leads to the revision <code>new</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bundle create full.bundle new</pre> </div> </div> <p>A revision range such as <code>old..new</code> will produce a bundle file that will require the revision <code>old</code> (and any objects reachable from it) to exist for the bundle to be "unbundle"-able:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bundle create full.bundle old..new</pre> </div> </div> <p>A self-contained bundle without any prerequisites can be extracted into anywhere, even into an empty repository, or be cloned from (i.e., <code>new</code>, but not <code>old..new</code>).</p> <p>It is okay to err on the side of caution, causing the bundle file to contain objects already in the destination, as these are ignored when unpacking at the destination.</p> <p>If you want to match <code>git clone --mirror</code>, which would include your refs such as <code>refs/remotes/*</code>, use <code>--all</code>. If you want to provide the same set of refs that a clone directly from the source repository would get, use <code>--branches --tags</code> for the <code><git-rev-list-args></code>.</p> <p>The <code>git bundle verify</code> command can be used to check whether your recipient repository has the required prerequisite commits for a bundle.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>Assume you want to transfer the history from a repository R1 on machine A to another repository R2 on machine B. For whatever reason, direct connection between A and B is not allowed, but we can move data from A to B via some mechanism (CD, email, etc.). We want to update R2 with development made on the branch master in R1.</p> <p>To bootstrap the process, you can first create a bundle that does not have any prerequisites. You can use a tag to remember up to what commit you last processed, in order to make it easy to later update the other repository with an incremental bundle:</p> <div class="listingblock"> <div class="content"> <pre>machineA$ cd R1 +machineA$ git bundle create file.bundle master +machineA$ git tag -f lastR2bundle master</pre> </div> </div> <p>Then you transfer file.bundle to the target machine B. Because this bundle does not require any existing object to be extracted, you can create a new repository on machine B by cloning from it:</p> <div class="listingblock"> <div class="content"> <pre>machineB$ git clone -b master /home/me/tmp/file.bundle R2</pre> </div> </div> <p>This will define a remote called "origin" in the resulting repository that lets you fetch and pull from the bundle. The $GIT_DIR/config file in R2 will have an entry like this:</p> <div class="listingblock"> <div class="content"> <pre>[remote "origin"] + url = /home/me/tmp/file.bundle + fetch = refs/heads/*:refs/remotes/origin/*</pre> </div> </div> <p>To update the resulting mine.git repository, you can fetch or pull after replacing the bundle stored at /home/me/tmp/file.bundle with incremental updates.</p> <p>After working some more in the original repository, you can create an incremental bundle to update the other repository:</p> <div class="listingblock"> <div class="content"> <pre>machineA$ cd R1 +machineA$ git bundle create file.bundle lastR2bundle..master +machineA$ git tag -f lastR2bundle master</pre> </div> </div> <p>You then transfer the bundle to the other machine to replace /home/me/tmp/file.bundle, and pull from it.</p> <div class="listingblock"> <div class="content"> <pre>machineB$ cd R2 +machineB$ git pull</pre> </div> </div> <p>If you know up to what commit the intended recipient repository should have the necessary objects, you can use that knowledge to specify the prerequisites, giving a cut-off point to limit the revisions and objects that go in the resulting bundle. The previous example used the lastR2bundle tag for this purpose, but you can use any other options that you would give to the <a href="git-log">git-log[1]</a> command. Here are more examples:</p> <p>You can use a tag that is present in both:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bundle create mybundle v1.0.0..master</pre> </div> </div> <p>You can use a prerequisite based on time:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bundle create mybundle --since=10.days master</pre> </div> </div> <p>You can use the number of commits:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bundle create mybundle -10 master</pre> </div> </div> <p>You can run <code>git-bundle verify</code> to see if you can extract from a bundle that was created with a prerequisite:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bundle verify mybundle</pre> </div> </div> <p>This will list what commits you must have in order to extract from the bundle and will error out if you do not have them.</p> <p>A bundle from a recipient repository’s point of view is just like a regular repository which it fetches or pulls from. You can, for example, map references when fetching:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch mybundle master:localRef</pre> </div> </div> <p>You can also see what references it offers:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-remote mybundle</pre> </div> </div> </div> <h2 id="_file_format">File format</h2> <div class="sectionbody"> <p>See <a href="gitformat-bundle">gitformat-bundle[5]</a>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-bundle" class="_attribution-link">https://git-scm.com/docs/git-bundle</a> + </p> +</div> diff --git a/devdocs/git/git-cat-file.html b/devdocs/git/git-cat-file.html new file mode 100644 index 00000000..7c87e32e --- /dev/null +++ b/devdocs/git/git-cat-file.html @@ -0,0 +1,25 @@ +<h1>git-cat-file</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-cat-file - Provide contents or details of repository objects</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git cat-file <type> <object> +git cat-file (-e | -p) <object> +git cat-file (-t | -s) [--allow-unknown-type] <object> +git cat-file (--textconv | --filters) + [<rev>:<path|tree-ish> | --path=<path|tree-ish> <rev>] +git cat-file (--batch | --batch-check | --batch-command) [--batch-all-objects] + [--buffer] [--follow-symlinks] [--unordered] + [--textconv | --filters] [-Z]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Output the contents or other properties such as size, type or delta information of one or more objects.</p> <p>This command can operate in two modes, depending on whether an option from the <code>--batch</code> family is specified.</p> <p>In non-batch mode, the command provides information on an object named on the command line.</p> <p>In batch mode, arguments are read from standard input.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cat-file.txt-ltobjectgt"> <object> </dt> <dd> <p>The name of the object to show. For a more complete list of ways to spell object names, see the "SPECIFYING REVISIONS" section in <a href="gitrevisions">gitrevisions[7]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt--t"> -t </dt> <dd> <p>Instead of the content, show the object type identified by <code><object></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt--s"> -s </dt> <dd> <p>Instead of the content, show the object size identified by <code><object></code>. If used with <code>--use-mailmap</code> option, will show the size of updated object after replacing idents using the mailmap mechanism.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt--e"> -e </dt> <dd> <p>Exit with zero status if <code><object></code> exists and is a valid object. If <code><object></code> is of an invalid format, exit with non-zero status and emit an error on stderr.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt--p"> -p </dt> <dd> <p>Pretty-print the contents of <code><object></code> based on its type.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt-lttypegt"> <type> </dt> <dd> <p>Typically this matches the real type of <code><object></code> but asking for a type that can trivially be dereferenced from the given <code><object></code> is also permitted. An example is to ask for a "tree" with <code><object></code> being a commit object that contains it, or to ask for a "blob" with <code><object></code> being a tag object that points at it.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt---no-mailmap"> --[no-]mailmap </dt> <dt class="hdlist1" id="Documentation/git-cat-file.txt---no-use-mailmap"> --[no-]use-mailmap </dt> <dd> <p>Use mailmap file to map author, committer and tagger names and email addresses to canonical real names and email addresses. See <a href="git-shortlog">git-shortlog[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt---textconv"> --textconv </dt> <dd> <p>Show the content as transformed by a textconv filter. In this case, <code><object></code> has to be of the form <code><tree-ish>:<path></code>, or <code>:<path></code> in order to apply the filter to the content recorded in the index at <code><path></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt---filters"> --filters </dt> <dd> <p>Show the content as converted by the filters configured in the current working tree for the given <code><path></code> (i.e. smudge filters, end-of-line conversion, etc). In this case, <code><object></code> has to be of the form <code><tree-ish>:<path></code>, or <code>:<path></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt---pathltpathgt"> --path=<path> </dt> <dd> <p>For use with <code>--textconv</code> or <code>--filters</code>, to allow specifying an object name and a path separately, e.g. when it is difficult to figure out the revision from which the blob came.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt---batch"> --batch </dt> <dt class="hdlist1" id="Documentation/git-cat-file.txt---batchltformatgt"> --batch=<format> </dt> <dd> <p>Print object information and contents for each object provided on stdin. May not be combined with any other options or arguments except <code>--textconv</code>, <code>--filters</code>, or <code>--use-mailmap</code>.</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>When used with <code>--textconv</code> or <code>--filters</code>, the input lines must specify the path, separated by whitespace. See the section <code>BATCH OUTPUT</code> below for details.</p> </li> <li> <p>When used with <code>--use-mailmap</code>, for commit and tag objects, the contents part of the output shows the identities replaced using the mailmap mechanism, while the information part of the output shows the size of the object as if it actually recorded the replacement identities.</p> </li> </ul> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt---batch-check"> --batch-check </dt> <dt class="hdlist1" id="Documentation/git-cat-file.txt---batch-checkltformatgt"> --batch-check=<format> </dt> <dd> <p>Print object information for each object provided on stdin. May not be combined with any other options or arguments except <code>--textconv</code>, <code>--filters</code> or <code>--use-mailmap</code>.</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>When used with <code>--textconv</code> or <code>--filters</code>, the input lines must specify the path, separated by whitespace. See the section <code>BATCH OUTPUT</code> below for details.</p> </li> <li> <p>When used with <code>--use-mailmap</code>, for commit and tag objects, the printed object information shows the size of the object as if the identities recorded in it were replaced by the mailmap mechanism.</p> </li> </ul> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt---batch-command"> --batch-command </dt> <dt class="hdlist1" id="Documentation/git-cat-file.txt---batch-commandltformatgt"> --batch-command=<format> </dt> <dd> <p>Enter a command mode that reads commands and arguments from stdin. May only be combined with <code>--buffer</code>, <code>--textconv</code>, <code>--use-mailmap</code> or <code>--filters</code>.</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>When used with <code>--textconv</code> or <code>--filters</code>, the input lines must specify the path, separated by whitespace. See the section <code>BATCH OUTPUT</code> below for details.</p> </li> <li> <p>When used with <code>--use-mailmap</code>, for commit and tag objects, the <code>contents</code> command shows the identities replaced using the mailmap mechanism, while the <code>info</code> command shows the size of the object as if it actually recorded the replacement identities.</p> </li> </ul> </div> </div> </div> <p><code>--batch-command</code> recognizes the following commands:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cat-file.txt-contentsltobjectgt"> contents <object> </dt> <dd> <p>Print object contents for object reference <code><object></code>. This corresponds to the output of <code>--batch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt-infoltobjectgt"> info <object> </dt> <dd> <p>Print object info for object reference <code><object></code>. This corresponds to the output of <code>--batch-check</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt-flush"> flush </dt> <dd> <p>Used with <code>--buffer</code> to execute all preceding commands that were issued since the beginning or since the last flush was issued. When <code>--buffer</code> is used, no output will come until a <code>flush</code> is issued. When <code>--buffer</code> is not used, commands are flushed each time without issuing <code>flush</code>.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt---batch-all-objects"> --batch-all-objects </dt> <dd> <p>Instead of reading a list of objects on stdin, perform the requested batch operation on all objects in the repository and any alternate object stores (not just reachable objects). Requires <code>--batch</code> or <code>--batch-check</code> be specified. By default, the objects are visited in order sorted by their hashes; see also <code>--unordered</code> below. Objects are presented as-is, without respecting the "replace" mechanism of <a href="git-replace">git-replace[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt---buffer"> --buffer </dt> <dd> <p>Normally batch output is flushed after each object is output, so that a process can interactively read and write from <code>cat-file</code>. With this option, the output uses normal stdio buffering; this is much more efficient when invoking <code>--batch-check</code> or <code>--batch-command</code> on a large number of objects.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt---unordered"> --unordered </dt> <dd> <p>When <code>--batch-all-objects</code> is in use, visit objects in an order which may be more efficient for accessing the object contents than hash order. The exact details of the order are unspecified, but if you do not require a specific order, this should generally result in faster output, especially with <code>--batch</code>. Note that <code>cat-file</code> will still show each object only once, even if it is stored multiple times in the repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt---allow-unknown-type"> --allow-unknown-type </dt> <dd> <p>Allow <code>-s</code> or <code>-t</code> to query broken/corrupt objects of unknown type.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt---follow-symlinks"> --follow-symlinks </dt> <dd> <p>With <code>--batch</code> or <code>--batch-check</code>, follow symlinks inside the repository when requesting objects with extended SHA-1 expressions of the form tree-ish:path-in-tree. Instead of providing output about the link itself, provide output about the linked-to object. If a symlink points outside the tree-ish (e.g. a link to <code>/foo</code> or a root-level link to <code>../foo</code>), the portion of the link which is outside the tree will be printed.</p> <p>This option does not (currently) work correctly when an object in the index is specified (e.g. <code>:link</code> instead of <code>HEAD:link</code>) rather than one in the tree.</p> <p>This option cannot (currently) be used unless <code>--batch</code> or <code>--batch-check</code> is used.</p> <p>For example, consider a git repository containing:</p> <div class="openblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre>f: a file containing "hello\n" +link: a symlink to f +dir/link: a symlink to ../f +plink: a symlink to ../f +alink: a symlink to /etc/passwd</pre> </div> </div> </div> </div> <p>For a regular file <code>f</code>, <code>echo HEAD:f | git cat-file --batch</code> would print</p> <div class="openblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre>ce013625030ba8dba906f756967f9e9ca394464a blob 6</pre> </div> </div> </div> </div> <p>And <code>echo HEAD:link | git cat-file --batch --follow-symlinks</code> would print the same thing, as would <code>HEAD:dir/link</code>, as they both point at <code>HEAD:f</code>.</p> <p>Without <code>--follow-symlinks</code>, these would print data about the symlink itself. In the case of <code>HEAD:link</code>, you would see</p> <div class="openblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre>4d1ae35ba2c8ec712fa2a379db44ad639ca277bd blob 1</pre> </div> </div> </div> </div> <p>Both <code>plink</code> and <code>alink</code> point outside the tree, so they would respectively print:</p> <div class="openblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre>symlink 4 +../f</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>symlink 11 +/etc/passwd</pre> </div> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt--Z"> -Z </dt> <dd> <p>Only meaningful with <code>--batch</code>, <code>--batch-check</code>, or <code>--batch-command</code>; input and output is NUL-delimited instead of newline-delimited.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt--z"> -z </dt> <dd> <p>Only meaningful with <code>--batch</code>, <code>--batch-check</code>, or <code>--batch-command</code>; input is NUL-delimited instead of newline-delimited. This option is deprecated in favor of <code>-Z</code> as the output can otherwise be ambiguous.</p> </dd> </dl> </div> </div> <h2 id="_output">Output</h2> <div class="sectionbody"> <p>If <code>-t</code> is specified, one of the <code><type></code>.</p> <p>If <code>-s</code> is specified, the size of the <code><object></code> in bytes.</p> <p>If <code>-e</code> is specified, no output, unless the <code><object></code> is malformed.</p> <p>If <code>-p</code> is specified, the contents of <code><object></code> are pretty-printed.</p> <p>If <code><type></code> is specified, the raw (though uncompressed) contents of the <code><object></code> will be returned.</p> </div> <h2 id="_batch_output">Batch output</h2> <div class="sectionbody"> <p>If <code>--batch</code> or <code>--batch-check</code> is given, <code>cat-file</code> will read objects from stdin, one per line, and print information about them. By default, the whole line is considered as an object, as if it were fed to <a href="git-rev-parse">git-rev-parse[1]</a>.</p> <p>When <code>--batch-command</code> is given, <code>cat-file</code> will read commands from stdin, one per line, and print information based on the command given. With <code>--batch-command</code>, the <code>info</code> command followed by an object will print information about the object the same way <code>--batch-check</code> would, and the <code>contents</code> command followed by an object prints contents in the same way <code>--batch</code> would.</p> <p>You can specify the information shown for each object by using a custom <code><format></code>. The <code><format></code> is copied literally to stdout for each object, with placeholders of the form <code>%(atom)</code> expanded, followed by a newline. The available atoms are:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cat-file.txt-codeobjectnamecode"> <code>objectname</code> </dt> <dd> <p>The full hex representation of the object name.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt-codeobjecttypecode"> <code>objecttype</code> </dt> <dd> <p>The type of the object (the same as <code>cat-file -t</code> reports).</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt-codeobjectsizecode"> <code>objectsize</code> </dt> <dd> <p>The size, in bytes, of the object (the same as <code>cat-file -s</code> reports).</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt-codeobjectsizediskcode"> <code>objectsize:disk</code> </dt> <dd> <p>The size, in bytes, that the object takes up on disk. See the note about on-disk sizes in the <code>CAVEATS</code> section below.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt-codedeltabasecode"> <code>deltabase</code> </dt> <dd> <p>If the object is stored as a delta on-disk, this expands to the full hex representation of the delta base object name. Otherwise, expands to the null OID (all zeroes). See <code>CAVEATS</code> below.</p> </dd> <dt class="hdlist1" id="Documentation/git-cat-file.txt-coderestcode"> <code>rest</code> </dt> <dd> <p>If this atom is used in the output string, input lines are split at the first whitespace boundary. All characters before that whitespace are considered to be the object name; characters after that first run of whitespace (i.e., the "rest" of the line) are output in place of the <code>%(rest)</code> atom.</p> </dd> </dl> </div> <p>If no format is specified, the default format is <code>%(objectname) +%(objecttype) %(objectsize)</code>.</p> <p>If <code>--batch</code> is specified, or if <code>--batch-command</code> is used with the <code>contents</code> command, the object information is followed by the object contents (consisting of <code>%(objectsize)</code> bytes), followed by a newline.</p> <p>For example, <code>--batch</code> without a custom format would produce:</p> <div class="listingblock"> <div class="content"> <pre><oid> SP <type> SP <size> LF +<contents> LF</pre> </div> </div> <p>Whereas <code>--batch-check='%(objectname) %(objecttype)'</code> would produce:</p> <div class="listingblock"> <div class="content"> <pre><oid> SP <type> LF</pre> </div> </div> <p>If a name is specified on stdin that cannot be resolved to an object in the repository, then <code>cat-file</code> will ignore any custom format and print:</p> <div class="listingblock"> <div class="content"> <pre><object> SP missing LF</pre> </div> </div> <p>If a name is specified that might refer to more than one object (an ambiguous short sha), then <code>cat-file</code> will ignore any custom format and print:</p> <div class="listingblock"> <div class="content"> <pre><object> SP ambiguous LF</pre> </div> </div> <p>If <code>--follow-symlinks</code> is used, and a symlink in the repository points outside the repository, then <code>cat-file</code> will ignore any custom format and print:</p> <div class="listingblock"> <div class="content"> <pre>symlink SP <size> LF +<symlink> LF</pre> </div> </div> <p>The symlink will either be absolute (beginning with a <code>/</code>), or relative to the tree root. For instance, if dir/link points to <code>../../foo</code>, then <code><symlink></code> will be <code>../foo</code>. <code><size></code> is the size of the symlink in bytes.</p> <p>If <code>--follow-symlinks</code> is used, the following error messages will be displayed:</p> <div class="listingblock"> <div class="content"> <pre><object> SP missing LF</pre> </div> </div> <p>is printed when the initial symlink requested does not exist.</p> <div class="listingblock"> <div class="content"> <pre>dangling SP <size> LF +<object> LF</pre> </div> </div> <p>is printed when the initial symlink exists, but something that it (transitive-of) points to does not.</p> <div class="listingblock"> <div class="content"> <pre>loop SP <size> LF +<object> LF</pre> </div> </div> <p>is printed for symlink loops (or any symlinks that require more than 40 link resolutions to resolve).</p> <div class="listingblock"> <div class="content"> <pre>notdir SP <size> LF +<object> LF</pre> </div> </div> <p>is printed when, during symlink resolution, a file is used as a directory name.</p> <p>Alternatively, when <code>-Z</code> is passed, the line feeds in any of the above examples are replaced with NUL terminators. This ensures that output will be parsable if the output itself would contain a linefeed and is thus recommended for scripting purposes.</p> </div> <h2 id="_caveats">Caveats</h2> <div class="sectionbody"> <p>Note that the sizes of objects on disk are reported accurately, but care should be taken in drawing conclusions about which refs or objects are responsible for disk usage. The size of a packed non-delta object may be much larger than the size of objects which delta against it, but the choice of which object is the base and which is the delta is arbitrary and is subject to change during a repack.</p> <p>Note also that multiple copies of an object may be present in the object database; in this case, it is undefined which copy’s size or delta base will be reported.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-cat-file" class="_attribution-link">https://git-scm.com/docs/git-cat-file</a> + </p> +</div> diff --git a/devdocs/git/git-check-attr.html b/devdocs/git/git-check-attr.html new file mode 100644 index 00000000..99961732 --- /dev/null +++ b/devdocs/git/git-check-attr.html @@ -0,0 +1,18 @@ +<h1>git-check-attr</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-check-attr - Display gitattributes information</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git check-attr [--source <tree-ish>] [-a | --all | <attr>…] [--] <pathname>… +git check-attr --stdin [-z] [--source <tree-ish>] [-a | --all | <attr>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>For every pathname, this command will list if each attribute is <code>unspecified</code>, <code>set</code>, or <code>unset</code> as a gitattribute on that pathname.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-check-attr.txt--a--all"> -a, --all </dt> <dd> <p>List all attributes that are associated with the specified paths. If this option is used, then <code>unspecified</code> attributes will not be included in the output.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt---cached"> --cached </dt> <dd> <p>Consider <code>.gitattributes</code> in the index only, ignoring the working tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt---stdin"> --stdin </dt> <dd> <p>Read pathnames from the standard input, one per line, instead of from the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt--z"> -z </dt> <dd> <p>The output format is modified to be machine-parsable. If <code>--stdin</code> is also given, input paths are separated with a NUL character instead of a linefeed character.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt---sourcelttree-ishgt"> --source=<tree-ish> </dt> <dd> <p>Check attributes against the specified tree-ish. It is common to specify the source tree by naming a commit, branch, or tag associated with it.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt---"> -- </dt> <dd> <p>Interpret all preceding arguments as attributes and all following arguments as path names.</p> </dd> </dl> </div> <p>If none of <code>--stdin</code>, <code>--all</code>, or <code>--</code> is used, the first argument will be treated as an attribute and the rest of the arguments as pathnames.</p> </div> <h2 id="_output">Output</h2> <div class="sectionbody"> <p>The output is of the form: <path> COLON SP <attribute> COLON SP <info> LF</p> <p>unless <code>-z</code> is in effect, in which case NUL is used as delimiter: <path> NUL <attribute> NUL <info> NUL</p> <p><path> is the path of a file being queried, <attribute> is an attribute being queried, and <info> can be either:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-check-attr.txt-emunspecifiedem"> <em>unspecified</em> </dt> <dd> <p>when the attribute is not defined for the path.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt-emunsetem"> <em>unset</em> </dt> <dd> <p>when the attribute is defined as false.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt-emsetem"> <em>set</em> </dt> <dd> <p>when the attribute is defined as true.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt-ltvaluegt"> <value> </dt> <dd> <p>when a value has been assigned to the attribute.</p> </dd> </dl> </div> <p>Buffering happens as documented under the <code>GIT_FLUSH</code> option in <a href="git">git[1]</a>. The caller is responsible for avoiding deadlocks caused by overfilling an input buffer or reading from an empty output buffer.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>In the examples, the following <code>.gitattributes</code> file is used:</p> <div class="listingblock"> <div class="content"> <pre>*.java diff=java -crlf myAttr +NoMyAttr.java !myAttr +README caveat=unspecified</pre> </div> </div> <div class="ulist"> <ul> <li> <p>Listing a single attribute:</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git check-attr diff org/example/MyClass.java +org/example/MyClass.java: diff: java</pre> </div> </div> <div class="ulist"> <ul> <li> <p>Listing multiple attributes for a file:</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git check-attr crlf diff myAttr -- org/example/MyClass.java +org/example/MyClass.java: crlf: unset +org/example/MyClass.java: diff: java +org/example/MyClass.java: myAttr: set</pre> </div> </div> <div class="ulist"> <ul> <li> <p>Listing all attributes for a file:</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git check-attr --all -- org/example/MyClass.java +org/example/MyClass.java: diff: java +org/example/MyClass.java: myAttr: set</pre> </div> </div> <div class="ulist"> <ul> <li> <p>Listing an attribute for multiple files:</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git check-attr myAttr -- org/example/MyClass.java org/example/NoMyAttr.java +org/example/MyClass.java: myAttr: set +org/example/NoMyAttr.java: myAttr: unspecified</pre> </div> </div> <div class="ulist"> <ul> <li> <p>Not all values are equally unambiguous:</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git check-attr caveat README +README: caveat: unspecified</pre> </div> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gitattributes">gitattributes[5]</a>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-check-attr" class="_attribution-link">https://git-scm.com/docs/git-check-attr</a> + </p> +</div> diff --git a/devdocs/git/git-check-ignore.html b/devdocs/git/git-check-ignore.html new file mode 100644 index 00000000..4f2f6465 --- /dev/null +++ b/devdocs/git/git-check-ignore.html @@ -0,0 +1,7 @@ +<h1>git-check-ignore</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-check-ignore - Debug gitignore / exclude files</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git check-ignore [<options>] <pathname>… +git check-ignore [<options>] --stdin</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>For each pathname given via the command-line or from a file via <code>--stdin</code>, check whether the file is excluded by .gitignore (or other input files to the exclude mechanism) and output the path if it is excluded.</p> <p>By default, tracked files are not shown at all since they are not subject to exclude rules; but see ‘--no-index’.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-check-ignore.txt--q--quiet"> -q, --quiet </dt> <dd> <p>Don’t output anything, just set exit status. This is only valid with a single pathname.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-ignore.txt--v--verbose"> -v, --verbose </dt> <dd> <p>Instead of printing the paths that are excluded, for each path that matches an exclude pattern, print the exclude pattern together with the path. (Matching an exclude pattern usually means the path is excluded, but if the pattern begins with "<code>!</code>" then it is a negated pattern and matching it means the path is NOT excluded.)</p> <p>For precedence rules within and between exclude sources, see <a href="gitignore">gitignore[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-ignore.txt---stdin"> --stdin </dt> <dd> <p>Read pathnames from the standard input, one per line, instead of from the command-line.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-ignore.txt--z"> -z </dt> <dd> <p>The output format is modified to be machine-parsable (see below). If <code>--stdin</code> is also given, input paths are separated with a NUL character instead of a linefeed character.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-ignore.txt--n--non-matching"> -n, --non-matching </dt> <dd> <p>Show given paths which don’t match any pattern. This only makes sense when <code>--verbose</code> is enabled, otherwise it would not be possible to distinguish between paths which match a pattern and those which don’t.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-ignore.txt---no-index"> --no-index </dt> <dd> <p>Don’t look in the index when undertaking the checks. This can be used to debug why a path became tracked by e.g. <code>git add .</code> and was not ignored by the rules as expected by the user or when developing patterns including negation to match a path previously added with <code>git add -f</code>.</p> </dd> </dl> </div> </div> <h2 id="_output">Output</h2> <div class="sectionbody"> <p>By default, any of the given pathnames which match an ignore pattern will be output, one per line. If no pattern matches a given path, nothing will be output for that path; this means that path will not be ignored.</p> <p>If <code>--verbose</code> is specified, the output is a series of lines of the form:</p> <p><source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname></p> <p><pathname> is the path of a file being queried, <pattern> is the matching pattern, <source> is the pattern’s source file, and <linenum> is the line number of the pattern within that source. If the pattern contained a "<code>!</code>" prefix or "<code>/</code>" suffix, it will be preserved in the output. <source> will be an absolute path when referring to the file configured by <code>core.excludesFile</code>, or relative to the repository root when referring to <code>.git/info/exclude</code> or a per-directory exclude file.</p> <p>If <code>-z</code> is specified, the pathnames in the output are delimited by the null character; if <code>--verbose</code> is also specified then null characters are also used instead of colons and hard tabs:</p> <p><source> <NULL> <linenum> <NULL> <pattern> <NULL> <pathname> <NULL></p> <p>If <code>-n</code> or <code>--non-matching</code> are specified, non-matching pathnames will also be output, in which case all fields in each output record except for <pathname> will be empty. This can be useful when running non-interactively, so that files can be incrementally streamed to STDIN of a long-running check-ignore process, and for each of these files, STDOUT will indicate whether that file matched a pattern or not. (Without this option, it would be impossible to tell whether the absence of output for a given file meant that it didn’t match any pattern, or that the output hadn’t been generated yet.)</p> <p>Buffering happens as documented under the <code>GIT_FLUSH</code> option in <a href="git">git[1]</a>. The caller is responsible for avoiding deadlocks caused by overfilling an input buffer or reading from an empty output buffer.</p> </div> <h2 id="_exit_status">Exit status</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-check-ignore.txt-0"> 0 </dt> <dd> <p>One or more of the provided paths is ignored.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-ignore.txt-1"> 1 </dt> <dd> <p>None of the provided paths are ignored.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-ignore.txt-128"> 128 </dt> <dd> <p>A fatal error was encountered.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gitignore">gitignore[5]</a> <a href="git-config">git-config[1]</a> <a href="git-ls-files">git-ls-files[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-check-ignore" class="_attribution-link">https://git-scm.com/docs/git-check-ignore</a> + </p> +</div> diff --git a/devdocs/git/git-check-mailmap.html b/devdocs/git/git-check-mailmap.html new file mode 100644 index 00000000..c9de4506 --- /dev/null +++ b/devdocs/git/git-check-mailmap.html @@ -0,0 +1,6 @@ +<h1>git-check-mailmap</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-check-mailmap - Show canonical names and email addresses of contacts</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git check-mailmap [<options>] <contact>…</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>For each “Name <user@host>” or “<user@host>” from the command-line or standard input (when using <code>--stdin</code>), look up the person’s canonical name and email address (see "Mapping Authors" below). If found, print them; otherwise print the input as-is.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-check-mailmap.txt---stdin"> --stdin </dt> <dd> <p>Read contacts, one per line, from the standard input after exhausting contacts provided on the command-line.</p> </dd> </dl> </div> </div> <h2 id="_output">Output</h2> <div class="sectionbody"> <p>For each contact, a single line is output, terminated by a newline. If the name is provided or known to the <code>mailmap</code>, “Name <user@host>” is printed; otherwise only “<user@host>” is printed.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>See <code>mailmap.file</code> and <code>mailmap.blob</code> in <a href="git-config">git-config[1]</a> for how to specify a custom <code>.mailmap</code> target file or object.</p> </div> <h2 id="_mapping_authors">Mapping authors</h2> <div class="sectionbody"> <p>See <a href="gitmailmap">gitmailmap[5]</a>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-check-mailmap" class="_attribution-link">https://git-scm.com/docs/git-check-mailmap</a> + </p> +</div> diff --git a/devdocs/git/git-check-ref-format.html b/devdocs/git/git-check-ref-format.html new file mode 100644 index 00000000..713418ee --- /dev/null +++ b/devdocs/git/git-check-ref-format.html @@ -0,0 +1,10 @@ +<h1>git-check-ref-format</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-check-ref-format - Ensures that a reference name is well formed</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git check-ref-format [--normalize] + [--[no-]allow-onelevel] [--refspec-pattern] + <refname> +git check-ref-format --branch <branchname-shorthand></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Checks if a given <code>refname</code> is acceptable, and exits with a non-zero status if it is not.</p> <p>A reference is used in Git to specify branches and tags. A branch head is stored in the <code>refs/heads</code> hierarchy, while a tag is stored in the <code>refs/tags</code> hierarchy of the ref namespace (typically in <code>$GIT_DIR/refs/heads</code> and <code>$GIT_DIR/refs/tags</code> directories or, as entries in file <code>$GIT_DIR/packed-refs</code> if refs are packed by <code>git gc</code>).</p> <p>Git imposes the following rules on how references are named:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>They can include slash <code>/</code> for hierarchical (directory) grouping, but no slash-separated component can begin with a dot <code>.</code> or end with the sequence <code>.lock</code>.</p> </li> <li> <p>They must contain at least one <code>/</code>. This enforces the presence of a category like <code>heads/</code>, <code>tags/</code> etc. but the actual names are not restricted. If the <code>--allow-onelevel</code> option is used, this rule is waived.</p> </li> <li> <p>They cannot have two consecutive dots <code>..</code> anywhere.</p> </li> <li> <p>They cannot have ASCII control characters (i.e. bytes whose values are lower than \040, or \177 <code>DEL</code>), space, tilde <code>~</code>, caret <code>^</code>, or colon <code>:</code> anywhere.</p> </li> <li> <p>They cannot have question-mark <code>?</code>, asterisk <code>*</code>, or open bracket <code>[</code> anywhere. See the <code>--refspec-pattern</code> option below for an exception to this rule.</p> </li> <li> <p>They cannot begin or end with a slash <code>/</code> or contain multiple consecutive slashes (see the <code>--normalize</code> option below for an exception to this rule).</p> </li> <li> <p>They cannot end with a dot <code>.</code>.</p> </li> <li> <p>They cannot contain a sequence <code>@{</code>.</p> </li> <li> <p>They cannot be the single character <code>@</code>.</p> </li> <li> <p>They cannot contain a <code>\</code>.</p> </li> </ol> </div> <p>These rules make it easy for shell script based tools to parse reference names, pathname expansion by the shell when a reference name is used unquoted (by mistake), and also avoid ambiguities in certain reference name expressions (see <a href="gitrevisions">gitrevisions[7]</a>):</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>A double-dot <code>..</code> is often used as in <code>ref1..ref2</code>, and in some contexts this notation means <code>^ref1 ref2</code> (i.e. not in <code>ref1</code> and in <code>ref2</code>).</p> </li> <li> <p>A tilde <code>~</code> and caret <code>^</code> are used to introduce the postfix <code>nth parent</code> and <code>peel onion</code> operation.</p> </li> <li> <p>A colon <code>:</code> is used as in <code>srcref:dstref</code> to mean "use srcref’s value and store it in dstref" in fetch and push operations. It may also be used to select a specific object such as with 'git cat-file': "git cat-file blob v1.3.3:refs.c".</p> </li> <li> <p>at-open-brace <code>@{</code> is used as a notation to access a reflog entry.</p> </li> </ol> </div> <p>With the <code>--branch</code> option, the command takes a name and checks if it can be used as a valid branch name (e.g. when creating a new branch). But be cautious when using the previous checkout syntax that may refer to a detached HEAD state. The rule <code>git check-ref-format --branch $name</code> implements may be stricter than what <code>git check-ref-format refs/heads/$name</code> says (e.g. a dash may appear at the beginning of a ref component, but it is explicitly forbidden at the beginning of a branch name). When run with the <code>--branch</code> option in a repository, the input is first expanded for the “previous checkout syntax” <code>@{-n}</code>. For example, <code>@{-1}</code> is a way to refer the last thing that was checked out using "git switch" or "git checkout" operation. This option should be used by porcelains to accept this syntax anywhere a branch name is expected, so they can act as if you typed the branch name. As an exception note that, the “previous checkout operation” might result in a commit object name when the N-th last thing checked out was not a branch.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-check-ref-format.txt---no-allow-onelevel"> --[no-]allow-onelevel </dt> <dd> <p>Controls whether one-level refnames are accepted (i.e., refnames that do not contain multiple <code>/</code>-separated components). The default is <code>--no-allow-onelevel</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-ref-format.txt---refspec-pattern"> --refspec-pattern </dt> <dd> <p>Interpret <refname> as a reference name pattern for a refspec (as used with remote repositories). If this option is enabled, <refname> is allowed to contain a single <code>*</code> in the refspec (e.g., <code>foo/bar*/baz</code> or <code>foo/bar*baz/</code> but not <code>foo/bar*/baz*</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-check-ref-format.txt---normalize"> --normalize </dt> <dd> <p>Normalize <code>refname</code> by removing any leading slash (<code>/</code>) characters and collapsing runs of adjacent slashes between name components into a single slash. If the normalized refname is valid then print it to standard output and exit with a status of 0, otherwise exit with a non-zero status. (<code>--print</code> is a deprecated way to spell <code>--normalize</code>.)</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Print the name of the previous thing checked out:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git check-ref-format --branch @{-1}</pre> </div> </div> </li> <li> <p>Determine the reference name to use for a new branch:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ ref=$(git check-ref-format --normalize "refs/heads/$newbranch")|| +{ echo "we do not like '$newbranch' as a branch name." >&2 ; exit 1 ; }</pre> </div> </div> </li> </ul> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-check-ref-format" class="_attribution-link">https://git-scm.com/docs/git-check-ref-format</a> + </p> +</div> diff --git a/devdocs/git/git-checkout-index.html b/devdocs/git/git-checkout-index.html new file mode 100644 index 00000000..1b1f8b65 --- /dev/null +++ b/devdocs/git/git-checkout-index.html @@ -0,0 +1,11 @@ +<h1>git-checkout-index</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-checkout-index - Copy files from the index to the working tree</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git checkout-index [-u] [-q] [-a] [-f] [-n] [--prefix=<string>] + [--stage=<number>|all] + [--temp] + [--ignore-skip-worktree-bits] + [-z] [--stdin] + [--] [<file>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Copies all listed files from the index to the working directory (not overwriting existing files).</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-checkout-index.txt--u"> -u </dt> <dt class="hdlist1" id="Documentation/git-checkout-index.txt---index"> --index </dt> <dd> <p>update stat information for the checked out entries in the index file.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout-index.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-checkout-index.txt---quiet"> --quiet </dt> <dd> <p>be quiet if files exist or are not in the index</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout-index.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-checkout-index.txt---force"> --force </dt> <dd> <p>forces overwrite of existing files</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout-index.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-checkout-index.txt---all"> --all </dt> <dd> <p>checks out all files in the index except for those with the skip-worktree bit set (see <code>--ignore-skip-worktree-bits</code>). Cannot be used together with explicit filenames.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout-index.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-checkout-index.txt---no-create"> --no-create </dt> <dd> <p>Don’t checkout new files, only refresh files already checked out.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout-index.txt---prefixltstringgt"> --prefix=<string> </dt> <dd> <p>When creating files, prepend <string> (usually a directory including a trailing /)</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout-index.txt---stageltnumbergtall"> --stage=<number>|all </dt> <dd> <p>Instead of checking out unmerged entries, copy out the files from the named stage. <number> must be between 1 and 3. Note: --stage=all automatically implies --temp.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout-index.txt---temp"> --temp </dt> <dd> <p>Instead of copying the files to the working directory, write the content to temporary files. The temporary name associations will be written to stdout.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout-index.txt---ignore-skip-worktree-bits"> --ignore-skip-worktree-bits </dt> <dd> <p>Check out all files, including those with the skip-worktree bit set.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout-index.txt---stdin"> --stdin </dt> <dd> <p>Instead of taking a list of paths from the command line, read the list of paths from the standard input. Paths are separated by LF (i.e. one path per line) by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout-index.txt--z"> -z </dt> <dd> <p>Only meaningful with <code>--stdin</code>; paths are separated with NUL character instead of LF.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout-index.txt---"> -- </dt> <dd> <p>Do not interpret any more arguments as options.</p> </dd> </dl> </div> <p>The order of the flags used to matter, but not anymore.</p> <p>Just doing <code>git checkout-index</code> does nothing. You probably meant <code>git checkout-index -a</code>. And if you want to force it, you want <code>git checkout-index -f -a</code>.</p> <p>Intuitiveness is not the goal here. Repeatability is. The reason for the "no arguments means no work" behavior is that from scripts you are supposed to be able to do:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ find . -name '*.h' -print0 | xargs -0 git checkout-index -f --</pre> </div> </div> <p>which will force all existing <code>*.h</code> files to be replaced with their cached copies. If an empty command line implied "all", then this would force-refresh everything in the index, which was not the point. But since <code>git checkout-index</code> accepts --stdin it would be faster to use:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ find . -name '*.h' -print0 | git checkout-index -f -z --stdin</pre> </div> </div> <p>The <code>--</code> is just a good idea when you know the rest will be filenames; it will prevent problems with a filename of, for example, <code>-a</code>. Using <code>--</code> is probably a good policy in scripts.</p> </div> <h2 id="_using_temp_or_stageall">Using --temp or --stage=all</h2> <div class="sectionbody"> <p>When <code>--temp</code> is used (or implied by <code>--stage=all</code>) <code>git checkout-index</code> will create a temporary file for each index entry being checked out. The index will not be updated with stat information. These options can be useful if the caller needs all stages of all unmerged entries so that the unmerged files can be processed by an external merge tool.</p> <p>A listing will be written to stdout providing the association of temporary file names to tracked path names. The listing format has two variations:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>tempname TAB path RS</p> <p>The first format is what gets used when <code>--stage</code> is omitted or is not <code>--stage=all</code>. The field tempname is the temporary file name holding the file content and path is the tracked path name in the index. Only the requested entries are output.</p> </li> <li> <p>stage1temp SP stage2temp SP stage3tmp TAB path RS</p> <p>The second format is what gets used when <code>--stage=all</code>. The three stage temporary fields (stage1temp, stage2temp, stage3temp) list the name of the temporary file if there is a stage entry in the index or <code>.</code> if there is no stage entry. Paths which only have a stage 0 entry will always be omitted from the output.</p> </li> </ol> </div> <p>In both formats RS (the record separator) is newline by default but will be the null byte if -z was passed on the command line. The temporary file names are always safe strings; they will never contain directory separators or whitespace characters. The path field is always relative to the current directory and the temporary file names are always relative to the top level directory.</p> <p>If the object being copied out to a temporary file is a symbolic link the content of the link will be written to a normal file. It is up to the end-user or the Porcelain to make use of this information.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-checkout-index.txt-Toupdateandrefreshonlythefilesalreadycheckedout"> To update and refresh only the files already checked out </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout-index -n -f -a && git update-index --ignore-missing --refresh</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-checkout-index.txt-Usingemgitcheckout-indexemtoexportanentiretree"> Using <em>git checkout-index</em> to "export an entire tree" </dt> <dd> <p>The prefix ability basically makes it trivial to use <code>git checkout-index</code> as an "export as tree" function. Just read the desired tree into the index, and do:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout-index --prefix=git-export-dir/ -a</pre> </div> </div> <p><code>git checkout-index</code> will "export" the index into the specified directory.</p> <p>The final "/" is important. The exported name is literally just prefixed with the specified string. Contrast this with the following example.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout-index.txt-Exportfileswithaprefix"> Export files with a prefix </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout-index --prefix=.merged- Makefile</pre> </div> </div> <p>This will check out the currently cached copy of <code>Makefile</code> into the file <code>.merged-Makefile</code>.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-checkout-index" class="_attribution-link">https://git-scm.com/docs/git-checkout-index</a> + </p> +</div> diff --git a/devdocs/git/git-checkout.html b/devdocs/git/git-checkout.html new file mode 100644 index 00000000..41dab60c --- /dev/null +++ b/devdocs/git/git-checkout.html @@ -0,0 +1,83 @@ +<h1>git-checkout</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-checkout - Switch branches or restore working tree files</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git checkout [-q] [-f] [-m] [<branch>] +git checkout [-q] [-f] [-m] --detach [<branch>] +git checkout [-q] [-f] [-m] [--detach] <commit> +git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new-branch>] [<start-point>] +git checkout [-f] <tree-ish> [--] <pathspec>… +git checkout [-f] <tree-ish> --pathspec-from-file=<file> [--pathspec-file-nul] +git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [--] <pathspec>… +git checkout [-f|--ours|--theirs|-m|--conflict=<style>] --pathspec-from-file=<file> [--pathspec-file-nul] +git checkout (-p|--patch) [<tree-ish>] [--] [<pathspec>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Updates files in the working tree to match the version in the index or the specified tree. If no pathspec was given, <code>git checkout</code> will also update <code>HEAD</code> to set the specified branch as the current branch.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-checkout.txt-emgitcheckoutemltbranchgt"> <em>git checkout</em> [<branch>] </dt> <dd> <p>To prepare for working on <code><branch></code>, switch to it by updating the index and the files in the working tree, and by pointing <code>HEAD</code> at the branch. Local modifications to the files in the working tree are kept, so that they can be committed to the <code><branch></code>.</p> <p>If <code><branch></code> is not found but there does exist a tracking branch in exactly one remote (call it <code><remote></code>) with a matching name and <code>--no-guess</code> is not specified, treat as equivalent to</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout -b <branch> --track <remote>/<branch></pre> </div> </div> <p>You could omit <code><branch></code>, in which case the command degenerates to "check out the current branch", which is a glorified no-op with rather expensive side-effects to show only the tracking information, if it exists, for the current branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt-emgitcheckoutem-b-Bltnew-branchgtltstart-pointgt"> <em>git checkout</em> -b|-B <new-branch> [<start-point>] </dt> <dd> <p>Specifying <code>-b</code> causes a new branch to be created as if <a href="git-branch">git-branch[1]</a> were called and then checked out. In this case you can use the <code>--track</code> or <code>--no-track</code> options, which will be passed to <code>git branch</code>. As a convenience, <code>--track</code> without <code>-b</code> implies branch creation; see the description of <code>--track</code> below.</p> <p>If <code>-B</code> is given, <code><new-branch></code> is created if it doesn’t exist; otherwise, it is reset. This is the transactional equivalent of</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch -f <branch> [<start-point>] +$ git checkout <branch></pre> </div> </div> <p>that is to say, the branch is not reset/created unless "git checkout" is successful.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt-emgitcheckoutem--detachltbranchgt"> <em>git checkout</em> --detach [<branch>] </dt> <dt class="hdlist1" id="Documentation/git-checkout.txt-emgitcheckoutem--detachltcommitgt"> <em>git checkout</em> [--detach] <commit> </dt> <dd> <p>Prepare to work on top of <code><commit></code>, by detaching <code>HEAD</code> at it (see "DETACHED HEAD" section), and updating the index and the files in the working tree. Local modifications to the files in the working tree are kept, so that the resulting working tree will be the state recorded in the commit plus the local modifications.</p> <p>When the <code><commit></code> argument is a branch name, the <code>--detach</code> option can be used to detach <code>HEAD</code> at the tip of the branch (<code>git checkout +<branch></code> would check out that branch without detaching <code>HEAD</code>).</p> <p>Omitting <code><branch></code> detaches <code>HEAD</code> at the tip of the current branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt-emgitcheckoutem-f--ours--theirs-m--conflictltstylegtlttree-ishgt--ltpathspecgt82308203"> <em>git checkout</em> [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <pathspec>… </dt> <dt class="hdlist1" id="Documentation/git-checkout.txt-emgitcheckoutem-f--ours--theirs-m--conflictltstylegtlttree-ishgt--pathspec-from-fileltfilegt--pathspec-file-nul"> <em>git checkout</em> [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] --pathspec-from-file=<file> [--pathspec-file-nul] </dt> <dd> <p>Overwrite the contents of the files that match the pathspec. When the <code><tree-ish></code> (most often a commit) is not given, overwrite working tree with the contents in the index. When the <code><tree-ish></code> is given, overwrite both the index and the working tree with the contents at the <code><tree-ish></code>.</p> <p>The index may contain unmerged entries because of a previous failed merge. By default, if you try to check out such an entry from the index, the checkout operation will fail and nothing will be checked out. Using <code>-f</code> will ignore these unmerged entries. The contents from a specific side of the merge can be checked out of the index by using <code>--ours</code> or <code>--theirs</code>. With <code>-m</code>, changes made to the working tree file can be discarded to re-create the original conflicted merge result.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt-emgitcheckoutem-p--patchlttree-ishgt--ltpathspecgt82308203"> <em>git checkout</em> (-p|--patch) [<tree-ish>] [--] [<pathspec>…] </dt> <dd> <p>This is similar to the previous mode, but lets you use the interactive interface to show the "diff" output and choose which hunks to use in the result. See below for the description of <code>--patch</code> option.</p> </dd> </dl> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-checkout.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-checkout.txt---quiet"> --quiet </dt> <dd> <p>Quiet, suppress feedback messages.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt---progress"> --progress </dt> <dt class="hdlist1" id="Documentation/git-checkout.txt---no-progress"> --no-progress </dt> <dd> <p>Progress status is reported on the standard error stream by default when it is attached to a terminal, unless <code>--quiet</code> is specified. This flag enables progress reporting even if not attached to a terminal, regardless of <code>--quiet</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-checkout.txt---force"> --force </dt> <dd> <p>When switching branches, proceed even if the index or the working tree differs from <code>HEAD</code>, and even if there are untracked files in the way. This is used to throw away local changes and any untracked files or directories that are in the way.</p> <p>When checking out paths from the index, do not fail upon unmerged entries; instead, unmerged entries are ignored.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt---ours"> --ours </dt> <dt class="hdlist1" id="Documentation/git-checkout.txt---theirs"> --theirs </dt> <dd> <p>When checking out paths from the index, check out stage #2 (<code>ours</code>) or #3 (<code>theirs</code>) for unmerged paths.</p> <p>Note that during <code>git rebase</code> and <code>git pull --rebase</code>, <code>ours</code> and <code>theirs</code> may appear swapped; <code>--ours</code> gives the version from the branch the changes are rebased onto, while <code>--theirs</code> gives the version from the branch that holds your work that is being rebased.</p> <p>This is because <code>rebase</code> is used in a workflow that treats the history at the remote as the shared canonical one, and treats the work done on the branch you are rebasing as the third-party work to be integrated, and you are temporarily assuming the role of the keeper of the canonical history during the rebase. As the keeper of the canonical history, you need to view the history from the remote as <code>ours</code> (i.e. "our shared canonical history"), while what you did on your side branch as <code>theirs</code> (i.e. "one contributor’s work on top of it").</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt--bltnew-branchgt"> -b <new-branch> </dt> <dd> <p>Create a new branch named <code><new-branch></code>, start it at <code><start-point></code>, and check the resulting branch out; see <a href="git-branch">git-branch[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt--Bltnew-branchgt"> -B <new-branch> </dt> <dd> <p>Creates the branch <code><new-branch></code>, start it at <code><start-point></code>; if it already exists, then reset it to <code><start-point></code>. And then check the resulting branch out. This is equivalent to running "git branch" with "-f" followed by "git checkout" of that branch; see <a href="git-branch">git-branch[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt--t"> -t </dt> <dt class="hdlist1" id="Documentation/git-checkout.txt---trackdirectinherit"> --track[=(direct|inherit)] </dt> <dd> <p>When creating a new branch, set up "upstream" configuration. See "--track" in <a href="git-branch">git-branch[1]</a> for details.</p> <p>If no <code>-b</code> option is given, the name of the new branch will be derived from the remote-tracking branch, by looking at the local part of the refspec configured for the corresponding remote, and then stripping the initial part up to the "*". This would tell us to use <code>hack</code> as the local branch when branching off of <code>origin/hack</code> (or <code>remotes/origin/hack</code>, or even <code>refs/remotes/origin/hack</code>). If the given name has no slash, or the above guessing results in an empty name, the guessing is aborted. You can explicitly give a name with <code>-b</code> in such a case.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt---no-track"> --no-track </dt> <dd> <p>Do not set up "upstream" configuration, even if the <code>branch.autoSetupMerge</code> configuration variable is true.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt---guess"> --guess </dt> <dt class="hdlist1" id="Documentation/git-checkout.txt---no-guess"> --no-guess </dt> <dd> <p>If <code><branch></code> is not found but there does exist a tracking branch in exactly one remote (call it <code><remote></code>) with a matching name, treat as equivalent to</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout -b <branch> --track <remote>/<branch></pre> </div> </div> <p>If the branch exists in multiple remotes and one of them is named by the <code>checkout.defaultRemote</code> configuration variable, we’ll use that one for the purposes of disambiguation, even if the <code><branch></code> isn’t unique across all remotes. Set it to e.g. <code>checkout.defaultRemote=origin</code> to always checkout remote branches from there if <code><branch></code> is ambiguous but exists on the <code>origin</code> remote. See also <code>checkout.defaultRemote</code> in <a href="git-config">git-config[1]</a>.</p> <p><code>--guess</code> is the default behavior. Use <code>--no-guess</code> to disable it.</p> <p>The default behavior can be set via the <code>checkout.guess</code> configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt--l"> -l </dt> <dd> <p>Create the new branch’s reflog; see <a href="git-branch">git-branch[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt--d"> -d </dt> <dt class="hdlist1" id="Documentation/git-checkout.txt---detach"> --detach </dt> <dd> <p>Rather than checking out a branch to work on it, check out a commit for inspection and discardable experiments. This is the default behavior of <code>git checkout <commit></code> when <code><commit></code> is not a branch name. See the "DETACHED HEAD" section below for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt---orphanltnew-branchgt"> --orphan <new-branch> </dt> <dd> <p>Create a new unborn branch, named <code><new-branch></code>, started from <code><start-point></code> and switch to it. The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits.</p> <p>The index and the working tree are adjusted as if you had previously run <code>git checkout <start-point></code>. This allows you to start a new history that records a set of paths similar to <code><start-point></code> by easily running <code>git commit -a</code> to make the root commit.</p> <p>This can be useful when you want to publish the tree from a commit without exposing its full history. You might want to do this to publish an open source branch of a project whose current tree is "clean", but whose full history contains proprietary or otherwise encumbered bits of code.</p> <p>If you want to start a disconnected history that records a set of paths that is totally different from the one of <code><start-point></code>, then you should clear the index and the working tree right after creating the orphan branch by running <code>git rm -rf .</code> from the top level of the working tree. Afterwards you will be ready to prepare your new files, repopulating the working tree, by copying them from elsewhere, extracting a tarball, etc.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt---ignore-skip-worktree-bits"> --ignore-skip-worktree-bits </dt> <dd> <p>In sparse checkout mode, <code>git checkout -- <paths></code> would update only entries matched by <code><paths></code> and sparse patterns in <code>$GIT_DIR/info/sparse-checkout</code>. This option ignores the sparse patterns and adds back any files in <code><paths></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt--m"> -m </dt> <dt class="hdlist1" id="Documentation/git-checkout.txt---merge"> --merge </dt> <dd> <p>When switching branches, if you have local modifications to one or more files that are different between the current branch and the branch to which you are switching, the command refuses to switch branches in order to preserve your modifications in context. However, with this option, a three-way merge between the current branch, your working tree contents, and the new branch is done, and you will be on the new branch.</p> <p>When a merge conflict happens, the index entries for conflicting paths are left unmerged, and you need to resolve the conflicts and mark the resolved paths with <code>git add</code> (or <code>git rm</code> if the merge should result in deletion of the path).</p> <p>When checking out paths from the index, this option lets you recreate the conflicted merge in the specified paths. This option cannot be used when checking out paths from a tree-ish.</p> <p>When switching branches with <code>--merge</code>, staged changes may be lost.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt---conflictltstylegt"> --conflict=<style> </dt> <dd> <p>The same as <code>--merge</code> option above, but changes the way the conflicting hunks are presented, overriding the <code>merge.conflictStyle</code> configuration variable. Possible values are "merge" (default), "diff3", and "zdiff3".</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-checkout.txt---patch"> --patch </dt> <dd> <p>Interactively select hunks in the difference between the <code><tree-ish></code> (or the index, if unspecified) and the working tree. The chosen hunks are then applied in reverse to the working tree (and if a <code><tree-ish></code> was specified, the index).</p> <p>This means that you can use <code>git checkout -p</code> to selectively discard edits from your current working tree. See the “Interactive Mode” section of <a href="git-add">git-add[1]</a> to learn how to operate the <code>--patch</code> mode.</p> <p>Note that this option uses the no overlay mode by default (see also <code>--overlay</code>), and currently doesn’t support overlay mode.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt---ignore-other-worktrees"> --ignore-other-worktrees </dt> <dd> <p><code>git checkout</code> refuses when the wanted ref is already checked out by another worktree. This option makes it check the ref out anyway. In other words, the ref can be held by more than one worktree.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt---overwrite-ignore"> --overwrite-ignore </dt> <dt class="hdlist1" id="Documentation/git-checkout.txt---no-overwrite-ignore"> --no-overwrite-ignore </dt> <dd> <p>Silently overwrite ignored files when switching branches. This is the default behavior. Use <code>--no-overwrite-ignore</code> to abort the operation when the new branch contains ignored files.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt---recurse-submodules"> --recurse-submodules </dt> <dt class="hdlist1" id="Documentation/git-checkout.txt---no-recurse-submodules"> --no-recurse-submodules </dt> <dd> <p>Using <code>--recurse-submodules</code> will update the content of all active submodules according to the commit recorded in the superproject. If local modifications in a submodule would be overwritten the checkout will fail unless <code>-f</code> is used. If nothing (or <code>--no-recurse-submodules</code>) is used, submodules working trees will not be updated. Just like <a href="git-submodule">git-submodule[1]</a>, this will detach <code>HEAD</code> of the submodule.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt---overlay"> --overlay </dt> <dt class="hdlist1" id="Documentation/git-checkout.txt---no-overlay"> --no-overlay </dt> <dd> <p>In the default overlay mode, <code>git checkout</code> never removes files from the index or the working tree. When specifying <code>--no-overlay</code>, files that appear in the index and working tree, but not in <code><tree-ish></code> are removed, to make them match <code><tree-ish></code> exactly.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt---pathspec-from-fileltfilegt"> --pathspec-from-file=<file> </dt> <dd> <p>Pathspec is passed in <code><file></code> instead of commandline args. If <code><file></code> is exactly <code>-</code> then standard input is used. Pathspec elements are separated by LF or CR/LF. Pathspec elements can be quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>). See also <code>--pathspec-file-nul</code> and global <code>--literal-pathspecs</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt---pathspec-file-nul"> --pathspec-file-nul </dt> <dd> <p>Only meaningful with <code>--pathspec-from-file</code>. Pathspec elements are separated with NUL character and all other characters are taken literally (including newlines and quotes).</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt-ltbranchgt"> <branch> </dt> <dd> <p>Branch to checkout; if it refers to a branch (i.e., a name that, when prepended with "refs/heads/", is a valid ref), then that branch is checked out. Otherwise, if it refers to a valid commit, your <code>HEAD</code> becomes "detached" and you are no longer on any branch (see below for details).</p> <p>You can use the <code>@{-N}</code> syntax to refer to the N-th last branch/commit checked out using "git checkout" operation. You may also specify <code>-</code> which is synonymous to <code>@{-1}</code>.</p> <p>As a special case, you may use <code>A...B</code> as a shortcut for the merge base of <code>A</code> and <code>B</code> if there is exactly one merge base. You can leave out at most one of <code>A</code> and <code>B</code>, in which case it defaults to <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt-ltnew-branchgt"> <new-branch> </dt> <dd> <p>Name for the new branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt-ltstart-pointgt"> <start-point> </dt> <dd> <p>The name of a commit at which to start the new branch; see <a href="git-branch">git-branch[1]</a> for details. Defaults to <code>HEAD</code>.</p> <p>As a special case, you may use <code>"A...B"</code> as a shortcut for the merge base of <code>A</code> and <code>B</code> if there is exactly one merge base. You can leave out at most one of <code>A</code> and <code>B</code>, in which case it defaults to <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt-lttree-ishgt"> <tree-ish> </dt> <dd> <p>Tree to checkout from (when paths are given). If not specified, the index will be used.</p> <p>As a special case, you may use <code>"A...B"</code> as a shortcut for the merge base of <code>A</code> and <code>B</code> if there is exactly one merge base. You can leave out at most one of <code>A</code> and <code>B</code>, in which case it defaults to <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt---"> -- </dt> <dd> <p>Do not interpret any more arguments as options.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt-ltpathspecgt82308203"> <pathspec>… </dt> <dd> <p>Limits the paths affected by the operation.</p> <p>For more details, see the <code>pathspec</code> entry in <a href="gitglossary">gitglossary[7]</a>.</p> </dd> </dl> </div> </div> <h2 id="_detached_head">Detached head</h2> <div class="sectionbody"> <p><code>HEAD</code> normally refers to a named branch (e.g. <code>master</code>). Meanwhile, each branch refers to a specific commit. Let’s look at a repo with three commits, one of them tagged, and with branch <code>master</code> checked out:</p> <div class="listingblock"> <div class="content"> <pre> HEAD (refers to branch 'master') + | + v +a---b---c branch 'master' (refers to commit 'c') + ^ + | + tag 'v2.0' (refers to commit 'b')</pre> </div> </div> <p>When a commit is created in this state, the branch is updated to refer to the new commit. Specifically, <code>git commit</code> creates a new commit <code>d</code>, whose parent is commit <code>c</code>, and then updates branch <code>master</code> to refer to new commit <code>d</code>. <code>HEAD</code> still refers to branch <code>master</code> and so indirectly now refers to commit <code>d</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ edit; git add; git commit + + HEAD (refers to branch 'master') + | + v +a---b---c---d branch 'master' (refers to commit 'd') + ^ + | + tag 'v2.0' (refers to commit 'b')</pre> </div> </div> <p>It is sometimes useful to be able to checkout a commit that is not at the tip of any named branch, or even to create a new commit that is not referenced by a named branch. Let’s look at what happens when we checkout commit <code>b</code> (here we show two ways this may be done):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout v2.0 # or +$ git checkout master^^ + + HEAD (refers to commit 'b') + | + v +a---b---c---d branch 'master' (refers to commit 'd') + ^ + | + tag 'v2.0' (refers to commit 'b')</pre> </div> </div> <p>Notice that regardless of which checkout command we use, <code>HEAD</code> now refers directly to commit <code>b</code>. This is known as being in detached <code>HEAD</code> state. It means simply that <code>HEAD</code> refers to a specific commit, as opposed to referring to a named branch. Let’s see what happens when we create a commit:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ edit; git add; git commit + + HEAD (refers to commit 'e') + | + v + e + / +a---b---c---d branch 'master' (refers to commit 'd') + ^ + | + tag 'v2.0' (refers to commit 'b')</pre> </div> </div> <p>There is now a new commit <code>e</code>, but it is referenced only by <code>HEAD</code>. We can of course add yet another commit in this state:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ edit; git add; git commit + + HEAD (refers to commit 'f') + | + v + e---f + / +a---b---c---d branch 'master' (refers to commit 'd') + ^ + | + tag 'v2.0' (refers to commit 'b')</pre> </div> </div> <p>In fact, we can perform all the normal Git operations. But, let’s look at what happens when we then checkout <code>master</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout master + + HEAD (refers to branch 'master') + e---f | + / v +a---b---c---d branch 'master' (refers to commit 'd') + ^ + | + tag 'v2.0' (refers to commit 'b')</pre> </div> </div> <p>It is important to realize that at this point nothing refers to commit <code>f</code>. Eventually commit <code>f</code> (and by extension commit <code>e</code>) will be deleted by the routine Git garbage collection process, unless we create a reference before that happens. If we have not yet moved away from commit <code>f</code>, any of these will create a reference to it:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout -b foo # or "git switch -c foo" (1) +$ git branch foo (2) +$ git tag foo (3)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>creates a new branch <code>foo</code>, which refers to commit <code>f</code>, and then updates <code>HEAD</code> to refer to branch <code>foo</code>. In other words, we’ll no longer be in detached <code>HEAD</code> state after this command.</p> </li> <li> <p>similarly creates a new branch <code>foo</code>, which refers to commit <code>f</code>, but leaves <code>HEAD</code> detached.</p> </li> <li> <p>creates a new tag <code>foo</code>, which refers to commit <code>f</code>, leaving <code>HEAD</code> detached.</p> </li> </ol> </div> <p>If we have moved away from commit <code>f</code>, then we must first recover its object name (typically by using git reflog), and then we can create a reference to it. For example, to see the last two commits to which <code>HEAD</code> referred, we can use either of these commands:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git reflog -2 HEAD # or +$ git log -g -2 HEAD</pre> </div> </div> </div> <h2 id="_argument_disambiguation">Argument disambiguation</h2> <div class="sectionbody"> <p>When there is only one argument given and it is not <code>--</code> (e.g. <code>git +checkout abc</code>), and when the argument is both a valid <code><tree-ish></code> (e.g. a branch <code>abc</code> exists) and a valid <code><pathspec></code> (e.g. a file or a directory whose name is "abc" exists), Git would usually ask you to disambiguate. Because checking out a branch is so common an operation, however, <code>git checkout abc</code> takes "abc" as a <code><tree-ish></code> in such a situation. Use <code>git checkout -- <pathspec></code> if you want to checkout these paths out of the index.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_1_paths"> +1. Paths</h3> <p>The following sequence checks out the <code>master</code> branch, reverts the <code>Makefile</code> to two revisions back, deletes <code>hello.c</code> by mistake, and gets it back from the index.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout master (1) +$ git checkout master~2 Makefile (2) +$ rm -f hello.c +$ git checkout hello.c (3)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>switch branch</p> </li> <li> <p>take a file out of another commit</p> </li> <li> <p>restore <code>hello.c</code> from the index</p> </li> </ol> </div> <p>If you want to check out <code>all</code> C source files out of the index, you can say</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout -- '*.c'</pre> </div> </div> <p>Note the quotes around <code>*.c</code>. The file <code>hello.c</code> will also be checked out, even though it is no longer in the working tree, because the file globbing is used to match entries in the index (not in the working tree by the shell).</p> <p>If you have an unfortunate branch that is named <code>hello.c</code>, this step would be confused as an instruction to switch to that branch. You should instead write:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout -- hello.c</pre> </div> </div> </div> <div class="sect2"> <h3 id="_2_merge"> +2. Merge</h3> <p>After working in the wrong branch, switching to the correct branch would be done using:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout mytopic</pre> </div> </div> <p>However, your "wrong" branch and correct <code>mytopic</code> branch may differ in files that you have modified locally, in which case the above checkout would fail like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout mytopic +error: You have local changes to 'frotz'; not switching branches.</pre> </div> </div> <p>You can give the <code>-m</code> flag to the command, which would try a three-way merge:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout -m mytopic +Auto-merging frotz</pre> </div> </div> <p>After this three-way merge, the local modifications are <code>not</code> registered in your index file, so <code>git diff</code> would show you what changes you made since the tip of the new branch.</p> </div> <div class="sect2"> <h3 id="_3_merge_conflict"> +3. Merge conflict</h3> <p>When a merge conflict happens during switching branches with the <code>-m</code> option, you would see something like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout -m mytopic +Auto-merging frotz +ERROR: Merge conflict in frotz +fatal: merge program failed</pre> </div> </div> <p>At this point, <code>git diff</code> shows the changes cleanly merged as in the previous example, as well as the changes in the conflicted files. Edit and resolve the conflict and mark it resolved with <code>git add</code> as usual:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ edit frotz +$ git add frotz</pre> </div> </div> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-checkout.txt-checkoutdefaultRemote"> checkout.defaultRemote </dt> <dd> <p>When you run <code>git checkout <something></code> or <code>git switch <something></code> and only have one remote, it may implicitly fall back on checking out and tracking e.g. <code>origin/<something></code>. This stops working as soon as you have more than one remote with a <code><something></code> reference. This setting allows for setting the name of a preferred remote that should always win when it comes to disambiguation. The typical use-case is to set this to <code>origin</code>.</p> <p>Currently this is used by <a href="git-switch">git-switch[1]</a> and <a href="git-checkout">git-checkout[1]</a> when <code>git checkout <something></code> or <code>git switch <something></code> will checkout the <code><something></code> branch on another remote, and by <a href="git-worktree">git-worktree[1]</a> when <code>git worktree add</code> refers to a remote branch. This setting might be used for other checkout-like commands or functionality in the future.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt-checkoutguess"> checkout.guess </dt> <dd> <p>Provides the default value for the <code>--guess</code> or <code>--no-guess</code> option in <code>git checkout</code> and <code>git switch</code>. See <a href="git-switch">git-switch[1]</a> and <a href="git-checkout">git-checkout[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt-checkoutworkers"> checkout.workers </dt> <dd> <p>The number of parallel workers to use when updating the working tree. The default is one, i.e. sequential execution. If set to a value less than one, Git will use as many workers as the number of logical cores available. This setting and <code>checkout.thresholdForParallelism</code> affect all commands that perform checkout. E.g. checkout, clone, reset, sparse-checkout, etc.</p> <p>Note: Parallel checkout usually delivers better performance for repositories located on SSDs or over NFS. For repositories on spinning disks and/or machines with a small number of cores, the default sequential checkout often performs better. The size and compression level of a repository might also influence how well the parallel version performs.</p> </dd> <dt class="hdlist1" id="Documentation/git-checkout.txt-checkoutthresholdForParallelism"> checkout.thresholdForParallelism </dt> <dd> <p>When running parallel checkout with a small number of files, the cost of subprocess spawning and inter-process communication might outweigh the parallelization gains. This setting allows you to define the minimum number of files for which parallel checkout should be attempted. The default is 100.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-switch">git-switch[1]</a>, <a href="git-restore">git-restore[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-checkout" class="_attribution-link">https://git-scm.com/docs/git-checkout</a> + </p> +</div> diff --git a/devdocs/git/git-cherry-pick.html b/devdocs/git/git-cherry-pick.html new file mode 100644 index 00000000..2403f2c6 --- /dev/null +++ b/devdocs/git/git-cherry-pick.html @@ -0,0 +1,12 @@ +<h1>git-cherry-pick</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-cherry-pick - Apply the changes introduced by some existing commits</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git cherry-pick [--edit] [-n] [-m <parent-number>] [-s] [-x] [--ff] + [-S[<keyid>]] <commit>… +git cherry-pick (--continue | --skip | --abort | --quit)</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Given one or more existing commits, apply the change each one introduces, recording a new commit for each. This requires your working tree to be clean (no modifications from the HEAD commit).</p> <p>When it is not obvious how to apply a change, the following happens:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>The current branch and <code>HEAD</code> pointer stay at the last commit successfully made.</p> </li> <li> <p>The <code>CHERRY_PICK_HEAD</code> ref is set to point at the commit that introduced the change that is difficult to apply.</p> </li> <li> <p>Paths in which the change applied cleanly are updated both in the index file and in your working tree.</p> </li> <li> <p>For conflicting paths, the index file records up to three versions, as described in the "TRUE MERGE" section of <a href="git-merge">git-merge[1]</a>. The working tree files will include a description of the conflict bracketed by the usual conflict markers <code><<<<<<<</code> and <code>>>>>>>></code>.</p> </li> <li> <p>No other modifications are made.</p> </li> </ol> </div> <p>See <a href="git-merge">git-merge[1]</a> for some hints on resolving such conflicts.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-ltcommitgt82308203"> <commit>… </dt> <dd> <p>Commits to cherry-pick. For a more complete list of ways to spell commits, see <a href="gitrevisions">gitrevisions[7]</a>. Sets of commits can be passed but no traversal is done by default, as if the <code>--no-walk</code> option was specified, see <a href="git-rev-list">git-rev-list[1]</a>. Note that specifying a range will feed all <commit>… arguments to a single revision walk (see a later example that uses <code>maint master..next</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt--e"> -e </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---edit"> --edit </dt> <dd> <p>With this option, <code>git cherry-pick</code> will let you edit the commit message prior to committing.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---cleanupltmodegt"> --cleanup=<mode> </dt> <dd> <p>This option determines how the commit message will be cleaned up before being passed on to the commit machinery. See <a href="git-commit">git-commit[1]</a> for more details. In particular, if the <code><mode></code> is given a value of <code>scissors</code>, scissors will be appended to <code>MERGE_MSG</code> before being passed on in the case of a conflict.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt--x"> -x </dt> <dd> <p>When recording the commit, append a line that says "(cherry picked from commit …)" to the original commit message in order to indicate which commit this change was cherry-picked from. This is done only for cherry picks without conflicts. Do not use this option if you are cherry-picking from your private branch because the information is useless to the recipient. If on the other hand you are cherry-picking between two publicly visible branches (e.g. backporting a fix to a maintenance branch for an older release from a development branch), adding this information can be useful.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt--r"> -r </dt> <dd> <p>It used to be that the command defaulted to do <code>-x</code> described above, and <code>-r</code> was to disable it. Now the default is not to do <code>-x</code> so this option is a no-op.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt--mltparent-numbergt"> -m <parent-number> </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---mainlineltparent-numbergt"> --mainline <parent-number> </dt> <dd> <p>Usually you cannot cherry-pick a merge because you do not know which side of the merge should be considered the mainline. This option specifies the parent number (starting from 1) of the mainline and allows cherry-pick to replay the change relative to the specified parent.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---no-commit"> --no-commit </dt> <dd> <p>Usually the command automatically creates a sequence of commits. This flag applies the changes necessary to cherry-pick each named commit to your working tree and the index, without making any commit. In addition, when this option is used, your index does not have to match the HEAD commit. The cherry-pick is done against the beginning state of your index.</p> <p>This is useful when cherry-picking more than one commits' effect to your index in a row.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---signoff"> --signoff </dt> <dd> <p>Add a <code>Signed-off-by</code> trailer at the end of the commit message. See the signoff option in <a href="git-commit">git-commit[1]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt--Sltkeyidgt"> -S[<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---gpg-signltkeyidgt"> --gpg-sign[=<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---no-gpg-sign"> --no-gpg-sign </dt> <dd> <p>GPG-sign commits. The <code>keyid</code> argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space. <code>--no-gpg-sign</code> is useful to countermand both <code>commit.gpgSign</code> configuration variable, and earlier <code>--gpg-sign</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---ff"> --ff </dt> <dd> <p>If the current HEAD is the same as the parent of the cherry-pick’ed commit, then a fast forward to this commit will be performed.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---allow-empty"> --allow-empty </dt> <dd> <p>By default, cherry-picking an empty commit will fail, indicating that an explicit invocation of <code>git commit +--allow-empty</code> is required. This option overrides that behavior, allowing empty commits to be preserved automatically in a cherry-pick. Note that when "--ff" is in effect, empty commits that meet the "fast-forward" requirement will be kept even without this option. Note also, that use of this option only keeps commits that were initially empty (i.e. the commit recorded the same tree as its parent). Commits which are made empty due to a previous commit are dropped. To force the inclusion of those commits use <code>--keep-redundant-commits</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---allow-empty-message"> --allow-empty-message </dt> <dd> <p>By default, cherry-picking a commit with an empty message will fail. This option overrides that behavior, allowing commits with empty messages to be cherry picked.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---keep-redundant-commits"> --keep-redundant-commits </dt> <dd> <p>If a commit being cherry picked duplicates a commit already in the current history, it will become empty. By default these redundant commits cause <code>cherry-pick</code> to stop so the user can examine the commit. This option overrides that behavior and creates an empty commit object. Implies <code>--allow-empty</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---strategyltstrategygt"> --strategy=<strategy> </dt> <dd> <p>Use the given merge strategy. Should only be used once. See the MERGE STRATEGIES section in <a href="git-merge">git-merge[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt--Xltoptiongt"> -X<option> </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---strategy-optionltoptiongt"> --strategy-option=<option> </dt> <dd> <p>Pass the merge strategy-specific option through to the merge strategy. See <a href="git-merge">git-merge[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---rerere-autoupdate"> --rerere-autoupdate </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---no-rerere-autoupdate"> --no-rerere-autoupdate </dt> <dd> <p>After the rerere mechanism reuses a recorded resolution on the current conflict to update the files in the working tree, allow it to also update the index with the result of resolution. <code>--no-rerere-autoupdate</code> is a good way to double-check what <code>rerere</code> did and catch potential mismerges, before committing the result to the index with a separate <code>git add</code>.</p> </dd> </dl> </div> </div> <h2 id="_sequencer_subcommands">Sequencer subcommands</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---continue"> --continue </dt> <dd> <p>Continue the operation in progress using the information in <code>.git/sequencer</code>. Can be used to continue after resolving conflicts in a failed cherry-pick or revert.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---skip"> --skip </dt> <dd> <p>Skip the current commit and continue with the rest of the sequence.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---quit"> --quit </dt> <dd> <p>Forget about the current operation in progress. Can be used to clear the sequencer state after a failed cherry-pick or revert.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt---abort"> --abort </dt> <dd> <p>Cancel the operation and return to the pre-sequence state.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitcherry-pickmastercode"> <code>git cherry-pick master</code> </dt> <dd> <p>Apply the change introduced by the commit at the tip of the master branch and create a new commit with this change.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitcherry-pickmastercode-1"> <code>git cherry-pick ..master</code> </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitcherry-pickHEADmastercode"> <code>git cherry-pick ^HEAD master</code> </dt> <dd> <p>Apply the changes introduced by all commits that are ancestors of master but not of HEAD to produce new commits.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitcherry-pickmaintnextmastercode"> <code>git cherry-pick maint next ^master</code> </dt> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitcherry-pickmaintmasternextcode"> <code>git cherry-pick maint master..next</code> </dt> <dd> <p>Apply the changes introduced by all commits that are ancestors of maint or next, but not master or any of its ancestors. Note that the latter does not mean <code>maint</code> and everything between <code>master</code> and <code>next</code>; specifically, <code>maint</code> will not be used if it is included in <code>master</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitcherry-pickmaster4master2code"> <code>git cherry-pick master~4 master~2</code> </dt> <dd> <p>Apply the changes introduced by the fifth and third last commits pointed to by master and create 2 new commits with these changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitcherry-pick-nmaster1nextcode"> <code>git cherry-pick -n master~1 next</code> </dt> <dd> <p>Apply to the working tree and the index the changes introduced by the second last commit pointed to by master and by the last commit pointed to by next, but do not create any commit with these changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitcherry-pick--ffnextcode"> <code>git cherry-pick --ff ..next</code> </dt> <dd> <p>If history is linear and HEAD is an ancestor of next, update the working tree and advance the HEAD pointer to match next. Otherwise, apply the changes introduced by those commits that are in next but not HEAD to the current branch, creating a new commit for each new change.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry-pick.txt-codegitrev-list--reversemaster--READMEgitcherry-pick-n--stdincode"> <code>git rev-list --reverse master -- README | git cherry-pick -n --stdin</code> </dt> <dd> <p>Apply the changes introduced by all commits on the master branch that touched README to the working tree and index, so the result can be inspected and made into a single new commit if suitable.</p> </dd> </dl> </div> <p>The following sequence attempts to backport a patch, bails out because the code the patch applies to has changed too much, and then tries again, this time exercising more care about matching up context lines.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cherry-pick topic^ (1) +$ git diff (2) +$ git cherry-pick --abort (3) +$ git cherry-pick -Xpatience topic^ (4)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>apply the change that would be shown by <code>git show topic^</code>. In this example, the patch does not apply cleanly, so information about the conflict is written to the index and working tree and no new commit results.</p> </li> <li> <p>summarize changes to be reconciled</p> </li> <li> <p>cancel the cherry-pick. In other words, return to the pre-cherry-pick state, preserving any local modifications you had in the working tree.</p> </li> <li> <p>try to apply the change introduced by <code>topic^</code> again, spending extra time to avoid mistakes based on incorrectly matching context lines.</p> </li> </ol> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-revert">git-revert[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-cherry-pick" class="_attribution-link">https://git-scm.com/docs/git-cherry-pick</a> + </p> +</div> diff --git a/devdocs/git/git-cherry.html b/devdocs/git/git-cherry.html new file mode 100644 index 00000000..2a53f374 --- /dev/null +++ b/devdocs/git/git-cherry.html @@ -0,0 +1,42 @@ +<h1>git-cherry</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-cherry - Find commits yet to be applied to upstream</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git cherry [-v] [<upstream> [<head> [<limit>]]]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Determine whether there are commits in <code><head>..<upstream></code> that are equivalent to those in the range <code><limit>..<head></code>.</p> <p>The equivalence test is based on the diff, after removing whitespace and line numbers. git-cherry therefore detects when commits have been "copied" by means of <a href="git-cherry-pick">git-cherry-pick[1]</a>, <a href="git-am">git-am[1]</a> or <a href="git-rebase">git-rebase[1]</a>.</p> <p>Outputs the SHA1 of every commit in <code><limit>..<head></code>, prefixed with <code>-</code> for commits that have an equivalent in <upstream>, and <code>+</code> for commits that do not.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cherry.txt--v"> -v </dt> <dd> <p>Show the commit subjects next to the SHA1s.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry.txt-ltupstreamgt"> <upstream> </dt> <dd> <p>Upstream branch to search for equivalent commits. Defaults to the upstream branch of HEAD.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry.txt-ltheadgt"> <head> </dt> <dd> <p>Working branch; defaults to HEAD.</p> </dd> <dt class="hdlist1" id="Documentation/git-cherry.txt-ltlimitgt"> <limit> </dt> <dd> <p>Do not report commits up to (and including) limit.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_patch_workflows"> +Patch workflows</h3> <p>git-cherry is frequently used in patch-based workflows (see <a href="gitworkflows">gitworkflows[7]</a>) to determine if a series of patches has been applied by the upstream maintainer. In such a workflow you might create and send a topic branch like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout -b topic origin/master +# work and create some commits +$ git format-patch origin/master +$ git send-email ... 00*</pre> </div> </div> <p>Later, you can see whether your changes have been applied by saying (still on <code>topic</code>):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch # update your notion of origin/master +$ git cherry -v</pre> </div> </div> </div> <div class="sect2"> <h3 id="_concrete_example"> +Concrete example</h3> <p>In a situation where topic consisted of three commits, and the maintainer applied two of them, the situation might look like:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log --graph --oneline --decorate --boundary origin/master...topic +* 7654321 (origin/master) upstream tip commit +[... snip some other commits ...] +* cccc111 cherry-pick of C +* aaaa111 cherry-pick of A +[... snip a lot more that has happened ...] +| * cccc000 (topic) commit C +| * bbbb000 commit B +| * aaaa000 commit A +|/ +o 1234567 branch point</pre> </div> </div> <p>In such cases, git-cherry shows a concise summary of what has yet to be applied:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cherry origin/master topic +- cccc000... commit C ++ bbbb000... commit B +- aaaa000... commit A</pre> </div> </div> <p>Here, we see that the commits A and C (marked with <code>-</code>) can be dropped from your <code>topic</code> branch when you rebase it on top of <code>origin/master</code>, while the commit B (marked with <code>+</code>) still needs to be kept so that it will be sent to be applied to <code>origin/master</code>.</p> </div> <div class="sect2"> <h3 id="_using_a_limit"> +Using a limit</h3> <p>The optional <limit> is useful in cases where your topic is based on other work that is not in upstream. Expanding on the previous example, this might look like:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log --graph --oneline --decorate --boundary origin/master...topic +* 7654321 (origin/master) upstream tip commit +[... snip some other commits ...] +* cccc111 cherry-pick of C +* aaaa111 cherry-pick of A +[... snip a lot more that has happened ...] +| * cccc000 (topic) commit C +| * bbbb000 commit B +| * aaaa000 commit A +| * 0000fff (base) unpublished stuff F +[... snip ...] +| * 0000aaa unpublished stuff A +|/ +o 1234567 merge-base between upstream and topic</pre> </div> </div> <p>By specifying <code>base</code> as the limit, you can avoid listing commits between <code>base</code> and <code>topic</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cherry origin/master topic base +- cccc000... commit C ++ bbbb000... commit B +- aaaa000... commit A</pre> </div> </div> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-patch-id">git-patch-id[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-cherry" class="_attribution-link">https://git-scm.com/docs/git-cherry</a> + </p> +</div> diff --git a/devdocs/git/git-citool.html b/devdocs/git/git-citool.html new file mode 100644 index 00000000..8d71101a --- /dev/null +++ b/devdocs/git/git-citool.html @@ -0,0 +1,6 @@ +<h1>git-citool</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-citool - Graphical alternative to git-commit</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git citool</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>A Tcl/Tk based graphical interface to review modified files, stage them into the index, enter a commit message and record the new commit onto the current branch. This interface is an alternative to the less interactive <code>git commit</code> program.</p> <p><code>git citool</code> is actually a standard alias for <code>git gui citool</code>. See <a href="git-gui">git-gui[1]</a> for more details.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-citool" class="_attribution-link">https://git-scm.com/docs/git-citool</a> + </p> +</div> diff --git a/devdocs/git/git-clean.html b/devdocs/git/git-clean.html new file mode 100644 index 00000000..a29cb971 --- /dev/null +++ b/devdocs/git/git-clean.html @@ -0,0 +1,9 @@ +<h1>git-clean</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-clean - Remove untracked files from the working tree</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] [<pathspec>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Cleans the working tree by recursively removing files that are not under version control, starting from the current directory.</p> <p>Normally, only files unknown to Git are removed, but if the <code>-x</code> option is specified, ignored files are also removed. This can, for example, be useful to remove all build products.</p> <p>If any optional <code><pathspec>...</code> arguments are given, only those paths that match the pathspec are affected.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-clean.txt--d"> -d </dt> <dd> <p>Normally, when no <pathspec> is specified, git clean will not recurse into untracked directories to avoid removing too much. Specify -d to have it recurse into such directories as well. If a <pathspec> is specified, -d is irrelevant; all untracked files matching the specified paths (with exceptions for nested git directories mentioned under <code>--force</code>) will be removed.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-clean.txt---force"> --force </dt> <dd> <p>If the Git configuration variable clean.requireForce is not set to false, <code>git clean</code> will refuse to delete files or directories unless given -f or -i. Git will refuse to modify untracked nested git repositories (directories with a .git subdirectory) unless a second -f is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt--i"> -i </dt> <dt class="hdlist1" id="Documentation/git-clean.txt---interactive"> --interactive </dt> <dd> <p>Show what would be done and clean files interactively. See “Interactive mode” for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-clean.txt---dry-run"> --dry-run </dt> <dd> <p>Don’t actually remove anything, just show what would be done.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-clean.txt---quiet"> --quiet </dt> <dd> <p>Be quiet, only report errors, but not the files that are successfully removed.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt--eltpatterngt"> -e <pattern> </dt> <dt class="hdlist1" id="Documentation/git-clean.txt---excludeltpatterngt"> --exclude=<pattern> </dt> <dd> <p>Use the given exclude pattern in addition to the standard ignore rules (see <a href="gitignore">gitignore[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt--x"> -x </dt> <dd> <p>Don’t use the standard ignore rules (see <a href="gitignore">gitignore[5]</a>), but still use the ignore rules given with <code>-e</code> options from the command line. This allows removing all untracked files, including build products. This can be used (possibly in conjunction with <code>git restore</code> or <code>git reset</code>) to create a pristine working directory to test a clean build.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt--X"> -X </dt> <dd> <p>Remove only files ignored by Git. This may be useful to rebuild everything from scratch, but keep manually created files.</p> </dd> </dl> </div> </div> <h2 id="_interactive_mode">Interactive mode</h2> <div class="sectionbody"> <p>When the command enters the interactive mode, it shows the files and directories to be cleaned, and goes into its interactive command loop.</p> <p>The command loop shows the list of subcommands available, and gives a prompt "What now> ". In general, when the prompt ends with a single <code>></code>, you can pick only one of the choices given and type return, like this:</p> <div class="listingblock"> <div class="content"> <pre> *** Commands *** + 1: clean 2: filter by pattern 3: select by numbers + 4: ask each 5: quit 6: help + What now> 1</pre> </div> </div> <p>You also could say <code>c</code> or <code>clean</code> above as long as the choice is unique.</p> <p>The main command loop has 6 subcommands.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-clean.txt-clean"> clean </dt> <dd> <p>Start cleaning files and directories, and then quit.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt-filterbypattern"> filter by pattern </dt> <dd> <p>This shows the files and directories to be deleted and issues an "Input ignore patterns>>" prompt. You can input space-separated patterns to exclude files and directories from deletion. E.g. "*.c *.h" will exclude files ending with ".c" and ".h" from deletion. When you are satisfied with the filtered result, press ENTER (empty) back to the main menu.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt-selectbynumbers"> select by numbers </dt> <dd> <p>This shows the files and directories to be deleted and issues an "Select items to delete>>" prompt. When the prompt ends with double <code>>></code> like this, you can make more than one selection, concatenated with whitespace or comma. Also you can say ranges. E.g. "2-5 7,9" to choose 2,3,4,5,7,9 from the list. If the second number in a range is omitted, all remaining items are selected. E.g. "7-" to choose 7,8,9 from the list. You can say <code>*</code> to choose everything. Also when you are satisfied with the filtered result, press ENTER (empty) back to the main menu.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt-askeach"> ask each </dt> <dd> <p>This will start to clean, and you must confirm one by one in order to delete items. Please note that this action is not as efficient as the above two actions.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt-quit"> quit </dt> <dd> <p>This lets you quit without doing any cleaning.</p> </dd> <dt class="hdlist1" id="Documentation/git-clean.txt-help"> help </dt> <dd> <p>Show brief usage of interactive git-clean.</p> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-clean.txt-cleanrequireForce"> clean.requireForce </dt> <dd> <p>A boolean to make git-clean do nothing unless given -f, -i, or -n. Defaults to true.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gitignore">gitignore[5]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-clean" class="_attribution-link">https://git-scm.com/docs/git-clean</a> + </p> +</div> diff --git a/devdocs/git/git-clone.html b/devdocs/git/git-clone.html new file mode 100644 index 00000000..de489c70 --- /dev/null +++ b/devdocs/git/git-clone.html @@ -0,0 +1,26 @@ +<h1>git-clone</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-clone - Clone a repository into a new directory</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git clone [--template=<template-directory>] + [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror] + [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>] + [--dissociate] [--separate-git-dir <git-dir>] + [--depth <depth>] [--[no-]single-branch] [--no-tags] + [--recurse-submodules[=<pathspec>]] [--[no-]shallow-submodules] + [--[no-]remote-submodules] [--jobs <n>] [--sparse] [--[no-]reject-shallow] + [--filter=<filter> [--also-filter-submodules]] [--] <repository> + [<directory>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Clones a repository into a newly created directory, creates remote-tracking branches for each branch in the cloned repository (visible using <code>git branch --remotes</code>), and creates and checks out an initial branch that is forked from the cloned repository’s currently active branch.</p> <p>After the clone, a plain <code>git fetch</code> without arguments will update all the remote-tracking branches, and a <code>git pull</code> without arguments will in addition merge the remote master branch into the current master branch, if any (this is untrue when "--single-branch" is given; see below).</p> <p>This default configuration is achieved by creating references to the remote branch heads under <code>refs/remotes/origin</code> and by initializing <code>remote.origin.url</code> and <code>remote.origin.fetch</code> configuration variables.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-clone.txt--l"> -l </dt> <dt class="hdlist1" id="Documentation/git-clone.txt---local"> --local </dt> <dd> <p>When the repository to clone from is on a local machine, this flag bypasses the normal "Git aware" transport mechanism and clones the repository by making a copy of HEAD and everything under objects and refs directories. The files under <code>.git/objects/</code> directory are hardlinked to save space when possible.</p> <p>If the repository is specified as a local path (e.g., <code>/path/to/repo</code>), this is the default, and --local is essentially a no-op. If the repository is specified as a URL, then this flag is ignored (and we never use the local optimizations). Specifying <code>--no-local</code> will override the default when <code>/path/to/repo</code> is given, using the regular Git transport instead.</p> <p>If the repository’s <code>$GIT_DIR/objects</code> has symbolic links or is a symbolic link, the clone will fail. This is a security measure to prevent the unintentional copying of files by dereferencing the symbolic links.</p> <p><strong>NOTE</strong>: this operation can race with concurrent modification to the source repository, similar to running <code>cp -r src dst</code> while modifying <code>src</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---no-hardlinks"> --no-hardlinks </dt> <dd> <p>Force the cloning process from a repository on a local filesystem to copy the files under the <code>.git/objects</code> directory instead of using hardlinks. This may be desirable if you are trying to make a back-up of your repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-clone.txt---shared"> --shared </dt> <dd> <p>When the repository to clone is on the local machine, instead of using hard links, automatically setup <code>.git/objects/info/alternates</code> to share the objects with the source repository. The resulting repository starts out without any object of its own.</p> <p><strong>NOTE</strong>: this is a possibly dangerous operation; do <strong>not</strong> use it unless you understand what it does. If you clone your repository using this option and then delete branches (or use any other Git command that makes any existing commit unreferenced) in the source repository, some objects may become unreferenced (or dangling). These objects may be removed by normal Git operations (such as <code>git commit</code>) which automatically call <code>git maintenance run --auto</code>. (See <a href="git-maintenance">git-maintenance[1]</a>.) If these objects are removed and were referenced by the cloned repository, then the cloned repository will become corrupt.</p> <p>Note that running <code>git repack</code> without the <code>--local</code> option in a repository cloned with <code>--shared</code> will copy objects from the source repository into a pack in the cloned repository, removing the disk space savings of <code>clone --shared</code>. It is safe, however, to run <code>git gc</code>, which uses the <code>--local</code> option by default.</p> <p>If you want to break the dependency of a repository cloned with <code>--shared</code> on its source repository, you can simply run <code>git repack -a</code> to copy all objects from the source repository into a pack in the cloned repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---reference-if-ableltrepositorygt"> --reference[-if-able] <repository> </dt> <dd> <p>If the reference repository is on the local machine, automatically setup <code>.git/objects/info/alternates</code> to obtain objects from the reference repository. Using an already existing repository as an alternate will require fewer objects to be copied from the repository being cloned, reducing network and local storage costs. When using the <code>--reference-if-able</code>, a non existing directory is skipped with a warning instead of aborting the clone.</p> <p><strong>NOTE</strong>: see the NOTE for the <code>--shared</code> option, and also the <code>--dissociate</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---dissociate"> --dissociate </dt> <dd> <p>Borrow the objects from reference repositories specified with the <code>--reference</code> options only to reduce network transfer, and stop borrowing from them after a clone is made by making necessary local copies of borrowed objects. This option can also be used when cloning locally from a repository that already borrows objects from another repository—the new repository will borrow objects from the same repository, and this option can be used to stop the borrowing.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-clone.txt---quiet"> --quiet </dt> <dd> <p>Operate quietly. Progress is not reported to the standard error stream.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-clone.txt---verbose"> --verbose </dt> <dd> <p>Run verbosely. Does not affect the reporting of progress status to the standard error stream.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---progress"> --progress </dt> <dd> <p>Progress status is reported on the standard error stream by default when it is attached to a terminal, unless <code>--quiet</code> is specified. This flag forces progress status even if the standard error stream is not directed to a terminal.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---server-optionltoptiongt"> --server-option=<option> </dt> <dd> <p>Transmit the given string to the server when communicating using protocol version 2. The given string must not contain a NUL or LF character. The server’s handling of server options, including unknown ones, is server-specific. When multiple <code>--server-option=<option></code> are given, they are all sent to the other side in the order listed on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-clone.txt---no-checkout"> --no-checkout </dt> <dd> <p>No checkout of HEAD is performed after the clone is complete.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---no-reject-shallow"> --[no-]reject-shallow </dt> <dd> <p>Fail if the source repository is a shallow repository. The <code>clone.rejectShallow</code> configuration variable can be used to specify the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---bare"> --bare </dt> <dd> <p>Make a <code>bare</code> Git repository. That is, instead of creating <code><directory></code> and placing the administrative files in <code><directory>/.git</code>, make the <code><directory></code> itself the <code>$GIT_DIR</code>. This obviously implies the <code>--no-checkout</code> because there is nowhere to check out the working tree. Also the branch heads at the remote are copied directly to corresponding local branch heads, without mapping them to <code>refs/remotes/origin/</code>. When this option is used, neither remote-tracking branches nor the related configuration variables are created.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---sparse"> --sparse </dt> <dd> <p>Employ a sparse-checkout, with only files in the toplevel directory initially being present. The <a href="git-sparse-checkout">git-sparse-checkout[1]</a> command can be used to grow the working directory as needed.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---filterltfilter-specgt"> --filter=<filter-spec> </dt> <dd> <p>Use the partial clone feature and request that the server sends a subset of reachable objects according to a given object filter. When using <code>--filter</code>, the supplied <code><filter-spec></code> is used for the partial clone filter. For example, <code>--filter=blob:none</code> will filter out all blobs (file contents) until needed by Git. Also, <code>--filter=blob:limit=<size></code> will filter out all blobs of size at least <code><size></code>. For more details on filter specifications, see the <code>--filter</code> option in <a href="git-rev-list">git-rev-list[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---also-filter-submodules"> --also-filter-submodules </dt> <dd> <p>Also apply the partial clone filter to any submodules in the repository. Requires <code>--filter</code> and <code>--recurse-submodules</code>. This can be turned on by default by setting the <code>clone.filterSubmodules</code> config option.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---mirror"> --mirror </dt> <dd> <p>Set up a mirror of the source repository. This implies <code>--bare</code>. Compared to <code>--bare</code>, <code>--mirror</code> not only maps local branches of the source to local branches of the target, it maps all refs (including remote-tracking branches, notes etc.) and sets up a refspec configuration such that all these refs are overwritten by a <code>git remote update</code> in the target repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt--oltnamegt"> -o <name> </dt> <dt class="hdlist1" id="Documentation/git-clone.txt---originltnamegt"> --origin <name> </dt> <dd> <p>Instead of using the remote name <code>origin</code> to keep track of the upstream repository, use <code><name></code>. Overrides <code>clone.defaultRemoteName</code> from the config.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt--bltnamegt"> -b <name> </dt> <dt class="hdlist1" id="Documentation/git-clone.txt---branchltnamegt"> --branch <name> </dt> <dd> <p>Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository’s HEAD, point to <code><name></code> branch instead. In a non-bare repository, this is the branch that will be checked out. <code>--branch</code> can also take tags and detaches the HEAD at that commit in the resulting repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt--ultupload-packgt"> -u <upload-pack> </dt> <dt class="hdlist1" id="Documentation/git-clone.txt---upload-packltupload-packgt"> --upload-pack <upload-pack> </dt> <dd> <p>When given, and the repository to clone from is accessed via ssh, this specifies a non-default path for the command run on the other end.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---templatelttemplate-directorygt"> --template=<template-directory> </dt> <dd> <p>Specify the directory from which templates will be used; (See the "TEMPLATE DIRECTORY" section of <a href="git-init">git-init[1]</a>.)</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt--cltkeygtltvaluegt"> -c <key>=<value> </dt> <dt class="hdlist1" id="Documentation/git-clone.txt---configltkeygtltvaluegt"> --config <key>=<value> </dt> <dd> <p>Set a configuration variable in the newly-created repository; this takes effect immediately after the repository is initialized, but before the remote history is fetched or any files checked out. The key is in the same format as expected by <a href="git-config">git-config[1]</a> (e.g., <code>core.eol=true</code>). If multiple values are given for the same key, each value will be written to the config file. This makes it safe, for example, to add additional fetch refspecs to the origin remote.</p> <p>Due to limitations of the current implementation, some configuration variables do not take effect until after the initial fetch and checkout. Configuration variables known to not take effect are: <code>remote.<name>.mirror</code> and <code>remote.<name>.tagOpt</code>. Use the corresponding <code>--mirror</code> and <code>--no-tags</code> options instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---depthltdepthgt"> --depth <depth> </dt> <dd> <p>Create a <code>shallow</code> clone with a history truncated to the specified number of commits. Implies <code>--single-branch</code> unless <code>--no-single-branch</code> is given to fetch the histories near the tips of all branches. If you want to clone submodules shallowly, also pass <code>--shallow-submodules</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---shallow-sinceltdategt"> --shallow-since=<date> </dt> <dd> <p>Create a shallow clone with a history after the specified time.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---shallow-excludeltrevisiongt"> --shallow-exclude=<revision> </dt> <dd> <p>Create a shallow clone with a history, excluding commits reachable from a specified remote branch or tag. This option can be specified multiple times.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---no-single-branch"> --[no-]single-branch </dt> <dd> <p>Clone only the history leading to the tip of a single branch, either specified by the <code>--branch</code> option or the primary branch remote’s <code>HEAD</code> points at. Further fetches into the resulting repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If the HEAD at the remote did not point at any branch when <code>--single-branch</code> clone was made, no remote-tracking branch is created.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---no-tags"> --no-tags </dt> <dd> <p>Don’t clone any tags, and set <code>remote.<remote>.tagOpt=--no-tags</code> in the config, ensuring that future <code>git pull</code> and <code>git fetch</code> operations won’t follow any tags. Subsequent explicit tag fetches will still work, (see <a href="git-fetch">git-fetch[1]</a>).</p> <p>Can be used in conjunction with <code>--single-branch</code> to clone and maintain a branch with no references other than a single cloned branch. This is useful e.g. to maintain minimal clones of the default branch of some repository for search indexing.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---recurse-submodulesltpathspecgt"> --recurse-submodules[=<pathspec>] </dt> <dd> <p>After the clone is created, initialize and clone submodules within based on the provided pathspec. If no pathspec is provided, all submodules are initialized and cloned. This option can be given multiple times for pathspecs consisting of multiple entries. The resulting clone has <code>submodule.active</code> set to the provided pathspec, or "." (meaning all submodules) if no pathspec is provided.</p> <p>Submodules are initialized and cloned using their default settings. This is equivalent to running <code>git submodule update --init --recursive <pathspec></code> immediately after the clone is finished. This option is ignored if the cloned repository does not have a worktree/checkout (i.e. if any of <code>--no-checkout</code>/<code>-n</code>, <code>--bare</code>, or <code>--mirror</code> is given)</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---no-shallow-submodules"> --[no-]shallow-submodules </dt> <dd> <p>All submodules which are cloned will be shallow with a depth of 1.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---no-remote-submodules"> --[no-]remote-submodules </dt> <dd> <p>All submodules which are cloned will use the status of the submodule’s remote-tracking branch to update the submodule, rather than the superproject’s recorded SHA-1. Equivalent to passing <code>--remote</code> to <code>git submodule update</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---separate-git-dirltgit-dirgt"> --separate-git-dir=<git-dir> </dt> <dd> <p>Instead of placing the cloned repository where it is supposed to be, place the cloned repository at the specified directory, then make a filesystem-agnostic Git symbolic link to there. The result is Git repository can be separated from working tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt--jltngt"> -j <n> </dt> <dt class="hdlist1" id="Documentation/git-clone.txt---jobsltngt"> --jobs <n> </dt> <dd> <p>The number of submodules fetched at the same time. Defaults to the <code>submodule.fetchJobs</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt-ltrepositorygt"> <repository> </dt> <dd> <p>The (possibly remote) repository to clone from. See the <a href="#URLS">GIT URLS</a> section below for more information on specifying repositories.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt-ltdirectorygt"> <directory> </dt> <dd> <p>The name of a new directory to clone into. The "humanish" part of the source repository is used if no directory is explicitly given (<code>repo</code> for <code>/path/to/repo.git</code> and <code>foo</code> for <code>host.xz:foo/.git</code>). Cloning into an existing directory is only allowed if the directory is empty.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt---bundle-urilturigt"> --bundle-uri=<uri> </dt> <dd> <p>Before fetching from the remote, fetch a bundle from the given <code><uri></code> and unbundle the data into the local repository. The refs in the bundle will be stored under the hidden <code>refs/bundle/*</code> namespace. This option is incompatible with <code>--depth</code>, <code>--shallow-since</code>, and <code>--shallow-exclude</code>.</p> </dd> </dl> </div> </div> <h2 id="_git_urls">Git urls</h2> <div class="sectionbody"> <p>In general, URLs contain information about the transport protocol, the address of the remote server, and the path to the repository. Depending on the transport protocol, some of this information may be absent.</p> <p>Git supports ssh, git, http, and https protocols (in addition, ftp and ftps can be used for fetching, but this is inefficient and deprecated; do not use them).</p> <p>The native transport (i.e. git:// URL) does no authentication and should be used with caution on unsecured networks.</p> <p>The following syntaxes may be used with them:</p> <div class="ulist"> <ul> <li> <p>ssh://[user@]host.xz[:port]/path/to/repo.git/</p> </li> <li> <p>git://host.xz[:port]/path/to/repo.git/</p> </li> <li> <p>http[s]://host.xz[:port]/path/to/repo.git/</p> </li> <li> <p>ftp[s]://host.xz[:port]/path/to/repo.git/</p> </li> </ul> </div> <p>An alternative scp-like syntax may also be used with the ssh protocol:</p> <div class="ulist"> <ul> <li> <p>[user@]host.xz:path/to/repo.git/</p> </li> </ul> </div> <p>This syntax is only recognized if there are no slashes before the first colon. This helps differentiate a local path that contains a colon. For example the local path <code>foo:bar</code> could be specified as an absolute path or <code>./foo:bar</code> to avoid being misinterpreted as an ssh url.</p> <p>The ssh and git protocols additionally support ~username expansion:</p> <div class="ulist"> <ul> <li> <p>ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/</p> </li> <li> <p>git://host.xz[:port]/~[user]/path/to/repo.git/</p> </li> <li> <p>[user@]host.xz:/~[user]/path/to/repo.git/</p> </li> </ul> </div> <p>For local repositories, also supported by Git natively, the following syntaxes may be used:</p> <div class="ulist"> <ul> <li> <p>/path/to/repo.git/</p> </li> <li> <p>file:///path/to/repo.git/</p> </li> </ul> </div> <p>These two syntaxes are mostly equivalent, except the former implies --local option.</p> <p><code>git clone</code>, <code>git fetch</code> and <code>git pull</code>, but not <code>git push</code>, will also accept a suitable bundle file. See <a href="git-bundle">git-bundle[1]</a>.</p> <p>When Git doesn’t know how to handle a certain transport protocol, it attempts to use the <code>remote-<transport></code> remote helper, if one exists. To explicitly request a remote helper, the following syntax may be used:</p> <div class="ulist"> <ul> <li> <p><transport>::<address></p> </li> </ul> </div> <p>where <address> may be a path, a server and path, or an arbitrary URL-like string recognized by the specific remote helper being invoked. See <a href="gitremote-helpers">gitremote-helpers[7]</a> for details.</p> <p>If there are a large number of similarly-named remote repositories and you want to use a different format for them (such that the URLs you use will be rewritten into URLs that work), you can create a configuration section of the form:</p> <div class="listingblock"> <div class="content"> <pre> [url "<actual url base>"] + insteadOf = <other url base></pre> </div> </div> <p>For example, with this:</p> <div class="listingblock"> <div class="content"> <pre> [url "git://git.host.xz/"] + insteadOf = host.xz:/path/to/ + insteadOf = work:</pre> </div> </div> <p>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</p> <p>If you want to rewrite URLs for push only, you can create a configuration section of the form:</p> <div class="listingblock"> <div class="content"> <pre> [url "<actual url base>"] + pushInsteadOf = <other url base></pre> </div> </div> <p>For example, with this:</p> <div class="listingblock"> <div class="content"> <pre> [url "ssh://example.org/"] + pushInsteadOf = git://example.org/</pre> </div> </div> <p>a URL like "git://example.org/path/to/repo.git" will be rewritten to "ssh://example.org/path/to/repo.git" for pushes, but pulls will still use the original URL.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Clone from upstream:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git clone git://git.kernel.org/pub/scm/.../linux.git my-linux +$ cd my-linux +$ make</pre> </div> </div> </li> <li> <p>Make a local clone that borrows from the current directory, without checking things out:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git clone -l -s -n . ../copy +$ cd ../copy +$ git show-branch</pre> </div> </div> </li> <li> <p>Clone from upstream while borrowing from an existing local directory:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git clone --reference /git/linux.git \ + git://git.kernel.org/pub/scm/.../linux.git \ + my-linux +$ cd my-linux</pre> </div> </div> </li> <li> <p>Create a bare repository to publish your changes to the public:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git clone --bare -l /home/proj/.git /pub/scm/proj.git</pre> </div> </div> </li> </ul> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-clone.txt-inittemplateDir"> init.templateDir </dt> <dd> <p>Specify the directory from which templates will be copied. (See the "TEMPLATE DIRECTORY" section of <a href="git-init">git-init[1]</a>.)</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt-initdefaultBranch"> init.defaultBranch </dt> <dd> <p>Allows overriding the default branch name e.g. when initializing a new repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt-clonedefaultRemoteName"> clone.defaultRemoteName </dt> <dd> <p>The name of the remote to create when cloning a repository. Defaults to <code>origin</code>, and can be overridden by passing the <code>--origin</code> command-line option to <a href="git-clone">git-clone[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt-clonerejectShallow"> clone.rejectShallow </dt> <dd> <p>Reject cloning a repository if it is a shallow one; this can be overridden by passing the <code>--reject-shallow</code> option on the command line. See <a href="git-clone">git-clone[1]</a></p> </dd> <dt class="hdlist1" id="Documentation/git-clone.txt-clonefilterSubmodules"> clone.filterSubmodules </dt> <dd> <p>If a partial clone filter is provided (see <code>--filter</code> in <a href="git-rev-list">git-rev-list[1]</a>) and <code>--recurse-submodules</code> is used, also apply the filter to submodules.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-clone" class="_attribution-link">https://git-scm.com/docs/git-clone</a> + </p> +</div> diff --git a/devdocs/git/git-column.html b/devdocs/git/git-column.html new file mode 100644 index 00000000..265cb72b --- /dev/null +++ b/devdocs/git/git-column.html @@ -0,0 +1,17 @@ +<h1>git-column</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-column - Display data in columns</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git column [--command=<name>] [--[raw-]mode=<mode>] [--width=<width>] + [--indent=<string>] [--nl=<string>] [--padding=<n>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This command formats the lines of its standard input into a table with multiple columns. Each input line occupies one cell of the table. It is used internally by other git commands to format output into columns.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-column.txt---commandltnamegt"> --command=<name> </dt> <dd> <p>Look up layout mode using configuration variable column.<name> and column.ui.</p> </dd> <dt class="hdlist1" id="Documentation/git-column.txt---modeltmodegt"> --mode=<mode> </dt> <dd> <p>Specify layout mode. See configuration variable column.ui for option syntax in <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-column.txt---raw-modeltngt"> --raw-mode=<n> </dt> <dd> <p>Same as --mode but take mode encoded as a number. This is mainly used by other commands that have already parsed layout mode.</p> </dd> <dt class="hdlist1" id="Documentation/git-column.txt---widthltwidthgt"> --width=<width> </dt> <dd> <p>Specify the terminal width. By default <code>git column</code> will detect the terminal width, or fall back to 80 if it is unable to do so.</p> </dd> <dt class="hdlist1" id="Documentation/git-column.txt---indentltstringgt"> --indent=<string> </dt> <dd> <p>String to be printed at the beginning of each line.</p> </dd> <dt class="hdlist1" id="Documentation/git-column.txt---nlltstringgt"> --nl=<string> </dt> <dd> <p>String to be printed at the end of each line, including newline character.</p> </dd> <dt class="hdlist1" id="Documentation/git-column.txt---paddingltNgt"> --padding=<N> </dt> <dd> <p>The number of spaces between columns. One space by default.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>Format data by columns:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ seq 1 24 | git column --mode=column --padding=5 +1 4 7 10 13 16 19 22 +2 5 8 11 14 17 20 23 +3 6 9 12 15 18 21 24</pre> </div> </div> <p>Format data by rows:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ seq 1 21 | git column --mode=row --padding=5 +1 2 3 4 5 6 7 +8 9 10 11 12 13 14 +15 16 17 18 19 20 21</pre> </div> </div> <p>List some tags in a table with unequal column widths:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git tag --list 'v2.4.*' --column=row,dense +v2.4.0 v2.4.0-rc0 v2.4.0-rc1 v2.4.0-rc2 v2.4.0-rc3 +v2.4.1 v2.4.10 v2.4.11 v2.4.12 v2.4.2 +v2.4.3 v2.4.4 v2.4.5 v2.4.6 v2.4.7 +v2.4.8 v2.4.9</pre> </div> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-column.txt-columnui"> column.ui </dt> <dd> <p>Specify whether supported commands should output in columns. This variable consists of a list of tokens separated by spaces or commas:</p> <p>These options control when the feature should be enabled (defaults to <code>never</code>):</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-column.txt-codealwayscode"> <code>always</code> </dt> <dd> <p>always show in columns</p> </dd> <dt class="hdlist1" id="Documentation/git-column.txt-codenevercode"> <code>never</code> </dt> <dd> <p>never show in columns</p> </dd> <dt class="hdlist1" id="Documentation/git-column.txt-codeautocode"> <code>auto</code> </dt> <dd> <p>show in columns if the output is to the terminal</p> </dd> </dl> </div> </div> </div> <p>These options control layout (defaults to <code>column</code>). Setting any of these implies <code>always</code> if none of <code>always</code>, <code>never</code>, or <code>auto</code> are specified.</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-column.txt-codecolumncode"> <code>column</code> </dt> <dd> <p>fill columns before rows</p> </dd> <dt class="hdlist1" id="Documentation/git-column.txt-coderowcode"> <code>row</code> </dt> <dd> <p>fill rows before columns</p> </dd> <dt class="hdlist1" id="Documentation/git-column.txt-codeplaincode"> <code>plain</code> </dt> <dd> <p>show in one column</p> </dd> </dl> </div> </div> </div> <p>Finally, these options can be combined with a layout option (defaults to <code>nodense</code>):</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-column.txt-codedensecode"> <code>dense</code> </dt> <dd> <p>make unequal size columns to utilize more space</p> </dd> <dt class="hdlist1" id="Documentation/git-column.txt-codenodensecode"> <code>nodense</code> </dt> <dd> <p>make equal size columns</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-column.txt-columnbranch"> column.branch </dt> <dd> <p>Specify whether to output branch listing in <code>git branch</code> in columns. See <code>column.ui</code> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-column.txt-columnclean"> column.clean </dt> <dd> <p>Specify the layout when listing items in <code>git clean -i</code>, which always shows files and directories in columns. See <code>column.ui</code> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-column.txt-columnstatus"> column.status </dt> <dd> <p>Specify whether to output untracked files in <code>git status</code> in columns. See <code>column.ui</code> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-column.txt-columntag"> column.tag </dt> <dd> <p>Specify whether to output tag listings in <code>git tag</code> in columns. See <code>column.ui</code> for details.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-column" class="_attribution-link">https://git-scm.com/docs/git-column</a> + </p> +</div> diff --git a/devdocs/git/git-commit-graph.html b/devdocs/git/git-commit-graph.html new file mode 100644 index 00000000..4cc60e38 --- /dev/null +++ b/devdocs/git/git-commit-graph.html @@ -0,0 +1,11 @@ +<h1>git-commit-graph</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-commit-graph - Write and verify Git commit-graph files</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git commit-graph verify [--object-dir <dir>] [--shallow] [--[no-]progress] +git commit-graph write [--object-dir <dir>] [--append] + [--split[=<strategy>]] [--reachable | --stdin-packs | --stdin-commits] + [--changed-paths] [--[no-]max-new-filters <n>] [--[no-]progress] + <split options></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Manage the serialized commit-graph file.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-commit-graph.txt---object-dir"> --object-dir </dt> <dd> <p>Use given directory for the location of packfiles and commit-graph file. This parameter exists to specify the location of an alternate that only has the objects directory, not a full <code>.git</code> directory. The commit-graph file is expected to be in the <code><dir>/info</code> directory and the packfiles are expected to be in <code><dir>/pack</code>. If the directory could not be made into an absolute path, or does not match any known object directory, <code>git commit-graph ...</code> will exit with non-zero status.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit-graph.txt---no-progress"> --[no-]progress </dt> <dd> <p>Turn progress on/off explicitly. If neither is specified, progress is shown if standard error is connected to a terminal.</p> </dd> </dl> </div> </div> <h2 id="_commands">Commands</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-commit-graph.txt-emwriteem"> <em>write</em> </dt> <dd> <p>Write a commit-graph file based on the commits found in packfiles. If the config option <code>core.commitGraph</code> is disabled, then this command will output a warning, then return success without writing a commit-graph file.</p> <p>With the <code>--stdin-packs</code> option, generate the new commit graph by walking objects only in the specified pack-indexes. (Cannot be combined with <code>--stdin-commits</code> or <code>--reachable</code>.)</p> <p>With the <code>--stdin-commits</code> option, generate the new commit graph by walking commits starting at the commits specified in stdin as a list of OIDs in hex, one OID per line. OIDs that resolve to non-commits (either directly, or by peeling tags) are silently ignored. OIDs that are malformed, or do not exist generate an error. (Cannot be combined with <code>--stdin-packs</code> or <code>--reachable</code>.)</p> <p>With the <code>--reachable</code> option, generate the new commit graph by walking commits starting at all refs. (Cannot be combined with <code>--stdin-commits</code> or <code>--stdin-packs</code>.)</p> <p>With the <code>--append</code> option, include all commits that are present in the existing commit-graph file.</p> <p>With the <code>--changed-paths</code> option, compute and write information about the paths changed between a commit and its first parent. This operation can take a while on large repositories. It provides significant performance gains for getting history of a directory or a file with <code>git log -- <path></code>. If this option is given, future commit-graph writes will automatically assume that this option was intended. Use <code>--no-changed-paths</code> to stop storing this data.</p> <p>With the <code>--max-new-filters=<n></code> option, generate at most <code>n</code> new Bloom filters (if <code>--changed-paths</code> is specified). If <code>n</code> is <code>-1</code>, no limit is enforced. Only commits present in the new layer count against this limit. To retroactively compute Bloom filters over earlier layers, it is advised to use <code>--split=replace</code>. Overrides the <code>commitGraph.maxNewFilters</code> configuration.</p> <p>With the <code>--split[=<strategy>]</code> option, write the commit-graph as a chain of multiple commit-graph files stored in <code><dir>/info/commit-graphs</code>. Commit-graph layers are merged based on the strategy and other splitting options. The new commits not already in the commit-graph are added in a new "tip" file. This file is merged with the existing file if the following merge conditions are met:</p> <div class="ulist"> <ul> <li> <p>If <code>--split=no-merge</code> is specified, a merge is never performed, and the remaining options are ignored. <code>--split=replace</code> overwrites the existing chain with a new one. A bare <code>--split</code> defers to the remaining options. (Note that merging a chain of commit graphs replaces the existing chain with a length-1 chain where the first and only incremental holds the entire graph).</p> </li> <li> <p>If <code>--size-multiple=<X></code> is not specified, let <code>X</code> equal 2. If the new tip file would have <code>N</code> commits and the previous tip has <code>M</code> commits and <code>X</code> times <code>N</code> is greater than <code>M</code>, instead merge the two files into a single file.</p> </li> <li> <p>If <code>--max-commits=<M></code> is specified with <code>M</code> a positive integer, and the new tip file would have more than <code>M</code> commits, then instead merge the new tip with the previous tip.</p> <p>Finally, if <code>--expire-time=<datetime></code> is not specified, let <code>datetime</code> be the current time. After writing the split commit-graph, delete all unused commit-graph whose modified times are older than <code>datetime</code>.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-commit-graph.txt-emverifyem"> <em>verify</em> </dt> <dd> <p>Read the commit-graph file and verify its contents against the object database. Used to check for corrupted data.</p> <p>With the <code>--shallow</code> option, only check the tip commit-graph file in a chain of split commit-graphs.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Write a commit-graph file for the packed commits in your local <code>.git</code> directory.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit-graph write</pre> </div> </div> </li> <li> <p>Write a commit-graph file, extending the current commit-graph file using commits in <code><pack-index></code>.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ echo <pack-index> | git commit-graph write --stdin-packs</pre> </div> </div> </li> <li> <p>Write a commit-graph file containing all reachable commits.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show-ref -s | git commit-graph write --stdin-commits</pre> </div> </div> </li> <li> <p>Write a commit-graph file containing all commits in the current commit-graph file along with those reachable from <code>HEAD</code>.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rev-parse HEAD | git commit-graph write --stdin-commits --append</pre> </div> </div> </li> </ul> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-commit-graph.txt-commitGraphgenerationVersion"> commitGraph.generationVersion </dt> <dd> <p>Specifies the type of generation number version to use when writing or reading the commit-graph file. If version 1 is specified, then the corrected commit dates will not be written or read. Defaults to 2.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit-graph.txt-commitGraphmaxNewFilters"> commitGraph.maxNewFilters </dt> <dd> <p>Specifies the default value for the <code>--max-new-filters</code> option of <code>git +commit-graph write</code> (c.f., <a href="git-commit-graph">git-commit-graph[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-commit-graph.txt-commitGraphreadChangedPaths"> commitGraph.readChangedPaths </dt> <dd> <p>If true, then git will use the changed-path Bloom filters in the commit-graph file (if it exists, and they are present). Defaults to true. See <a href="git-commit-graph">git-commit-graph[1]</a> for more information.</p> </dd> </dl> </div> </div> <h2 id="_file_format">File format</h2> <div class="sectionbody"> <p>see <a href="gitformat-commit-graph">gitformat-commit-graph[5]</a>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-commit-graph" class="_attribution-link">https://git-scm.com/docs/git-commit-graph</a> + </p> +</div> diff --git a/devdocs/git/git-commit-tree.html b/devdocs/git/git-commit-tree.html new file mode 100644 index 00000000..c5b04bae --- /dev/null +++ b/devdocs/git/git-commit-tree.html @@ -0,0 +1,10 @@ +<h1>git-commit-tree</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-commit-tree - Create a new commit object</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git commit-tree <tree> [(-p <parent>)…] +git commit-tree [(-p <parent>)…] [-S[<keyid>]] [(-m <message>)…] + [(-F <file>)…] <tree></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This is usually not what an end user wants to run directly. See <a href="git-commit">git-commit[1]</a> instead.</p> <p>Creates a new commit object based on the provided tree object and emits the new commit object id on stdout. The log message is read from the standard input, unless <code>-m</code> or <code>-F</code> options are given.</p> <p>The <code>-m</code> and <code>-F</code> options can be given any number of times, in any order. The commit log message will be composed in the order in which the options are given.</p> <p>A commit object may have any number of parents. With exactly one parent, it is an ordinary commit. Having more than one parent makes the commit a merge between several lines of history. Initial (root) commits have no parents.</p> <p>While a tree represents a particular directory state of a working directory, a commit represents that state in "time", and explains how to get there.</p> <p>Normally a commit would identify a new "HEAD" state, and while Git doesn’t care where you save the note about that state, in practice we tend to just write the result to the file that is pointed at by <code>.git/HEAD</code>, so that we can always see what the last committed state was.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-commit-tree.txt-lttreegt"> <tree> </dt> <dd> <p>An existing tree object.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit-tree.txt--pltparentgt"> -p <parent> </dt> <dd> <p>Each <code>-p</code> indicates the id of a parent commit object.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit-tree.txt--mltmessagegt"> -m <message> </dt> <dd> <p>A paragraph in the commit log message. This can be given more than once and each <message> becomes its own paragraph.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit-tree.txt--Fltfilegt"> -F <file> </dt> <dd> <p>Read the commit log message from the given file. Use <code>-</code> to read from the standard input. This can be given more than once and the content of each file becomes its own paragraph.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit-tree.txt--Sltkeyidgt"> -S[<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-commit-tree.txt---gpg-signltkeyidgt"> --gpg-sign[=<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-commit-tree.txt---no-gpg-sign"> --no-gpg-sign </dt> <dd> <p>GPG-sign commits. The <code>keyid</code> argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space. <code>--no-gpg-sign</code> is useful to countermand a <code>--gpg-sign</code> option given earlier on the command line.</p> </dd> </dl> </div> </div> <h2 id="_commit_information">Commit information</h2> <div class="sectionbody"> <p>A commit encapsulates:</p> <div class="ulist"> <ul> <li> <p>all parent object ids</p> </li> <li> <p>author name, email and date</p> </li> <li> <p>committer name and email and the commit time.</p> </li> </ul> </div> <p>A commit comment is read from stdin. If a changelog entry is not provided via "<" redirection, <code>git commit-tree</code> will just wait for one to be entered and terminated with ^D.</p> </div> <h2 id="_date_formats">Date formats</h2> <div class="sectionbody"> <p>The <code>GIT_AUTHOR_DATE</code> and <code>GIT_COMMITTER_DATE</code> environment variables support the following date formats:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-commit-tree.txt-Gitinternalformat"> Git internal format </dt> <dd> <p>It is <code><unix-timestamp> <time-zone-offset></code>, where <code><unix-timestamp></code> is the number of seconds since the UNIX epoch. <code><time-zone-offset></code> is a positive or negative offset from UTC. For example CET (which is 1 hour ahead of UTC) is <code>+0100</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit-tree.txt-RFC2822"> RFC 2822 </dt> <dd> <p>The standard email format as described by RFC 2822, for example <code>Thu, 07 Apr 2005 22:13:13 +0200</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit-tree.txt-ISO8601"> ISO 8601 </dt> <dd> <p>Time and date specified by the ISO 8601 standard, for example <code>2005-04-07T22:13:13</code>. The parser accepts a space instead of the <code>T</code> character as well. Fractional parts of a second will be ignored, for example <code>2005-04-07T22:13:13.019</code> will be treated as <code>2005-04-07T22:13:13</code>.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> In addition, the date part is accepted in the following formats: <code>YYYY.MM.DD</code>, <code>MM/DD/YYYY</code> and <code>DD.MM.YYYY</code>. </td> </tr> </table> </div> </dd> </dl> </div> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>Git is to some extent character encoding agnostic.</p> <div class="ulist"> <ul> <li> <p>The contents of the blob objects are uninterpreted sequences of bytes. There is no encoding translation at the core level.</p> </li> <li> <p>Path names are encoded in UTF-8 normalization form C. This applies to tree objects, the index file, ref names, as well as path names in command line arguments, environment variables and config files (<code>.git/config</code> (see <a href="git-config">git-config[1]</a>), <a href="gitignore">gitignore[5]</a>, <a href="gitattributes">gitattributes[5]</a> and <a href="gitmodules">gitmodules[5]</a>).</p> <p>Note that Git at the core level treats path names simply as sequences of non-NUL bytes, there are no path name encoding conversions (except on Mac and Windows). Therefore, using non-ASCII path names will mostly work even on platforms and file systems that use legacy extended ASCII encodings. However, repositories created on such systems will not work properly on UTF-8-based systems (e.g. Linux, Mac, Windows) and vice versa. Additionally, many Git-based tools simply assume path names to be UTF-8 and will fail to display other encodings correctly.</p> </li> <li> <p>Commit log messages are typically encoded in UTF-8, but other extended ASCII encodings are also supported. This includes ISO-8859-x, CP125x and many others, but <code>not</code> UTF-16/32, EBCDIC and CJK multi-byte encodings (GBK, Shift-JIS, Big5, EUC-x, CP9xx etc.).</p> </li> </ul> </div> <p>Although we encourage that the commit log messages are encoded in UTF-8, both the core and Git Porcelain are designed not to force UTF-8 on projects. If all participants of a particular project find it more convenient to use legacy encodings, Git does not forbid it. However, there are a few things to keep in mind.</p> <div class="olist arabic"> <ol class="arabic"> <li> <p><code>git commit</code> and <code>git commit-tree</code> issue a warning if the commit log message given to it does not look like a valid UTF-8 string, unless you explicitly say your project uses a legacy encoding. The way to say this is to have <code>i18n.commitEncoding</code> in <code>.git/config</code> file, like this:</p> <div class="listingblock"> <div class="content"> <pre>[i18n] + commitEncoding = ISO-8859-1</pre> </div> </div> <p>Commit objects created with the above setting record the value of <code>i18n.commitEncoding</code> in their <code>encoding</code> header. This is to help other people who look at them later. Lack of this header implies that the commit log message is encoded in UTF-8.</p> </li> <li> <p><code>git log</code>, <code>git show</code>, <code>git blame</code> and friends look at the <code>encoding</code> header of a commit object, and try to re-code the log message into UTF-8 unless otherwise specified. You can specify the desired output encoding with <code>i18n.logOutputEncoding</code> in <code>.git/config</code> file, like this:</p> <div class="listingblock"> <div class="content"> <pre>[i18n] + logOutputEncoding = ISO-8859-1</pre> </div> </div> <p>If you do not have this configuration variable, the value of <code>i18n.commitEncoding</code> is used instead.</p> </li> </ol> </div> <p>Note that we deliberately chose not to re-code the commit log message when a commit is made to force UTF-8 at the commit object level, because re-coding to UTF-8 is not necessarily a reversible operation.</p> </div> <h2 id="_files">Files</h2> <div class="sectionbody"> <p>/etc/mailname</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-write-tree">git-write-tree[1]</a> <a href="git-commit">git-commit[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-commit-tree" class="_attribution-link">https://git-scm.com/docs/git-commit-tree</a> + </p> +</div> diff --git a/devdocs/git/git-commit.html b/devdocs/git/git-commit.html new file mode 100644 index 00000000..18824e9a --- /dev/null +++ b/devdocs/git/git-commit.html @@ -0,0 +1,38 @@ +<h1>git-commit</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-commit - Record changes to the repository</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git commit [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend] + [--dry-run] [(-c | -C | --squash) <commit> | --fixup [(amend|reword):]<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] [--pathspec-from-file=<file> [--pathspec-file-nul]] + [(--trailer <token>[(=|:)<value>])…] [-S[<keyid>]] + [--] [<pathspec>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Create a new commit containing the current contents of the index and the given log message describing the changes. The new commit is a direct child of HEAD, usually the tip of the current branch, and the branch is updated to point to it (unless no branch is associated with the working tree, in which case HEAD is "detached" as described in <a href="git-checkout">git-checkout[1]</a>).</p> <p>The content to be committed can be specified in several ways:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>by using <a href="git-add">git-add[1]</a> to incrementally "add" changes to the index before using the <code>commit</code> command (Note: even modified files must be "added");</p> </li> <li> <p>by using <a href="git-rm">git-rm[1]</a> to remove files from the working tree and the index, again before using the <code>commit</code> command;</p> </li> <li> <p>by listing files as arguments to the <code>commit</code> command (without --interactive or --patch switch), in which case the commit will ignore changes staged in the index, and instead record the current content of the listed files (which must already be known to Git);</p> </li> <li> <p>by using the -a switch with the <code>commit</code> command to automatically "add" changes from all known files (i.e. all files that are already listed in the index) and to automatically "rm" files in the index that have been removed from the working tree, and then perform the actual commit;</p> </li> <li> <p>by using the --interactive or --patch switches with the <code>commit</code> command to decide one by one which files or hunks should be part of the commit in addition to contents in the index, before finalizing the operation. See the “Interactive Mode” section of <a href="git-add">git-add[1]</a> to learn how to operate these modes.</p> </li> </ol> </div> <p>The <code>--dry-run</code> option can be used to obtain a summary of what is included by any of the above for the next commit by giving the same set of parameters (options and paths).</p> <p>If you make a commit and then find a mistake immediately after that, you can recover from it with <code>git reset</code>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-commit.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---all"> --all </dt> <dd> <p>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.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---patch"> --patch </dt> <dd> <p>Use the interactive patch selection interface to choose which changes to commit. See <a href="git-add">git-add[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--Cltcommitgt"> -C <commit> </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---reuse-messageltcommitgt"> --reuse-message=<commit> </dt> <dd> <p>Take an existing commit object, and reuse the log message and the authorship information (including the timestamp) when creating the commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--cltcommitgt"> -c <commit> </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---reedit-messageltcommitgt"> --reedit-message=<commit> </dt> <dd> <p>Like <code>-C</code>, but with <code>-c</code> the editor is invoked, so that the user can further edit the commit message.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---fixupamendrewordltcommitgt"> --fixup=[(amend|reword):]<commit> </dt> <dd> <p>Create a new commit which "fixes up" <code><commit></code> when applied with <code>git rebase --autosquash</code>. Plain <code>--fixup=<commit></code> creates a "fixup!" commit which changes the content of <code><commit></code> but leaves its log message untouched. <code>--fixup=amend:<commit></code> is similar but creates an "amend!" commit which also replaces the log message of <code><commit></code> with the log message of the "amend!" commit. <code>--fixup=reword:<commit></code> creates an "amend!" commit which replaces the log message of <code><commit></code> with its own log message but makes no changes to the content of <code><commit></code>.</p> <p>The commit created by plain <code>--fixup=<commit></code> has a subject composed of "fixup!" followed by the subject line from <commit>, and is recognized specially by <code>git rebase --autosquash</code>. The <code>-m</code> option may be used to supplement the log message of the created commit, but the additional commentary will be thrown away once the "fixup!" commit is squashed into <code><commit></code> by <code>git rebase --autosquash</code>.</p> <p>The commit created by <code>--fixup=amend:<commit></code> is similar but its subject is instead prefixed with "amend!". The log message of <commit> is copied into the log message of the "amend!" commit and opened in an editor so it can be refined. When <code>git rebase +--autosquash</code> squashes the "amend!" commit into <code><commit></code>, the log message of <code><commit></code> is replaced by the refined log message from the "amend!" commit. It is an error for the "amend!" commit’s log message to be empty unless <code>--allow-empty-message</code> is specified.</p> <p><code>--fixup=reword:<commit></code> is shorthand for <code>--fixup=amend:<commit> +--only</code>. It creates an "amend!" commit with only a log message (ignoring any changes staged in the index). When squashed by <code>git +rebase --autosquash</code>, it replaces the log message of <code><commit></code> without making any other changes.</p> <p>Neither "fixup!" nor "amend!" commits change authorship of <code><commit></code> when applied by <code>git rebase --autosquash</code>. See <a href="git-rebase">git-rebase[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---squashltcommitgt"> --squash=<commit> </dt> <dd> <p>Construct a commit message for use with <code>rebase --autosquash</code>. The commit message subject line is taken from the specified commit with a prefix of "squash! ". Can be used with additional commit message options (<code>-m</code>/<code>-c</code>/<code>-C</code>/<code>-F</code>). See <a href="git-rebase">git-rebase[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---reset-author"> --reset-author </dt> <dd> <p>When used with -C/-c/--amend options, or when committing after a conflicting cherry-pick, declare that the authorship of the resulting commit now belongs to the committer. This also renews the author timestamp.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---short"> --short </dt> <dd> <p>When doing a dry-run, give the output in the short-format. See <a href="git-status">git-status[1]</a> for details. Implies <code>--dry-run</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---branch"> --branch </dt> <dd> <p>Show the branch and tracking info even in short-format.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---porcelain"> --porcelain </dt> <dd> <p>When doing a dry-run, give the output in a porcelain-ready format. See <a href="git-status">git-status[1]</a> for details. Implies <code>--dry-run</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---long"> --long </dt> <dd> <p>When doing a dry-run, give the output in the long-format. Implies <code>--dry-run</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--z"> -z </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---null"> --null </dt> <dd> <p>When showing <code>short</code> or <code>porcelain</code> status output, print the filename verbatim and terminate the entries with NUL, instead of LF. If no format is given, implies the <code>--porcelain</code> output format. Without the <code>-z</code> option, filenames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--Fltfilegt"> -F <file> </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---fileltfilegt"> --file=<file> </dt> <dd> <p>Take the commit message from the given file. Use <code>-</code> to read the message from the standard input.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---authorltauthorgt"> --author=<author> </dt> <dd> <p>Override the commit author. Specify an explicit author using the standard <code>A U Thor <author@example.com></code> format. Otherwise <author> is assumed to be a pattern and is used to search for an existing commit by that author (i.e. rev-list --all -i --author=<author>); the commit author is then copied from the first such commit found.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---dateltdategt"> --date=<date> </dt> <dd> <p>Override the author date used in the commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--mltmsggt"> -m <msg> </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---messageltmsggt"> --message=<msg> </dt> <dd> <p>Use the given <msg> as the commit message. If multiple <code>-m</code> options are given, their values are concatenated as separate paragraphs.</p> <p>The <code>-m</code> option is mutually exclusive with <code>-c</code>, <code>-C</code>, and <code>-F</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--tltfilegt"> -t <file> </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---templateltfilegt"> --template=<file> </dt> <dd> <p>When editing the commit message, start the editor with the contents in the given file. The <code>commit.template</code> 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 <code>-m</code> or <code>-F</code> options.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---signoff"> --signoff </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---no-signoff"> --no-signoff </dt> <dd> <p>Add a <code>Signed-off-by</code> trailer by the committer at the end of the commit log message. The meaning of a signoff depends on the project to which you’re committing. For example, it may certify that the committer has the rights to submit the work under the project’s license or agrees to some contributor representation, such as a Developer Certificate of Origin. (See <a href="https://developercertificate.org" class="bare">https://developercertificate.org</a> for the one used by the Linux kernel and Git projects.) Consult the documentation or leadership of the project to which you’re contributing to understand how the signoffs are used in that project.</p> <p>The --no-signoff option can be used to countermand an earlier --signoff option on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---trailerlttokengtltvaluegt"> --trailer <token>[(=|:)<value>] </dt> <dd> <p>Specify a (<token>, <value>) pair that should be applied as a trailer. (e.g. <code>git commit --trailer "Signed-off-by:C O Mitter \ +<committer@example.com>" --trailer "Helped-by:C O Mitter \ +<committer@example.com>"</code> will add the "Signed-off-by" trailer and the "Helped-by" trailer to the commit message.) The <code>trailer.*</code> configuration variables (<a href="git-interpret-trailers">git-interpret-trailers[1]</a>) can be used to define if a duplicated trailer is omitted, where in the run of trailers each trailer would appear, and other details.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---no-verify"> --[no-]verify </dt> <dd> <p>By default, the pre-commit and commit-msg hooks are run. When any of <code>--no-verify</code> or <code>-n</code> is given, these are bypassed. See also <a href="githooks">githooks[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---allow-empty"> --allow-empty </dt> <dd> <p>Usually recording a commit that has the exact same tree as its sole parent commit is a mistake, and the command prevents you from making such a commit. This option bypasses the safety, and is primarily for use by foreign SCM interface scripts.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---allow-empty-message"> --allow-empty-message </dt> <dd> <p>Like --allow-empty this command is primarily for use by foreign SCM interface scripts. It allows you to create a commit with an empty commit message without using plumbing commands like <a href="git-commit-tree">git-commit-tree[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---cleanupltmodegt"> --cleanup=<mode> </dt> <dd> <p>This option determines how the supplied commit message should be cleaned up before committing. The <code><mode></code> can be <code>strip</code>, <code>whitespace</code>, <code>verbatim</code>, <code>scissors</code> or <code>default</code>.</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-commit.txt-strip"> strip </dt> <dd> <p>Strip leading and trailing empty lines, trailing whitespace, commentary and collapse consecutive empty lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt-whitespace"> whitespace </dt> <dd> <p>Same as <code>strip</code> except #commentary is not removed.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt-verbatim"> verbatim </dt> <dd> <p>Do not change the message at all.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt-scissors"> scissors </dt> <dd> <p>Same as <code>whitespace</code> except that everything from (and including) the line found below is truncated, if the message is to be edited. "<code>#</code>" can be customized with core.commentChar.</p> <div class="literalblock"> <div class="content"> <pre># ------------------------ >8 ------------------------</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt-default"> default </dt> <dd> <p>Same as <code>strip</code> if the message is to be edited. Otherwise <code>whitespace</code>.</p> </dd> </dl> </div> </div> </div> <p>The default can be changed by the <code>commit.cleanup</code> configuration variable (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--e"> -e </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---edit"> --edit </dt> <dd> <p>The message taken from file with <code>-F</code>, command line with <code>-m</code>, and from commit object with <code>-C</code> are usually used as the commit log message unmodified. This option lets you further edit the message taken from these sources.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---no-edit"> --no-edit </dt> <dd> <p>Use the selected commit message without launching an editor. For example, <code>git commit --amend --no-edit</code> amends a commit without changing its commit message.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---amend"> --amend </dt> <dd> <p>Replace the tip of the current branch by creating a new commit. The recorded tree is prepared as usual (including the effect of the <code>-i</code> and <code>-o</code> options and explicit pathspec), and the message from the original commit is used as the starting point, instead of an empty message, when no other message is specified from the command line via options such as <code>-m</code>, <code>-F</code>, <code>-c</code>, etc. The new commit has the same parents and author as the current one (the <code>--reset-author</code> option can countermand this).</p> <div class="openblock"> <div class="content"> <p>It is a rough equivalent for:</p> <div class="listingblock"> <div class="content"> <pre> $ git reset --soft HEAD^ + $ ... do something else to come up with the right tree ... + $ git commit -c ORIG_HEAD</pre> </div> </div> <p>but can be used to amend a merge commit.</p> </div> </div> <p>You should understand the implications of rewriting history if you amend a commit that has already been published. (See the "RECOVERING FROM UPSTREAM REBASE" section in <a href="git-rebase">git-rebase[1]</a>.)</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---no-post-rewrite"> --no-post-rewrite </dt> <dd> <p>Bypass the post-rewrite hook.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--i"> -i </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---include"> --include </dt> <dd> <p>Before making a commit out of staged contents so far, stage the contents of paths given on the command line as well. This is usually not what you want unless you are concluding a conflicted merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--o"> -o </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---only"> --only </dt> <dd> <p>Make a commit by taking the updated working tree contents of the paths specified on the command line, disregarding any contents that have been staged for other paths. This is the default mode of operation of <code>git commit</code> if any paths are given on the command line, in which case this option can be omitted. If this option is specified together with <code>--amend</code>, then no paths need to be specified, which can be used to amend the last commit without committing changes that have already been staged. If used together with <code>--allow-empty</code> paths are also not required, and an empty commit will be created.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---pathspec-from-fileltfilegt"> --pathspec-from-file=<file> </dt> <dd> <p>Pathspec is passed in <code><file></code> instead of commandline args. If <code><file></code> is exactly <code>-</code> then standard input is used. Pathspec elements are separated by LF or CR/LF. Pathspec elements can be quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>). See also <code>--pathspec-file-nul</code> and global <code>--literal-pathspecs</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---pathspec-file-nul"> --pathspec-file-nul </dt> <dd> <p>Only meaningful with <code>--pathspec-from-file</code>. Pathspec elements are separated with NUL character and all other characters are taken literally (including newlines and quotes).</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--ultmodegt"> -u[<mode>] </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---untracked-filesltmodegt"> --untracked-files[=<mode>] </dt> <dd> <p>Show untracked files.</p> <div class="openblock"> <div class="content"> <p>The mode parameter is optional (defaults to <code>all</code>), and is used to specify the handling of untracked files; when -u is not used, the default is <code>normal</code>, i.e. show untracked files and directories.</p> <p>The possible options are:</p> <div class="ulist"> <ul> <li> <p><code>no</code> - Show no untracked files</p> </li> <li> <p><code>normal</code> - Shows untracked files and directories</p> </li> <li> <p><code>all</code> - Also shows individual files in untracked directories.</p> </li> </ul> </div> <p>The default can be changed using the status.showUntrackedFiles configuration variable documented in <a href="git-config">git-config[1]</a>.</p> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---verbose"> --verbose </dt> <dd> <p>Show unified diff between the HEAD commit and what would be committed at the bottom of the commit message template to help the user describe the commit by reminding what changes the commit has. Note that this diff output doesn’t have its lines prefixed with <code>#</code>. This diff will not be a part of the commit message. See the <code>commit.verbose</code> configuration variable in <a href="git-config">git-config[1]</a>.</p> <p>If specified twice, show in addition the unified diff between what would be committed and the worktree files, i.e. the unstaged changes to tracked files.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---quiet"> --quiet </dt> <dd> <p>Suppress commit summary message.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---dry-run"> --dry-run </dt> <dd> <p>Do not create a commit, but show a list of paths that are to be committed, paths with local changes that will be left uncommitted and paths that are untracked.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---status"> --status </dt> <dd> <p>Include the output of <a href="git-status">git-status[1]</a> in the commit message template when using an editor to prepare the commit message. Defaults to on, but can be used to override configuration variable commit.status.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---no-status"> --no-status </dt> <dd> <p>Do not include the output of <a href="git-status">git-status[1]</a> in the commit message template when using an editor to prepare the default commit message.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt--Sltkeyidgt"> -S[<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---gpg-signltkeyidgt"> --gpg-sign[=<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-commit.txt---no-gpg-sign"> --no-gpg-sign </dt> <dd> <p>GPG-sign commits. The <code>keyid</code> argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space. <code>--no-gpg-sign</code> is useful to countermand both <code>commit.gpgSign</code> configuration variable, and earlier <code>--gpg-sign</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt---"> -- </dt> <dd> <p>Do not interpret any more arguments as options.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt-ltpathspecgt82308203"> <pathspec>… </dt> <dd> <p>When pathspec is given on the command line, commit the contents of the files that match the pathspec without recording the changes already added to the index. The contents of these files are also staged for the next commit on top of what have been staged before.</p> <p>For more details, see the <code>pathspec</code> entry in <a href="gitglossary">gitglossary[7]</a>.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>When recording your own work, the contents of modified files in your working tree are temporarily stored to a staging area called the "index" with <code>git add</code>. A file can be reverted back, only in the index but not in the working tree, to that of the last commit with <code>git restore --staged <file></code>, which effectively reverts <code>git add</code> and prevents the changes to this file from participating in the next commit. After building the state to be committed incrementally with these commands, <code>git commit</code> (without any pathname parameter) is used to record what has been staged so far. This is the most basic form of the command. An example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ edit hello.c +$ git rm goodbye.c +$ git add hello.c +$ git commit</pre> </div> </div> <p>Instead of staging files after each individual change, you can tell <code>git commit</code> to notice the changes to the files whose contents are tracked in your working tree and do corresponding <code>git add</code> and <code>git rm</code> for you. That is, this example does the same as the earlier example if there is no other change in your working tree:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ edit hello.c +$ rm goodbye.c +$ git commit -a</pre> </div> </div> <p>The command <code>git commit -a</code> first looks at your working tree, notices that you have modified hello.c and removed goodbye.c, and performs necessary <code>git add</code> and <code>git rm</code> for you.</p> <p>After staging changes to many files, you can alter the order the changes are recorded in, by giving pathnames to <code>git commit</code>. When pathnames are given, the command makes a commit that only records the changes made to the named paths:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ edit hello.c hello.h +$ git add hello.c hello.h +$ edit Makefile +$ git commit Makefile</pre> </div> </div> <p>This makes a commit that records the modification to <code>Makefile</code>. The changes staged for <code>hello.c</code> and <code>hello.h</code> are not included in the resulting commit. However, their changes are not lost — they are still staged and merely held back. After the above sequence, if you do:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit</pre> </div> </div> <p>this second commit would record the changes to <code>hello.c</code> and <code>hello.h</code> as expected.</p> <p>After a merge (initiated by <code>git merge</code> or <code>git pull</code>) stops because of conflicts, cleanly merged paths are already staged to be committed for you, and paths that conflicted are left in unmerged state. You would have to first check which paths are conflicting with <code>git status</code> and after fixing them manually in your working tree, you would stage the result as usual with <code>git add</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git status | grep unmerged +unmerged: hello.c +$ edit hello.c +$ git add hello.c</pre> </div> </div> <p>After resolving conflicts and staging the result, <code>git ls-files -u</code> would stop mentioning the conflicted path. When you are done, run <code>git commit</code> to finally record the merge:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit</pre> </div> </div> <p>As with the case to record your own changes, you can use <code>-a</code> option to save typing. One difference is that during a merge resolution, you cannot use <code>git commit</code> with pathnames to alter the order the changes are committed, because the merge should be recorded as a single commit. In fact, the command refuses to run when given pathnames (but see <code>-i</code> option).</p> </div> <h2 id="_commit_information">Commit information</h2> <div class="sectionbody"> <p>Author and committer information is taken from the following environment variables, if set:</p> <div class="literalblock"> <div class="content"> <pre>GIT_AUTHOR_NAME +GIT_AUTHOR_EMAIL +GIT_AUTHOR_DATE +GIT_COMMITTER_NAME +GIT_COMMITTER_EMAIL +GIT_COMMITTER_DATE</pre> </div> </div> <p>(nb "<", ">" and "\n"s are stripped)</p> <p>The author and committer names are by convention some form of a personal name (that is, the name by which other humans refer to you), although Git does not enforce or require any particular form. Arbitrary Unicode may be used, subject to the constraints listed above. This name has no effect on authentication; for that, see the <code>credential.username</code> variable in <a href="git-config">git-config[1]</a>.</p> <p>In case (some of) these environment variables are not set, the information is taken from the configuration items <code>user.name</code> and <code>user.email</code>, or, if not present, the environment variable EMAIL, or, if that is not set, system user name and the hostname used for outgoing mail (taken from <code>/etc/mailname</code> and falling back to the fully qualified hostname when that file does not exist).</p> <p>The <code>author.name</code> and <code>committer.name</code> and their corresponding email options override <code>user.name</code> and <code>user.email</code> if set and are overridden themselves by the environment variables.</p> <p>The typical usage is to set just the <code>user.name</code> and <code>user.email</code> variables; the other options are provided for more complex use cases.</p> </div> <h2 id="_date_formats">Date formats</h2> <div class="sectionbody"> <p>The <code>GIT_AUTHOR_DATE</code> and <code>GIT_COMMITTER_DATE</code> environment variables support the following date formats:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-commit.txt-Gitinternalformat"> Git internal format </dt> <dd> <p>It is <code><unix-timestamp> <time-zone-offset></code>, where <code><unix-timestamp></code> is the number of seconds since the UNIX epoch. <code><time-zone-offset></code> is a positive or negative offset from UTC. For example CET (which is 1 hour ahead of UTC) is <code>+0100</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt-RFC2822"> RFC 2822 </dt> <dd> <p>The standard email format as described by RFC 2822, for example <code>Thu, 07 Apr 2005 22:13:13 +0200</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt-ISO8601"> ISO 8601 </dt> <dd> <p>Time and date specified by the ISO 8601 standard, for example <code>2005-04-07T22:13:13</code>. The parser accepts a space instead of the <code>T</code> character as well. Fractional parts of a second will be ignored, for example <code>2005-04-07T22:13:13.019</code> will be treated as <code>2005-04-07T22:13:13</code>.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> In addition, the date part is accepted in the following formats: <code>YYYY.MM.DD</code>, <code>MM/DD/YYYY</code> and <code>DD.MM.YYYY</code>. </td> </tr> </table> </div> </dd> </dl> </div> <p>In addition to recognizing all date formats above, the <code>--date</code> option will also try to make sense of other, more human-centric date formats, such as relative dates like "yesterday" or "last Friday at noon".</p> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>Though not required, it’s a good idea to begin the commit message with a single short (no more than 50 characters) line summarizing the change, followed by a blank line and then a more thorough description. The text up to the first blank line in a commit message is treated as the commit title, and that title is used throughout Git. For example, <a href="git-format-patch">git-format-patch[1]</a> turns a commit into email, and it uses the title on the Subject line and the rest of the commit in the body.</p> <p>Git is to some extent character encoding agnostic.</p> <div class="ulist"> <ul> <li> <p>The contents of the blob objects are uninterpreted sequences of bytes. There is no encoding translation at the core level.</p> </li> <li> <p>Path names are encoded in UTF-8 normalization form C. This applies to tree objects, the index file, ref names, as well as path names in command line arguments, environment variables and config files (<code>.git/config</code> (see <a href="git-config">git-config[1]</a>), <a href="gitignore">gitignore[5]</a>, <a href="gitattributes">gitattributes[5]</a> and <a href="gitmodules">gitmodules[5]</a>).</p> <p>Note that Git at the core level treats path names simply as sequences of non-NUL bytes, there are no path name encoding conversions (except on Mac and Windows). Therefore, using non-ASCII path names will mostly work even on platforms and file systems that use legacy extended ASCII encodings. However, repositories created on such systems will not work properly on UTF-8-based systems (e.g. Linux, Mac, Windows) and vice versa. Additionally, many Git-based tools simply assume path names to be UTF-8 and will fail to display other encodings correctly.</p> </li> <li> <p>Commit log messages are typically encoded in UTF-8, but other extended ASCII encodings are also supported. This includes ISO-8859-x, CP125x and many others, but <code>not</code> UTF-16/32, EBCDIC and CJK multi-byte encodings (GBK, Shift-JIS, Big5, EUC-x, CP9xx etc.).</p> </li> </ul> </div> <p>Although we encourage that the commit log messages are encoded in UTF-8, both the core and Git Porcelain are designed not to force UTF-8 on projects. If all participants of a particular project find it more convenient to use legacy encodings, Git does not forbid it. However, there are a few things to keep in mind.</p> <div class="olist arabic"> <ol class="arabic"> <li> <p><code>git commit</code> and <code>git commit-tree</code> issue a warning if the commit log message given to it does not look like a valid UTF-8 string, unless you explicitly say your project uses a legacy encoding. The way to say this is to have <code>i18n.commitEncoding</code> in <code>.git/config</code> file, like this:</p> <div class="listingblock"> <div class="content"> <pre>[i18n] + commitEncoding = ISO-8859-1</pre> </div> </div> <p>Commit objects created with the above setting record the value of <code>i18n.commitEncoding</code> in their <code>encoding</code> header. This is to help other people who look at them later. Lack of this header implies that the commit log message is encoded in UTF-8.</p> </li> <li> <p><code>git log</code>, <code>git show</code>, <code>git blame</code> and friends look at the <code>encoding</code> header of a commit object, and try to re-code the log message into UTF-8 unless otherwise specified. You can specify the desired output encoding with <code>i18n.logOutputEncoding</code> in <code>.git/config</code> file, like this:</p> <div class="listingblock"> <div class="content"> <pre>[i18n] + logOutputEncoding = ISO-8859-1</pre> </div> </div> <p>If you do not have this configuration variable, the value of <code>i18n.commitEncoding</code> is used instead.</p> </li> </ol> </div> <p>Note that we deliberately chose not to re-code the commit log message when a commit is made to force UTF-8 at the commit object level, because re-coding to UTF-8 is not necessarily a reversible operation.</p> </div> <h2 id="_environment_and_configuration_variables">Environment and configuration variables</h2> <div class="sectionbody"> <p>The editor used to edit the commit log message will be chosen from the <code>GIT_EDITOR</code> environment variable, the core.editor configuration variable, the <code>VISUAL</code> environment variable, or the <code>EDITOR</code> environment variable (in that order). See <a href="git-var">git-var[1]</a> for details.</p> <p>Everything above this line in this section isn’t included from the <a href="git-config">git-config[1]</a> documentation. The content that follows is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-commit.txt-commitcleanup"> commit.cleanup </dt> <dd> <p>This setting overrides the default of the <code>--cleanup</code> option in <code>git commit</code>. See <a href="git-commit">git-commit[1]</a> for details. Changing the default can be useful when you always want to keep lines that begin with the comment character <code>#</code> in your log message, in which case you would do <code>git config commit.cleanup whitespace</code> (note that you will have to remove the help lines that begin with <code>#</code> in the commit log template yourself, if you do this).</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt-commitgpgSign"> commit.gpgSign </dt> <dd> <p>A boolean to specify whether all commits should be GPG signed. Use of this option when doing operations such as rebase can result in a large number of commits being signed. It may be convenient to use an agent to avoid typing your GPG passphrase several times.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt-commitstatus"> commit.status </dt> <dd> <p>A boolean to enable/disable inclusion of status information in the commit message template when using an editor to prepare the commit message. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt-committemplate"> commit.template </dt> <dd> <p>Specify the pathname of a file to use as the template for new commit messages.</p> </dd> <dt class="hdlist1" id="Documentation/git-commit.txt-commitverbose"> commit.verbose </dt> <dd> <p>A boolean or int to specify the level of verbosity with <code>git commit</code>. See <a href="git-commit">git-commit[1]</a>.</p> </dd> </dl> </div> </div> <h2 id="_hooks">Hooks</h2> <div class="sectionbody"> <p>This command can run <code>commit-msg</code>, <code>prepare-commit-msg</code>, <code>pre-commit</code>, <code>post-commit</code> and <code>post-rewrite</code> hooks. See <a href="githooks">githooks[5]</a> for more information.</p> </div> <h2 id="_files">Files</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-commit.txt-codeGITDIRCOMMITEDITMSGcode"> <code>$GIT_DIR/COMMIT_EDITMSG</code> </dt> <dd> <p>This file contains the commit message of a commit in progress. If <code>git commit</code> exits due to an error before creating a commit, any commit message that has been provided by the user (e.g., in an editor session) will be available in this file, but will be overwritten by the next invocation of <code>git commit</code>.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-add">git-add[1]</a>, <a href="git-rm">git-rm[1]</a>, <a href="git-mv">git-mv[1]</a>, <a href="git-merge">git-merge[1]</a>, <a href="git-commit-tree">git-commit-tree[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-commit" class="_attribution-link">https://git-scm.com/docs/git-commit</a> + </p> +</div> diff --git a/devdocs/git/git-config.html b/devdocs/git/git-config.html new file mode 100644 index 00000000..bc3a93f3 --- /dev/null +++ b/devdocs/git/git-config.html @@ -0,0 +1,151 @@ +<h1>git-config</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-config - Get and set repository or global options</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git config [<file-option>] [--type=<type>] [--fixed-value] [--show-origin] [--show-scope] [-z|--null] <name> [<value> [<value-pattern>]] +git config [<file-option>] [--type=<type>] --add <name> <value> +git config [<file-option>] [--type=<type>] [--fixed-value] --replace-all <name> <value> [<value-pattern>] +git config [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] --get <name> [<value-pattern>] +git config [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] --get-all <name> [<value-pattern>] +git config [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] [--name-only] --get-regexp <name-regex> [<value-pattern>] +git config [<file-option>] [--type=<type>] [-z|--null] --get-urlmatch <name> <URL> +git config [<file-option>] [--fixed-value] --unset <name> [<value-pattern>] +git config [<file-option>] [--fixed-value] --unset-all <name> [<value-pattern>] +git config [<file-option>] --rename-section <old-name> <new-name> +git config [<file-option>] --remove-section <name> +git config [<file-option>] [--show-origin] [--show-scope] [-z|--null] [--name-only] -l | --list +git config [<file-option>] --get-color <name> [<default>] +git config [<file-option>] --get-colorbool <name> [<stdout-is-tty>] +git config [<file-option>] -e | --edit</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>You can query/set/replace/unset options with this command. The name is actually the section and the key separated by a dot, and the value will be escaped.</p> <p>Multiple lines can be added to an option by using the <code>--add</code> option. If you want to update or unset an option which can occur on multiple lines, a <code>value-pattern</code> (which is an extended regular expression, unless the <code>--fixed-value</code> option is given) needs to be given. Only the existing values that match the pattern are updated or unset. If you want to handle the lines that do <strong>not</strong> match the pattern, just prepend a single exclamation mark in front (see also <a href="#EXAMPLES">EXAMPLES</a>), but note that this only works when the <code>--fixed-value</code> option is not in use.</p> <p>The <code>--type=<type></code> option instructs <code>git config</code> to ensure that incoming and outgoing values are canonicalize-able under the given <type>. If no <code>--type=<type></code> is given, no canonicalization will be performed. Callers may unset an existing <code>--type</code> specifier with <code>--no-type</code>.</p> <p>When reading, the values are read from the system, global and repository local configuration files by default, and options <code>--system</code>, <code>--global</code>, <code>--local</code>, <code>--worktree</code> and <code>--file <filename></code> can be used to tell the command to read from only that location (see <a href="#FILES">FILES</a>).</p> <p>When writing, the new value is written to the repository local configuration file by default, and options <code>--system</code>, <code>--global</code>, <code>--worktree</code>, <code>--file <filename></code> can be used to tell the command to write to that location (you can say <code>--local</code> but that is the default).</p> <p>This command will fail with non-zero status upon error. Some exit codes are:</p> <div class="ulist"> <ul> <li> <p>The section or key is invalid (ret=1),</p> </li> <li> <p>no section or name was provided (ret=2),</p> </li> <li> <p>the config file is invalid (ret=3),</p> </li> <li> <p>the config file cannot be written (ret=4),</p> </li> <li> <p>you try to unset an option which does not exist (ret=5),</p> </li> <li> <p>you try to unset/set an option for which multiple lines match (ret=5), or</p> </li> <li> <p>you try to use an invalid regexp (ret=6).</p> </li> </ul> </div> <p>On success, the command returns the exit code 0.</p> <p>A list of all available configuration variables can be obtained using the <code>git help --config</code> command.</p> </div> <h2 id="OPTIONS">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt---replace-all"> --replace-all </dt> <dd> <p>Default behavior is to replace at most one line. This replaces all lines matching the key (and optionally the <code>value-pattern</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---add"> --add </dt> <dd> <p>Adds a new line to the option without altering any existing values. This is the same as providing <code>^$</code> as the <code>value-pattern</code> in <code>--replace-all</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---get"> --get </dt> <dd> <p>Get the value for a given key (optionally filtered by a regex matching the value). Returns error code 1 if the key was not found and the last value if multiple key values were found.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---get-all"> --get-all </dt> <dd> <p>Like get, but returns all values for a multi-valued key.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---get-regexp"> --get-regexp </dt> <dd> <p>Like --get-all, but interprets the name as a regular expression and writes out the key names. Regular expression matching is currently case-sensitive and done against a canonicalized version of the key in which section and variable names are lowercased, but subsection names are not.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---get-urlmatchltnamegtltURLgt"> --get-urlmatch <name> <URL> </dt> <dd> <p>When given a two-part name section.key, the value for section.<URL>.key whose <URL> part matches the best to the given URL is returned (if no such key exists, the value for section.key is used as a fallback). When given just the section as name, do so for all the keys in the section and list them. Returns error code 1 if no value is found.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---global"> --global </dt> <dd> <p>For writing options: write to global <code>~/.gitconfig</code> file rather than the repository <code>.git/config</code>, write to <code>$XDG_CONFIG_HOME/git/config</code> file if this file exists and the <code>~/.gitconfig</code> file doesn’t.</p> <p>For reading options: read only from global <code>~/.gitconfig</code> and from <code>$XDG_CONFIG_HOME/git/config</code> rather than from all available files.</p> <p>See also <a href="#FILES">FILES</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---system"> --system </dt> <dd> <p>For writing options: write to system-wide <code>$(prefix)/etc/gitconfig</code> rather than the repository <code>.git/config</code>.</p> <p>For reading options: read only from system-wide <code>$(prefix)/etc/gitconfig</code> rather than from all available files.</p> <p>See also <a href="#FILES">FILES</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---local"> --local </dt> <dd> <p>For writing options: write to the repository <code>.git/config</code> file. This is the default behavior.</p> <p>For reading options: read only from the repository <code>.git/config</code> rather than from all available files.</p> <p>See also <a href="#FILES">FILES</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---worktree"> --worktree </dt> <dd> <p>Similar to <code>--local</code> except that <code>$GIT_DIR/config.worktree</code> is read from or written to if <code>extensions.worktreeConfig</code> is enabled. If not it’s the same as <code>--local</code>. Note that <code>$GIT_DIR</code> is equal to <code>$GIT_COMMON_DIR</code> for the main working tree, but is of the form <code>$GIT_DIR/worktrees/<id>/</code> for other working trees. See <a href="git-worktree">git-worktree[1]</a> to learn how to enable <code>extensions.worktreeConfig</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt--fltconfig-filegt"> -f <config-file> </dt> <dt class="hdlist1" id="Documentation/git-config.txt---fileltconfig-filegt"> --file <config-file> </dt> <dd> <p>For writing options: write to the specified file rather than the repository <code>.git/config</code>.</p> <p>For reading options: read only from the specified file rather than from all available files.</p> <p>See also <a href="#FILES">FILES</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---blobltblobgt"> --blob <blob> </dt> <dd> <p>Similar to <code>--file</code> but use the given blob instead of a file. E.g. you can use <code>master:.gitmodules</code> to read values from the file <code>.gitmodules</code> in the master branch. See "SPECIFYING REVISIONS" section in <a href="gitrevisions">gitrevisions[7]</a> for a more complete list of ways to spell blob names.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---remove-section"> --remove-section </dt> <dd> <p>Remove the given section from the configuration file.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---rename-section"> --rename-section </dt> <dd> <p>Rename the given section to a new name.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---unset"> --unset </dt> <dd> <p>Remove the line matching the key from config file.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---unset-all"> --unset-all </dt> <dd> <p>Remove all lines matching the key from config file.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt--l"> -l </dt> <dt class="hdlist1" id="Documentation/git-config.txt---list"> --list </dt> <dd> <p>List all variables set in config file, along with their values.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---fixed-value"> --fixed-value </dt> <dd> <p>When used with the <code>value-pattern</code> argument, treat <code>value-pattern</code> as an exact string instead of a regular expression. This will restrict the name/value pairs that are matched to only those where the value is exactly equal to the <code>value-pattern</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---typelttypegt"> --type <type> </dt> <dd> <p><code>git config</code> will ensure that any input or output is valid under the given type constraint(s), and will canonicalize outgoing values in <code><type></code>'s canonical form.</p> <p>Valid <code><type></code>'s include:</p> <div class="ulist"> <ul> <li> <p><code>bool</code>: canonicalize values as either "true" or "false".</p> </li> <li> <p><code>int</code>: canonicalize values as simple decimal numbers. An optional suffix of <code>k</code>, <code>m</code>, or <code>g</code> will cause the value to be multiplied by 1024, 1048576, or 1073741824 upon input.</p> </li> <li> <p><code>bool-or-int</code>: canonicalize according to either <code>bool</code> or <code>int</code>, as described above.</p> </li> <li> <p><code>path</code>: canonicalize by expanding a leading <code>~</code> to the value of <code>$HOME</code> and <code>~user</code> to the home directory for the specified user. This specifier has no effect when setting the value (but you can use <code>git config section.variable +~/</code> from the command line to let your shell do the expansion.)</p> </li> <li> <p><code>expiry-date</code>: canonicalize by converting from a fixed or relative date-string to a timestamp. This specifier has no effect when setting the value.</p> </li> <li> <p><code>color</code>: When getting a value, canonicalize by converting to an ANSI color escape sequence. When setting a value, a sanity-check is performed to ensure that the given value is canonicalize-able as an ANSI color, but it is written as-is.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---bool"> --bool </dt> <dt class="hdlist1" id="Documentation/git-config.txt---int"> --int </dt> <dt class="hdlist1" id="Documentation/git-config.txt---bool-or-int"> --bool-or-int </dt> <dt class="hdlist1" id="Documentation/git-config.txt---path"> --path </dt> <dt class="hdlist1" id="Documentation/git-config.txt---expiry-date"> --expiry-date </dt> <dd> <p>Historical options for selecting a type specifier. Prefer instead <code>--type</code> (see above).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---no-type"> --no-type </dt> <dd> <p>Un-sets the previously set type specifier (if one was previously set). This option requests that <code>git config</code> not canonicalize the retrieved variable. <code>--no-type</code> has no effect without <code>--type=<type></code> or <code>--<type></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt--z"> -z </dt> <dt class="hdlist1" id="Documentation/git-config.txt---null"> --null </dt> <dd> <p>For all options that output values and/or keys, always end values with the null character (instead of a newline). Use newline instead as a delimiter between key and value. This allows for secure parsing of the output without getting confused e.g. by values that contain line breaks.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---name-only"> --name-only </dt> <dd> <p>Output only the names of config variables for <code>--list</code> or <code>--get-regexp</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---show-origin"> --show-origin </dt> <dd> <p>Augment the output of all queried config options with the origin type (file, standard input, blob, command line) and the actual origin (config file path, ref, or blob id if applicable).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---show-scope"> --show-scope </dt> <dd> <p>Similar to <code>--show-origin</code> in that it augments the output of all queried config options with the scope of that value (worktree, local, global, system, command).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---get-colorboolltnamegtltstdout-is-ttygt"> --get-colorbool <name> [<stdout-is-tty>] </dt> <dd> <p>Find the color setting for <code><name></code> (e.g. <code>color.diff</code>) and output "true" or "false". <code><stdout-is-tty></code> should be either "true" or "false", and is taken into account when configuration says "auto". If <code><stdout-is-tty></code> is missing, then checks the standard output of the command itself, and exits with status 0 if color is to be used, or exits with status 1 otherwise. When the color setting for <code>name</code> is undefined, the command uses <code>color.ui</code> as fallback.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---get-colorltnamegtltdefaultgt"> --get-color <name> [<default>] </dt> <dd> <p>Find the color configured for <code>name</code> (e.g. <code>color.diff.new</code>) and output it as the ANSI color escape sequence to the standard output. The optional <code>default</code> parameter is used instead, if there is no color configured for <code>name</code>.</p> <p><code>--type=color [--default=<default>]</code> is preferred over <code>--get-color</code> (but note that <code>--get-color</code> will omit the trailing newline printed by <code>--type=color</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt--e"> -e </dt> <dt class="hdlist1" id="Documentation/git-config.txt---edit"> --edit </dt> <dd> <p>Opens an editor to modify the specified config file; either <code>--system</code>, <code>--global</code>, or repository (default).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---no-includes"> --[no-]includes </dt> <dd> <p>Respect <code>include.*</code> directives in config files when looking up values. Defaults to <code>off</code> when a specific file is given (e.g., using <code>--file</code>, <code>--global</code>, etc) and <code>on</code> when searching all config files.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt---defaultltvaluegt"> --default <value> </dt> <dd> <p>When using <code>--get</code>, and the requested variable is not found, behave as if <value> were the value assigned to the that variable.</p> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p><code>pager.config</code> is only respected when listing configuration, i.e., when using <code>--list</code> or any of the <code>--get-*</code> which may return multiple results. The default is to use a pager.</p> </div> <h2 id="FILES">Files</h2> <div class="sectionbody"> <p>By default, <code>git config</code> will read configuration options from multiple files:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-prefixetcgitconfig"> $(prefix)/etc/gitconfig </dt> <dd> <p>System-wide configuration file.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-XDGCONFIGHOMEgitconfig"> $XDG_CONFIG_HOME/git/config </dt> <dt class="hdlist1" id="Documentation/git-config.txt-gitconfig"> ~/.gitconfig </dt> <dd> <p>User-specific configuration files. When the XDG_CONFIG_HOME environment variable is not set or empty, $HOME/.config/ is used as $XDG_CONFIG_HOME.</p> <p>These are also called "global" configuration files. If both files exist, both files are read in the order given above.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-GITDIRconfig"> $GIT_DIR/config </dt> <dd> <p>Repository specific configuration file.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-GITDIRconfigworktree"> $GIT_DIR/config.worktree </dt> <dd> <p>This is optional and is only searched when <code>extensions.worktreeConfig</code> is present in $GIT_DIR/config.</p> </dd> </dl> </div> <p>You may also provide additional configuration parameters when running any git command by using the <code>-c</code> option. See <a href="git">git[1]</a> for details.</p> <p>Options will be read from all of these files that are available. If the global or the system-wide configuration files are missing or unreadable they will be ignored. If the repository configuration file is missing or unreadable, <code>git config</code> will exit with a non-zero error code. An error message is produced if the file is unreadable, but not if it is missing.</p> <p>The files are read in the order given above, with last value found taking precedence over values read earlier. When multiple values are taken then all values of a key from all files will be used.</p> <p>By default, options are only written to the repository specific configuration file. Note that this also affects options like <code>--replace-all</code> and <code>--unset</code>. <strong><em>git config</em> will only ever change one file at a time</strong>.</p> <p>You can limit which configuration sources are read from or written to by specifying the path of a file with the <code>--file</code> option, or by specifying a configuration scope with <code>--system</code>, <code>--global</code>, <code>--local</code>, or <code>--worktree</code>. For more, see <a href="#OPTIONS">OPTIONS</a> above.</p> </div> <h2 id="SCOPES">Scopes</h2> <div class="sectionbody"> <p>Each configuration source falls within a configuration scope. The scopes are:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-system"> system </dt> <dd> <p>$(prefix)/etc/gitconfig</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-global"> global </dt> <dd> <p>$XDG_CONFIG_HOME/git/config</p> <p>~/.gitconfig</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-local"> local </dt> <dd> <p>$GIT_DIR/config</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-worktree"> worktree </dt> <dd> <p>$GIT_DIR/config.worktree</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-command"> command </dt> <dd> <p>GIT_CONFIG_{COUNT,KEY,VALUE} environment variables (see <a href="#ENVIRONMENT">ENVIRONMENT</a> below)</p> <p>the <code>-c</code> option</p> </dd> </dl> </div> <p>With the exception of <code>command</code>, each scope corresponds to a command line option: <code>--system</code>, <code>--global</code>, <code>--local</code>, <code>--worktree</code>.</p> <p>When reading options, specifying a scope will only read options from the files within that scope. When writing options, specifying a scope will write to the files within that scope (instead of the repository specific configuration file). See <a href="#OPTIONS">OPTIONS</a> above for a complete description.</p> <p>Most configuration options are respected regardless of the scope it is defined in, but some options are only respected in certain scopes. See the respective option’s documentation for the full details.</p> <div class="sect2"> <h3 id="_protected_configuration"> +Protected configuration</h3> <p>Protected configuration refers to the <code>system</code>, <code>global</code>, and <code>command</code> scopes. For security reasons, certain options are only respected when they are specified in protected configuration, and ignored otherwise.</p> <p>Git treats these scopes as if they are controlled by the user or a trusted administrator. This is because an attacker who controls these scopes can do substantial harm without using Git, so it is assumed that the user’s environment protects these scopes against attackers.</p> </div> </div> <h2 id="ENVIRONMENT">Environment</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-GITCONFIGGLOBAL"> GIT_CONFIG_GLOBAL </dt> <dt class="hdlist1" id="Documentation/git-config.txt-GITCONFIGSYSTEM"> GIT_CONFIG_SYSTEM </dt> <dd> <p>Take the configuration from the given files instead from global or system-level configuration. See <a href="git">git[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-GITCONFIGNOSYSTEM"> GIT_CONFIG_NOSYSTEM </dt> <dd> <p>Whether to skip reading settings from the system-wide $(prefix)/etc/gitconfig file. See <a href="git">git[1]</a> for details.</p> </dd> </dl> </div> <p>See also <a href="#FILES">FILES</a>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-GITCONFIGCOUNT"> GIT_CONFIG_COUNT </dt> <dt class="hdlist1" id="Documentation/git-config.txt-GITCONFIGKEYltngt"> GIT_CONFIG_KEY_<n> </dt> <dt class="hdlist1" id="Documentation/git-config.txt-GITCONFIGVALUEltngt"> GIT_CONFIG_VALUE_<n> </dt> <dd> <p>If GIT_CONFIG_COUNT is set to a positive number, all environment pairs GIT_CONFIG_KEY_<n> and GIT_CONFIG_VALUE_<n> up to that number will be added to the process’s runtime configuration. The config pairs are zero-indexed. Any missing key or value is treated as an error. An empty GIT_CONFIG_COUNT is treated the same as GIT_CONFIG_COUNT=0, namely no pairs are processed. These environment variables will override values in configuration files, but will be overridden by any explicit options passed via <code>git -c</code>.</p> <p>This is useful for cases where you want to spawn multiple git commands with a common configuration but cannot depend on a configuration file, for example when writing scripts.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-GITCONFIG"> GIT_CONFIG </dt> <dd> <p>If no <code>--file</code> option is provided to <code>git config</code>, use the file given by <code>GIT_CONFIG</code> as if it were provided via <code>--file</code>. This variable has no effect on other Git commands, and is mostly for historical compatibility; there is generally no reason to use it instead of the <code>--file</code> option.</p> </dd> </dl> </div> </div> <h2 id="EXAMPLES">Examples</h2> <div class="sectionbody"> <p>Given a .git/config like this:</p> <div class="listingblock"> <div class="content"> <pre># +# This is the config file, and +# a '#' or ';' character indicates +# a comment +# + +; core variables +[core] + ; Don't trust file modes + filemode = false + +; Our diff algorithm +[diff] + external = /usr/local/bin/diff-wrapper + renames = true + +; Proxy settings +[core] + gitproxy=proxy-command for kernel.org + gitproxy=default-proxy ; for all the rest + +; HTTP +[http] + sslVerify +[http "https://weak.example.com"] + sslVerify = false + cookieFile = /tmp/cookie.txt</pre> </div> </div> <p>you can set the filemode to true with</p> <div class="listingblock"> <div class="content"> <pre>% git config core.filemode true</pre> </div> </div> <p>The hypothetical proxy command entries actually have a postfix to discern what URL they apply to. Here is how to change the entry for kernel.org to "ssh".</p> <div class="listingblock"> <div class="content"> <pre>% git config core.gitproxy '"ssh" for kernel.org' 'for kernel.org$'</pre> </div> </div> <p>This makes sure that only the key/value pair for kernel.org is replaced.</p> <p>To delete the entry for renames, do</p> <div class="listingblock"> <div class="content"> <pre>% git config --unset diff.renames</pre> </div> </div> <p>If you want to delete an entry for a multivar (like core.gitproxy above), you have to provide a regex matching the value of exactly one line.</p> <p>To query the value for a given key, do</p> <div class="listingblock"> <div class="content"> <pre>% git config --get core.filemode</pre> </div> </div> <p>or</p> <div class="listingblock"> <div class="content"> <pre>% git config core.filemode</pre> </div> </div> <p>or, to query a multivar:</p> <div class="listingblock"> <div class="content"> <pre>% git config --get core.gitproxy "for kernel.org$"</pre> </div> </div> <p>If you want to know all the values for a multivar, do:</p> <div class="listingblock"> <div class="content"> <pre>% git config --get-all core.gitproxy</pre> </div> </div> <p>If you like to live dangerously, you can replace <strong>all</strong> core.gitproxy by a new one with</p> <div class="listingblock"> <div class="content"> <pre>% git config --replace-all core.gitproxy ssh</pre> </div> </div> <p>However, if you really only want to replace the line for the default proxy, i.e. the one without a "for …" postfix, do something like this:</p> <div class="listingblock"> <div class="content"> <pre>% git config core.gitproxy ssh '! for '</pre> </div> </div> <p>To actually match only values with an exclamation mark, you have to</p> <div class="listingblock"> <div class="content"> <pre>% git config section.key value '[!]'</pre> </div> </div> <p>To add a new proxy, without altering any of the existing ones, use</p> <div class="listingblock"> <div class="content"> <pre>% git config --add core.gitproxy '"proxy-command" for example.com'</pre> </div> </div> <p>An example to use customized color from the configuration in your script:</p> <div class="listingblock"> <div class="content"> <pre>#!/bin/sh +WS=$(git config --get-color color.diff.whitespace "blue reverse") +RESET=$(git config --get-color "" "reset") +echo "${WS}your whitespace color or blue reverse${RESET}"</pre> </div> </div> <p>For URLs in <code>https://weak.example.com</code>, <code>http.sslVerify</code> is set to false, while it is set to <code>true</code> for all others:</p> <div class="listingblock"> <div class="content"> <pre>% git config --type=bool --get-urlmatch http.sslverify https://good.example.com +true +% git config --type=bool --get-urlmatch http.sslverify https://weak.example.com +false +% git config --get-urlmatch http https://weak.example.com +http.cookieFile /tmp/cookie.txt +http.sslverify false</pre> </div> </div> </div> <h2 id="_configuration_file">Configuration file</h2> <div class="sectionbody"> <p>The Git configuration file contains a number of variables that affect the Git commands' behavior. The files <code>.git/config</code> and optionally <code>config.worktree</code> (see the "CONFIGURATION FILE" section of <a href="git-worktree">git-worktree[1]</a>) in each repository are used to store the configuration for that repository, and <code>$HOME/.gitconfig</code> is used to store a per-user configuration as fallback values for the <code>.git/config</code> file. The file <code>/etc/gitconfig</code> can be used to store a system-wide default configuration.</p> <p>The configuration variables are used by both the Git plumbing and the porcelain commands. The variables are divided into sections, wherein the fully qualified variable name of the variable itself is the last dot-separated segment and the section name is everything before the last dot. The variable names are case-insensitive, allow only alphanumeric characters and <code>-</code>, and must start with an alphabetic character. Some variables may appear multiple times; we say then that the variable is multivalued.</p> <div class="sect2"> <h3 id="_syntax"> +Syntax</h3> <p>The syntax is fairly flexible and permissive; whitespaces are mostly ignored. The <code>#</code> and <code>;</code> characters begin comments to the end of line, blank lines are ignored.</p> <p>The file consists of sections and variables. A section begins with the name of the section in square brackets and continues until the next section begins. Section names are case-insensitive. Only alphanumeric characters, <code>-</code> and <code>.</code> are allowed in section names. Each variable must belong to some section, which means that there must be a section header before the first setting of a variable.</p> <p>Sections can be further divided into subsections. To begin a subsection put its name in double quotes, separated by space from the section name, in the section header, like in the example below:</p> <div class="listingblock"> <div class="content"> <pre> [section "subsection"]</pre> </div> </div> <p>Subsection names are case sensitive and can contain any characters except newline and the null byte. Doublequote <code>"</code> and backslash can be included by escaping them as <code>\"</code> and <code>\\</code>, respectively. Backslashes preceding other characters are dropped when reading; for example, <code>\t</code> is read as <code>t</code> and <code>\0</code> is read as <code>0</code>. Section headers cannot span multiple lines. Variables may belong directly to a section or to a given subsection. You can have <code>[section]</code> if you have <code>[section "subsection"]</code>, but you don’t need to.</p> <p>There is also a deprecated <code>[section.subsection]</code> syntax. With this syntax, the subsection name is converted to lower-case and is also compared case sensitively. These subsection names follow the same restrictions as section names.</p> <p>All the other lines (and the remainder of the line after the section header) are recognized as setting variables, in the form <code>name = value</code> (or just <code>name</code>, which is a short-hand to say that the variable is the boolean "true"). The variable names are case-insensitive, allow only alphanumeric characters and <code>-</code>, and must start with an alphabetic character.</p> <p>A line that defines a value can be continued to the next line by ending it with a <code>\</code>; the backslash and the end-of-line are stripped. Leading whitespaces after <code>name =</code>, the remainder of the line after the first comment character <code>#</code> or <code>;</code>, and trailing whitespaces of the line are discarded unless they are enclosed in double quotes. Internal whitespaces within the value are retained verbatim.</p> <p>Inside double quotes, double quote <code>"</code> and backslash <code>\</code> characters must be escaped: use <code>\"</code> for <code>"</code> and <code>\\</code> for <code>\</code>.</p> <p>The following escape sequences (beside <code>\"</code> and <code>\\</code>) are recognized: <code>\n</code> for newline character (NL), <code>\t</code> for horizontal tabulation (HT, TAB) and <code>\b</code> for backspace (BS). Other char escape sequences (including octal escape sequences) are invalid.</p> </div> <div class="sect2"> <h3 id="_includes"> +Includes</h3> <p>The <code>include</code> and <code>includeIf</code> sections allow you to include config directives from another source. These sections behave identically to each other with the exception that <code>includeIf</code> sections may be ignored if their condition does not evaluate to true; see "Conditional includes" below.</p> <p>You can include a config file from another by setting the special <code>include.path</code> (or <code>includeIf.*.path</code>) variable to the name of the file to be included. The variable takes a pathname as its value, and is subject to tilde expansion. These variables can be given multiple times.</p> <p>The contents of the included file are inserted immediately, as if they had been found at the location of the include directive. If the value of the variable is a relative path, the path is considered to be relative to the configuration file in which the include directive was found. See below for examples.</p> </div> <div class="sect2"> <h3 id="_conditional_includes"> +Conditional includes</h3> <p>You can conditionally include a config file from another by setting an <code>includeIf.<condition>.path</code> variable to the name of the file to be included.</p> <p>The condition starts with a keyword followed by a colon and some data whose format and meaning depends on the keyword. Supported keywords are:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-codegitdircode"> <code>gitdir</code> </dt> <dd> <p>The data that follows the keyword <code>gitdir:</code> is used as a glob pattern. If the location of the .git directory matches the pattern, the include condition is met.</p> <p>The .git location may be auto-discovered, or come from <code>$GIT_DIR</code> environment variable. If the repository is auto-discovered via a .git file (e.g. from submodules, or a linked worktree), the .git location would be the final location where the .git directory is, not where the .git file is.</p> <p>The pattern can contain standard globbing wildcards and two additional ones, <code>**/</code> and <code>/**</code>, that can match multiple path components. Please refer to <a href="gitignore">gitignore[5]</a> for details. For convenience:</p> <div class="ulist"> <ul> <li> <p>If the pattern starts with <code>~/</code>, <code>~</code> will be substituted with the content of the environment variable <code>HOME</code>.</p> </li> <li> <p>If the pattern starts with <code>./</code>, it is replaced with the directory containing the current config file.</p> </li> <li> <p>If the pattern does not start with either <code>~/</code>, <code>./</code> or <code>/</code>, <code>**/</code> will be automatically prepended. For example, the pattern <code>foo/bar</code> becomes <code>**/foo/bar</code> and would match <code>/any/path/to/foo/bar</code>.</p> </li> <li> <p>If the pattern ends with <code>/</code>, <code>**</code> will be automatically added. For example, the pattern <code>foo/</code> becomes <code>foo/**</code>. In other words, it matches "foo" and everything inside, recursively.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codegitdiricode"> <code>gitdir/i</code> </dt> <dd> <p>This is the same as <code>gitdir</code> except that matching is done case-insensitively (e.g. on case-insensitive file systems)</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codeonbranchcode"> <code>onbranch</code> </dt> <dd> <p>The data that follows the keyword <code>onbranch:</code> is taken to be a pattern with standard globbing wildcards and two additional ones, <code>**/</code> and <code>/**</code>, that can match multiple path components. If we are in a worktree where the name of the branch that is currently checked out matches the pattern, the include condition is met.</p> <p>If the pattern ends with <code>/</code>, <code>**</code> will be automatically added. For example, the pattern <code>foo/</code> becomes <code>foo/**</code>. In other words, it matches all branches that begin with <code>foo/</code>. This is useful if your branches are organized hierarchically and you would like to apply a configuration to all the branches in that hierarchy.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codehasconfigremoteurlcode"> <code>hasconfig:remote.*.url:</code> </dt> <dd> <p>The data that follows this keyword is taken to be a pattern with standard globbing wildcards and two additional ones, <code>**/</code> and <code>/**</code>, that can match multiple components. The first time this keyword is seen, the rest of the config files will be scanned for remote URLs (without applying any values). If there exists at least one remote URL that matches this pattern, the include condition is met.</p> <p>Files included by this option (directly or indirectly) are not allowed to contain remote URLs.</p> <p>Note that unlike other includeIf conditions, resolving this condition relies on information that is not yet known at the point of reading the condition. A typical use case is this option being present as a system-level or global-level config, and the remote URL being in a local-level config; hence the need to scan ahead when resolving this condition. In order to avoid the chicken-and-egg problem in which potentially-included files can affect whether such files are potentially included, Git breaks the cycle by prohibiting these files from affecting the resolution of these conditions (thus, prohibiting them from declaring remote URLs).</p> <p>As for the naming of this keyword, it is for forwards compatibility with a naming scheme that supports more variable-based include conditions, but currently Git only supports the exact keyword described above.</p> </dd> </dl> </div> <p>A few more notes on matching via <code>gitdir</code> and <code>gitdir/i</code>:</p> <div class="ulist"> <ul> <li> <p>Symlinks in <code>$GIT_DIR</code> are not resolved before matching.</p> </li> <li> <p>Both the symlink & realpath versions of paths will be matched outside of <code>$GIT_DIR</code>. E.g. if ~/git is a symlink to /mnt/storage/git, both <code>gitdir:~/git</code> and <code>gitdir:/mnt/storage/git</code> will match.</p> <p>This was not the case in the initial release of this feature in v2.13.0, which only matched the realpath version. Configuration that wants to be compatible with the initial release of this feature needs to either specify only the realpath version, or both versions.</p> </li> <li> <p>Note that "../" is not special and will match literally, which is unlikely what you want.</p> </li> </ul> </div> </div> <div class="sect2"> <h3 id="_example"> +Example</h3> <div class="listingblock"> <div class="content"> <pre># Core variables +[core] + ; Don't trust file modes + filemode = false + +# Our diff algorithm +[diff] + external = /usr/local/bin/diff-wrapper + renames = true + +[branch "devel"] + remote = origin + merge = refs/heads/devel + +# Proxy settings +[core] + gitProxy="ssh" for "kernel.org" + gitProxy=default-proxy ; for the rest + +[include] + path = /path/to/foo.inc ; include by absolute path + path = foo.inc ; find "foo.inc" relative to the current file + path = ~/foo.inc ; find "foo.inc" in your `$HOME` directory + +; include if $GIT_DIR is /path/to/foo/.git +[includeIf "gitdir:/path/to/foo/.git"] + path = /path/to/foo.inc + +; include for all repositories inside /path/to/group +[includeIf "gitdir:/path/to/group/"] + path = /path/to/foo.inc + +; include for all repositories inside $HOME/to/group +[includeIf "gitdir:~/to/group/"] + path = /path/to/foo.inc + +; relative paths are always relative to the including +; file (if the condition is true); their location is not +; affected by the condition +[includeIf "gitdir:/path/to/group/"] + path = foo.inc + +; include only if we are in a worktree where foo-branch is +; currently checked out +[includeIf "onbranch:foo-branch"] + path = foo.inc + +; include only if a remote with the given URL exists (note +; that such a URL may be provided later in a file or in a +; file read after this file is read, as seen in this example) +[includeIf "hasconfig:remote.*.url:https://example.com/**"] + path = foo.inc +[remote "origin"] + url = https://example.com/git</pre> </div> </div> </div> <div class="sect2"> <h3 id="_values"> +Values</h3> <p>Values of many variables are treated as a simple string, but there are variables that take values of specific types and there are rules as to how to spell them.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-boolean"> boolean </dt> <dd> <p>When a variable is said to take a boolean value, many synonyms are accepted for <code>true</code> and <code>false</code>; these are all case-insensitive.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-true"> true </dt> <dd> <p>Boolean true literals are <code>yes</code>, <code>on</code>, <code>true</code>, and <code>1</code>. Also, a variable defined without <code>= <value></code> is taken as true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-false"> false </dt> <dd> <p>Boolean false literals are <code>no</code>, <code>off</code>, <code>false</code>, <code>0</code> and the empty string.</p> <p>When converting a value to its canonical form using the <code>--type=bool</code> type specifier, <code>git config</code> will ensure that the output is "true" or "false" (spelled in lowercase).</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-integer"> integer </dt> <dd> <p>The value for many variables that specify various sizes can be suffixed with <code>k</code>, <code>M</code>,… to mean "scale the number by 1024", "by 1024x1024", etc.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-color"> color </dt> <dd> <p>The value for a variable that takes a color is a list of colors (at most two, one for foreground and one for background) and attributes (as many as you want), separated by spaces.</p> <p>The basic colors accepted are <code>normal</code>, <code>black</code>, <code>red</code>, <code>green</code>, <code>yellow</code>, <code>blue</code>, <code>magenta</code>, <code>cyan</code>, <code>white</code> and <code>default</code>. The first color given is the foreground; the second is the background. All the basic colors except <code>normal</code> and <code>default</code> have a bright variant that can be specified by prefixing the color with <code>bright</code>, like <code>brightred</code>.</p> <p>The color <code>normal</code> makes no change to the color. It is the same as an empty string, but can be used as the foreground color when specifying a background color alone (for example, "normal red").</p> <p>The color <code>default</code> explicitly resets the color to the terminal default, for example to specify a cleared background. Although it varies between terminals, this is usually not the same as setting to "white black".</p> <p>Colors may also be given as numbers between 0 and 255; these use ANSI 256-color mode (but note that not all terminals may support this). If your terminal supports it, you may also specify 24-bit RGB values as hex, like <code>#ff0ab3</code>.</p> <p>The accepted attributes are <code>bold</code>, <code>dim</code>, <code>ul</code>, <code>blink</code>, <code>reverse</code>, <code>italic</code>, and <code>strike</code> (for crossed-out or "strikethrough" letters). The position of any attributes with respect to the colors (before, after, or in between), doesn’t matter. Specific attributes may be turned off by prefixing them with <code>no</code> or <code>no-</code> (e.g., <code>noreverse</code>, <code>no-ul</code>, etc).</p> <p>The pseudo-attribute <code>reset</code> resets all colors and attributes before applying the specified coloring. For example, <code>reset green</code> will result in a green foreground and default background without any active attributes.</p> <p>An empty color string produces no color effect at all. This can be used to avoid coloring specific elements without disabling color entirely.</p> <p>For git’s pre-defined color slots, the attributes are meant to be reset at the beginning of each item in the colored output. So setting <code>color.decorate.branch</code> to <code>black</code> will paint that branch name in a plain <code>black</code>, even if the previous thing on the same output line (e.g. opening parenthesis before the list of branch names in <code>log --decorate</code> output) is set to be painted with <code>bold</code> or some other attribute. However, custom log formats may do more complicated and layered coloring, and the negated forms may be useful there.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pathname"> pathname </dt> <dd> <p>A variable that takes a pathname value can be given a string that begins with "<code>~/</code>" or "<code>~user/</code>", and the usual tilde expansion happens to such a string: <code>~/</code> is expanded to the value of <code>$HOME</code>, and <code>~user/</code> to the specified user’s home directory.</p> <p>If a path starts with <code>%(prefix)/</code>, the remainder is interpreted as a path relative to Git’s "runtime prefix", i.e. relative to the location where Git itself was installed. For example, <code>%(prefix)/bin/</code> refers to the directory in which the Git executable itself lives. If Git was compiled without runtime prefix support, the compiled-in prefix will be substituted instead. In the unlikely event that a literal path needs to be specified that should <code>not</code> be expanded, it needs to be prefixed by <code>./</code>, like so: <code>./%(prefix)/bin</code>.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_variables"> +Variables</h3> <p>Note that this list is non-comprehensive and not necessarily complete. For command-specific variables, you will find a more detailed description in the appropriate manual page.</p> <p>Other git-related tools may and do use their own variables. When inventing new variables for use in your own tool, make sure their names do not conflict with those that are used by Git itself and other popular tools, and describe them in your documentation.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-advice"> advice.* </dt> <dd> <p>These variables control various optional help messages designed to aid new users. All <code>advice.*</code> variables default to <code>true</code>, and you can tell Git that you do not need help by setting these to <code>false</code>:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-ambiguousFetchRefspec"> ambiguousFetchRefspec </dt> <dd> <p>Advice shown when a fetch refspec for multiple remotes maps to the same remote-tracking branch namespace and causes branch tracking set-up to fail.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fetchShowForcedUpdates"> fetchShowForcedUpdates </dt> <dd> <p>Advice shown when <a href="git-fetch">git-fetch[1]</a> takes a long time to calculate forced updates after ref updates, or to warn that the check is disabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushUpdateRejected"> pushUpdateRejected </dt> <dd> <p>Set this variable to <code>false</code> if you want to disable <code>pushNonFFCurrent</code>, <code>pushNonFFMatching</code>, <code>pushAlreadyExists</code>, <code>pushFetchFirst</code>, <code>pushNeedsForce</code>, and <code>pushRefNeedsUpdate</code> simultaneously.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushNonFFCurrent"> pushNonFFCurrent </dt> <dd> <p>Advice shown when <a href="git-push">git-push[1]</a> fails due to a non-fast-forward update to the current branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushNonFFMatching"> pushNonFFMatching </dt> <dd> <p>Advice shown when you ran <a href="git-push">git-push[1]</a> and pushed <code>matching refs</code> explicitly (i.e. you used <code>:</code>, or specified a refspec that isn’t your current branch) and it resulted in a non-fast-forward error.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushAlreadyExists"> pushAlreadyExists </dt> <dd> <p>Shown when <a href="git-push">git-push[1]</a> rejects an update that does not qualify for fast-forwarding (e.g., a tag.)</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushFetchFirst"> pushFetchFirst </dt> <dd> <p>Shown when <a href="git-push">git-push[1]</a> rejects an update that tries to overwrite a remote ref that points at an object we do not have.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushNeedsForce"> pushNeedsForce </dt> <dd> <p>Shown when <a href="git-push">git-push[1]</a> rejects an update that tries to overwrite a remote ref that points at an object that is not a commit-ish, or make the remote ref point at an object that is not a commit-ish.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushUnqualifiedRefname"> pushUnqualifiedRefname </dt> <dd> <p>Shown when <a href="git-push">git-push[1]</a> gives up trying to guess based on the source and destination refs what remote ref namespace the source belongs in, but where we can still suggest that the user push to either refs/heads/* or refs/tags/* based on the type of the source object.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushRefNeedsUpdate"> pushRefNeedsUpdate </dt> <dd> <p>Shown when <a href="git-push">git-push[1]</a> rejects a forced update of a branch when its remote-tracking ref has updates that we do not have locally.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-skippedCherryPicks"> skippedCherryPicks </dt> <dd> <p>Shown when <a href="git-rebase">git-rebase[1]</a> skips a commit that has already been cherry-picked onto the upstream branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-statusAheadBehind"> statusAheadBehind </dt> <dd> <p>Shown when <a href="git-status">git-status[1]</a> computes the ahead/behind counts for a local ref compared to its remote tracking ref, and that calculation takes longer than expected. Will not appear if <code>status.aheadBehind</code> is false or the option <code>--no-ahead-behind</code> is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-statusHints"> statusHints </dt> <dd> <p>Show directions on how to proceed from the current state in the output of <a href="git-status">git-status[1]</a>, in the template shown when writing commit messages in <a href="git-commit">git-commit[1]</a>, and in the help message shown by <a href="git-switch">git-switch[1]</a> or <a href="git-checkout">git-checkout[1]</a> when switching branches.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-statusUoption"> statusUoption </dt> <dd> <p>Advise to consider using the <code>-u</code> option to <a href="git-status">git-status[1]</a> when the command takes more than 2 seconds to enumerate untracked files.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-commitBeforeMerge"> commitBeforeMerge </dt> <dd> <p>Advice shown when <a href="git-merge">git-merge[1]</a> refuses to merge to avoid overwriting local changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-resetNoRefresh"> resetNoRefresh </dt> <dd> <p>Advice to consider using the <code>--no-refresh</code> option to <a href="git-reset">git-reset[1]</a> when the command takes more than 2 seconds to refresh the index after reset.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-resolveConflict"> resolveConflict </dt> <dd> <p>Advice shown by various commands when conflicts prevent the operation from being performed.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sequencerInUse"> sequencerInUse </dt> <dd> <p>Advice shown when a sequencer command is already in progress.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-implicitIdentity"> implicitIdentity </dt> <dd> <p>Advice on how to set your identity configuration when your information is guessed from the system username and domain name.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-detachedHead"> detachedHead </dt> <dd> <p>Advice shown when you used <a href="git-switch">git-switch[1]</a> or <a href="git-checkout">git-checkout[1]</a> to move to the detached HEAD state, to instruct how to create a local branch after the fact.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-suggestDetachingHead"> suggestDetachingHead </dt> <dd> <p>Advice shown when <a href="git-switch">git-switch[1]</a> refuses to detach HEAD without the explicit <code>--detach</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-checkoutAmbiguousRemoteBranchName"> checkoutAmbiguousRemoteBranchName </dt> <dd> <p>Advice shown when the argument to <a href="git-checkout">git-checkout[1]</a> and <a href="git-switch">git-switch[1]</a> ambiguously resolves to a remote tracking branch on more than one remote in situations where an unambiguous argument would have otherwise caused a remote-tracking branch to be checked out. See the <code>checkout.defaultRemote</code> configuration variable for how to set a given remote to be used by default in some situations where this advice would be printed.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-amWorkDir"> amWorkDir </dt> <dd> <p>Advice that shows the location of the patch file when <a href="git-am">git-am[1]</a> fails to apply it.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-rmHints"> rmHints </dt> <dd> <p>In case of failure in the output of <a href="git-rm">git-rm[1]</a>, show directions on how to proceed from the current state.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-addEmbeddedRepo"> addEmbeddedRepo </dt> <dd> <p>Advice on what to do when you’ve accidentally added one git repo inside of another.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-ignoredHook"> ignoredHook </dt> <dd> <p>Advice shown if a hook is ignored because the hook is not set as executable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-waitingForEditor"> waitingForEditor </dt> <dd> <p>Print a message to the terminal whenever Git is waiting for editor input from the user.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-nestedTag"> nestedTag </dt> <dd> <p>Advice shown if a user attempts to recursively tag a tag object.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-submoduleAlternateErrorStrategyDie"> submoduleAlternateErrorStrategyDie </dt> <dd> <p>Advice shown when a submodule.alternateErrorStrategy option configured to "die" causes a fatal error.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-submodulesNotUpdated"> submodulesNotUpdated </dt> <dd> <p>Advice shown when a user runs a submodule command that fails because <code>git submodule update --init</code> was not run.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-addIgnoredFile"> addIgnoredFile </dt> <dd> <p>Advice shown if a user attempts to add an ignored file to the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-addEmptyPathspec"> addEmptyPathspec </dt> <dd> <p>Advice shown if a user runs the add command without providing the pathspec parameter.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-updateSparsePath"> updateSparsePath </dt> <dd> <p>Advice shown when either <a href="git-add">git-add[1]</a> or <a href="git-rm">git-rm[1]</a> is asked to update index entries outside the current sparse checkout.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diverging"> diverging </dt> <dd> <p>Advice shown when a fast-forward is not possible.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-worktreeAddOrphan"> worktreeAddOrphan </dt> <dd> <p>Advice shown when a user tries to create a worktree from an invalid reference, to instruct how to create a new unborn branch instead.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-attrtree"> attr.tree </dt> <dd> <p>A reference to a tree in the repository from which to read attributes, instead of the <code>.gitattributes</code> file in the working tree. In a bare repository, this defaults to <code>HEAD:.gitattributes</code>. If the value does not resolve to a valid tree object, an empty tree is used instead. When the <code>GIT_ATTR_SOURCE</code> environment variable or <code>--attr-source</code> command line option are used, this configuration variable has no effect.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corefileMode"> core.fileMode </dt> <dd> <p>Tells Git if the executable bit of files in the working tree is to be honored.</p> <p>Some filesystems lose the executable bit when a file that is marked as executable is checked out, or checks out a non-executable file with executable bit on. <a href="git-clone">git-clone[1]</a> or <a href="git-init">git-init[1]</a> probe the filesystem to see if it handles the executable bit correctly and this variable is automatically set as necessary.</p> <p>A repository, however, may be on a filesystem that handles the filemode correctly, and this variable is set to <code>true</code> when created, but later may be made accessible from another environment that loses the filemode (e.g. exporting ext4 via CIFS mount, visiting a Cygwin created repository with Git for Windows or Eclipse). In such a case it may be necessary to set this variable to <code>false</code>. See <a href="git-update-index">git-update-index[1]</a>.</p> <p>The default is true (when core.filemode is not specified in the config file).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corehideDotFiles"> core.hideDotFiles </dt> <dd> <p>(Windows-only) If true, mark newly-created directories and files whose name starts with a dot as hidden. If <code>dotGitOnly</code>, only the <code>.git/</code> directory is hidden, but no other files starting with a dot. The default mode is <code>dotGitOnly</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreignoreCase"> core.ignoreCase </dt> <dd> <p>Internal variable which enables various workarounds to enable Git to work better on filesystems that are not case sensitive, like APFS, HFS+, FAT, NTFS, etc. For example, if a directory listing finds "makefile" when Git expects "Makefile", Git will assume it is really the same file, and continue to remember it as "Makefile".</p> <p>The default is false, except <a href="git-clone">git-clone[1]</a> or <a href="git-init">git-init[1]</a> will probe and set core.ignoreCase true if appropriate when the repository is created.</p> <p>Git relies on the proper configuration of this variable for your operating and file system. Modifying this value may result in unexpected behavior.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreprecomposeUnicode"> core.precomposeUnicode </dt> <dd> <p>This option is only used by Mac OS implementation of Git. When core.precomposeUnicode=true, Git reverts the unicode decomposition of filenames done by Mac OS. This is useful when sharing a repository between Mac OS and Linux or Windows. (Git for Windows 1.7.10 or higher is needed, or Git under cygwin 1.7). When false, file names are handled fully transparent by Git, which is backward compatible with older versions of Git.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreprotectHFS"> core.protectHFS </dt> <dd> <p>If set to true, do not allow checkout of paths that would be considered equivalent to <code>.git</code> on an HFS+ filesystem. Defaults to <code>true</code> on Mac OS, and <code>false</code> elsewhere.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreprotectNTFS"> core.protectNTFS </dt> <dd> <p>If set to true, do not allow checkout of paths that would cause problems with the NTFS filesystem, e.g. conflict with 8.3 "short" names. Defaults to <code>true</code> on Windows, and <code>false</code> elsewhere.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corefsmonitor"> core.fsmonitor </dt> <dd> <p>If set to true, enable the built-in file system monitor daemon for this working directory (<a href="git-fsmonitor--daemon">git-fsmonitor--daemon[1]</a>).</p> <p>Like hook-based file system monitors, the built-in file system monitor can speed up Git commands that need to refresh the Git index (e.g. <code>git status</code>) in a working directory with many files. The built-in monitor eliminates the need to install and maintain an external third-party tool.</p> <p>The built-in file system monitor is currently available only on a limited set of supported platforms. Currently, this includes Windows and MacOS.</p> <div class="literalblock"> <div class="content"> <pre>Otherwise, this variable contains the pathname of the "fsmonitor" +hook command.</pre> </div> </div> <p>This hook command is used to identify all files that may have changed since the requested date/time. This information is used to speed up git by avoiding unnecessary scanning of files that have not changed.</p> <p>See the "fsmonitor-watchman" section of <a href="githooks">githooks[5]</a>.</p> <p>Note that if you concurrently use multiple versions of Git, such as one version on the command line and another version in an IDE tool, that the definition of <code>core.fsmonitor</code> was extended to allow boolean values in addition to hook pathnames. Git versions 2.35.1 and prior will not understand the boolean values and will consider the "true" or "false" values as hook pathnames to be invoked. Git versions 2.26 thru 2.35.1 default to hook protocol V2 and will fall back to no fsmonitor (full scan). Git versions prior to 2.26 default to hook protocol V1 and will silently assume there were no changes to report (no scan), so status commands may report incomplete results. For this reason, it is best to upgrade all of your Git versions before using the built-in file system monitor.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corefsmonitorHookVersion"> core.fsmonitorHookVersion </dt> <dd> <p>Sets the protocol version to be used when invoking the "fsmonitor" hook.</p> <p>There are currently versions 1 and 2. When this is not set, version 2 will be tried first and if it fails then version 1 will be tried. Version 1 uses a timestamp as input to determine which files have changes since that time but some monitors like Watchman have race conditions when used with a timestamp. Version 2 uses an opaque string so that the monitor can return something that can be used to determine what files have changed without race conditions.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coretrustctime"> core.trustctime </dt> <dd> <p>If false, the ctime differences between the index and the working tree are ignored; useful when the inode change time is regularly modified by something outside Git (file system crawlers and some backup systems). See <a href="git-update-index">git-update-index[1]</a>. True by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coresplitIndex"> core.splitIndex </dt> <dd> <p>If true, the split-index feature of the index will be used. See <a href="git-update-index">git-update-index[1]</a>. False by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreuntrackedCache"> core.untrackedCache </dt> <dd> <p>Determines what to do about the untracked cache feature of the index. It will be kept, if this variable is unset or set to <code>keep</code>. It will automatically be added if set to <code>true</code>. And it will automatically be removed, if set to <code>false</code>. Before setting it to <code>true</code>, you should check that mtime is working properly on your system. See <a href="git-update-index">git-update-index[1]</a>. <code>keep</code> by default, unless <code>feature.manyFiles</code> is enabled which sets this setting to <code>true</code> by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corecheckStat"> core.checkStat </dt> <dd> <p>When missing or is set to <code>default</code>, many fields in the stat structure are checked to detect if a file has been modified since Git looked at it. When this configuration variable is set to <code>minimal</code>, sub-second part of mtime and ctime, the uid and gid of the owner of the file, the inode number (and the device number, if Git was compiled to use it), are excluded from the check among these fields, leaving only the whole-second part of mtime (and ctime, if <code>core.trustCtime</code> is set) and the filesize to be checked.</p> <p>There are implementations of Git that do not leave usable values in some fields (e.g. JGit); by excluding these fields from the comparison, the <code>minimal</code> mode may help interoperability when the same repository is used by these other systems at the same time.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corequotePath"> core.quotePath </dt> <dd> <p>Commands that output paths (e.g. <code>ls-files</code>, <code>diff</code>), will quote "unusual" characters in the pathname by enclosing the pathname in double-quotes and escaping those characters with backslashes in the same way C escapes control characters (e.g. <code>\t</code> for TAB, <code>\n</code> for LF, <code>\\</code> for backslash) or bytes with values larger than 0x80 (e.g. octal <code>\302\265</code> for "micro" in UTF-8). If this variable is set to false, bytes higher than 0x80 are not considered "unusual" any more. Double-quotes, backslash and control characters are always escaped regardless of the setting of this variable. A simple space character is not considered "unusual". Many commands can output pathnames completely verbatim using the <code>-z</code> option. The default value is true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreeol"> core.eol </dt> <dd> <p>Sets the line ending type to use in the working directory for files that are marked as text (either by having the <code>text</code> attribute set, or by having <code>text=auto</code> and Git auto-detecting the contents as text). Alternatives are <code>lf</code>, <code>crlf</code> and <code>native</code>, which uses the platform’s native line ending. The default value is <code>native</code>. See <a href="gitattributes">gitattributes[5]</a> for more information on end-of-line conversion. Note that this value is ignored if <code>core.autocrlf</code> is set to <code>true</code> or <code>input</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coresafecrlf"> core.safecrlf </dt> <dd> <p>If true, makes Git check if converting <code>CRLF</code> is reversible when end-of-line conversion is active. Git will verify if a command modifies a file in the work tree either directly or indirectly. For example, committing a file followed by checking out the same file should yield the original file in the work tree. If this is not the case for the current setting of <code>core.autocrlf</code>, Git will reject the file. The variable can be set to "warn", in which case Git will only warn about an irreversible conversion but continue the operation.</p> <p>CRLF conversion bears a slight chance of corrupting data. When it is enabled, Git will convert CRLF to LF during commit and LF to CRLF during checkout. A file that contains a mixture of LF and CRLF before the commit cannot be recreated by Git. For text files this is the right thing to do: it corrects line endings such that we have only LF line endings in the repository. But for binary files that are accidentally classified as text the conversion can corrupt data.</p> <p>If you recognize such corruption early you can easily fix it by setting the conversion type explicitly in .gitattributes. Right after committing you still have the original file in your work tree and this file is not yet corrupted. You can explicitly tell Git that this file is binary and Git will handle the file appropriately.</p> <p>Unfortunately, the desired effect of cleaning up text files with mixed line endings and the undesired effect of corrupting binary files cannot be distinguished. In both cases CRLFs are removed in an irreversible way. For text files this is the right thing to do because CRLFs are line endings, while for binary files converting CRLFs corrupts data.</p> <p>Note, this safety check does not mean that a checkout will generate a file identical to the original file for a different setting of <code>core.eol</code> and <code>core.autocrlf</code>, but only for the current one. For example, a text file with <code>LF</code> would be accepted with <code>core.eol=lf</code> and could later be checked out with <code>core.eol=crlf</code>, in which case the resulting file would contain <code>CRLF</code>, although the original file contained <code>LF</code>. However, in both work trees the line endings would be consistent, that is either all <code>LF</code> or all <code>CRLF</code>, but never mixed. A file with mixed line endings would be reported by the <code>core.safecrlf</code> mechanism.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreautocrlf"> core.autocrlf </dt> <dd> <p>Setting this variable to "true" is the same as setting the <code>text</code> attribute to "auto" on all files and core.eol to "crlf". Set to true if you want to have <code>CRLF</code> line endings in your working directory and the repository has LF line endings. This variable can be set to <code>input</code>, in which case no output conversion is performed.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corecheckRoundtripEncoding"> core.checkRoundtripEncoding </dt> <dd> <p>A comma and/or whitespace separated list of encodings that Git performs UTF-8 round trip checks on if they are used in an <code>working-tree-encoding</code> attribute (see <a href="gitattributes">gitattributes[5]</a>). The default value is <code>SHIFT-JIS</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coresymlinks"> core.symlinks </dt> <dd> <p>If false, symbolic links are checked out as small plain files that contain the link text. <a href="git-update-index">git-update-index[1]</a> and <a href="git-add">git-add[1]</a> will not change the recorded type to regular file. Useful on filesystems like FAT that do not support symbolic links.</p> <p>The default is true, except <a href="git-clone">git-clone[1]</a> or <a href="git-init">git-init[1]</a> will probe and set core.symlinks false if appropriate when the repository is created.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coregitProxy"> core.gitProxy </dt> <dd> <p>A "proxy command" to execute (as <code>command host port</code>) instead of establishing direct connection to the remote server when using the Git protocol for fetching. If the variable value is in the "COMMAND for DOMAIN" format, the command is applied only on hostnames ending with the specified domain string. This variable may be set multiple times and is matched in the given order; the first match wins.</p> <p>Can be overridden by the <code>GIT_PROXY_COMMAND</code> environment variable (which always applies universally, without the special "for" handling).</p> <p>The special string <code>none</code> can be used as the proxy command to specify that no proxy be used for a given domain pattern. This is useful for excluding servers inside a firewall from proxy use, while defaulting to a common proxy for external domains.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coresshCommand"> core.sshCommand </dt> <dd> <p>If this variable is set, <code>git fetch</code> and <code>git push</code> will use the specified command instead of <code>ssh</code> when they need to connect to a remote system. The command is in the same form as the <code>GIT_SSH_COMMAND</code> environment variable and is overridden when the environment variable is set.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreignoreStat"> core.ignoreStat </dt> <dd> <p>If true, Git will avoid using lstat() calls to detect if files have changed by setting the "assume-unchanged" bit for those tracked files which it has updated identically in both the index and working tree.</p> <p>When files are modified outside of Git, the user will need to stage the modified files explicitly (e.g. see <code>Examples</code> section in <a href="git-update-index">git-update-index[1]</a>). Git will not normally detect changes to those files.</p> <p>This is useful on systems where lstat() calls are very slow, such as CIFS/Microsoft Windows.</p> <p>False by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corepreferSymlinkRefs"> core.preferSymlinkRefs </dt> <dd> <p>Instead of the default "symref" format for HEAD and other symbolic reference files, use symbolic links. This is sometimes needed to work with old scripts that expect HEAD to be a symbolic link.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corealternateRefsCommand"> core.alternateRefsCommand </dt> <dd> <p>When advertising tips of available history from an alternate, use the shell to execute the specified command instead of <a href="git-for-each-ref">git-for-each-ref[1]</a>. The first argument is the absolute path of the alternate. Output must contain one hex object id per line (i.e., the same as produced by <code>git for-each-ref +--format='%(objectname)'</code>).</p> <p>Note that you cannot generally put <code>git for-each-ref</code> directly into the config value, as it does not take a repository path as an argument (but you can wrap the command above in a shell script).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corealternateRefsPrefixes"> core.alternateRefsPrefixes </dt> <dd> <p>When listing references from an alternate, list only references that begin with the given prefix. Prefixes match as if they were given as arguments to <a href="git-for-each-ref">git-for-each-ref[1]</a>. To list multiple prefixes, separate them with whitespace. If <code>core.alternateRefsCommand</code> is set, setting <code>core.alternateRefsPrefixes</code> has no effect.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corebare"> core.bare </dt> <dd> <p>If true this repository is assumed to be <code>bare</code> and has no working directory associated with it. If this is the case a number of commands that require a working directory will be disabled, such as <a href="git-add">git-add[1]</a> or <a href="git-merge">git-merge[1]</a>.</p> <p>This setting is automatically guessed by <a href="git-clone">git-clone[1]</a> or <a href="git-init">git-init[1]</a> when the repository was created. By default a repository that ends in "/.git" is assumed to be not bare (bare = false), while all other repositories are assumed to be bare (bare = true).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreworktree"> core.worktree </dt> <dd> <p>Set the path to the root of the working tree. If <code>GIT_COMMON_DIR</code> environment variable is set, core.worktree is ignored and not used for determining the root of working tree. This can be overridden by the <code>GIT_WORK_TREE</code> environment variable and the <code>--work-tree</code> command-line option. The value can be an absolute path or relative to the path to the .git directory, which is either specified by --git-dir or GIT_DIR, or automatically discovered. If --git-dir or GIT_DIR is specified but none of --work-tree, GIT_WORK_TREE and core.worktree is specified, the current working directory is regarded as the top level of your working tree.</p> <p>Note that this variable is honored even when set in a configuration file in a ".git" subdirectory of a directory and its value differs from the latter directory (e.g. "/path/to/.git/config" has core.worktree set to "/different/path"), which is most likely a misconfiguration. Running Git commands in the "/path/to" directory will still use "/different/path" as the root of the work tree and can cause confusion unless you know what you are doing (e.g. you are creating a read-only snapshot of the same index to a location different from the repository’s usual working tree).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corelogAllRefUpdates"> core.logAllRefUpdates </dt> <dd> <p>Enable the reflog. Updates to a ref <ref> is logged to the file "<code>$GIT_DIR/logs/<ref></code>", by appending the new and old SHA-1, the date/time and the reason of the update, but only when the file exists. If this configuration variable is set to <code>true</code>, missing "<code>$GIT_DIR/logs/<ref></code>" file is automatically created for branch heads (i.e. under <code>refs/heads/</code>), remote refs (i.e. under <code>refs/remotes/</code>), note refs (i.e. under <code>refs/notes/</code>), and the symbolic ref <code>HEAD</code>. If it is set to <code>always</code>, then a missing reflog is automatically created for any ref under <code>refs/</code>.</p> <p>This information can be used to determine what commit was the tip of a branch "2 days ago".</p> <p>This value is true by default in a repository that has a working directory associated with it, and false by default in a bare repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corerepositoryFormatVersion"> core.repositoryFormatVersion </dt> <dd> <p>Internal variable identifying the repository format and layout version.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coresharedRepository"> core.sharedRepository </dt> <dd> <p>When <code>group</code> (or <code>true</code>), the repository is made shareable between several users in a group (making sure all the files and objects are group-writable). When <code>all</code> (or <code>world</code> or <code>everybody</code>), the repository will be readable by all users, additionally to being group-shareable. When <code>umask</code> (or <code>false</code>), Git will use permissions reported by umask(2). When <code>0xxx</code>, where <code>0xxx</code> is an octal number, files in the repository will have this mode value. <code>0xxx</code> will override user’s umask value (whereas the other options will only override requested parts of the user’s umask value). Examples: <code>0660</code> will make the repo read/write-able for the owner and group, but inaccessible to others (equivalent to <code>group</code> unless umask is e.g. <code>0022</code>). <code>0640</code> is a repository that is group-readable but not group-writable. See <a href="git-init">git-init[1]</a>. False by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corewarnAmbiguousRefs"> core.warnAmbiguousRefs </dt> <dd> <p>If true, Git will warn you if the ref name you passed it is ambiguous and might match multiple refs in the repository. True by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corecompression"> core.compression </dt> <dd> <p>An integer -1..9, indicating a default compression level. -1 is the zlib default. 0 means no compression, and 1..9 are various speed/size tradeoffs, 9 being slowest. If set, this provides a default to other compression variables, such as <code>core.looseCompression</code> and <code>pack.compression</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corelooseCompression"> core.looseCompression </dt> <dd> <p>An integer -1..9, indicating the compression level for objects that are not in a pack file. -1 is the zlib default. 0 means no compression, and 1..9 are various speed/size tradeoffs, 9 being slowest. If not set, defaults to core.compression. If that is not set, defaults to 1 (best speed).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corepackedGitWindowSize"> core.packedGitWindowSize </dt> <dd> <p>Number of bytes of a pack file to map into memory in a single mapping operation. Larger window sizes may allow your system to process a smaller number of large pack files more quickly. Smaller window sizes will negatively affect performance due to increased calls to the operating system’s memory manager, but may improve performance when accessing a large number of large pack files.</p> <p>Default is 1 MiB if NO_MMAP was set at compile time, otherwise 32 MiB on 32 bit platforms and 1 GiB on 64 bit platforms. This should be reasonable for all users/operating systems. You probably do not need to adjust this value.</p> <p>Common unit suffixes of <code>k</code>, <code>m</code>, or <code>g</code> are supported.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corepackedGitLimit"> core.packedGitLimit </dt> <dd> <p>Maximum number of bytes to map simultaneously into memory from pack files. If Git needs to access more than this many bytes at once to complete an operation it will unmap existing regions to reclaim virtual address space within the process.</p> <p>Default is 256 MiB on 32 bit platforms and 32 TiB (effectively unlimited) on 64 bit platforms. This should be reasonable for all users/operating systems, except on the largest projects. You probably do not need to adjust this value.</p> <p>Common unit suffixes of <code>k</code>, <code>m</code>, or <code>g</code> are supported.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coredeltaBaseCacheLimit"> core.deltaBaseCacheLimit </dt> <dd> <p>Maximum number of bytes per thread to reserve for caching base objects that may be referenced by multiple deltified objects. By storing the entire decompressed base objects in a cache Git is able to avoid unpacking and decompressing frequently used base objects multiple times.</p> <p>Default is 96 MiB on all platforms. This should be reasonable for all users/operating systems, except on the largest projects. You probably do not need to adjust this value.</p> <p>Common unit suffixes of <code>k</code>, <code>m</code>, or <code>g</code> are supported.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corebigFileThreshold"> core.bigFileThreshold </dt> <dd> <p>The size of files considered "big", which as discussed below changes the behavior of numerous git commands, as well as how such files are stored within the repository. The default is 512 MiB. Common unit suffixes of <code>k</code>, <code>m</code>, or <code>g</code> are supported.</p> <p>Files above the configured limit will be:</p> <div class="ulist"> <ul> <li> <p>Stored deflated in packfiles, without attempting delta compression.</p> <p>The default limit is primarily set with this use-case in mind. With it, most projects will have their source code and other text files delta compressed, but not larger binary media files.</p> <p>Storing large files without delta compression avoids excessive memory usage, at the slight expense of increased disk usage.</p> </li> <li> <p>Will be treated as if they were labeled "binary" (see <a href="gitattributes">gitattributes[5]</a>). e.g. <a href="git-log">git-log[1]</a> and <a href="git-diff">git-diff[1]</a> will not compute diffs for files above this limit.</p> </li> <li> <p>Will generally be streamed when written, which avoids excessive memory usage, at the cost of some fixed overhead. Commands that make use of this include <a href="git-archive">git-archive[1]</a>, <a href="git-fast-import">git-fast-import[1]</a>, <a href="git-index-pack">git-index-pack[1]</a>, <a href="git-unpack-objects">git-unpack-objects[1]</a> and <a href="git-fsck">git-fsck[1]</a>.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreexcludesFile"> core.excludesFile </dt> <dd> <p>Specifies the pathname to the file that contains patterns to describe paths that are not meant to be tracked, in addition to <code>.gitignore</code> (per-directory) and <code>.git/info/exclude</code>. Defaults to <code>$XDG_CONFIG_HOME/git/ignore</code>. If <code>$XDG_CONFIG_HOME</code> is either not set or empty, <code>$HOME/.config/git/ignore</code> is used instead. See <a href="gitignore">gitignore[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreaskPass"> core.askPass </dt> <dd> <p>Some commands (e.g. svn and http interfaces) that interactively ask for a password can be told to use an external program given via the value of this variable. Can be overridden by the <code>GIT_ASKPASS</code> environment variable. If not set, fall back to the value of the <code>SSH_ASKPASS</code> environment variable or, failing that, a simple password prompt. The external program shall be given a suitable prompt as command-line argument and write the password on its STDOUT.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreattributesFile"> core.attributesFile </dt> <dd> <p>In addition to <code>.gitattributes</code> (per-directory) and <code>.git/info/attributes</code>, Git looks into this file for attributes (see <a href="gitattributes">gitattributes[5]</a>). Path expansions are made the same way as for <code>core.excludesFile</code>. Its default value is <code>$XDG_CONFIG_HOME/git/attributes</code>. If <code>$XDG_CONFIG_HOME</code> is either not set or empty, <code>$HOME/.config/git/attributes</code> is used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corehooksPath"> core.hooksPath </dt> <dd> <p>By default Git will look for your hooks in the <code>$GIT_DIR/hooks</code> directory. Set this to different path, e.g. <code>/etc/git/hooks</code>, and Git will try to find your hooks in that directory, e.g. <code>/etc/git/hooks/pre-receive</code> instead of in <code>$GIT_DIR/hooks/pre-receive</code>.</p> <p>The path can be either absolute or relative. A relative path is taken as relative to the directory where the hooks are run (see the "DESCRIPTION" section of <a href="githooks">githooks[5]</a>).</p> <p>This configuration variable is useful in cases where you’d like to centrally configure your Git hooks instead of configuring them on a per-repository basis, or as a more flexible and centralized alternative to having an <code>init.templateDir</code> where you’ve changed default hooks.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreeditor"> core.editor </dt> <dd> <p>Commands such as <code>commit</code> and <code>tag</code> that let you edit messages by launching an editor use the value of this variable when it is set, and the environment variable <code>GIT_EDITOR</code> is not set. See <a href="git-var">git-var[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corecommentChar"> core.commentChar </dt> <dd> <p>Commands such as <code>commit</code> and <code>tag</code> that let you edit messages consider a line that begins with this character commented, and removes them after the editor returns (default <code>#</code>).</p> <p>If set to "auto", <code>git-commit</code> would select a character that is not the beginning character of any line in existing commit messages.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corefilesRefLockTimeout"> core.filesRefLockTimeout </dt> <dd> <p>The length of time, in milliseconds, to retry when trying to lock an individual reference. Value 0 means not to retry at all; -1 means to try indefinitely. Default is 100 (i.e., retry for 100ms).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corepackedRefsTimeout"> core.packedRefsTimeout </dt> <dd> <p>The length of time, in milliseconds, to retry when trying to lock the <code>packed-refs</code> file. Value 0 means not to retry at all; -1 means to try indefinitely. Default is 1000 (i.e., retry for 1 second).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corepager"> core.pager </dt> <dd> <p>Text viewer for use by Git commands (e.g., <code>less</code>). The value is meant to be interpreted by the shell. The order of preference is the <code>$GIT_PAGER</code> environment variable, then <code>core.pager</code> configuration, then <code>$PAGER</code>, and then the default chosen at compile time (usually <code>less</code>).</p> <p>When the <code>LESS</code> environment variable is unset, Git sets it to <code>FRX</code> (if <code>LESS</code> environment variable is set, Git does not change it at all). If you want to selectively override Git’s default setting for <code>LESS</code>, you can set <code>core.pager</code> to e.g. <code>less -S</code>. This will be passed to the shell by Git, which will translate the final command to <code>LESS=FRX less -S</code>. The environment does not set the <code>S</code> option but the command line does, instructing less to truncate long lines. Similarly, setting <code>core.pager</code> to <code>less -+F</code> will deactivate the <code>F</code> option specified by the environment from the command-line, deactivating the "quit if one screen" behavior of <code>less</code>. One can specifically activate some flags for particular commands: for example, setting <code>pager.blame</code> to <code>less -S</code> enables line truncation only for <code>git blame</code>.</p> <p>Likewise, when the <code>LV</code> environment variable is unset, Git sets it to <code>-c</code>. You can override this setting by exporting <code>LV</code> with another value or setting <code>core.pager</code> to <code>lv +c</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corewhitespace"> core.whitespace </dt> <dd> <p>A comma separated list of common whitespace problems to notice. <code>git diff</code> will use <code>color.diff.whitespace</code> to highlight them, and <code>git apply --whitespace=error</code> will consider them as errors. You can prefix <code>-</code> to disable any of them (e.g. <code>-trailing-space</code>):</p> <div class="ulist"> <ul> <li> <p><code>blank-at-eol</code> treats trailing whitespaces at the end of the line as an error (enabled by default).</p> </li> <li> <p><code>space-before-tab</code> treats a space character that appears immediately before a tab character in the initial indent part of the line as an error (enabled by default).</p> </li> <li> <p><code>indent-with-non-tab</code> treats a line that is indented with space characters instead of the equivalent tabs as an error (not enabled by default).</p> </li> <li> <p><code>tab-in-indent</code> treats a tab character in the initial indent part of the line as an error (not enabled by default).</p> </li> <li> <p><code>blank-at-eof</code> treats blank lines added at the end of file as an error (enabled by default).</p> </li> <li> <p><code>trailing-space</code> is a short-hand to cover both <code>blank-at-eol</code> and <code>blank-at-eof</code>.</p> </li> <li> <p><code>cr-at-eol</code> treats a carriage-return at the end of line as part of the line terminator, i.e. with it, <code>trailing-space</code> does not trigger if the character before such a carriage-return is not a whitespace (not enabled by default).</p> </li> <li> <p><code>tabwidth=<n></code> tells how many character positions a tab occupies; this is relevant for <code>indent-with-non-tab</code> and when Git fixes <code>tab-in-indent</code> errors. The default tab width is 8. Allowed values are 1 to 63.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corefsync"> core.fsync </dt> <dd> <p>A comma-separated list of components of the repository that should be hardened via the core.fsyncMethod when created or modified. You can disable hardening of any component by prefixing it with a <code>-</code>. Items that are not hardened may be lost in the event of an unclean system shutdown. Unless you have special requirements, it is recommended that you leave this option empty or pick one of <code>committed</code>, <code>added</code>, or <code>all</code>.</p> <p>When this configuration is encountered, the set of components starts with the platform default value, disabled components are removed, and additional components are added. <code>none</code> resets the state so that the platform default is ignored.</p> <p>The empty string resets the fsync configuration to the platform default. The default on most platforms is equivalent to <code>core.fsync=committed,-loose-object</code>, which has good performance, but risks losing recent work in the event of an unclean system shutdown.</p> <div class="ulist"> <ul> <li> <p><code>none</code> clears the set of fsynced components.</p> </li> <li> <p><code>loose-object</code> hardens objects added to the repo in loose-object form.</p> </li> <li> <p><code>pack</code> hardens objects added to the repo in packfile form.</p> </li> <li> <p><code>pack-metadata</code> hardens packfile bitmaps and indexes.</p> </li> <li> <p><code>commit-graph</code> hardens the commit-graph file.</p> </li> <li> <p><code>index</code> hardens the index when it is modified.</p> </li> <li> <p><code>objects</code> is an aggregate option that is equivalent to <code>loose-object,pack</code>.</p> </li> <li> <p><code>reference</code> hardens references modified in the repo.</p> </li> <li> <p><code>derived-metadata</code> is an aggregate option that is equivalent to <code>pack-metadata,commit-graph</code>.</p> </li> <li> <p><code>committed</code> is an aggregate option that is currently equivalent to <code>objects</code>. This mode sacrifices some performance to ensure that work that is committed to the repository with <code>git commit</code> or similar commands is hardened.</p> </li> <li> <p><code>added</code> is an aggregate option that is currently equivalent to <code>committed,index</code>. This mode sacrifices additional performance to ensure that the results of commands like <code>git add</code> and similar operations are hardened.</p> </li> <li> <p><code>all</code> is an aggregate option that syncs all individual components above.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corefsyncMethod"> core.fsyncMethod </dt> <dd> <p>A value indicating the strategy Git will use to harden repository data using fsync and related primitives.</p> <div class="ulist"> <ul> <li> <p><code>fsync</code> uses the fsync() system call or platform equivalents.</p> </li> <li> <p><code>writeout-only</code> issues pagecache writeback requests, but depending on the filesystem and storage hardware, data added to the repository may not be durable in the event of a system crash. This is the default mode on macOS.</p> </li> <li> <p><code>batch</code> enables a mode that uses writeout-only flushes to stage multiple updates in the disk writeback cache and then does a single full fsync of a dummy file to trigger the disk cache flush at the end of the operation.</p> <p>Currently <code>batch</code> mode only applies to loose-object files. Other repository data is made durable as if <code>fsync</code> was specified. This mode is expected to be as safe as <code>fsync</code> on macOS for repos stored on HFS+ or APFS filesystems and on Windows for repos stored on NTFS or ReFS filesystems.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corefsyncObjectFiles"> core.fsyncObjectFiles </dt> <dd> <p>This boolean will enable <code>fsync()</code> when writing object files. This setting is deprecated. Use core.fsync instead.</p> <p>This setting affects data added to the Git repository in loose-object form. When set to true, Git will issue an fsync or similar system call to flush caches so that loose-objects remain consistent in the face of a unclean system shutdown.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corepreloadIndex"> core.preloadIndex </dt> <dd> <p>Enable parallel index preload for operations like <code>git diff</code></p> <p>This can speed up operations like <code>git diff</code> and <code>git status</code> especially on filesystems like NFS that have weak caching semantics and thus relatively high IO latencies. When enabled, Git will do the index comparison to the filesystem data in parallel, allowing overlapping IO’s. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreunsetenvvars"> core.unsetenvvars </dt> <dd> <p>Windows-only: comma-separated list of environment variables' names that need to be unset before spawning any other process. Defaults to <code>PERL5LIB</code> to account for the fact that Git for Windows insists on using its own Perl interpreter.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corerestrictinheritedhandles"> core.restrictinheritedhandles </dt> <dd> <p>Windows-only: override whether spawned processes inherit only standard file handles (<code>stdin</code>, <code>stdout</code> and <code>stderr</code>) or all handles. Can be <code>auto</code>, <code>true</code> or <code>false</code>. Defaults to <code>auto</code>, which means <code>true</code> on Windows 7 and later, and <code>false</code> on older Windows versions.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corecreateObject"> core.createObject </dt> <dd> <p>You can set this to <code>link</code>, in which case a hardlink followed by a delete of the source are used to make sure that object creation will not overwrite existing objects.</p> <p>On some file system/operating system combinations, this is unreliable. Set this config setting to <code>rename</code> there; However, This will remove the check that makes sure that existing object files will not get overwritten.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corenotesRef"> core.notesRef </dt> <dd> <p>When showing commit messages, also show notes which are stored in the given ref. The ref must be fully qualified. If the given ref does not exist, it is not an error but means that no notes should be printed.</p> <p>This setting defaults to "refs/notes/commits", and it can be overridden by the <code>GIT_NOTES_REF</code> environment variable. See <a href="git-notes">git-notes[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-corecommitGraph"> core.commitGraph </dt> <dd> <p>If true, then git will read the commit-graph file (if it exists) to parse the graph structure of commits. Defaults to true. See <a href="git-commit-graph">git-commit-graph[1]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreuseReplaceRefs"> core.useReplaceRefs </dt> <dd> <p>If set to <code>false</code>, behave as if the <code>--no-replace-objects</code> option was given on the command line. See <a href="git">git[1]</a> and <a href="git-replace">git-replace[1]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coremultiPackIndex"> core.multiPackIndex </dt> <dd> <p>Use the multi-pack-index file to track multiple packfiles using a single index. See <a href="git-multi-pack-index">git-multi-pack-index[1]</a> for more information. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coresparseCheckout"> core.sparseCheckout </dt> <dd> <p>Enable "sparse checkout" feature. See <a href="git-sparse-checkout">git-sparse-checkout[1]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coresparseCheckoutCone"> core.sparseCheckoutCone </dt> <dd> <p>Enables the "cone mode" of the sparse checkout feature. When the sparse-checkout file contains a limited set of patterns, this mode provides significant performance advantages. The "non-cone mode" can be requested to allow specifying more flexible patterns by setting this variable to <code>false</code>. See <a href="git-sparse-checkout">git-sparse-checkout[1]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coreabbrev"> core.abbrev </dt> <dd> <p>Set the length object names are abbreviated to. If unspecified or set to "auto", an appropriate value is computed based on the approximate number of packed objects in your repository, which hopefully is enough for abbreviated object names to stay unique for some time. If set to "no", no abbreviation is made and the object names are shown in their full length. The minimum length is 4.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coremaxTreeDepth"> core.maxTreeDepth </dt> <dd> <p>The maximum depth Git is willing to recurse while traversing a tree (e.g., "a/b/cde/f" has a depth of 4). This is a fail-safe to allow Git to abort cleanly, and should not generally need to be adjusted. The default is 4096.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-addignoreErrors"> add.ignoreErrors </dt> <dt class="hdlist1" id="Documentation/git-config.txt-addignore-errorsdeprecated"> add.ignore-errors (deprecated) </dt> <dd> <p>Tells <code>git add</code> to continue adding files when some files cannot be added due to indexing errors. Equivalent to the <code>--ignore-errors</code> option of <a href="git-add">git-add[1]</a>. <code>add.ignore-errors</code> is deprecated, as it does not follow the usual naming convention for configuration variables.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-addinteractiveuseBuiltin"> add.interactive.useBuiltin </dt> <dd> <p>Unused configuration variable. Used in Git versions v2.25.0 to v2.36.0 to enable the built-in version of <a href="git-add">git-add[1]</a>'s interactive mode, which then became the default in Git versions v2.37.0 to v2.39.0.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-alias"> alias.* </dt> <dd> <p>Command aliases for the <a href="git">git[1]</a> command wrapper - e.g. after defining <code>alias.last = cat-file commit HEAD</code>, the invocation <code>git last</code> is equivalent to <code>git cat-file commit HEAD</code>. To avoid confusion and troubles with script usage, aliases that hide existing Git commands are ignored. Arguments are split by spaces, the usual shell quoting and escaping are supported. A quote pair or a backslash can be used to quote them.</p> <p>Note that the first word of an alias does not necessarily have to be a command. It can be a command-line option that will be passed into the invocation of <code>git</code>. In particular, this is useful when used with <code>-c</code> to pass in one-time configurations or <code>-p</code> to force pagination. For example, <code>loud-rebase = -c commit.verbose=true rebase</code> can be defined such that running <code>git loud-rebase</code> would be equivalent to <code>git -c commit.verbose=true rebase</code>. Also, <code>ps = -p status</code> would be a helpful alias since <code>git ps</code> would paginate the output of <code>git status</code> where the original command does not.</p> <p>If the alias expansion is prefixed with an exclamation point, it will be treated as a shell command. For example, defining <code>alias.new = !gitk --all --not ORIG_HEAD</code>, the invocation <code>git new</code> is equivalent to running the shell command <code>gitk --all --not ORIG_HEAD</code>. Note that shell commands will be executed from the top-level directory of a repository, which may not necessarily be the current directory. <code>GIT_PREFIX</code> is set as returned by running <code>git rev-parse --show-prefix</code> from the original current directory. See <a href="git-rev-parse">git-rev-parse[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-amkeepcr"> am.keepcr </dt> <dd> <p>If true, git-am will call git-mailsplit for patches in mbox format with parameter <code>--keep-cr</code>. In this case git-mailsplit will not remove <code>\r</code> from lines ending with <code>\r\n</code>. Can be overridden by giving <code>--no-keep-cr</code> from the command line. See <a href="git-am">git-am[1]</a>, <a href="git-mailsplit">git-mailsplit[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-amthreeWay"> am.threeWay </dt> <dd> <p>By default, <code>git am</code> will fail if the patch does not apply cleanly. When set to true, this setting tells <code>git am</code> to fall back on 3-way merge if the patch records the identity of blobs it is supposed to apply to and we have those blobs available locally (equivalent to giving the <code>--3way</code> option from the command line). Defaults to <code>false</code>. See <a href="git-am">git-am[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-applyignoreWhitespace"> apply.ignoreWhitespace </dt> <dd> <p>When set to <code>change</code>, tells <code>git apply</code> to ignore changes in whitespace, in the same way as the <code>--ignore-space-change</code> option. When set to one of: no, none, never, false, it tells <code>git apply</code> to respect all whitespace differences. See <a href="git-apply">git-apply[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-applywhitespace"> apply.whitespace </dt> <dd> <p>Tells <code>git apply</code> how to handle whitespace, in the same way as the <code>--whitespace</code> option. See <a href="git-apply">git-apply[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-blameblankBoundary"> blame.blankBoundary </dt> <dd> <p>Show blank commit object name for boundary commits in <a href="git-blame">git-blame[1]</a>. This option defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-blamecoloring"> blame.coloring </dt> <dd> <p>This determines the coloring scheme to be applied to blame output. It can be <code>repeatedLines</code>, <code>highlightRecent</code>, or <code>none</code> which is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-blamedate"> blame.date </dt> <dd> <p>Specifies the format used to output dates in <a href="git-blame">git-blame[1]</a>. If unset the iso format is used. For supported values, see the discussion of the <code>--date</code> option at <a href="git-log">git-log[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-blameshowEmail"> blame.showEmail </dt> <dd> <p>Show the author email instead of author name in <a href="git-blame">git-blame[1]</a>. This option defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-blameshowRoot"> blame.showRoot </dt> <dd> <p>Do not treat root commits as boundaries in <a href="git-blame">git-blame[1]</a>. This option defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-blameignoreRevsFile"> blame.ignoreRevsFile </dt> <dd> <p>Ignore revisions listed in the file, one unabbreviated object name per line, in <a href="git-blame">git-blame[1]</a>. Whitespace and comments beginning with <code>#</code> are ignored. This option may be repeated multiple times. Empty file names will reset the list of ignored revisions. This option will be handled before the command line option <code>--ignore-revs-file</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-blamemarkUnblamableLines"> blame.markUnblamableLines </dt> <dd> <p>Mark lines that were changed by an ignored revision that we could not attribute to another commit with a <code>*</code> in the output of <a href="git-blame">git-blame[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-blamemarkIgnoredLines"> blame.markIgnoredLines </dt> <dd> <p>Mark lines that were changed by an ignored revision that we attributed to another commit with a <code>?</code> in the output of <a href="git-blame">git-blame[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-branchautoSetupMerge"> branch.autoSetupMerge </dt> <dd> <p>Tells <code>git branch</code>, <code>git switch</code> and <code>git checkout</code> to set up new branches so that <a href="git-pull">git-pull[1]</a> will appropriately merge from the starting point branch. Note that even if this option is not set, this behavior can be chosen per-branch using the <code>--track</code> and <code>--no-track</code> options. The valid settings are: <code>false</code> — no automatic setup is done; <code>true</code> — automatic setup is done when the starting point is a remote-tracking branch; <code>always</code> — automatic setup is done when the starting point is either a local branch or remote-tracking branch; <code>inherit</code> — if the starting point has a tracking configuration, it is copied to the new branch; <code>simple</code> — automatic setup is done only when the starting point is a remote-tracking branch and the new branch has the same name as the remote branch. This option defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-branchautoSetupRebase"> branch.autoSetupRebase </dt> <dd> <p>When a new branch is created with <code>git branch</code>, <code>git switch</code> or <code>git checkout</code> that tracks another branch, this variable tells Git to set up pull to rebase instead of merge (see "branch.<name>.rebase"). When <code>never</code>, rebase is never automatically set to true. When <code>local</code>, rebase is set to true for tracked branches of other local branches. When <code>remote</code>, rebase is set to true for tracked branches of remote-tracking branches. When <code>always</code>, rebase will be set to true for all tracking branches. See "branch.autoSetupMerge" for details on how to set up a branch to track another branch. This option defaults to never.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-branchsort"> branch.sort </dt> <dd> <p>This variable controls the sort ordering of branches when displayed by <a href="git-branch">git-branch[1]</a>. Without the "--sort=<value>" option provided, the value of this variable will be used as the default. See <a href="git-for-each-ref">git-for-each-ref[1]</a> field names for valid values.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-branchltnamegtremote"> branch.<name>.remote </dt> <dd> <p>When on branch <name>, it tells <code>git fetch</code> and <code>git push</code> which remote to fetch from or push to. The remote to push to may be overridden with <code>remote.pushDefault</code> (for all branches). The remote to push to, for the current branch, may be further overridden by <code>branch.<name>.pushRemote</code>. If no remote is configured, or if you are not on any branch and there is more than one remote defined in the repository, it defaults to <code>origin</code> for fetching and <code>remote.pushDefault</code> for pushing. Additionally, <code>.</code> (a period) is the current local repository (a dot-repository), see <code>branch.<name>.merge</code>'s final note below.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-branchltnamegtpushRemote"> branch.<name>.pushRemote </dt> <dd> <p>When on branch <name>, it overrides <code>branch.<name>.remote</code> for pushing. It also overrides <code>remote.pushDefault</code> for pushing from branch <name>. When you pull from one place (e.g. your upstream) and push to another place (e.g. your own publishing repository), you would want to set <code>remote.pushDefault</code> to specify the remote to push to for all branches, and use this option to override it for a specific branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-branchltnamegtmerge"> branch.<name>.merge </dt> <dd> <p>Defines, together with branch.<name>.remote, the upstream branch for the given branch. It tells <code>git fetch</code>/<code>git pull</code>/<code>git rebase</code> which branch to merge and can also affect <code>git push</code> (see push.default). When in branch <name>, it tells <code>git fetch</code> the default refspec to be marked for merging in FETCH_HEAD. The value is handled like the remote part of a refspec, and must match a ref which is fetched from the remote given by "branch.<name>.remote". The merge information is used by <code>git pull</code> (which first calls <code>git fetch</code>) to lookup the default branch for merging. Without this option, <code>git pull</code> defaults to merge the first refspec fetched. Specify multiple values to get an octopus merge. If you wish to setup <code>git pull</code> so that it merges into <name> from another branch in the local repository, you can point branch.<name>.merge to the desired branch, and use the relative path setting <code>.</code> (a period) for branch.<name>.remote.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-branchltnamegtmergeOptions"> branch.<name>.mergeOptions </dt> <dd> <p>Sets default options for merging into branch <name>. The syntax and supported options are the same as those of <a href="git-merge">git-merge[1]</a>, but option values containing whitespace characters are currently not supported.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-branchltnamegtrebase"> branch.<name>.rebase </dt> <dd> <p>When true, rebase the branch <name> on top of the fetched branch, instead of merging the default branch from the default remote when "git pull" is run. See "pull.rebase" for doing this in a non branch-specific manner.</p> <p>When <code>merges</code> (or just <code>m</code>), pass the <code>--rebase-merges</code> option to <code>git rebase</code> so that the local merge commits are included in the rebase (see <a href="git-rebase">git-rebase[1]</a> for details).</p> <p>When the value is <code>interactive</code> (or just <code>i</code>), the rebase is run in interactive mode.</p> <p><strong>NOTE</strong>: this is a possibly dangerous operation; do <strong>not</strong> use it unless you understand the implications (see <a href="git-rebase">git-rebase[1]</a> for details).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-branchltnamegtdescription"> branch.<name>.description </dt> <dd> <p>Branch description, can be edited with <code>git branch --edit-description</code>. Branch description is automatically added to the format-patch cover letter or request-pull summary.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-browserlttoolgtcmd"> browser.<tool>.cmd </dt> <dd> <p>Specify the command to invoke the specified browser. The specified command is evaluated in shell with the URLs passed as arguments. (See <a href="git-web--browse">git-web--browse[1]</a>.)</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-browserlttoolgtpath"> browser.<tool>.path </dt> <dd> <p>Override the path for the given tool that may be used to browse HTML help (see <code>-w</code> option in <a href="git-help">git-help[1]</a>) or a working repository in gitweb (see <a href="git-instaweb">git-instaweb[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-bundle"> bundle.* </dt> <dd> <p>The <code>bundle.*</code> keys may appear in a bundle list file found via the <code>git clone --bundle-uri</code> option. These keys currently have no effect if placed in a repository config file, though this will change in the future. See <a href="bundle-uri">the bundle URI design document</a> for more details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-bundleversion"> bundle.version </dt> <dd> <p>This integer value advertises the version of the bundle list format used by the bundle list. Currently, the only accepted value is <code>1</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-bundlemode"> bundle.mode </dt> <dd> <p>This string value should be either <code>all</code> or <code>any</code>. This value describes whether all of the advertised bundles are required to unbundle a complete understanding of the bundled information (<code>all</code>) or if any one of the listed bundle URIs is sufficient (<code>any</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-bundleheuristic"> bundle.heuristic </dt> <dd> <p>If this string-valued key exists, then the bundle list is designed to work well with incremental <code>git fetch</code> commands. The heuristic signals that there are additional keys available for each bundle that help determine which subset of bundles the client should download. The only value currently understood is <code>creationToken</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-bundleltidgt"> bundle.<id>.* </dt> <dd> <p>The <code>bundle.<id>.*</code> keys are used to describe a single item in the bundle list, grouped under <code><id></code> for identification purposes.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-bundleltidgturi"> bundle.<id>.uri </dt> <dd> <p>This string value defines the URI by which Git can reach the contents of this <code><id></code>. This URI may be a bundle file or another bundle list.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-checkoutdefaultRemote"> checkout.defaultRemote </dt> <dd> <p>When you run <code>git checkout <something></code> or <code>git switch <something></code> and only have one remote, it may implicitly fall back on checking out and tracking e.g. <code>origin/<something></code>. This stops working as soon as you have more than one remote with a <code><something></code> reference. This setting allows for setting the name of a preferred remote that should always win when it comes to disambiguation. The typical use-case is to set this to <code>origin</code>.</p> <p>Currently this is used by <a href="git-switch">git-switch[1]</a> and <a href="git-checkout">git-checkout[1]</a> when <code>git checkout <something></code> or <code>git switch <something></code> will checkout the <code><something></code> branch on another remote, and by <a href="git-worktree">git-worktree[1]</a> when <code>git worktree add</code> refers to a remote branch. This setting might be used for other checkout-like commands or functionality in the future.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-checkoutguess"> checkout.guess </dt> <dd> <p>Provides the default value for the <code>--guess</code> or <code>--no-guess</code> option in <code>git checkout</code> and <code>git switch</code>. See <a href="git-switch">git-switch[1]</a> and <a href="git-checkout">git-checkout[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-checkoutworkers"> checkout.workers </dt> <dd> <p>The number of parallel workers to use when updating the working tree. The default is one, i.e. sequential execution. If set to a value less than one, Git will use as many workers as the number of logical cores available. This setting and <code>checkout.thresholdForParallelism</code> affect all commands that perform checkout. E.g. checkout, clone, reset, sparse-checkout, etc.</p> <p>Note: Parallel checkout usually delivers better performance for repositories located on SSDs or over NFS. For repositories on spinning disks and/or machines with a small number of cores, the default sequential checkout often performs better. The size and compression level of a repository might also influence how well the parallel version performs.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-checkoutthresholdForParallelism"> checkout.thresholdForParallelism </dt> <dd> <p>When running parallel checkout with a small number of files, the cost of subprocess spawning and inter-process communication might outweigh the parallelization gains. This setting allows you to define the minimum number of files for which parallel checkout should be attempted. The default is 100.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-cleanrequireForce"> clean.requireForce </dt> <dd> <p>A boolean to make git-clean do nothing unless given -f, -i, or -n. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-clonedefaultRemoteName"> clone.defaultRemoteName </dt> <dd> <p>The name of the remote to create when cloning a repository. Defaults to <code>origin</code>, and can be overridden by passing the <code>--origin</code> command-line option to <a href="git-clone">git-clone[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-clonerejectShallow"> clone.rejectShallow </dt> <dd> <p>Reject cloning a repository if it is a shallow one; this can be overridden by passing the <code>--reject-shallow</code> option on the command line. See <a href="git-clone">git-clone[1]</a></p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-clonefilterSubmodules"> clone.filterSubmodules </dt> <dd> <p>If a partial clone filter is provided (see <code>--filter</code> in <a href="git-rev-list">git-rev-list[1]</a>) and <code>--recurse-submodules</code> is used, also apply the filter to submodules.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coloradvice"> color.advice </dt> <dd> <p>A boolean to enable/disable color in hints (e.g. when a push failed, see <code>advice.*</code> for a list). May be set to <code>always</code>, <code>false</code> (or <code>never</code>) or <code>auto</code> (or <code>true</code>), in which case colors are used only when the error output goes to a terminal. If unset, then the value of <code>color.ui</code> is used (<code>auto</code> by default).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coloradvicehint"> color.advice.hint </dt> <dd> <p>Use customized color for hints.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorblamehighlightRecent"> color.blame.highlightRecent </dt> <dd> <p>Specify the line annotation color for <code>git blame --color-by-age</code> depending upon the age of the line.</p> <p>This setting should be set to a comma-separated list of color and date settings, starting and ending with a color, the dates should be set from oldest to newest. The metadata will be colored with the specified colors if the line was introduced before the given timestamp, overwriting older timestamped colors.</p> <p>Instead of an absolute timestamp relative timestamps work as well, e.g. <code>2.weeks.ago</code> is valid to address anything older than 2 weeks.</p> <p>It defaults to <code>blue,12 month ago,white,1 month ago,red</code>, which colors everything older than one year blue, recent changes between one month and one year old are kept white, and lines introduced within the last month are colored red.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorblamerepeatedLines"> color.blame.repeatedLines </dt> <dd> <p>Use the specified color to colorize line annotations for <code>git blame --color-lines</code>, if they come from the same commit as the preceding line. Defaults to cyan.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorbranch"> color.branch </dt> <dd> <p>A boolean to enable/disable color in the output of <a href="git-branch">git-branch[1]</a>. May be set to <code>always</code>, <code>false</code> (or <code>never</code>) or <code>auto</code> (or <code>true</code>), in which case colors are used only when the output is to a terminal. If unset, then the value of <code>color.ui</code> is used (<code>auto</code> by default).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorbranchltslotgt"> color.branch.<slot> </dt> <dd> <p>Use customized color for branch coloration. <code><slot></code> is one of <code>current</code> (the current branch), <code>local</code> (a local branch), <code>remote</code> (a remote-tracking branch in refs/remotes/), <code>upstream</code> (upstream tracking branch), <code>plain</code> (other refs).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colordiff"> color.diff </dt> <dd> <p>Whether to use ANSI escape sequences to add color to patches. If this is set to <code>always</code>, <a href="git-diff">git-diff[1]</a>, <a href="git-log">git-log[1]</a>, and <a href="git-show">git-show[1]</a> will use color for all patches. If it is set to <code>true</code> or <code>auto</code>, those commands will only use color when output is to the terminal. If unset, then the value of <code>color.ui</code> is used (<code>auto</code> by default).</p> <p>This does not affect <a href="git-format-patch">git-format-patch[1]</a> or the <code>git-diff-*</code> plumbing commands. Can be overridden on the command line with the <code>--color[=<when>]</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colordiffltslotgt"> color.diff.<slot> </dt> <dd> <p>Use customized color for diff colorization. <code><slot></code> specifies which part of the patch to use the specified color, and is one of <code>context</code> (context text - <code>plain</code> is a historical synonym), <code>meta</code> (metainformation), <code>frag</code> (hunk header), <code>func</code> (function in hunk header), <code>old</code> (removed lines), <code>new</code> (added lines), <code>commit</code> (commit headers), <code>whitespace</code> (highlighting whitespace errors), <code>oldMoved</code> (deleted lines), <code>newMoved</code> (added lines), <code>oldMovedDimmed</code>, <code>oldMovedAlternative</code>, <code>oldMovedAlternativeDimmed</code>, <code>newMovedDimmed</code>, <code>newMovedAlternative</code> <code>newMovedAlternativeDimmed</code> (See the <code><mode></code> setting of <code>--color-moved</code> in <a href="git-diff">git-diff[1]</a> for details), <code>contextDimmed</code>, <code>oldDimmed</code>, <code>newDimmed</code>, <code>contextBold</code>, <code>oldBold</code>, and <code>newBold</code> (see <a href="git-range-diff">git-range-diff[1]</a> for details).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colordecorateltslotgt"> color.decorate.<slot> </dt> <dd> <p>Use customized color for <code>git log --decorate</code> output. <code><slot></code> is one of <code>branch</code>, <code>remoteBranch</code>, <code>tag</code>, <code>stash</code> or <code>HEAD</code> for local branches, remote-tracking branches, tags, stash and HEAD, respectively and <code>grafted</code> for grafted commits.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorgrep"> color.grep </dt> <dd> <p>When set to <code>always</code>, always highlight matches. When <code>false</code> (or <code>never</code>), never. When set to <code>true</code> or <code>auto</code>, use color only when the output is written to the terminal. If unset, then the value of <code>color.ui</code> is used (<code>auto</code> by default).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorgrepltslotgt"> color.grep.<slot> </dt> <dd> <p>Use customized color for grep colorization. <code><slot></code> specifies which part of the line to use the specified color, and is one of</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-codecontextcode"> <code>context</code> </dt> <dd> <p>non-matching text in context lines (when using <code>-A</code>, <code>-B</code>, or <code>-C</code>)</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codefilenamecode"> <code>filename</code> </dt> <dd> <p>filename prefix (when not using <code>-h</code>)</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codefunctioncode"> <code>function</code> </dt> <dd> <p>function name lines (when using <code>-p</code>)</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codelineNumbercode"> <code>lineNumber</code> </dt> <dd> <p>line number prefix (when using <code>-n</code>)</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codecolumncode"> <code>column</code> </dt> <dd> <p>column number prefix (when using <code>--column</code>)</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codematchcode"> <code>match</code> </dt> <dd> <p>matching text (same as setting <code>matchContext</code> and <code>matchSelected</code>)</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codematchContextcode"> <code>matchContext</code> </dt> <dd> <p>matching text in context lines</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codematchSelectedcode"> <code>matchSelected</code> </dt> <dd> <p>matching text in selected lines. Also, used to customize the following <a href="git-log">git-log[1]</a> subcommands: <code>--grep</code>, <code>--author</code>, and <code>--committer</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codeselectedcode"> <code>selected</code> </dt> <dd> <p>non-matching text in selected lines. Also, used to customize the following <a href="git-log">git-log[1]</a> subcommands: <code>--grep</code>, <code>--author</code> and <code>--committer</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codeseparatorcode"> <code>separator</code> </dt> <dd> <p>separators between fields on a line (<code>:</code>, <code>-</code>, and <code>=</code>) and between hunks (<code>--</code>)</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorinteractive"> color.interactive </dt> <dd> <p>When set to <code>always</code>, always use colors for interactive prompts and displays (such as those used by "git-add --interactive" and "git-clean --interactive"). When false (or <code>never</code>), never. When set to <code>true</code> or <code>auto</code>, use colors only when the output is to the terminal. If unset, then the value of <code>color.ui</code> is used (<code>auto</code> by default).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorinteractiveltslotgt"> color.interactive.<slot> </dt> <dd> <p>Use customized color for <code>git add --interactive</code> and <code>git clean --interactive</code> output. <code><slot></code> may be <code>prompt</code>, <code>header</code>, <code>help</code> or <code>error</code>, for four distinct types of normal output from interactive commands.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorpager"> color.pager </dt> <dd> <p>A boolean to specify whether <code>auto</code> color modes should colorize output going to the pager. Defaults to true; set this to false if your pager does not understand ANSI color codes.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorpush"> color.push </dt> <dd> <p>A boolean to enable/disable color in push errors. May be set to <code>always</code>, <code>false</code> (or <code>never</code>) or <code>auto</code> (or <code>true</code>), in which case colors are used only when the error output goes to a terminal. If unset, then the value of <code>color.ui</code> is used (<code>auto</code> by default).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorpusherror"> color.push.error </dt> <dd> <p>Use customized color for push errors.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorremote"> color.remote </dt> <dd> <p>If set, keywords at the start of the line are highlighted. The keywords are "error", "warning", "hint" and "success", and are matched case-insensitively. May be set to <code>always</code>, <code>false</code> (or <code>never</code>) or <code>auto</code> (or <code>true</code>). If unset, then the value of <code>color.ui</code> is used (<code>auto</code> by default).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorremoteltslotgt"> color.remote.<slot> </dt> <dd> <p>Use customized color for each remote keyword. <code><slot></code> may be <code>hint</code>, <code>warning</code>, <code>success</code> or <code>error</code> which match the corresponding keyword.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorshowBranch"> color.showBranch </dt> <dd> <p>A boolean to enable/disable color in the output of <a href="git-show-branch">git-show-branch[1]</a>. May be set to <code>always</code>, <code>false</code> (or <code>never</code>) or <code>auto</code> (or <code>true</code>), in which case colors are used only when the output is to a terminal. If unset, then the value of <code>color.ui</code> is used (<code>auto</code> by default).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorstatus"> color.status </dt> <dd> <p>A boolean to enable/disable color in the output of <a href="git-status">git-status[1]</a>. May be set to <code>always</code>, <code>false</code> (or <code>never</code>) or <code>auto</code> (or <code>true</code>), in which case colors are used only when the output is to a terminal. If unset, then the value of <code>color.ui</code> is used (<code>auto</code> by default).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorstatusltslotgt"> color.status.<slot> </dt> <dd> <p>Use customized color for status colorization. <code><slot></code> is one of <code>header</code> (the header text of the status message), <code>added</code> or <code>updated</code> (files which are added but not committed), <code>changed</code> (files which are changed but not added in the index), <code>untracked</code> (files which are not tracked by Git), <code>branch</code> (the current branch), <code>nobranch</code> (the color the <code>no branch</code> warning is shown in, defaulting to red), <code>localBranch</code> or <code>remoteBranch</code> (the local and remote branch names, respectively, when branch and tracking information is displayed in the status short-format), or <code>unmerged</code> (files which have unmerged changes).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colortransport"> color.transport </dt> <dd> <p>A boolean to enable/disable color when pushes are rejected. May be set to <code>always</code>, <code>false</code> (or <code>never</code>) or <code>auto</code> (or <code>true</code>), in which case colors are used only when the error output goes to a terminal. If unset, then the value of <code>color.ui</code> is used (<code>auto</code> by default).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colortransportrejected"> color.transport.rejected </dt> <dd> <p>Use customized color when a push was rejected.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-colorui"> color.ui </dt> <dd> <p>This variable determines the default value for variables such as <code>color.diff</code> and <code>color.grep</code> that control the use of color per command family. Its scope will expand as more commands learn configuration to set a default for the <code>--color</code> option. Set it to <code>false</code> or <code>never</code> if you prefer Git commands not to use color unless enabled explicitly with some other configuration or the <code>--color</code> option. Set it to <code>always</code> if you want all output not intended for machine consumption to use color, to <code>true</code> or <code>auto</code> (this is the default since Git 1.8.4) if you want such output to use color when written to the terminal.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-columnui"> column.ui </dt> <dd> <p>Specify whether supported commands should output in columns. This variable consists of a list of tokens separated by spaces or commas:</p> <p>These options control when the feature should be enabled (defaults to <code>never</code>):</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-codealwayscode"> <code>always</code> </dt> <dd> <p>always show in columns</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codenevercode"> <code>never</code> </dt> <dd> <p>never show in columns</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codeautocode"> <code>auto</code> </dt> <dd> <p>show in columns if the output is to the terminal</p> </dd> </dl> </div> </div> </div> <p>These options control layout (defaults to <code>column</code>). Setting any of these implies <code>always</code> if none of <code>always</code>, <code>never</code>, or <code>auto</code> are specified.</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-codecolumncode-1"> <code>column</code> </dt> <dd> <p>fill columns before rows</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-coderowcode"> <code>row</code> </dt> <dd> <p>fill rows before columns</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codeplaincode"> <code>plain</code> </dt> <dd> <p>show in one column</p> </dd> </dl> </div> </div> </div> <p>Finally, these options can be combined with a layout option (defaults to <code>nodense</code>):</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-codedensecode"> <code>dense</code> </dt> <dd> <p>make unequal size columns to utilize more space</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codenodensecode"> <code>nodense</code> </dt> <dd> <p>make equal size columns</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-columnbranch"> column.branch </dt> <dd> <p>Specify whether to output branch listing in <code>git branch</code> in columns. See <code>column.ui</code> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-columnclean"> column.clean </dt> <dd> <p>Specify the layout when listing items in <code>git clean -i</code>, which always shows files and directories in columns. See <code>column.ui</code> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-columnstatus"> column.status </dt> <dd> <p>Specify whether to output untracked files in <code>git status</code> in columns. See <code>column.ui</code> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-columntag"> column.tag </dt> <dd> <p>Specify whether to output tag listings in <code>git tag</code> in columns. See <code>column.ui</code> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-commitcleanup"> commit.cleanup </dt> <dd> <p>This setting overrides the default of the <code>--cleanup</code> option in <code>git commit</code>. See <a href="git-commit">git-commit[1]</a> for details. Changing the default can be useful when you always want to keep lines that begin with the comment character <code>#</code> in your log message, in which case you would do <code>git config commit.cleanup whitespace</code> (note that you will have to remove the help lines that begin with <code>#</code> in the commit log template yourself, if you do this).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-commitgpgSign"> commit.gpgSign </dt> <dd> <p>A boolean to specify whether all commits should be GPG signed. Use of this option when doing operations such as rebase can result in a large number of commits being signed. It may be convenient to use an agent to avoid typing your GPG passphrase several times.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-commitstatus"> commit.status </dt> <dd> <p>A boolean to enable/disable inclusion of status information in the commit message template when using an editor to prepare the commit message. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-committemplate"> commit.template </dt> <dd> <p>Specify the pathname of a file to use as the template for new commit messages.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-commitverbose"> commit.verbose </dt> <dd> <p>A boolean or int to specify the level of verbosity with <code>git commit</code>. See <a href="git-commit">git-commit[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-commitGraphgenerationVersion"> commitGraph.generationVersion </dt> <dd> <p>Specifies the type of generation number version to use when writing or reading the commit-graph file. If version 1 is specified, then the corrected commit dates will not be written or read. Defaults to 2.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-commitGraphmaxNewFilters"> commitGraph.maxNewFilters </dt> <dd> <p>Specifies the default value for the <code>--max-new-filters</code> option of <code>git +commit-graph write</code> (c.f., <a href="git-commit-graph">git-commit-graph[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-commitGraphreadChangedPaths"> commitGraph.readChangedPaths </dt> <dd> <p>If true, then git will use the changed-path Bloom filters in the commit-graph file (if it exists, and they are present). Defaults to true. See <a href="git-commit-graph">git-commit-graph[1]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-credentialhelper"> credential.helper </dt> <dd> <p>Specify an external helper to be called when a username or password credential is needed; the helper may consult external storage to avoid prompting the user for the credentials. This is normally the name of a credential helper with possible arguments, but may also be an absolute path with arguments or, if preceded by <code>!</code>, shell commands.</p> <p>Note that multiple helpers may be defined. See <a href="gitcredentials">gitcredentials[7]</a> for details and examples.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-credentialuseHttpPath"> credential.useHttpPath </dt> <dd> <p>When acquiring credentials, consider the "path" component of an http or https URL to be important. Defaults to false. See <a href="gitcredentials">gitcredentials[7]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-credentialusername"> credential.username </dt> <dd> <p>If no username is set for a network authentication, use this username by default. See credential.<context>.* below, and <a href="gitcredentials">gitcredentials[7]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-credentiallturlgt"> credential.<url>.* </dt> <dd> <p>Any of the credential.* options above can be applied selectively to some credentials. For example, "credential.https://example.com.username" would set the default username only for https connections to example.com. See <a href="gitcredentials">gitcredentials[7]</a> for details on how URLs are matched.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-credentialCacheignoreSIGHUP"> credentialCache.ignoreSIGHUP </dt> <dd> <p>Tell git-credential-cache—daemon to ignore SIGHUP, instead of quitting.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-credentialStorelockTimeoutMS"> credentialStore.lockTimeoutMS </dt> <dd> <p>The length of time, in milliseconds, for git-credential-store to retry when trying to lock the credentials file. A value of 0 means not to retry at all; -1 means to try indefinitely. Default is 1000 (i.e., retry for 1s).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-completioncommands"> completion.commands </dt> <dd> <p>This is only used by git-completion.bash to add or remove commands from the list of completed commands. Normally only porcelain commands and a few select others are completed. You can add more commands, separated by space, in this variable. Prefixing the command with <code>-</code> will remove it from the existing list.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffautoRefreshIndex"> diff.autoRefreshIndex </dt> <dd> <p>When using <code>git diff</code> to compare with work tree files, do not consider stat-only changes as changed. Instead, silently run <code>git update-index --refresh</code> to update the cached stat information for paths whose contents in the work tree match the contents in the index. This option defaults to true. Note that this affects only <code>git diff</code> Porcelain, and not lower level <code>diff</code> commands such as <code>git diff-files</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffdirstat"> diff.dirstat </dt> <dd> <p>A comma separated list of <code>--dirstat</code> parameters specifying the default behavior of the <code>--dirstat</code> option to <a href="git-diff">git-diff[1]</a> and friends. The defaults can be overridden on the command line (using <code>--dirstat=<param1,param2,...></code>). The fallback defaults (when not changed by <code>diff.dirstat</code>) are <code>changes,noncumulative,3</code>. The following parameters are available:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-codechangescode"> <code>changes</code> </dt> <dd> <p>Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination. This ignores the amount of pure code movements within a file. In other words, rearranging lines in a file is not counted as much as other changes. This is the default behavior when no parameter is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codelinescode"> <code>lines</code> </dt> <dd> <p>Compute the dirstat numbers by doing the regular line-based diff analysis, and summing the removed/added line counts. (For binary files, count 64-byte chunks instead, since binary files have no natural concept of lines). This is a more expensive <code>--dirstat</code> behavior than the <code>changes</code> behavior, but it does count rearranged lines within a file as much as other changes. The resulting output is consistent with what you get from the other <code>--*stat</code> options.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codefilescode"> <code>files</code> </dt> <dd> <p>Compute the dirstat numbers by counting the number of files changed. Each changed file counts equally in the dirstat analysis. This is the computationally cheapest <code>--dirstat</code> behavior, since it does not have to look at the file contents at all.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codecumulativecode"> <code>cumulative</code> </dt> <dd> <p>Count changes in a child directory for the parent directory as well. Note that when using <code>cumulative</code>, the sum of the percentages reported may exceed 100%. The default (non-cumulative) behavior can be specified with the <code>noncumulative</code> parameter.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-ltlimitgt"> <limit> </dt> <dd> <p>An integer parameter specifies a cut-off percent (3% by default). Directories contributing less than this percentage of the changes are not shown in the output.</p> </dd> </dl> </div> </div> </div> <p>Example: The following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories: <code>files,10,cumulative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffstatNameWidth"> diff.statNameWidth </dt> <dd> <p>Limit the width of the filename part in --stat output. If set, applies to all commands generating --stat output except format-patch.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffstatGraphWidth"> diff.statGraphWidth </dt> <dd> <p>Limit the width of the graph part in --stat output. If set, applies to all commands generating --stat output except format-patch.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffcontext"> diff.context </dt> <dd> <p>Generate diffs with <n> lines of context instead of the default of 3. This value is overridden by the -U option.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffinterHunkContext"> diff.interHunkContext </dt> <dd> <p>Show the context between diff hunks, up to the specified number of lines, thereby fusing the hunks that are close to each other. This value serves as the default for the <code>--inter-hunk-context</code> command line option.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffexternal"> diff.external </dt> <dd> <p>If this config variable is set, diff generation is not performed using the internal diff machinery, but using the given command. Can be overridden with the ‘GIT_EXTERNAL_DIFF’ environment variable. The command is called with parameters as described under "git Diffs" in <a href="git">git[1]</a>. Note: if you want to use an external diff program only on a subset of your files, you might want to use <a href="gitattributes">gitattributes[5]</a> instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffignoreSubmodules"> diff.ignoreSubmodules </dt> <dd> <p>Sets the default value of --ignore-submodules. Note that this affects only <code>git diff</code> Porcelain, and not lower level <code>diff</code> commands such as <code>git diff-files</code>. <code>git checkout</code> and <code>git switch</code> also honor this setting when reporting uncommitted changes. Setting it to <code>all</code> disables the submodule summary normally shown by <code>git commit</code> and <code>git status</code> when <code>status.submoduleSummary</code> is set unless it is overridden by using the --ignore-submodules command-line option. The <code>git submodule</code> commands are not affected by this setting. By default this is set to untracked so that any untracked submodules are ignored.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffmnemonicPrefix"> diff.mnemonicPrefix </dt> <dd> <p>If set, <code>git diff</code> uses a prefix pair that is different from the standard "a/" and "b/" depending on what is being compared. When this configuration is in effect, reverse diff output also swaps the order of the prefixes:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-codegitdiffcode"> <code>git diff</code> </dt> <dd> <p>compares the (i)ndex and the (w)ork tree;</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codegitdiffHEADcode"> <code>git diff HEAD</code> </dt> <dd> <p>compares a (c)ommit and the (w)ork tree;</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codegitdiff--cachedcode"> <code>git diff --cached</code> </dt> <dd> <p>compares a (c)ommit and the (i)ndex;</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codegitdiffHEADfile1file2code"> <code>git diff HEAD:file1 file2</code> </dt> <dd> <p>compares an (o)bject and a (w)ork tree entity;</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codegitdiff--no-indexabcode"> <code>git diff --no-index a b</code> </dt> <dd> <p>compares two non-git things (1) and (2).</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffnoprefix"> diff.noprefix </dt> <dd> <p>If set, <code>git diff</code> does not show any source or destination prefix.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffrelative"> diff.relative </dt> <dd> <p>If set to <code>true</code>, <code>git diff</code> does not show changes outside of the directory and show pathnames relative to the current directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-difforderFile"> diff.orderFile </dt> <dd> <p>File indicating how to order files within a diff. See the <code>-O</code> option to <a href="git-diff">git-diff[1]</a> for details. If <code>diff.orderFile</code> is a relative pathname, it is treated as relative to the top of the working tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffrenameLimit"> diff.renameLimit </dt> <dd> <p>The number of files to consider in the exhaustive portion of copy/rename detection; equivalent to the <code>git diff</code> option <code>-l</code>. If not set, the default value is currently 1000. This setting has no effect if rename detection is turned off.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffrenames"> diff.renames </dt> <dd> <p>Whether and how Git detects renames. If set to "false", rename detection is disabled. If set to "true", basic rename detection is enabled. If set to "copies" or "copy", Git will detect copies, as well. Defaults to true. Note that this affects only <code>git diff</code> Porcelain like <a href="git-diff">git-diff[1]</a> and <a href="git-log">git-log[1]</a>, and not lower level commands such as <a href="git-diff-files">git-diff-files[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffsuppressBlankEmpty"> diff.suppressBlankEmpty </dt> <dd> <p>A boolean to inhibit the standard behavior of printing a space before each empty output line. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffsubmodule"> diff.submodule </dt> <dd> <p>Specify the format in which differences in submodules are shown. The "short" format just shows the names of the commits at the beginning and end of the range. The "log" format lists the commits in the range like <a href="git-submodule">git-submodule[1]</a> <code>summary</code> does. The "diff" format shows an inline diff of the changed contents of the submodule. Defaults to "short".</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffwordRegex"> diff.wordRegex </dt> <dd> <p>A POSIX Extended Regular Expression used to determine what is a "word" when performing word-by-word difference calculations. Character sequences that match the regular expression are "words", all other characters are <strong>ignorable</strong> whitespace.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffltdrivergtcommand"> diff.<driver>.command </dt> <dd> <p>The custom diff driver command. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffltdrivergtxfuncname"> diff.<driver>.xfuncname </dt> <dd> <p>The regular expression that the diff driver should use to recognize the hunk header. A built-in pattern may also be used. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffltdrivergtbinary"> diff.<driver>.binary </dt> <dd> <p>Set this option to true to make the diff driver treat files as binary. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffltdrivergttextconv"> diff.<driver>.textconv </dt> <dd> <p>The command that the diff driver should call to generate the text-converted version of a file. The result of the conversion is used to generate a human-readable diff. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffltdrivergtwordRegex"> diff.<driver>.wordRegex </dt> <dd> <p>The regular expression that the diff driver should use to split words in a line. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffltdrivergtcachetextconv"> diff.<driver>.cachetextconv </dt> <dd> <p>Set this option to true to make the diff driver cache the text conversion outputs. See <a href="gitattributes">gitattributes[5]</a> for details.</p> <div class="ulist"> <ul> <li> <p>araxis</p> </li> <li> <p>bc</p> </li> <li> <p>codecompare</p> </li> <li> <p>deltawalker</p> </li> <li> <p>diffmerge</p> </li> <li> <p>diffuse</p> </li> <li> <p>ecmerge</p> </li> <li> <p>emerge</p> </li> <li> <p>examdiff</p> </li> <li> <p>guiffy</p> </li> <li> <p>gvimdiff</p> </li> <li> <p>kdiff3</p> </li> <li> <p>kompare</p> </li> <li> <p>meld</p> </li> <li> <p>nvimdiff</p> </li> <li> <p>opendiff</p> </li> <li> <p>p4merge</p> </li> <li> <p>smerge</p> </li> <li> <p>tkdiff</p> </li> <li> <p>vimdiff</p> </li> <li> <p>winmerge</p> </li> <li> <p>xxdiff</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffindentHeuristic"> diff.indentHeuristic </dt> <dd> <p>Set this option to <code>false</code> to disable the default heuristics that shift diff hunk boundaries to make patches easier to read.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffalgorithm"> diff.algorithm </dt> <dd> <p>Choose a diff algorithm. The variants are as follows:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-codedefaultcodecodemyerscode"> <code>default</code>, <code>myers</code> </dt> <dd> <p>The basic greedy diff algorithm. Currently, this is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codeminimalcode"> <code>minimal</code> </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codepatiencecode"> <code>patience</code> </dt> <dd> <p>Use "patience diff" algorithm when generating patches.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-codehistogramcode"> <code>histogram</code> </dt> <dd> <p>This algorithm extends the patience algorithm to "support low-occurrence common elements".</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffwsErrorHighlight"> diff.wsErrorHighlight </dt> <dd> <p>Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code> lines of the diff. Multiple values are separated by comma, <code>none</code> resets previous values, <code>default</code> reset the list to <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. The whitespace errors are colored with <code>color.diff.whitespace</code>. The command line option <code>--ws-error-highlight=<kind></code> overrides this setting.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffcolorMoved"> diff.colorMoved </dt> <dd> <p>If set to either a valid <code><mode></code> or a true value, moved lines in a diff are colored differently, for details of valid modes see <code>--color-moved</code> in <a href="git-diff">git-diff[1]</a>. If simply set to true the default color mode will be used. When set to false, moved lines are not colored.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffcolorMovedWS"> diff.colorMovedWS </dt> <dd> <p>When moved lines are colored using e.g. the <code>diff.colorMoved</code> setting, this option controls the <code><mode></code> how spaces are treated for details of valid modes see <code>--color-moved-ws</code> in <a href="git-diff">git-diff[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-difftool"> diff.tool </dt> <dd> <p>Controls which diff tool is used by <a href="git-difftool">git-difftool[1]</a>. This variable overrides the value configured in <code>merge.tool</code>. The list below shows the valid built-in values. Any other value is treated as a custom diff tool and requires that a corresponding difftool.<tool>.cmd variable is defined.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-diffguitool"> diff.guitool </dt> <dd> <p>Controls which diff tool is used by <a href="git-difftool">git-difftool[1]</a> when the -g/--gui flag is specified. This variable overrides the value configured in <code>merge.guitool</code>. The list below shows the valid built-in values. Any other value is treated as a custom diff tool and requires that a corresponding difftool.<guitool>.cmd variable is defined.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-difftoollttoolgtcmd"> difftool.<tool>.cmd </dt> <dd> <p>Specify the command to invoke the specified diff tool. The specified command is evaluated in shell with the following variables available: <code>LOCAL</code> is set to the name of the temporary file containing the contents of the diff pre-image and <code>REMOTE</code> is set to the name of the temporary file containing the contents of the diff post-image.</p> <p>See the <code>--tool=<tool></code> option in <a href="git-difftool">git-difftool[1]</a> for more details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-difftoollttoolgtpath"> difftool.<tool>.path </dt> <dd> <p>Override the path for the given tool. This is useful in case your tool is not in the PATH.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-difftooltrustExitCode"> difftool.trustExitCode </dt> <dd> <p>Exit difftool if the invoked diff tool returns a non-zero exit status.</p> <p>See the <code>--trust-exit-code</code> option in <a href="git-difftool">git-difftool[1]</a> for more details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-difftoolprompt"> difftool.prompt </dt> <dd> <p>Prompt before each invocation of the diff tool.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-difftoolguiDefault"> difftool.guiDefault </dt> <dd> <p>Set <code>true</code> to use the <code>diff.guitool</code> by default (equivalent to specifying the <code>--gui</code> argument), or <code>auto</code> to select <code>diff.guitool</code> or <code>diff.tool</code> depending on the presence of a <code>DISPLAY</code> environment variable value. The default is <code>false</code>, where the <code>--gui</code> argument must be provided explicitly for the <code>diff.guitool</code> to be used.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-extensionsobjectFormat"> extensions.objectFormat </dt> <dd> <p>Specify the hash algorithm to use. The acceptable values are <code>sha1</code> and <code>sha256</code>. If not specified, <code>sha1</code> is assumed. It is an error to specify this key unless <code>core.repositoryFormatVersion</code> is 1.</p> <p>Note that this setting should only be set by <a href="git-init">git-init[1]</a> or <a href="git-clone">git-clone[1]</a>. Trying to change it after initialization will not work and will produce hard-to-diagnose issues.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-extensionsworktreeConfig"> extensions.worktreeConfig </dt> <dd> <p>If enabled, then worktrees will load config settings from the <code>$GIT_DIR/config.worktree</code> file in addition to the <code>$GIT_COMMON_DIR/config</code> file. Note that <code>$GIT_COMMON_DIR</code> and <code>$GIT_DIR</code> are the same for the main working tree, while other working trees have <code>$GIT_DIR</code> equal to <code>$GIT_COMMON_DIR/worktrees/<id>/</code>. The settings in the <code>config.worktree</code> file will override settings from any other config files.</p> <p>When enabling <code>extensions.worktreeConfig</code>, you must be careful to move certain values from the common config file to the main working tree’s <code>config.worktree</code> file, if present:</p> <div class="ulist"> <ul> <li> <p><code>core.worktree</code> must be moved from <code>$GIT_COMMON_DIR/config</code> to <code>$GIT_COMMON_DIR/config.worktree</code>.</p> </li> <li> <p>If <code>core.bare</code> is true, then it must be moved from <code>$GIT_COMMON_DIR/config</code> to <code>$GIT_COMMON_DIR/config.worktree</code>.</p> <p>It may also be beneficial to adjust the locations of <code>core.sparseCheckout</code> and <code>core.sparseCheckoutCone</code> depending on your desire for customizable sparse-checkout settings for each worktree. By default, the <code>git +sparse-checkout</code> builtin enables <code>extensions.worktreeConfig</code>, assigns these config values on a per-worktree basis, and uses the <code>$GIT_DIR/info/sparse-checkout</code> file to specify the sparsity for each worktree independently. See <a href="git-sparse-checkout">git-sparse-checkout[1]</a> for more details.</p> <p>For historical reasons, <code>extensions.worktreeConfig</code> is respected regardless of the <code>core.repositoryFormatVersion</code> setting.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fastimportunpackLimit"> fastimport.unpackLimit </dt> <dd> <p>If the number of objects imported by <a href="git-fast-import">git-fast-import[1]</a> is below this limit, then the objects will be unpacked into loose object files. However, if the number of imported objects equals or exceeds this limit, then the pack will be stored as a pack. Storing the pack from a fast-import can make the import operation complete faster, especially on slow filesystems. If not set, the value of <code>transfer.unpackLimit</code> is used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-feature"> feature.* </dt> <dd> <p>The config settings that start with <code>feature.</code> modify the defaults of a group of other config settings. These groups are created by the Git developer community as recommended defaults and are subject to change. In particular, new config options may be added with different defaults.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-featureexperimental"> feature.experimental </dt> <dd> <p>Enable config options that are new to Git, and are being considered for future defaults. Config settings included here may be added or removed with each release, including minor version updates. These settings may have unintended interactions since they are so new. Please enable this setting if you are interested in providing feedback on experimental features. The new default values are:</p> <div class="ulist"> <ul> <li> <p><code>fetch.negotiationAlgorithm=skipping</code> may improve fetch negotiation times by skipping more commits at a time, reducing the number of round trips.</p> </li> <li> <p><code>pack.useBitmapBoundaryTraversal=true</code> may improve bitmap traversal times by walking fewer objects.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-featuremanyFiles"> feature.manyFiles </dt> <dd> <p>Enable config options that optimize for repos with many files in the working directory. With many files, commands such as <code>git status</code> and <code>git checkout</code> may be slow and these new defaults improve performance:</p> <div class="ulist"> <ul> <li> <p><code>index.skipHash=true</code> speeds up index writes by not computing a trailing checksum. Note that this will cause Git versions earlier than 2.13.0 to refuse to parse the index and Git versions earlier than 2.40.0 will report a corrupted index during <code>git fsck</code>.</p> </li> <li> <p><code>index.version=4</code> enables path-prefix compression in the index.</p> </li> <li> <p><code>core.untrackedCache=true</code> enables the untracked cache. This setting assumes that mtime is working on your machine.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fetchrecurseSubmodules"> fetch.recurseSubmodules </dt> <dd> <p>This option controls whether <code>git fetch</code> (and the underlying fetch in <code>git pull</code>) will recursively fetch into populated submodules. This option can be set either to a boolean value or to <code>on-demand</code>. Setting it to a boolean changes the behavior of fetch and pull to recurse unconditionally into submodules when set to true or to not recurse at all when set to false. When set to <code>on-demand</code>, fetch and pull will only recurse into a populated submodule when its superproject retrieves a commit that updates the submodule’s reference. Defaults to <code>on-demand</code>, or to the value of <code>submodule.recurse</code> if set.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fetchfsckObjects"> fetch.fsckObjects </dt> <dd> <p>If it is set to true, git-fetch-pack will check all fetched objects. See <code>transfer.fsckObjects</code> for what’s checked. Defaults to false. If not set, the value of <code>transfer.fsckObjects</code> is used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fetchfsckltmsg-idgt"> fetch.fsck.<msg-id> </dt> <dd> <p>Acts like <code>fsck.<msg-id></code>, but is used by <a href="git-fetch-pack">git-fetch-pack[1]</a> instead of <a href="git-fsck">git-fsck[1]</a>. See the <code>fsck.<msg-id></code> documentation for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fetchfsckskipList"> fetch.fsck.skipList </dt> <dd> <p>Acts like <code>fsck.skipList</code>, but is used by <a href="git-fetch-pack">git-fetch-pack[1]</a> instead of <a href="git-fsck">git-fsck[1]</a>. See the <code>fsck.skipList</code> documentation for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fetchunpackLimit"> fetch.unpackLimit </dt> <dd> <p>If the number of objects fetched over the Git native transfer is below this limit, then the objects will be unpacked into loose object files. However if the number of received objects equals or exceeds this limit then the received pack will be stored as a pack, after adding any missing delta bases. Storing the pack from a push can make the push operation complete faster, especially on slow filesystems. If not set, the value of <code>transfer.unpackLimit</code> is used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fetchprune"> fetch.prune </dt> <dd> <p>If true, fetch will automatically behave as if the <code>--prune</code> option was given on the command line. See also <code>remote.<name>.prune</code> and the PRUNING section of <a href="git-fetch">git-fetch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fetchpruneTags"> fetch.pruneTags </dt> <dd> <p>If true, fetch will automatically behave as if the <code>refs/tags/*:refs/tags/*</code> refspec was provided when pruning, if not set already. This allows for setting both this option and <code>fetch.prune</code> to maintain a 1=1 mapping to upstream refs. See also <code>remote.<name>.pruneTags</code> and the PRUNING section of <a href="git-fetch">git-fetch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fetchoutput"> fetch.output </dt> <dd> <p>Control how ref update status is printed. Valid values are <code>full</code> and <code>compact</code>. Default value is <code>full</code>. See the OUTPUT section in <a href="git-fetch">git-fetch[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fetchnegotiationAlgorithm"> fetch.negotiationAlgorithm </dt> <dd> <p>Control how information about the commits in the local repository is sent when negotiating the contents of the packfile to be sent by the server. Set to "consecutive" to use an algorithm that walks over consecutive commits checking each one. Set to "skipping" to use an algorithm that skips commits in an effort to converge faster, but may result in a larger-than-necessary packfile; or set to "noop" to not send any information at all, which will almost certainly result in a larger-than-necessary packfile, but will skip the negotiation step. Set to "default" to override settings made previously and use the default behaviour. The default is normally "consecutive", but if <code>feature.experimental</code> is true, then the default is "skipping". Unknown values will cause <code>git fetch</code> to error out.</p> <p>See also the <code>--negotiate-only</code> and <code>--negotiation-tip</code> options to <a href="git-fetch">git-fetch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fetchshowForcedUpdates"> fetch.showForcedUpdates </dt> <dd> <p>Set to false to enable <code>--no-show-forced-updates</code> in <a href="git-fetch">git-fetch[1]</a> and <a href="git-pull">git-pull[1]</a> commands. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fetchparallel"> fetch.parallel </dt> <dd> <p>Specifies the maximal number of fetch operations to be run in parallel at a time (submodules, or remotes when the <code>--multiple</code> option of <a href="git-fetch">git-fetch[1]</a> is in effect).</p> <p>A value of 0 will give some reasonable default. If unset, it defaults to 1.</p> <p>For submodules, this setting can be overridden using the <code>submodule.fetchJobs</code> config setting.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fetchwriteCommitGraph"> fetch.writeCommitGraph </dt> <dd> <p>Set to true to write a commit-graph after every <code>git fetch</code> command that downloads a pack-file from a remote. Using the <code>--split</code> option, most executions will create a very small commit-graph file on top of the existing commit-graph file(s). Occasionally, these files will merge and the write may take longer. Having an updated commit-graph file helps performance of many Git commands, including <code>git merge-base</code>, <code>git push -f</code>, and <code>git log --graph</code>. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fetchbundleURI"> fetch.bundleURI </dt> <dd> <p>This value stores a URI for downloading Git object data from a bundle URI before performing an incremental fetch from the origin Git server. This is similar to how the <code>--bundle-uri</code> option behaves in <a href="git-clone">git-clone[1]</a>. <code>git clone --bundle-uri</code> will set the <code>fetch.bundleURI</code> value if the supplied bundle URI contains a bundle list that is organized for incremental fetches.</p> <p>If you modify this value and your repository has a <code>fetch.bundleCreationToken</code> value, then remove that <code>fetch.bundleCreationToken</code> value before fetching from the new bundle URI.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fetchbundleCreationToken"> fetch.bundleCreationToken </dt> <dd> <p>When using <code>fetch.bundleURI</code> to fetch incrementally from a bundle list that uses the "creationToken" heuristic, this config value stores the maximum <code>creationToken</code> value of the downloaded bundles. This value is used to prevent downloading bundles in the future if the advertised <code>creationToken</code> is not strictly larger than this value.</p> <p>The creation token values are chosen by the provider serving the specific bundle URI. If you modify the URI at <code>fetch.bundleURI</code>, then be sure to remove the value for the <code>fetch.bundleCreationToken</code> value before fetching.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatattach"> format.attach </dt> <dd> <p>Enable multipart/mixed attachments as the default for <code>format-patch</code>. The value can also be a double quoted string which will enable attachments as the default and set the value as the boundary. See the --attach option in <a href="git-format-patch">git-format-patch[1]</a>. To countermand an earlier value, set it to an empty string.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatfrom"> format.from </dt> <dd> <p>Provides the default value for the <code>--from</code> option to format-patch. Accepts a boolean value, or a name and email address. If false, format-patch defaults to <code>--no-from</code>, using commit authors directly in the "From:" field of patch mails. If true, format-patch defaults to <code>--from</code>, using your committer identity in the "From:" field of patch mails and including a "From:" field in the body of the patch mail if different. If set to a non-boolean value, format-patch uses that value instead of your committer identity. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatforceInBodyFrom"> format.forceInBodyFrom </dt> <dd> <p>Provides the default value for the <code>--[no-]force-in-body-from</code> option to format-patch. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatnumbered"> format.numbered </dt> <dd> <p>A boolean which can enable or disable sequence numbers in patch subjects. It defaults to "auto" which enables it only if there is more than one patch. It can be enabled or disabled for all messages by setting it to "true" or "false". See --numbered option in <a href="git-format-patch">git-format-patch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatheaders"> format.headers </dt> <dd> <p>Additional email headers to include in a patch to be submitted by mail. See <a href="git-format-patch">git-format-patch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatto"> format.to </dt> <dt class="hdlist1" id="Documentation/git-config.txt-formatcc"> format.cc </dt> <dd> <p>Additional recipients to include in a patch to be submitted by mail. See the --to and --cc options in <a href="git-format-patch">git-format-patch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatsubjectPrefix"> format.subjectPrefix </dt> <dd> <p>The default for format-patch is to output files with the <code>[PATCH]</code> subject prefix. Use this variable to change that prefix.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatcoverFromDescription"> format.coverFromDescription </dt> <dd> <p>The default mode for format-patch to determine which parts of the cover letter will be populated using the branch’s description. See the <code>--cover-from-description</code> option in <a href="git-format-patch">git-format-patch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatsignature"> format.signature </dt> <dd> <p>The default for format-patch is to output a signature containing the Git version number. Use this variable to change that default. Set this variable to the empty string ("") to suppress signature generation.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatsignatureFile"> format.signatureFile </dt> <dd> <p>Works just like format.signature except the contents of the file specified by this variable will be used as the signature.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatsuffix"> format.suffix </dt> <dd> <p>The default for format-patch is to output files with the suffix <code>.patch</code>. Use this variable to change that suffix (make sure to include the dot if you want it).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatencodeEmailHeaders"> format.encodeEmailHeaders </dt> <dd> <p>Encode email headers that have non-ASCII characters with "Q-encoding" (described in RFC 2047) for email transmission. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatpretty"> format.pretty </dt> <dd> <p>The default pretty format for log/show/whatchanged command. See <a href="git-log">git-log[1]</a>, <a href="git-show">git-show[1]</a>, <a href="git-whatchanged">git-whatchanged[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatthread"> format.thread </dt> <dd> <p>The default threading style for <code>git format-patch</code>. Can be a boolean value, or <code>shallow</code> or <code>deep</code>. <code>shallow</code> threading makes every mail a reply to the head of the series, where the head is chosen from the cover letter, the <code>--in-reply-to</code>, and the first patch mail, in this order. <code>deep</code> threading makes every mail a reply to the previous one. A true boolean value is the same as <code>shallow</code>, and a false value disables threading.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatsignOff"> format.signOff </dt> <dd> <p>A boolean value which lets you enable the <code>-s/--signoff</code> option of format-patch by default. <strong>Note:</strong> Adding the <code>Signed-off-by</code> trailer to a patch should be a conscious act and means that you certify you have the rights to submit this work under the same open source license. Please see the <code>SubmittingPatches</code> document for further discussion.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatcoverLetter"> format.coverLetter </dt> <dd> <p>A boolean that controls whether to generate a cover-letter when format-patch is invoked, but in addition can be set to "auto", to generate a cover-letter only when there’s more than one patch. Default is false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatoutputDirectory"> format.outputDirectory </dt> <dd> <p>Set a custom directory to store the resulting files instead of the current working directory. All directory components will be created.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatfilenameMaxLength"> format.filenameMaxLength </dt> <dd> <p>The maximum length of the output filenames generated by the <code>format-patch</code> command; defaults to 64. Can be overridden by the <code>--filename-max-length=<n></code> command line option.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatuseAutoBase"> format.useAutoBase </dt> <dd> <p>A boolean value which lets you enable the <code>--base=auto</code> option of format-patch by default. Can also be set to "whenAble" to allow enabling <code>--base=auto</code> if a suitable base is available, but to skip adding base info otherwise without the format dying.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatnotes"> format.notes </dt> <dd> <p>Provides the default value for the <code>--notes</code> option to format-patch. Accepts a boolean value, or a ref which specifies where to get notes. If false, format-patch defaults to <code>--no-notes</code>. If true, format-patch defaults to <code>--notes</code>. If set to a non-boolean value, format-patch defaults to <code>--notes=<ref></code>, where <code>ref</code> is the non-boolean value. Defaults to false.</p> <p>If one wishes to use the ref <code>refs/notes/true</code>, please use that literal instead.</p> <p>This configuration can be specified multiple times in order to allow multiple notes refs to be included. In that case, it will behave similarly to multiple <code>--[no-]notes[=]</code> options passed in. That is, a value of <code>true</code> will show the default notes, a value of <code><ref></code> will also show notes from that notes ref and a value of <code>false</code> will negate previous configurations and not show notes.</p> <p>For example,</p> <div class="listingblock"> <div class="content"> <pre>[format] + notes = true + notes = foo + notes = false + notes = bar</pre> </div> </div> <p>will only show notes from <code>refs/notes/bar</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatmboxrd"> format.mboxrd </dt> <dd> <p>A boolean value which enables the robust "mboxrd" format when <code>--stdout</code> is in use to escape "^>+From " lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-formatnoprefix"> format.noprefix </dt> <dd> <p>If set, do not show any source or destination prefix in patches. This is equivalent to the <code>diff.noprefix</code> option used by <code>git +diff</code> (but which is not respected by <code>format-patch</code>). Note that by setting this, the receiver of any patches you generate will have to apply them using the <code>-p0</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-filterltdrivergtclean"> filter.<driver>.clean </dt> <dd> <p>The command which is used to convert the content of a worktree file to a blob upon checkin. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-filterltdrivergtsmudge"> filter.<driver>.smudge </dt> <dd> <p>The command which is used to convert the content of a blob object to a worktree file upon checkout. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fsckltmsg-idgt"> fsck.<msg-id> </dt> <dd> <p>During fsck git may find issues with legacy data which wouldn’t be generated by current versions of git, and which wouldn’t be sent over the wire if <code>transfer.fsckObjects</code> was set. This feature is intended to support working with legacy repositories containing such data.</p> <p>Setting <code>fsck.<msg-id></code> will be picked up by <a href="git-fsck">git-fsck[1]</a>, but to accept pushes of such data set <code>receive.fsck.<msg-id></code> instead, or to clone or fetch it set <code>fetch.fsck.<msg-id></code>.</p> <p>The rest of the documentation discusses <code>fsck.*</code> for brevity, but the same applies for the corresponding <code>receive.fsck.*</code> and <code>fetch.fsck.*</code>. variables.</p> <p>Unlike variables like <code>color.ui</code> and <code>core.editor</code>, the <code>receive.fsck.<msg-id></code> and <code>fetch.fsck.<msg-id></code> variables will not fall back on the <code>fsck.<msg-id></code> configuration if they aren’t set. To uniformly configure the same fsck settings in different circumstances, all three of them must be set to the same values.</p> <p>When <code>fsck.<msg-id></code> is set, errors can be switched to warnings and vice versa by configuring the <code>fsck.<msg-id></code> setting where the <code><msg-id></code> is the fsck message ID and the value is one of <code>error</code>, <code>warn</code> or <code>ignore</code>. For convenience, fsck prefixes the error/warning with the message ID, e.g. "missingEmail: invalid author/committer line - missing email" means that setting <code>fsck.missingEmail = ignore</code> will hide that issue.</p> <p>In general, it is better to enumerate existing objects with problems with <code>fsck.skipList</code>, instead of listing the kind of breakages these problematic objects share to be ignored, as doing the latter will allow new instances of the same breakages go unnoticed.</p> <p>Setting an unknown <code>fsck.<msg-id></code> value will cause fsck to die, but doing the same for <code>receive.fsck.<msg-id></code> and <code>fetch.fsck.<msg-id></code> will only cause git to warn.</p> <p>See the <code>Fsck Messages</code> section of <a href="git-fsck">git-fsck[1]</a> for supported values of <code><msg-id></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fsckskipList"> fsck.skipList </dt> <dd> <p>The path to a list of object names (i.e. one unabbreviated SHA-1 per line) that are known to be broken in a non-fatal way and should be ignored. On versions of Git 2.20 and later, comments (<code>#</code>), empty lines, and any leading and trailing whitespace are ignored. Everything but a SHA-1 per line will error out on older versions.</p> <p>This feature is useful when an established project should be accepted despite early commits containing errors that can be safely ignored, such as invalid committer email addresses. Note: corrupt objects cannot be skipped with this setting.</p> <p>Like <code>fsck.<msg-id></code> this variable has corresponding <code>receive.fsck.skipList</code> and <code>fetch.fsck.skipList</code> variants.</p> <p>Unlike variables like <code>color.ui</code> and <code>core.editor</code> the <code>receive.fsck.skipList</code> and <code>fetch.fsck.skipList</code> variables will not fall back on the <code>fsck.skipList</code> configuration if they aren’t set. To uniformly configure the same fsck settings in different circumstances, all three of them must be set to the same values.</p> <p>Older versions of Git (before 2.20) documented that the object names list should be sorted. This was never a requirement; the object names could appear in any order, but when reading the list we tracked whether the list was sorted for the purposes of an internal binary search implementation, which could save itself some work with an already sorted list. Unless you had a humongous list there was no reason to go out of your way to pre-sort the list. After Git version 2.20 a hash implementation is used instead, so there’s now no reason to pre-sort the list.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fsmonitorallowRemote"> fsmonitor.allowRemote </dt> <dd> <p>By default, the fsmonitor daemon refuses to work with network-mounted repositories. Setting <code>fsmonitor.allowRemote</code> to <code>true</code> overrides this behavior. Only respected when <code>core.fsmonitor</code> is set to <code>true</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-fsmonitorsocketDir"> fsmonitor.socketDir </dt> <dd> <p>This Mac OS-specific option, if set, specifies the directory in which to create the Unix domain socket used for communication between the fsmonitor daemon and various Git commands. The directory must reside on a native Mac OS filesystem. Only respected when <code>core.fsmonitor</code> is set to <code>true</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcaggressiveDepth"> gc.aggressiveDepth </dt> <dd> <p>The depth parameter used in the delta compression algorithm used by <code>git gc --aggressive</code>. This defaults to 50, which is the default for the <code>--depth</code> option when <code>--aggressive</code> isn’t in use.</p> <p>See the documentation for the <code>--depth</code> option in <a href="git-repack">git-repack[1]</a> for more details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcaggressiveWindow"> gc.aggressiveWindow </dt> <dd> <p>The window size parameter used in the delta compression algorithm used by <code>git gc --aggressive</code>. This defaults to 250, which is a much more aggressive window size than the default <code>--window</code> of 10.</p> <p>See the documentation for the <code>--window</code> option in <a href="git-repack">git-repack[1]</a> for more details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcauto"> gc.auto </dt> <dd> <p>When there are approximately more than this many loose objects in the repository, <code>git gc --auto</code> will pack them. Some Porcelain commands use this command to perform a light-weight garbage collection from time to time. The default value is 6700.</p> <p>Setting this to 0 disables not only automatic packing based on the number of loose objects, but also any other heuristic <code>git gc --auto</code> will otherwise use to determine if there’s work to do, such as <code>gc.autoPackLimit</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcautoPackLimit"> gc.autoPackLimit </dt> <dd> <p>When there are more than this many packs that are not marked with <code>*.keep</code> file in the repository, <code>git gc +--auto</code> consolidates them into one larger pack. The default value is 50. Setting this to 0 disables it. Setting <code>gc.auto</code> to 0 will also disable this.</p> <p>See the <code>gc.bigPackThreshold</code> configuration variable below. When in use, it’ll affect how the auto pack limit works.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcautoDetach"> gc.autoDetach </dt> <dd> <p>Make <code>git gc --auto</code> return immediately and run in the background if the system supports it. Default is true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcbigPackThreshold"> gc.bigPackThreshold </dt> <dd> <p>If non-zero, all non-cruft packs larger than this limit are kept when <code>git gc</code> is run. This is very similar to <code>--keep-largest-pack</code> except that all non-cruft packs that meet the threshold are kept, not just the largest pack. Defaults to zero. Common unit suffixes of <code>k</code>, <code>m</code>, or <code>g</code> are supported.</p> <p>Note that if the number of kept packs is more than gc.autoPackLimit, this configuration variable is ignored, all packs except the base pack will be repacked. After this the number of packs should go below gc.autoPackLimit and gc.bigPackThreshold should be respected again.</p> <p>If the amount of memory estimated for <code>git repack</code> to run smoothly is not available and <code>gc.bigPackThreshold</code> is not set, the largest pack will also be excluded (this is the equivalent of running <code>git gc</code> with <code>--keep-largest-pack</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcwriteCommitGraph"> gc.writeCommitGraph </dt> <dd> <p>If true, then gc will rewrite the commit-graph file when <a href="git-gc">git-gc[1]</a> is run. When using <code>git gc --auto</code> the commit-graph will be updated if housekeeping is required. Default is true. See <a href="git-commit-graph">git-commit-graph[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gclogExpiry"> gc.logExpiry </dt> <dd> <p>If the file gc.log exists, then <code>git gc --auto</code> will print its content and exit with status zero instead of running unless that file is more than <code>gc.logExpiry</code> old. Default is "1.day". See <code>gc.pruneExpire</code> for more ways to specify its value.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcpackRefs"> gc.packRefs </dt> <dd> <p>Running <code>git pack-refs</code> in a repository renders it unclonable by Git versions prior to 1.5.1.2 over dumb transports such as HTTP. This variable determines whether <code>git gc</code> runs <code>git pack-refs</code>. This can be set to <code>notbare</code> to enable it within all non-bare repos or it can be set to a boolean value. The default is <code>true</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gccruftPacks"> gc.cruftPacks </dt> <dd> <p>Store unreachable objects in a cruft pack (see <a href="git-repack">git-repack[1]</a>) instead of as loose objects. The default is <code>true</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcmaxCruftSize"> gc.maxCruftSize </dt> <dd> <p>Limit the size of new cruft packs when repacking. When specified in addition to <code>--max-cruft-size</code>, the command line option takes priority. See the <code>--max-cruft-size</code> option of <a href="git-repack">git-repack[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcpruneExpire"> gc.pruneExpire </dt> <dd> <p>When <code>git gc</code> is run, it will call <code>prune --expire 2.weeks.ago</code> (and <code>repack --cruft --cruft-expiration 2.weeks.ago</code> if using cruft packs via <code>gc.cruftPacks</code> or <code>--cruft</code>). Override the grace period with this config variable. The value "now" may be used to disable this grace period and always prune unreachable objects immediately, or "never" may be used to suppress pruning. This feature helps prevent corruption when <code>git gc</code> runs concurrently with another process writing to the repository; see the "NOTES" section of <a href="git-gc">git-gc[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcworktreePruneExpire"> gc.worktreePruneExpire </dt> <dd> <p>When <code>git gc</code> is run, it calls <code>git worktree prune --expire 3.months.ago</code>. This config variable can be used to set a different grace period. The value "now" may be used to disable the grace period and prune <code>$GIT_DIR/worktrees</code> immediately, or "never" may be used to suppress pruning.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcreflogExpire"> gc.reflogExpire </dt> <dt class="hdlist1" id="Documentation/git-config.txt-gcltpatterngtreflogExpire"> gc.<pattern>.reflogExpire </dt> <dd> <p><code>git reflog expire</code> removes reflog entries older than this time; defaults to 90 days. The value "now" expires all entries immediately, and "never" suppresses expiration altogether. With "<pattern>" (e.g. "refs/stash") in the middle the setting applies only to the refs that match the <pattern>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcreflogExpireUnreachable"> gc.reflogExpireUnreachable </dt> <dt class="hdlist1" id="Documentation/git-config.txt-gcltpatterngtreflogExpireUnreachable"> gc.<pattern>.reflogExpireUnreachable </dt> <dd> <p><code>git reflog expire</code> removes reflog entries older than this time and are not reachable from the current tip; defaults to 30 days. The value "now" expires all entries immediately, and "never" suppresses expiration altogether. With "<pattern>" (e.g. "refs/stash") in the middle, the setting applies only to the refs that match the <pattern>.</p> <p>These types of entries are generally created as a result of using <code>git +commit --amend</code> or <code>git rebase</code> and are the commits prior to the amend or rebase occurring. Since these changes are not part of the current project most users will want to expire them sooner, which is why the default is more aggressive than <code>gc.reflogExpire</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcrecentObjectsHook"> gc.recentObjectsHook </dt> <dd> <p>When considering whether or not to remove an object (either when generating a cruft pack or storing unreachable objects as loose), use the shell to execute the specified command(s). Interpret their output as object IDs which Git will consider as "recent", regardless of their age. By treating their mtimes as "now", any objects (and their descendants) mentioned in the output will be kept regardless of their true age.</p> <p>Output must contain exactly one hex object ID per line, and nothing else. Objects which cannot be found in the repository are ignored. Multiple hooks are supported, but all must exit successfully, else the operation (either generating a cruft pack or unpacking unreachable objects) will be halted.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcrepackFilter"> gc.repackFilter </dt> <dd> <p>When repacking, use the specified filter to move certain objects into a separate packfile. See the <code>--filter=<filter-spec></code> option of <a href="git-repack">git-repack[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcrepackFilterTo"> gc.repackFilterTo </dt> <dd> <p>When repacking and using a filter, see <code>gc.repackFilter</code>, the specified location will be used to create the packfile containing the filtered out objects. <strong>WARNING:</strong> The specified location should be accessible, using for example the Git alternates mechanism, otherwise the repo could be considered corrupt by Git as it migh not be able to access the objects in that packfile. See the <code>--filter-to=<dir></code> option of <a href="git-repack">git-repack[1]</a> and the <code>objects/info/alternates</code> section of <a href="gitrepository-layout">gitrepository-layout[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcrerereResolved"> gc.rerereResolved </dt> <dd> <p>Records of conflicted merge you resolved earlier are kept for this many days when <code>git rerere gc</code> is run. You can also use more human-readable "1.month.ago", etc. The default is 60 days. See <a href="git-rerere">git-rerere[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gcrerereUnresolved"> gc.rerereUnresolved </dt> <dd> <p>Records of conflicted merge you have not resolved are kept for this many days when <code>git rerere gc</code> is run. You can also use more human-readable "1.month.ago", etc. The default is 15 days. See <a href="git-rerere">git-rerere[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gitcvscommitMsgAnnotation"> gitcvs.commitMsgAnnotation </dt> <dd> <p>Append this string to each commit message. Set to empty string to disable this feature. Defaults to "via git-CVS emulator".</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gitcvsenabled"> gitcvs.enabled </dt> <dd> <p>Whether the CVS server interface is enabled for this repository. See <a href="git-cvsserver">git-cvsserver[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gitcvslogFile"> gitcvs.logFile </dt> <dd> <p>Path to a log file where the CVS server interface well… logs various stuff. See <a href="git-cvsserver">git-cvsserver[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gitcvsusecrlfattr"> gitcvs.usecrlfattr </dt> <dd> <p>If true, the server will look up the end-of-line conversion attributes for files to determine the <code>-k</code> modes to use. If the attributes force Git to treat a file as text, the <code>-k</code> mode will be left blank so CVS clients will treat it as text. If they suppress text conversion, the file will be set with <code>-kb</code> mode, which suppresses any newline munging the client might otherwise do. If the attributes do not allow the file type to be determined, then <code>gitcvs.allBinary</code> is used. See <a href="gitattributes">gitattributes[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gitcvsallBinary"> gitcvs.allBinary </dt> <dd> <p>This is used if <code>gitcvs.usecrlfattr</code> does not resolve the correct <code>-kb</code> mode to use. If true, all unresolved files are sent to the client in mode <code>-kb</code>. This causes the client to treat them as binary files, which suppresses any newline munging it otherwise might do. Alternatively, if it is set to "guess", then the contents of the file are examined to decide if it is binary, similar to <code>core.autocrlf</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gitcvsdbName"> gitcvs.dbName </dt> <dd> <p>Database used by git-cvsserver to cache revision information derived from the Git repository. The exact meaning depends on the used database driver, for SQLite (which is the default driver) this is a filename. Supports variable substitution (see <a href="git-cvsserver">git-cvsserver[1]</a> for details). May not contain semicolons (<code>;</code>). Default: <code>%Ggitcvs.%m.sqlite</code></p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gitcvsdbDriver"> gitcvs.dbDriver </dt> <dd> <p>Used Perl DBI driver. You can specify any available driver for this here, but it might not work. git-cvsserver is tested with <code>DBD::SQLite</code>, reported to work with <code>DBD::Pg</code>, and reported <strong>not</strong> to work with <code>DBD::mysql</code>. Experimental feature. May not contain double colons (<code>:</code>). Default: <code>SQLite</code>. See <a href="git-cvsserver">git-cvsserver[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gitcvsdbUsergitcvsdbPass"> gitcvs.dbUser, gitcvs.dbPass </dt> <dd> <p>Database user and password. Only useful if setting <code>gitcvs.dbDriver</code>, since SQLite has no concept of database users and/or passwords. <code>gitcvs.dbUser</code> supports variable substitution (see <a href="git-cvsserver">git-cvsserver[1]</a> for details).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gitcvsdbTableNamePrefix"> gitcvs.dbTableNamePrefix </dt> <dd> <p>Database table name prefix. Prepended to the names of any database tables used, allowing a single database to be used for several repositories. Supports variable substitution (see <a href="git-cvsserver">git-cvsserver[1]</a> for details). Any non-alphabetic characters will be replaced with underscores.</p> </dd> </dl> </div> <p>All gitcvs variables except for <code>gitcvs.usecrlfattr</code> and <code>gitcvs.allBinary</code> can also be specified as <code>gitcvs.<access_method>.<varname></code> (where <code>access_method</code> is one of "ext" and "pserver") to make them apply only for the given access method.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-gitwebcategory"> gitweb.category </dt> <dt class="hdlist1" id="Documentation/git-config.txt-gitwebdescription"> gitweb.description </dt> <dt class="hdlist1" id="Documentation/git-config.txt-gitwebowner"> gitweb.owner </dt> <dt class="hdlist1" id="Documentation/git-config.txt-gitweburl"> gitweb.url </dt> <dd> <p>See <a href="gitweb">gitweb[1]</a> for description.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gitwebavatar"> gitweb.avatar </dt> <dt class="hdlist1" id="Documentation/git-config.txt-gitwebblame"> gitweb.blame </dt> <dt class="hdlist1" id="Documentation/git-config.txt-gitwebgrep"> gitweb.grep </dt> <dt class="hdlist1" id="Documentation/git-config.txt-gitwebhighlight"> gitweb.highlight </dt> <dt class="hdlist1" id="Documentation/git-config.txt-gitwebpatches"> gitweb.patches </dt> <dt class="hdlist1" id="Documentation/git-config.txt-gitwebpickaxe"> gitweb.pickaxe </dt> <dt class="hdlist1" id="Documentation/git-config.txt-gitwebremoteheads"> gitweb.remote_heads </dt> <dt class="hdlist1" id="Documentation/git-config.txt-gitwebshowSizes"> gitweb.showSizes </dt> <dt class="hdlist1" id="Documentation/git-config.txt-gitwebsnapshot"> gitweb.snapshot </dt> <dd> <p>See <a href="gitweb.conf">gitweb.conf[5]</a> for description.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-greplineNumber"> grep.lineNumber </dt> <dd> <p>If set to true, enable <code>-n</code> option by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-grepcolumn"> grep.column </dt> <dd> <p>If set to true, enable the <code>--column</code> option by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-greppatternType"> grep.patternType </dt> <dd> <p>Set the default matching behavior. Using a value of <code>basic</code>, <code>extended</code>, <code>fixed</code>, or <code>perl</code> will enable the <code>--basic-regexp</code>, <code>--extended-regexp</code>, <code>--fixed-strings</code>, or <code>--perl-regexp</code> option accordingly, while the value <code>default</code> will use the <code>grep.extendedRegexp</code> option to choose between <code>basic</code> and <code>extended</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-grepextendedRegexp"> grep.extendedRegexp </dt> <dd> <p>If set to true, enable <code>--extended-regexp</code> option by default. This option is ignored when the <code>grep.patternType</code> option is set to a value other than <code>default</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-grepthreads"> grep.threads </dt> <dd> <p>Number of grep worker threads to use. If unset (or set to 0), Git will use as many threads as the number of logical cores available.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-grepfullName"> grep.fullName </dt> <dd> <p>If set to true, enable <code>--full-name</code> option by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-grepfallbackToNoIndex"> grep.fallbackToNoIndex </dt> <dd> <p>If set to true, fall back to git grep --no-index if git grep is executed outside of a git repository. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gpgprogram"> gpg.program </dt> <dd> <p>Use this custom program instead of "<code>gpg</code>" found on <code>$PATH</code> when making or verifying a PGP signature. The program must support the same command-line interface as GPG, namely, to verify a detached signature, "<code>gpg --verify $signature - <$file</code>" is run, and the program is expected to signal a good signature by exiting with code 0. To generate an ASCII-armored detached signature, the standard input of "<code>gpg -bsau $key</code>" is fed with the contents to be signed, and the program is expected to send the result to its standard output.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gpgformat"> gpg.format </dt> <dd> <p>Specifies which key format to use when signing with <code>--gpg-sign</code>. Default is "openpgp". Other possible values are "x509", "ssh".</p> <p>See <a href="gitformat-signature">gitformat-signature[5]</a> for the signature format, which differs based on the selected <code>gpg.format</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gpgltformatgtprogram"> gpg.<format>.program </dt> <dd> <p>Use this to customize the program used for the signing format you chose. (see <code>gpg.program</code> and <code>gpg.format</code>) <code>gpg.program</code> can still be used as a legacy synonym for <code>gpg.openpgp.program</code>. The default value for <code>gpg.x509.program</code> is "gpgsm" and <code>gpg.ssh.program</code> is "ssh-keygen".</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gpgminTrustLevel"> gpg.minTrustLevel </dt> <dd> <p>Specifies a minimum trust level for signature verification. If this option is unset, then signature verification for merge operations requires a key with at least <code>marginal</code> trust. Other operations that perform signature verification require a key with at least <code>undefined</code> trust. Setting this option overrides the required trust-level for all operations. Supported values, in increasing order of significance:</p> <div class="ulist"> <ul> <li> <p><code>undefined</code></p> </li> <li> <p><code>never</code></p> </li> <li> <p><code>marginal</code></p> </li> <li> <p><code>fully</code></p> </li> <li> <p><code>ultimate</code></p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gpgsshdefaultKeyCommand"> gpg.ssh.defaultKeyCommand </dt> <dd> <p>This command will be run when user.signingkey is not set and a ssh signature is requested. On successful exit a valid ssh public key prefixed with <code>key::</code> is expected in the first line of its output. This allows for a script doing a dynamic lookup of the correct public key when it is impractical to statically configure <code>user.signingKey</code>. For example when keys or SSH Certificates are rotated frequently or selection of the right key depends on external factors unknown to git.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gpgsshallowedSignersFile"> gpg.ssh.allowedSignersFile </dt> <dd> <p>A file containing ssh public keys which you are willing to trust. The file consists of one or more lines of principals followed by an ssh public key. e.g.: <code>user1@example.com,user2@example.com ssh-rsa AAAAX1...</code> See ssh-keygen(1) "ALLOWED SIGNERS" for details. The principal is only used to identify the key and is available when verifying a signature.</p> <p>SSH has no concept of trust levels like gpg does. To be able to differentiate between valid signatures and trusted signatures the trust level of a signature verification is set to <code>fully</code> when the public key is present in the allowedSignersFile. Otherwise the trust level is <code>undefined</code> and git verify-commit/tag will fail.</p> <p>This file can be set to a location outside of the repository and every developer maintains their own trust store. A central repository server could generate this file automatically from ssh keys with push access to verify the code against. In a corporate setting this file is probably generated at a global location from automation that already handles developer ssh keys.</p> <p>A repository that only allows signed commits can store the file in the repository itself using a path relative to the top-level of the working tree. This way only committers with an already valid key can add or change keys in the keyring.</p> <p>Since OpensSSH 8.8 this file allows specifying a key lifetime using valid-after & valid-before options. Git will mark signatures as valid if the signing key was valid at the time of the signature’s creation. This allows users to change a signing key without invalidating all previously made signatures.</p> <p>Using a SSH CA key with the cert-authority option (see ssh-keygen(1) "CERTIFICATES") is also valid.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-gpgsshrevocationFile"> gpg.ssh.revocationFile </dt> <dd> <p>Either a SSH KRL or a list of revoked public keys (without the principal prefix). See ssh-keygen(1) for details. If a public key is found in this file then it will always be treated as having trust level "never" and signatures will show as invalid.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guicommitMsgWidth"> gui.commitMsgWidth </dt> <dd> <p>Defines how wide the commit message window is in the <a href="git-gui">git-gui[1]</a>. "75" is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guidiffContext"> gui.diffContext </dt> <dd> <p>Specifies how many context lines should be used in calls to diff made by the <a href="git-gui">git-gui[1]</a>. The default is "5".</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guidisplayUntracked"> gui.displayUntracked </dt> <dd> <p>Determines if <a href="git-gui">git-gui[1]</a> shows untracked files in the file list. The default is "true".</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guiencoding"> gui.encoding </dt> <dd> <p>Specifies the default character encoding to use for displaying of file contents in <a href="git-gui">git-gui[1]</a> and <a href="gitk">gitk[1]</a>. It can be overridden by setting the <code>encoding</code> attribute for relevant files (see <a href="gitattributes">gitattributes[5]</a>). If this option is not set, the tools default to the locale encoding.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guimatchTrackingBranch"> gui.matchTrackingBranch </dt> <dd> <p>Determines if new branches created with <a href="git-gui">git-gui[1]</a> should default to tracking remote branches with matching names or not. Default: "false".</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guinewBranchTemplate"> gui.newBranchTemplate </dt> <dd> <p>Is used as a suggested name when creating new branches using the <a href="git-gui">git-gui[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guipruneDuringFetch"> gui.pruneDuringFetch </dt> <dd> <p>"true" if <a href="git-gui">git-gui[1]</a> should prune remote-tracking branches when performing a fetch. The default value is "false".</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guitrustmtime"> gui.trustmtime </dt> <dd> <p>Determines if <a href="git-gui">git-gui[1]</a> should trust the file modification timestamp or not. By default the timestamps are not trusted.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guispellingDictionary"> gui.spellingDictionary </dt> <dd> <p>Specifies the dictionary used for spell checking commit messages in the <a href="git-gui">git-gui[1]</a>. When set to "none" spell checking is turned off.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guifastCopyBlame"> gui.fastCopyBlame </dt> <dd> <p>If true, <code>git gui blame</code> uses <code>-C</code> instead of <code>-C -C</code> for original location detection. It makes blame significantly faster on huge repositories at the expense of less thorough copy detection.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guicopyBlameThreshold"> gui.copyBlameThreshold </dt> <dd> <p>Specifies the threshold to use in <code>git gui blame</code> original location detection, measured in alphanumeric characters. See the <a href="git-blame">git-blame[1]</a> manual for more information on copy detection.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guiblamehistoryctx"> gui.blamehistoryctx </dt> <dd> <p>Specifies the radius of history context in days to show in <a href="gitk">gitk[1]</a> for the selected commit, when the <code>Show History +Context</code> menu item is invoked from <code>git gui blame</code>. If this variable is set to zero, the whole history is shown.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guitoolltnamegtcmd"> guitool.<name>.cmd </dt> <dd> <p>Specifies the shell command line to execute when the corresponding item of the <a href="git-gui">git-gui[1]</a> <code>Tools</code> menu is invoked. This option is mandatory for every tool. The command is executed from the root of the working directory, and in the environment it receives the name of the tool as <code>GIT_GUITOOL</code>, the name of the currently selected file as <code>FILENAME</code>, and the name of the current branch as <code>CUR_BRANCH</code> (if the head is detached, <code>CUR_BRANCH</code> is empty).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guitoolltnamegtneedsFile"> guitool.<name>.needsFile </dt> <dd> <p>Run the tool only if a diff is selected in the GUI. It guarantees that <code>FILENAME</code> is not empty.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guitoolltnamegtnoConsole"> guitool.<name>.noConsole </dt> <dd> <p>Run the command silently, without creating a window to display its output.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guitoolltnamegtnoRescan"> guitool.<name>.noRescan </dt> <dd> <p>Don’t rescan the working directory for changes after the tool finishes execution.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guitoolltnamegtconfirm"> guitool.<name>.confirm </dt> <dd> <p>Show a confirmation dialog before actually running the tool.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guitoolltnamegtargPrompt"> guitool.<name>.argPrompt </dt> <dd> <p>Request a string argument from the user, and pass it to the tool through the <code>ARGS</code> environment variable. Since requesting an argument implies confirmation, the <code>confirm</code> option has no effect if this is enabled. If the option is set to <code>true</code>, <code>yes</code>, or <code>1</code>, the dialog uses a built-in generic prompt; otherwise the exact value of the variable is used.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guitoolltnamegtrevPrompt"> guitool.<name>.revPrompt </dt> <dd> <p>Request a single valid revision from the user, and set the <code>REVISION</code> environment variable. In other aspects this option is similar to <code>argPrompt</code>, and can be used together with it.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guitoolltnamegtrevUnmerged"> guitool.<name>.revUnmerged </dt> <dd> <p>Show only unmerged branches in the <code>revPrompt</code> subdialog. This is useful for tools similar to merge or rebase, but not for things like checkout or reset.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guitoolltnamegttitle"> guitool.<name>.title </dt> <dd> <p>Specifies the title to use for the prompt dialog. The default is the tool name.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-guitoolltnamegtprompt"> guitool.<name>.prompt </dt> <dd> <p>Specifies the general prompt string to display at the top of the dialog, before subsections for <code>argPrompt</code> and <code>revPrompt</code>. The default value includes the actual command.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-helpbrowser"> help.browser </dt> <dd> <p>Specify the browser that will be used to display help in the <code>web</code> format. See <a href="git-help">git-help[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-helpformat"> help.format </dt> <dd> <p>Override the default help format used by <a href="git-help">git-help[1]</a>. Values <code>man</code>, <code>info</code>, <code>web</code> and <code>html</code> are supported. <code>man</code> is the default. <code>web</code> and <code>html</code> are the same.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-helpautoCorrect"> help.autoCorrect </dt> <dd> <p>If git detects typos and can identify exactly one valid command similar to the error, git will try to suggest the correct command or even run the suggestion automatically. Possible config values are:</p> <div class="ulist"> <ul> <li> <p>0 (default): show the suggested command.</p> </li> <li> <p>positive number: run the suggested command after specified deciseconds (0.1 sec).</p> </li> <li> <p>"immediate": run the suggested command immediately.</p> </li> <li> <p>"prompt": show the suggestion and prompt for confirmation to run the command.</p> </li> <li> <p>"never": don’t run or show any suggested command.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-helphtmlPath"> help.htmlPath </dt> <dd> <p>Specify the path where the HTML documentation resides. File system paths and URLs are supported. HTML pages will be prefixed with this path when help is displayed in the <code>web</code> format. This defaults to the documentation path of your Git installation.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpproxy"> http.proxy </dt> <dd> <p>Override the HTTP proxy, normally configured using the <code>http_proxy</code>, <code>https_proxy</code>, and <code>all_proxy</code> environment variables (see <code>curl(1)</code>). In addition to the syntax understood by curl, it is possible to specify a proxy string with a user name but no password, in which case git will attempt to acquire one in the same way it does for other credentials. See <a href="gitcredentials">gitcredentials[7]</a> for more information. The syntax thus is <code>[protocol://][user[:password]@]proxyhost[:port]</code>. This can be overridden on a per-remote basis; see remote.<name>.proxy</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpproxyAuthMethod"> http.proxyAuthMethod </dt> <dd> <p>Set the method with which to authenticate against the HTTP proxy. This only takes effect if the configured proxy string contains a user name part (i.e. is of the form <code>user@host</code> or <code>user@host:port</code>). This can be overridden on a per-remote basis; see <code>remote.<name>.proxyAuthMethod</code>. Both can be overridden by the <code>GIT_HTTP_PROXY_AUTHMETHOD</code> environment variable. Possible values are:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>anyauth</code> - Automatically pick a suitable authentication method. It is assumed that the proxy answers an unauthenticated request with a 407 status code and one or more Proxy-authenticate headers with supported authentication methods. This is the default.</p> </li> <li> <p><code>basic</code> - HTTP Basic authentication</p> </li> <li> <p><code>digest</code> - HTTP Digest authentication; this prevents the password from being transmitted to the proxy in clear text</p> </li> <li> <p><code>negotiate</code> - GSS-Negotiate authentication (compare the --negotiate option of <code>curl(1)</code>)</p> </li> <li> <p><code>ntlm</code> - NTLM authentication (compare the --ntlm option of <code>curl(1)</code>)</p> </li> </ul> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpproxySSLCert"> http.proxySSLCert </dt> <dd> <p>The pathname of a file that stores a client certificate to use to authenticate with an HTTPS proxy. Can be overridden by the <code>GIT_PROXY_SSL_CERT</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpproxySSLKey"> http.proxySSLKey </dt> <dd> <p>The pathname of a file that stores a private key to use to authenticate with an HTTPS proxy. Can be overridden by the <code>GIT_PROXY_SSL_KEY</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpproxySSLCertPasswordProtected"> http.proxySSLCertPasswordProtected </dt> <dd> <p>Enable Git’s password prompt for the proxy SSL certificate. Otherwise OpenSSL will prompt the user, possibly many times, if the certificate or private key is encrypted. Can be overridden by the <code>GIT_PROXY_SSL_CERT_PASSWORD_PROTECTED</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpproxySSLCAInfo"> http.proxySSLCAInfo </dt> <dd> <p>Pathname to the file containing the certificate bundle that should be used to verify the proxy with when using an HTTPS proxy. Can be overridden by the <code>GIT_PROXY_SSL_CAINFO</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpemptyAuth"> http.emptyAuth </dt> <dd> <p>Attempt authentication without seeking a username or password. This can be used to attempt GSS-Negotiate authentication without specifying a username in the URL, as libcurl normally requires a username for authentication.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpdelegation"> http.delegation </dt> <dd> <p>Control GSSAPI credential delegation. The delegation is disabled by default in libcurl since version 7.21.7. Set parameter to tell the server what it is allowed to delegate when it comes to user credentials. Used with GSS/kerberos. Possible values are:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>none</code> - Don’t allow any delegation.</p> </li> <li> <p><code>policy</code> - Delegates if and only if the OK-AS-DELEGATE flag is set in the Kerberos service ticket, which is a matter of realm policy.</p> </li> <li> <p><code>always</code> - Unconditionally allow the server to delegate.</p> </li> </ul> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpextraHeader"> http.extraHeader </dt> <dd> <p>Pass an additional HTTP header when communicating with a server. If more than one such entry exists, all of them are added as extra headers. To allow overriding the settings inherited from the system config, an empty value will reset the extra headers to the empty list.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpcookieFile"> http.cookieFile </dt> <dd> <p>The pathname of a file containing previously stored cookie lines, which should be used in the Git http session, if they match the server. The file format of the file to read cookies from should be plain HTTP headers or the Netscape/Mozilla cookie file format (see <code>curl(1)</code>). NOTE that the file specified with http.cookieFile is used only as input unless http.saveCookies is set.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpsaveCookies"> http.saveCookies </dt> <dd> <p>If set, store cookies received during requests to the file specified by http.cookieFile. Has no effect if http.cookieFile is unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpversion"> http.version </dt> <dd> <p>Use the specified HTTP protocol version when communicating with a server. If you want to force the default. The available and default version depend on libcurl. Currently the possible values of this option are:</p> <div class="ulist"> <ul> <li> <p>HTTP/2</p> </li> <li> <p>HTTP/1.1</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpcurloptResolve"> http.curloptResolve </dt> <dd> <p>Hostname resolution information that will be used first by libcurl when sending HTTP requests. This information should be in one of the following formats:</p> <div class="ulist"> <ul> <li> <p>[+]HOST:PORT:ADDRESS[,ADDRESS]</p> </li> <li> <p>-HOST:PORT</p> </li> </ul> </div> <p>The first format redirects all requests to the given <code>HOST:PORT</code> to the provided <code>ADDRESS</code>(s). The second format clears all previous config values for that <code>HOST:PORT</code> combination. To allow easy overriding of all the settings inherited from the system config, an empty value will reset all resolution information to the empty list.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpsslVersion"> http.sslVersion </dt> <dd> <p>The SSL version to use when negotiating an SSL connection, if you want to force the default. The available and default version depend on whether libcurl was built against NSS or OpenSSL and the particular configuration of the crypto library in use. Internally this sets the <code>CURLOPT_SSL_VERSION</code> option; see the libcurl documentation for more details on the format of this option and for the ssl version supported. Currently the possible values of this option are:</p> <div class="ulist"> <ul> <li> <p>sslv2</p> </li> <li> <p>sslv3</p> </li> <li> <p>tlsv1</p> </li> <li> <p>tlsv1.0</p> </li> <li> <p>tlsv1.1</p> </li> <li> <p>tlsv1.2</p> </li> <li> <p>tlsv1.3</p> </li> </ul> </div> <p>Can be overridden by the <code>GIT_SSL_VERSION</code> environment variable. To force git to use libcurl’s default ssl version and ignore any explicit http.sslversion option, set <code>GIT_SSL_VERSION</code> to the empty string.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpsslCipherList"> http.sslCipherList </dt> <dd> <p>A list of SSL ciphers to use when negotiating an SSL connection. The available ciphers depend on whether libcurl was built against NSS or OpenSSL and the particular configuration of the crypto library in use. Internally this sets the <code>CURLOPT_SSL_CIPHER_LIST</code> option; see the libcurl documentation for more details on the format of this list.</p> <p>Can be overridden by the <code>GIT_SSL_CIPHER_LIST</code> environment variable. To force git to use libcurl’s default cipher list and ignore any explicit http.sslCipherList option, set <code>GIT_SSL_CIPHER_LIST</code> to the empty string.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpsslVerify"> http.sslVerify </dt> <dd> <p>Whether to verify the SSL certificate when fetching or pushing over HTTPS. Defaults to true. Can be overridden by the <code>GIT_SSL_NO_VERIFY</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpsslCert"> http.sslCert </dt> <dd> <p>File containing the SSL certificate when fetching or pushing over HTTPS. Can be overridden by the <code>GIT_SSL_CERT</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpsslKey"> http.sslKey </dt> <dd> <p>File containing the SSL private key when fetching or pushing over HTTPS. Can be overridden by the <code>GIT_SSL_KEY</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpsslCertPasswordProtected"> http.sslCertPasswordProtected </dt> <dd> <p>Enable Git’s password prompt for the SSL certificate. Otherwise OpenSSL will prompt the user, possibly many times, if the certificate or private key is encrypted. Can be overridden by the <code>GIT_SSL_CERT_PASSWORD_PROTECTED</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpsslCAInfo"> http.sslCAInfo </dt> <dd> <p>File containing the certificates to verify the peer with when fetching or pushing over HTTPS. Can be overridden by the <code>GIT_SSL_CAINFO</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpsslCAPath"> http.sslCAPath </dt> <dd> <p>Path containing files with the CA certificates to verify the peer with when fetching or pushing over HTTPS. Can be overridden by the <code>GIT_SSL_CAPATH</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpsslBackend"> http.sslBackend </dt> <dd> <p>Name of the SSL backend to use (e.g. "openssl" or "schannel"). This option is ignored if cURL lacks support for choosing the SSL backend at runtime.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpschannelCheckRevoke"> http.schannelCheckRevoke </dt> <dd> <p>Used to enforce or disable certificate revocation checks in cURL when http.sslBackend is set to "schannel". Defaults to <code>true</code> if unset. Only necessary to disable this if Git consistently errors and the message is about checking the revocation status of a certificate. This option is ignored if cURL lacks support for setting the relevant SSL option at runtime.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpschannelUseSSLCAInfo"> http.schannelUseSSLCAInfo </dt> <dd> <p>As of cURL v7.60.0, the Secure Channel backend can use the certificate bundle provided via <code>http.sslCAInfo</code>, but that would override the Windows Certificate Store. Since this is not desirable by default, Git will tell cURL not to use that bundle by default when the <code>schannel</code> backend was configured via <code>http.sslBackend</code>, unless <code>http.schannelUseSSLCAInfo</code> overrides this behavior.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httppinnedPubkey"> http.pinnedPubkey </dt> <dd> <p>Public key of the https service. It may either be the filename of a PEM or DER encoded public key file or a string starting with <code>sha256//</code> followed by the base64 encoded sha256 hash of the public key. See also libcurl <code>CURLOPT_PINNEDPUBLICKEY</code>. git will exit with an error if this option is set but not supported by cURL.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpsslTry"> http.sslTry </dt> <dd> <p>Attempt to use AUTH SSL/TLS and encrypted data transfers when connecting via regular FTP protocol. This might be needed if the FTP server requires it for security reasons or you wish to connect securely whenever remote FTP server supports it. Default is false since it might trigger certificate verification errors on misconfigured servers.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpmaxRequests"> http.maxRequests </dt> <dd> <p>How many HTTP requests to launch in parallel. Can be overridden by the <code>GIT_HTTP_MAX_REQUESTS</code> environment variable. Default is 5.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpminSessions"> http.minSessions </dt> <dd> <p>The number of curl sessions (counted across slots) to be kept across requests. They will not be ended with curl_easy_cleanup() until http_cleanup() is invoked. If USE_CURL_MULTI is not defined, this value will be capped at 1. Defaults to 1.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httppostBuffer"> http.postBuffer </dt> <dd> <p>Maximum size in bytes of the buffer used by smart HTTP transports when POSTing data to the remote system. For requests larger than this buffer size, HTTP/1.1 and Transfer-Encoding: chunked is used to avoid creating a massive pack file locally. Default is 1 MiB, which is sufficient for most requests.</p> <p>Note that raising this limit is only effective for disabling chunked transfer encoding and therefore should be used only where the remote server or a proxy only supports HTTP/1.0 or is noncompliant with the HTTP standard. Raising this is not, in general, an effective solution for most push problems, but can increase memory consumption significantly since the entire buffer is allocated even for small pushes.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httplowSpeedLimithttplowSpeedTime"> http.lowSpeedLimit, http.lowSpeedTime </dt> <dd> <p>If the HTTP transfer speed, in bytes per second, is less than <code>http.lowSpeedLimit</code> for longer than <code>http.lowSpeedTime</code> seconds, the transfer is aborted. Can be overridden by the <code>GIT_HTTP_LOW_SPEED_LIMIT</code> and <code>GIT_HTTP_LOW_SPEED_TIME</code> environment variables.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpnoEPSV"> http.noEPSV </dt> <dd> <p>A boolean which disables using of EPSV ftp command by curl. This can be helpful with some "poor" ftp servers which don’t support EPSV mode. Can be overridden by the <code>GIT_CURL_FTP_NO_EPSV</code> environment variable. Default is false (curl will use EPSV).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpuserAgent"> http.userAgent </dt> <dd> <p>The HTTP USER_AGENT string presented to an HTTP server. The default value represents the version of the Git client such as git/1.7.1. This option allows you to override this value to a more common value such as Mozilla/4.0. This may be necessary, for instance, if connecting through a firewall that restricts HTTP connections to a set of common USER_AGENT strings (but not including those like git/1.7.1). Can be overridden by the <code>GIT_HTTP_USER_AGENT</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httpfollowRedirects"> http.followRedirects </dt> <dd> <p>Whether git should follow HTTP redirects. If set to <code>true</code>, git will transparently follow any redirect issued by a server it encounters. If set to <code>false</code>, git will treat all redirects as errors. If set to <code>initial</code>, git will follow redirects only for the initial request to a remote, but not for subsequent follow-up HTTP requests. Since git uses the redirected URL as the base for the follow-up requests, this is generally sufficient. The default is <code>initial</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-httplturlgt"> http.<url>.* </dt> <dd> <p>Any of the http.* options above can be applied selectively to some URLs. For a config key to match a URL, each element of the config key is compared to that of the URL, in the following order:</p> <div class="openblock"> <div class="content"> <div class="olist arabic"> <ol class="arabic"> <li> <p>Scheme (e.g., <code>https</code> in <code>https://example.com/</code>). This field must match exactly between the config key and the URL.</p> </li> <li> <p>Host/domain name (e.g., <code>example.com</code> in <code>https://example.com/</code>). This field must match between the config key and the URL. It is possible to specify a <code>*</code> as part of the host name to match all subdomains at this level. <code>https://*.example.com/</code> for example would match <code>https://foo.example.com/</code>, but not <code>https://foo.bar.example.com/</code>.</p> </li> <li> <p>Port number (e.g., <code>8080</code> in <code>http://example.com:8080/</code>). This field must match exactly between the config key and the URL. Omitted port numbers are automatically converted to the correct default for the scheme before matching.</p> </li> <li> <p>Path (e.g., <code>repo.git</code> in <code>https://example.com/repo.git</code>). The path field of the config key must match the path field of the URL either exactly or as a prefix of slash-delimited path elements. This means a config key with path <code>foo/</code> matches URL path <code>foo/bar</code>. A prefix can only match on a slash (<code>/</code>) boundary. Longer matches take precedence (so a config key with path <code>foo/bar</code> is a better match to URL path <code>foo/bar</code> than a config key with just path <code>foo/</code>).</p> </li> <li> <p>User name (e.g., <code>user</code> in <code>https://user@example.com/repo.git</code>). If the config key has a user name it must match the user name in the URL exactly. If the config key does not have a user name, that config key will match a URL with any user name (including none), but at a lower precedence than a config key with a user name.</p> </li> </ol> </div> </div> </div> <p>The list above is ordered by decreasing precedence; a URL that matches a config key’s path is preferred to one that matches its user name. For example, if the URL is <code>https://user@example.com/foo/bar</code> a config key match of <code>https://example.com/foo</code> will be preferred over a config key match of <code>https://user@example.com</code>.</p> <p>All URLs are normalized before attempting any matching (the password part, if embedded in the URL, is always ignored for matching purposes) so that equivalent URLs that are simply spelled differently will match properly. Environment variable settings always override any matches. The URLs that are matched against are those given directly to Git commands. This means any URLs visited as a result of a redirection do not participate in matching.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-i18ncommitEncoding"> i18n.commitEncoding </dt> <dd> <p>Character encoding the commit messages are stored in; Git itself does not care per se, but this information is necessary e.g. when importing commits from emails or in the gitk graphical history browser (and possibly in other places in the future or in other porcelains). See e.g. <a href="git-mailinfo">git-mailinfo[1]</a>. Defaults to <code>utf-8</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-i18nlogOutputEncoding"> i18n.logOutputEncoding </dt> <dd> <p>Character encoding the commit messages are converted to when running <code>git log</code> and friends.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-imapfolder"> imap.folder </dt> <dd> <p>The folder to drop the mails into, which is typically the Drafts folder. For example: "INBOX.Drafts", "INBOX/Drafts" or "[Gmail]/Drafts". Required.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-imaptunnel"> imap.tunnel </dt> <dd> <p>Command used to set up a tunnel to the IMAP server through which commands will be piped instead of using a direct network connection to the server. Required when imap.host is not set.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-imaphost"> imap.host </dt> <dd> <p>A URL identifying the server. Use an <code>imap://</code> prefix for non-secure connections and an <code>imaps://</code> prefix for secure connections. Ignored when imap.tunnel is set, but required otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-imapuser"> imap.user </dt> <dd> <p>The username to use when logging in to the server.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-imappass"> imap.pass </dt> <dd> <p>The password to use when logging in to the server.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-imapport"> imap.port </dt> <dd> <p>An integer port number to connect to on the server. Defaults to 143 for imap:// hosts and 993 for imaps:// hosts. Ignored when imap.tunnel is set.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-imapsslverify"> imap.sslverify </dt> <dd> <p>A boolean to enable/disable verification of the server certificate used by the SSL/TLS connection. Default is <code>true</code>. Ignored when imap.tunnel is set.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-imappreformattedHTML"> imap.preformattedHTML </dt> <dd> <p>A boolean to enable/disable the use of html encoding when sending a patch. An html encoded patch will be bracketed with <pre> and have a content type of text/html. Ironically, enabling this option causes Thunderbird to send the patch as a plain/text, format=fixed email. Default is <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-imapauthMethod"> imap.authMethod </dt> <dd> <p>Specify the authentication method for authenticating with the IMAP server. If Git was built with the NO_CURL option, or if your curl version is older than 7.34.0, or if you’re running git-imap-send with the <code>--no-curl</code> option, the only supported method is <code>CRAM-MD5</code>. If this is not set then <code>git imap-send</code> uses the basic IMAP plaintext LOGIN command.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-includepath"> include.path </dt> <dt class="hdlist1" id="Documentation/git-config.txt-includeIfltconditiongtpath"> includeIf.<condition>.path </dt> <dd> <p>Special variables to include other configuration files. See the "CONFIGURATION FILE" section in the main <a href="git-config">git-config[1]</a> documentation, specifically the "Includes" and "Conditional Includes" subsections.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-indexrecordEndOfIndexEntries"> index.recordEndOfIndexEntries </dt> <dd> <p>Specifies whether the index file should include an "End Of Index Entry" section. This reduces index load time on multiprocessor machines but produces a message "ignoring EOIE extension" when reading the index using Git versions before 2.20. Defaults to <code>true</code> if index.threads has been explicitly enabled, <code>false</code> otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-indexrecordOffsetTable"> index.recordOffsetTable </dt> <dd> <p>Specifies whether the index file should include an "Index Entry Offset Table" section. This reduces index load time on multiprocessor machines but produces a message "ignoring IEOT extension" when reading the index using Git versions before 2.20. Defaults to <code>true</code> if index.threads has been explicitly enabled, <code>false</code> otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-indexsparse"> index.sparse </dt> <dd> <p>When enabled, write the index using sparse-directory entries. This has no effect unless <code>core.sparseCheckout</code> and <code>core.sparseCheckoutCone</code> are both enabled. Defaults to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-indexthreads"> index.threads </dt> <dd> <p>Specifies the number of threads to spawn when loading the index. This is meant to reduce index load time on multiprocessor machines. Specifying 0 or <code>true</code> will cause Git to auto-detect the number of CPUs and set the number of threads accordingly. Specifying 1 or <code>false</code> will disable multithreading. Defaults to <code>true</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-indexversion"> index.version </dt> <dd> <p>Specify the version with which new index files should be initialized. This does not affect existing repositories. If <code>feature.manyFiles</code> is enabled, then the default is 4.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-indexskipHash"> index.skipHash </dt> <dd> <p>When enabled, do not compute the trailing hash for the index file. This accelerates Git commands that manipulate the index, such as <code>git add</code>, <code>git commit</code>, or <code>git status</code>. Instead of storing the checksum, write a trailing set of bytes with value zero, indicating that the computation was skipped.</p> <p>If you enable <code>index.skipHash</code>, then Git clients older than 2.13.0 will refuse to parse the index and Git clients older than 2.40.0 will report an error during <code>git fsck</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-inittemplateDir"> init.templateDir </dt> <dd> <p>Specify the directory from which templates will be copied. (See the "TEMPLATE DIRECTORY" section of <a href="git-init">git-init[1]</a>.)</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-initdefaultBranch"> init.defaultBranch </dt> <dd> <p>Allows overriding the default branch name e.g. when initializing a new repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-instawebbrowser"> instaweb.browser </dt> <dd> <p>Specify the program that will be used to browse your working repository in gitweb. See <a href="git-instaweb">git-instaweb[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-instawebhttpd"> instaweb.httpd </dt> <dd> <p>The HTTP daemon command-line to start gitweb on your working repository. See <a href="git-instaweb">git-instaweb[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-instaweblocal"> instaweb.local </dt> <dd> <p>If true the web server started by <a href="git-instaweb">git-instaweb[1]</a> will be bound to the local IP (127.0.0.1).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-instawebmodulePath"> instaweb.modulePath </dt> <dd> <p>The default module path for <a href="git-instaweb">git-instaweb[1]</a> to use instead of /usr/lib/apache2/modules. Only used if httpd is Apache.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-instawebport"> instaweb.port </dt> <dd> <p>The port number to bind the gitweb httpd to. See <a href="git-instaweb">git-instaweb[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-interactivesingleKey"> interactive.singleKey </dt> <dd> <p>In interactive commands, allow the user to provide one-letter input with a single key (i.e., without hitting enter). Currently this is used by the <code>--patch</code> mode of <a href="git-add">git-add[1]</a>, <a href="git-checkout">git-checkout[1]</a>, <a href="git-restore">git-restore[1]</a>, <a href="git-commit">git-commit[1]</a>, <a href="git-reset">git-reset[1]</a>, and <a href="git-stash">git-stash[1]</a>. Note that this setting is silently ignored if portable keystroke input is not available; requires the Perl module Term::ReadKey.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-interactivediffFilter"> interactive.diffFilter </dt> <dd> <p>When an interactive command (such as <code>git add --patch</code>) shows a colorized diff, git will pipe the diff through the shell command defined by this configuration variable. The command may mark up the diff further for human consumption, provided that it retains a one-to-one correspondence with the lines in the original diff. Defaults to disabled (no filtering).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-logabbrevCommit"> log.abbrevCommit </dt> <dd> <p>If true, makes <a href="git-log">git-log[1]</a>, <a href="git-show">git-show[1]</a>, and <a href="git-whatchanged">git-whatchanged[1]</a> assume <code>--abbrev-commit</code>. You may override this option with <code>--no-abbrev-commit</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-logdate"> log.date </dt> <dd> <p>Set the default date-time mode for the <code>log</code> command. Setting a value for log.date is similar to using <code>git log</code>'s <code>--date</code> option. See <a href="git-log">git-log[1]</a> for details.</p> <p>If the format is set to "auto:foo" and the pager is in use, format "foo" will be used for the date format. Otherwise, "default" will be used.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-logdecorate"> log.decorate </dt> <dd> <p>Print out the ref names of any commits that are shown by the log command. If <code>short</code> is specified, the ref name prefixes <code>refs/heads/</code>, <code>refs/tags/</code> and <code>refs/remotes/</code> will not be printed. If <code>full</code> is specified, the full ref name (including prefix) will be printed. If <code>auto</code> is specified, then if the output is going to a terminal, the ref names are shown as if <code>short</code> were given, otherwise no ref names are shown. This is the same as the <code>--decorate</code> option of the <code>git log</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-loginitialDecorationSet"> log.initialDecorationSet </dt> <dd> <p>By default, <code>git log</code> only shows decorations for certain known ref namespaces. If <code>all</code> is specified, then show all refs as decorations.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-logexcludeDecoration"> log.excludeDecoration </dt> <dd> <p>Exclude the specified patterns from the log decorations. This is similar to the <code>--decorate-refs-exclude</code> command-line option, but the config option can be overridden by the <code>--decorate-refs</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-logdiffMerges"> log.diffMerges </dt> <dd> <p>Set diff format to be used when <code>--diff-merges=on</code> is specified, see <code>--diff-merges</code> in <a href="git-log">git-log[1]</a> for details. Defaults to <code>separate</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-logfollow"> log.follow </dt> <dd> <p>If <code>true</code>, <code>git log</code> will act as if the <code>--follow</code> option was used when a single <path> is given. This has the same limitations as <code>--follow</code>, i.e. it cannot be used to follow multiple files and does not work well on non-linear history.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-loggraphColors"> log.graphColors </dt> <dd> <p>A list of colors, separated by commas, that can be used to draw history lines in <code>git log --graph</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-logshowRoot"> log.showRoot </dt> <dd> <p>If true, the initial commit will be shown as a big creation event. This is equivalent to a diff against an empty tree. Tools like <a href="git-log">git-log[1]</a> or <a href="git-whatchanged">git-whatchanged[1]</a>, which normally hide the root commit will now show it. True by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-logshowSignature"> log.showSignature </dt> <dd> <p>If true, makes <a href="git-log">git-log[1]</a>, <a href="git-show">git-show[1]</a>, and <a href="git-whatchanged">git-whatchanged[1]</a> assume <code>--show-signature</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-logmailmap"> log.mailmap </dt> <dd> <p>If true, makes <a href="git-log">git-log[1]</a>, <a href="git-show">git-show[1]</a>, and <a href="git-whatchanged">git-whatchanged[1]</a> assume <code>--use-mailmap</code>, otherwise assume <code>--no-use-mailmap</code>. True by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-lsrefsunborn"> lsrefs.unborn </dt> <dd> <p>May be "advertise" (the default), "allow", or "ignore". If "advertise", the server will respond to the client sending "unborn" (as described in <a href="gitprotocol-v2">gitprotocol-v2[5]</a>) and will advertise support for this feature during the protocol v2 capability advertisement. "allow" is the same as "advertise" except that the server will not advertise support for this feature; this is useful for load-balanced servers that cannot be updated atomically (for example), since the administrator could configure "allow", then after a delay, configure "advertise".</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mailinfoscissors"> mailinfo.scissors </dt> <dd> <p>If true, makes <a href="git-mailinfo">git-mailinfo[1]</a> (and therefore <a href="git-am">git-am[1]</a>) act by default as if the --scissors option was provided on the command-line. When active, this feature removes everything from the message body before a scissors line (i.e. consisting mainly of ">8", "8<" and "-").</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mailmapfile"> mailmap.file </dt> <dd> <p>The location of an augmenting mailmap file. The default mailmap, located in the root of the repository, is loaded first, then the mailmap file pointed to by this variable. The location of the mailmap file may be in a repository subdirectory, or somewhere outside of the repository itself. See <a href="git-shortlog">git-shortlog[1]</a> and <a href="git-blame">git-blame[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mailmapblob"> mailmap.blob </dt> <dd> <p>Like <code>mailmap.file</code>, but consider the value as a reference to a blob in the repository. If both <code>mailmap.file</code> and <code>mailmap.blob</code> are given, both are parsed, with entries from <code>mailmap.file</code> taking precedence. In a bare repository, this defaults to <code>HEAD:.mailmap</code>. In a non-bare repository, it defaults to empty.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-maintenanceauto"> maintenance.auto </dt> <dd> <p>This boolean config option controls whether some commands run <code>git maintenance run --auto</code> after doing their normal work. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-maintenancestrategy"> maintenance.strategy </dt> <dd> <p>This string config option provides a way to specify one of a few recommended schedules for background maintenance. This only affects which tasks are run during <code>git maintenance run --schedule=X</code> commands, provided no <code>--task=<task></code> arguments are provided. Further, if a <code>maintenance.<task>.schedule</code> config value is set, then that value is used instead of the one provided by <code>maintenance.strategy</code>. The possible strategy strings are:</p> <div class="ulist"> <ul> <li> <p><code>none</code>: This default setting implies no tasks are run at any schedule.</p> </li> <li> <p><code>incremental</code>: This setting optimizes for performing small maintenance activities that do not delete any data. This does not schedule the <code>gc</code> task, but runs the <code>prefetch</code> and <code>commit-graph</code> tasks hourly, the <code>loose-objects</code> and <code>incremental-repack</code> tasks daily, and the <code>pack-refs</code> task weekly.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-maintenancelttaskgtenabled"> maintenance.<task>.enabled </dt> <dd> <p>This boolean config option controls whether the maintenance task with name <code><task></code> is run when no <code>--task</code> option is specified to <code>git maintenance run</code>. These config values are ignored if a <code>--task</code> option exists. By default, only <code>maintenance.gc.enabled</code> is true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-maintenancelttaskgtschedule"> maintenance.<task>.schedule </dt> <dd> <p>This config option controls whether or not the given <code><task></code> runs during a <code>git maintenance run --schedule=<frequency></code> command. The value must be one of "hourly", "daily", or "weekly".</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-maintenancecommit-graphauto"> maintenance.commit-graph.auto </dt> <dd> <p>This integer config option controls how often the <code>commit-graph</code> task should be run as part of <code>git maintenance run --auto</code>. If zero, then the <code>commit-graph</code> task will not run with the <code>--auto</code> option. A negative value will force the task to run every time. Otherwise, a positive value implies the command should run when the number of reachable commits that are not in the commit-graph file is at least the value of <code>maintenance.commit-graph.auto</code>. The default value is 100.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-maintenanceloose-objectsauto"> maintenance.loose-objects.auto </dt> <dd> <p>This integer config option controls how often the <code>loose-objects</code> task should be run as part of <code>git maintenance run --auto</code>. If zero, then the <code>loose-objects</code> task will not run with the <code>--auto</code> option. A negative value will force the task to run every time. Otherwise, a positive value implies the command should run when the number of loose objects is at least the value of <code>maintenance.loose-objects.auto</code>. The default value is 100.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-maintenanceincremental-repackauto"> maintenance.incremental-repack.auto </dt> <dd> <p>This integer config option controls how often the <code>incremental-repack</code> task should be run as part of <code>git maintenance run --auto</code>. If zero, then the <code>incremental-repack</code> task will not run with the <code>--auto</code> option. A negative value will force the task to run every time. Otherwise, a positive value implies the command should run when the number of pack-files not in the multi-pack-index is at least the value of <code>maintenance.incremental-repack.auto</code>. The default value is 10.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-manviewer"> man.viewer </dt> <dd> <p>Specify the programs that may be used to display help in the <code>man</code> format. See <a href="git-help">git-help[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-manlttoolgtcmd"> man.<tool>.cmd </dt> <dd> <p>Specify the command to invoke the specified man viewer. The specified command is evaluated in shell with the man page passed as an argument. (See <a href="git-help">git-help[1]</a>.)</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-manlttoolgtpath"> man.<tool>.path </dt> <dd> <p>Override the path for the given tool that may be used to display help in the <code>man</code> format. See <a href="git-help">git-help[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergeconflictStyle"> merge.conflictStyle </dt> <dd> <p>Specify the style in which conflicted hunks are written out to working tree files upon merge. The default is "merge", which shows a <code><<<<<<<</code> conflict marker, changes made by one side, a <code>=======</code> marker, changes made by the other side, and then a <code>>>>>>>></code> marker. An alternate style, "diff3", adds a <code>|||||||</code> marker and the original text before the <code>=======</code> marker. The "merge" style tends to produce smaller conflict regions than diff3, both because of the exclusion of the original text, and because when a subset of lines match on the two sides, they are just pulled out of the conflict region. Another alternate style, "zdiff3", is similar to diff3 but removes matching lines on the two sides from the conflict region when those matching lines appear near either the beginning or end of a conflict region.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergedefaultToUpstream"> merge.defaultToUpstream </dt> <dd> <p>If merge is called without any commit argument, merge the upstream branches configured for the current branch by using their last observed values stored in their remote-tracking branches. The values of the <code>branch.<current branch>.merge</code> that name the branches at the remote named by <code>branch.<current branch>.remote</code> are consulted, and then they are mapped via <code>remote.<remote>.fetch</code> to their corresponding remote-tracking branches, and the tips of these tracking branches are merged. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergeff"> merge.ff </dt> <dd> <p>By default, Git does not create an extra merge commit when merging a commit that is a descendant of the current commit. Instead, the tip of the current branch is fast-forwarded. When set to <code>false</code>, this variable tells Git to create an extra merge commit in such a case (equivalent to giving the <code>--no-ff</code> option from the command line). When set to <code>only</code>, only such fast-forward merges are allowed (equivalent to giving the <code>--ff-only</code> option from the command line).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergeverifySignatures"> merge.verifySignatures </dt> <dd> <p>If true, this is equivalent to the --verify-signatures command line option. See <a href="git-merge">git-merge[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergebranchdesc"> merge.branchdesc </dt> <dd> <p>In addition to branch names, populate the log message with the branch description text associated with them. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergelog"> merge.log </dt> <dd> <p>In addition to branch names, populate the log message with at most the specified number of one-line descriptions from the actual commits that are being merged. Defaults to false, and true is a synonym for 20.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergesuppressDest"> merge.suppressDest </dt> <dd> <p>By adding a glob that matches the names of integration branches to this multi-valued configuration variable, the default merge message computed for merges into these integration branches will omit "into <branch name>" from its title.</p> <p>An element with an empty value can be used to clear the list of globs accumulated from previous configuration entries. When there is no <code>merge.suppressDest</code> variable defined, the default value of <code>master</code> is used for backward compatibility.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergerenameLimit"> merge.renameLimit </dt> <dd> <p>The number of files to consider in the exhaustive portion of rename detection during a merge. If not specified, defaults to the value of diff.renameLimit. If neither merge.renameLimit nor diff.renameLimit are specified, currently defaults to 7000. This setting has no effect if rename detection is turned off.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergerenames"> merge.renames </dt> <dd> <p>Whether Git detects renames. If set to "false", rename detection is disabled. If set to "true", basic rename detection is enabled. Defaults to the value of diff.renames.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergedirectoryRenames"> merge.directoryRenames </dt> <dd> <p>Whether Git detects directory renames, affecting what happens at merge time to new files added to a directory on one side of history when that directory was renamed on the other side of history. If merge.directoryRenames is set to "false", directory rename detection is disabled, meaning that such new files will be left behind in the old directory. If set to "true", directory rename detection is enabled, meaning that such new files will be moved into the new directory. If set to "conflict", a conflict will be reported for such paths. If merge.renames is false, merge.directoryRenames is ignored and treated as false. Defaults to "conflict".</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergerenormalize"> merge.renormalize </dt> <dd> <p>Tell Git that canonical representation of files in the repository has changed over time (e.g. earlier commits record text files with CRLF line endings, but recent ones use LF line endings). In such a repository, Git can convert the data recorded in commits to a canonical form before performing a merge to reduce unnecessary conflicts. For more information, see section "Merging branches with differing checkin/checkout attributes" in <a href="gitattributes">gitattributes[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergestat"> merge.stat </dt> <dd> <p>Whether to print the diffstat between ORIG_HEAD and the merge result at the end of the merge. True by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergeautoStash"> merge.autoStash </dt> <dd> <p>When set to true, automatically create a temporary stash entry before the operation begins, and apply it after the operation ends. This means that you can run merge on a dirty worktree. However, use with care: the final stash application after a successful merge might result in non-trivial conflicts. This option can be overridden by the <code>--no-autostash</code> and <code>--autostash</code> options of <a href="git-merge">git-merge[1]</a>. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergetool"> merge.tool </dt> <dd> <p>Controls which merge tool is used by <a href="git-mergetool">git-mergetool[1]</a>. The list below shows the valid built-in values. Any other value is treated as a custom merge tool and requires that a corresponding mergetool.<tool>.cmd variable is defined.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergeguitool"> merge.guitool </dt> <dd> <p>Controls which merge tool is used by <a href="git-mergetool">git-mergetool[1]</a> when the -g/--gui flag is specified. The list below shows the valid built-in values. Any other value is treated as a custom merge tool and requires that a corresponding mergetool.<guitool>.cmd variable is defined.</p> <div class="ulist"> <ul> <li> <p>araxis</p> </li> <li> <p>bc</p> </li> <li> <p>codecompare</p> </li> <li> <p>deltawalker</p> </li> <li> <p>diffmerge</p> </li> <li> <p>diffuse</p> </li> <li> <p>ecmerge</p> </li> <li> <p>emerge</p> </li> <li> <p>examdiff</p> </li> <li> <p>guiffy</p> </li> <li> <p>gvimdiff</p> </li> <li> <p>kdiff3</p> </li> <li> <p>meld</p> </li> <li> <p>nvimdiff</p> </li> <li> <p>opendiff</p> </li> <li> <p>p4merge</p> </li> <li> <p>smerge</p> </li> <li> <p>tkdiff</p> </li> <li> <p>tortoisemerge</p> </li> <li> <p>vimdiff</p> </li> <li> <p>winmerge</p> </li> <li> <p>xxdiff</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergeverbosity"> merge.verbosity </dt> <dd> <p>Controls the amount of output shown by the recursive merge strategy. Level 0 outputs nothing except a final error message if conflicts were detected. Level 1 outputs only conflicts, 2 outputs conflicts and file changes. Level 5 and above outputs debugging information. The default is level 2. Can be overridden by the <code>GIT_MERGE_VERBOSITY</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergeltdrivergtname"> merge.<driver>.name </dt> <dd> <p>Defines a human-readable name for a custom low-level merge driver. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergeltdrivergtdriver"> merge.<driver>.driver </dt> <dd> <p>Defines the command that implements a custom low-level merge driver. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergeltdrivergtrecursive"> merge.<driver>.recursive </dt> <dd> <p>Names a low-level merge driver to be used when performing an internal merge between common ancestors. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergetoollttoolgtpath"> mergetool.<tool>.path </dt> <dd> <p>Override the path for the given tool. This is useful in case your tool is not in the PATH.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergetoollttoolgtcmd"> mergetool.<tool>.cmd </dt> <dd> <p>Specify the command to invoke the specified merge tool. The specified command is evaluated in shell with the following variables available: <code>BASE</code> is the name of a temporary file containing the common base of the files to be merged, if available; <code>LOCAL</code> is the name of a temporary file containing the contents of the file on the current branch; <code>REMOTE</code> is the name of a temporary file containing the contents of the file from the branch being merged; <code>MERGED</code> contains the name of the file to which the merge tool should write the results of a successful merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergetoollttoolgthideResolved"> mergetool.<tool>.hideResolved </dt> <dd> <p>Allows the user to override the global <code>mergetool.hideResolved</code> value for a specific tool. See <code>mergetool.hideResolved</code> for the full description.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergetoollttoolgttrustExitCode"> mergetool.<tool>.trustExitCode </dt> <dd> <p>For a custom merge command, specify whether the exit code of the merge command can be used to determine whether the merge was successful. If this is not set to true then the merge target file timestamp is checked, and the merge is assumed to have been successful if the file has been updated; otherwise, the user is prompted to indicate the success of the merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergetoolmeldhasOutput"> mergetool.meld.hasOutput </dt> <dd> <p>Older versions of <code>meld</code> do not support the <code>--output</code> option. Git will attempt to detect whether <code>meld</code> supports <code>--output</code> by inspecting the output of <code>meld --help</code>. Configuring <code>mergetool.meld.hasOutput</code> will make Git skip these checks and use the configured value instead. Setting <code>mergetool.meld.hasOutput</code> to <code>true</code> tells Git to unconditionally use the <code>--output</code> option, and <code>false</code> avoids using <code>--output</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergetoolmelduseAutoMerge"> mergetool.meld.useAutoMerge </dt> <dd> <p>When the <code>--auto-merge</code> is given, meld will merge all non-conflicting parts automatically, highlight the conflicting parts, and wait for user decision. Setting <code>mergetool.meld.useAutoMerge</code> to <code>true</code> tells Git to unconditionally use the <code>--auto-merge</code> option with <code>meld</code>. Setting this value to <code>auto</code> makes git detect whether <code>--auto-merge</code> is supported and will only use <code>--auto-merge</code> when available. A value of <code>false</code> avoids using <code>--auto-merge</code> altogether, and is the default value.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergetoolvimdifflayout"> mergetool.vimdiff.layout </dt> <dd> <p>The vimdiff backend uses this variable to control how its split windows appear. Applies even if you are using Neovim (<code>nvim</code>) or gVim (<code>gvim</code>) as the merge tool. See BACKEND SPECIFIC HINTS section in <a href="git-mergetool">git-mergetool[1]</a>. for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergetoolhideResolved"> mergetool.hideResolved </dt> <dd> <p>During a merge, Git will automatically resolve as many conflicts as possible and write the <code>MERGED</code> file containing conflict markers around any conflicts that it cannot resolve; <code>LOCAL</code> and <code>REMOTE</code> normally represent the versions of the file from before Git’s conflict resolution. This flag causes <code>LOCAL</code> and <code>REMOTE</code> to be overwritten so that only the unresolved conflicts are presented to the merge tool. Can be configured per-tool via the <code>mergetool.<tool>.hideResolved</code> configuration variable. Defaults to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergetoolkeepBackup"> mergetool.keepBackup </dt> <dd> <p>After performing a merge, the original file with conflict markers can be saved as a file with a <code>.orig</code> extension. If this variable is set to <code>false</code> then this file is not preserved. Defaults to <code>true</code> (i.e. keep the backup files).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergetoolkeepTemporaries"> mergetool.keepTemporaries </dt> <dd> <p>When invoking a custom merge tool, Git uses a set of temporary files to pass to the tool. If the tool returns an error and this variable is set to <code>true</code>, then these temporary files will be preserved; otherwise, they will be removed after the tool has exited. Defaults to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergetoolwriteToTemp"> mergetool.writeToTemp </dt> <dd> <p>Git writes temporary <code>BASE</code>, <code>LOCAL</code>, and <code>REMOTE</code> versions of conflicting files in the worktree by default. Git will attempt to use a temporary directory for these files when set <code>true</code>. Defaults to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergetoolprompt"> mergetool.prompt </dt> <dd> <p>Prompt before each invocation of the merge resolution program.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-mergetoolguiDefault"> mergetool.guiDefault </dt> <dd> <p>Set <code>true</code> to use the <code>merge.guitool</code> by default (equivalent to specifying the <code>--gui</code> argument), or <code>auto</code> to select <code>merge.guitool</code> or <code>merge.tool</code> depending on the presence of a <code>DISPLAY</code> environment variable value. The default is <code>false</code>, where the <code>--gui</code> argument must be provided explicitly for the <code>merge.guitool</code> to be used.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-notesmergeStrategy"> notes.mergeStrategy </dt> <dd> <p>Which merge strategy to choose by default when resolving notes conflicts. Must be one of <code>manual</code>, <code>ours</code>, <code>theirs</code>, <code>union</code>, or <code>cat_sort_uniq</code>. Defaults to <code>manual</code>. See the "NOTES MERGE STRATEGIES" section of <a href="git-notes">git-notes[1]</a> for more information on each strategy.</p> <p>This setting can be overridden by passing the <code>--strategy</code> option to <a href="git-notes">git-notes[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-notesltnamegtmergeStrategy"> notes.<name>.mergeStrategy </dt> <dd> <p>Which merge strategy to choose when doing a notes merge into refs/notes/<name>. This overrides the more general "notes.mergeStrategy". See the "NOTES MERGE STRATEGIES" section in <a href="git-notes">git-notes[1]</a> for more information on the available strategies.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-notesdisplayRef"> notes.displayRef </dt> <dd> <p>Which ref (or refs, if a glob or specified more than once), in addition to the default set by <code>core.notesRef</code> or <code>GIT_NOTES_REF</code>, to read notes from when showing commit messages with the <code>git log</code> family of commands.</p> <p>This setting can be overridden with the <code>GIT_NOTES_DISPLAY_REF</code> environment variable, which must be a colon separated list of refs or globs.</p> <p>A warning will be issued for refs that do not exist, but a glob that does not match any refs is silently ignored.</p> <p>This setting can be disabled by the <code>--no-notes</code> option to the <code>git log</code> family of commands, or by the <code>--notes=<ref></code> option accepted by those commands.</p> <p>The effective value of "core.notesRef" (possibly overridden by GIT_NOTES_REF) is also implicitly added to the list of refs to be displayed.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-notesrewriteltcommandgt"> notes.rewrite.<command> </dt> <dd> <p>When rewriting commits with <command> (currently <code>amend</code> or <code>rebase</code>), if this variable is <code>false</code>, git will not copy notes from the original to the rewritten commit. Defaults to <code>true</code>. See also "<code>notes.rewriteRef</code>" below.</p> <p>This setting can be overridden with the <code>GIT_NOTES_REWRITE_REF</code> environment variable, which must be a colon separated list of refs or globs.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-notesrewriteMode"> notes.rewriteMode </dt> <dd> <p>When copying notes during a rewrite (see the "notes.rewrite.<command>" option), determines what to do if the target commit already has a note. Must be one of <code>overwrite</code>, <code>concatenate</code>, <code>cat_sort_uniq</code>, or <code>ignore</code>. Defaults to <code>concatenate</code>.</p> <p>This setting can be overridden with the <code>GIT_NOTES_REWRITE_MODE</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-notesrewriteRef"> notes.rewriteRef </dt> <dd> <p>When copying notes during a rewrite, specifies the (fully qualified) ref whose notes should be copied. May be a glob, in which case notes in all matching refs will be copied. You may also specify this configuration several times.</p> <p>Does not have a default value; you must configure this variable to enable note rewriting. Set it to <code>refs/notes/commits</code> to enable rewriting for the default commit notes.</p> <p>Can be overridden with the <code>GIT_NOTES_REWRITE_REF</code> environment variable. See <code>notes.rewrite.<command></code> above for a further description of its format.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packwindow"> pack.window </dt> <dd> <p>The size of the window used by <a href="git-pack-objects">git-pack-objects[1]</a> when no window size is given on the command line. Defaults to 10.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packdepth"> pack.depth </dt> <dd> <p>The maximum delta depth used by <a href="git-pack-objects">git-pack-objects[1]</a> when no maximum depth is given on the command line. Defaults to 50. Maximum value is 4095.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packwindowMemory"> pack.windowMemory </dt> <dd> <p>The maximum size of memory that is consumed by each thread in <a href="git-pack-objects">git-pack-objects[1]</a> for pack window memory when no limit is given on the command line. The value can be suffixed with "k", "m", or "g". When left unconfigured (or set explicitly to 0), there will be no limit.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packcompression"> pack.compression </dt> <dd> <p>An integer -1..9, indicating the compression level for objects in a pack file. -1 is the zlib default. 0 means no compression, and 1..9 are various speed/size tradeoffs, 9 being slowest. If not set, defaults to core.compression. If that is not set, defaults to -1, the zlib default, which is "a default compromise between speed and compression (currently equivalent to level 6)."</p> <p>Note that changing the compression level will not automatically recompress all existing objects. You can force recompression by passing the -F option to <a href="git-repack">git-repack[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packallowPackReuse"> pack.allowPackReuse </dt> <dd> <p>When true, and when reachability bitmaps are enabled, pack-objects will try to send parts of the bitmapped packfile verbatim. This can reduce memory and CPU usage to serve fetches, but might result in sending a slightly larger pack. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packisland"> pack.island </dt> <dd> <p>An extended regular expression configuring a set of delta islands. See "DELTA ISLANDS" in <a href="git-pack-objects">git-pack-objects[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packislandCore"> pack.islandCore </dt> <dd> <p>Specify an island name which gets to have its objects be packed first. This creates a kind of pseudo-pack at the front of one pack, so that the objects from the specified island are hopefully faster to copy into any pack that should be served to a user requesting these objects. In practice this means that the island specified should likely correspond to what is the most commonly cloned in the repo. See also "DELTA ISLANDS" in <a href="git-pack-objects">git-pack-objects[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packdeltaCacheSize"> pack.deltaCacheSize </dt> <dd> <p>The maximum memory in bytes used for caching deltas in <a href="git-pack-objects">git-pack-objects[1]</a> before writing them out to a pack. This cache is used to speed up the writing object phase by not having to recompute the final delta result once the best match for all objects is found. Repacking large repositories on machines which are tight with memory might be badly impacted by this though, especially if this cache pushes the system into swapping. A value of 0 means no limit. The smallest size of 1 byte may be used to virtually disable this cache. Defaults to 256 MiB.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packdeltaCacheLimit"> pack.deltaCacheLimit </dt> <dd> <p>The maximum size of a delta, that is cached in <a href="git-pack-objects">git-pack-objects[1]</a>. This cache is used to speed up the writing object phase by not having to recompute the final delta result once the best match for all objects is found. Defaults to 1000. Maximum value is 65535.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packthreads"> pack.threads </dt> <dd> <p>Specifies the number of threads to spawn when searching for best delta matches. This requires that <a href="git-pack-objects">git-pack-objects[1]</a> be compiled with pthreads otherwise this option is ignored with a warning. This is meant to reduce packing time on multiprocessor machines. The required amount of memory for the delta search window is however multiplied by the number of threads. Specifying 0 will cause Git to auto-detect the number of CPUs and set the number of threads accordingly.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packindexVersion"> pack.indexVersion </dt> <dd> <p>Specify the default pack index version. Valid values are 1 for legacy pack index used by Git versions prior to 1.5.2, and 2 for the new pack index with capabilities for packs larger than 4 GB as well as proper protection against the repacking of corrupted packs. Version 2 is the default. Note that version 2 is enforced and this config option is ignored whenever the corresponding pack is larger than 2 GB.</p> <p>If you have an old Git that does not understand the version 2 <code>*.idx</code> file, cloning or fetching over a non-native protocol (e.g. "http") that will copy both <code>*.pack</code> file and corresponding <code>*.idx</code> file from the other side may give you a repository that cannot be accessed with your older version of Git. If the <code>*.pack</code> file is smaller than 2 GB, however, you can use <a href="git-index-pack">git-index-pack[1]</a> on the *.pack file to regenerate the <code>*.idx</code> file.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packpackSizeLimit"> pack.packSizeLimit </dt> <dd> <p>The maximum size of a pack. This setting only affects packing to a file when repacking, i.e. the git:// protocol is unaffected. It can be overridden by the <code>--max-pack-size</code> option of <a href="git-repack">git-repack[1]</a>. Reaching this limit results in the creation of multiple packfiles.</p> <p>Note that this option is rarely useful, and may result in a larger total on-disk size (because Git will not store deltas between packs) and worse runtime performance (object lookup within multiple packs is slower than a single pack, and optimizations like reachability bitmaps cannot cope with multiple packs).</p> <p>If you need to actively run Git using smaller packfiles (e.g., because your filesystem does not support large files), this option may help. But if your goal is to transmit a packfile over a medium that supports limited sizes (e.g., removable media that cannot store the whole repository), you are likely better off creating a single large packfile and splitting it using a generic multi-volume archive tool (e.g., Unix <code>split</code>).</p> <p>The minimum size allowed is limited to 1 MiB. The default is unlimited. Common unit suffixes of <code>k</code>, <code>m</code>, or <code>g</code> are supported.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packuseBitmaps"> pack.useBitmaps </dt> <dd> <p>When true, git will use pack bitmaps (if available) when packing to stdout (e.g., during the server side of a fetch). Defaults to true. You should not generally need to turn this off unless you are debugging pack bitmaps.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packuseBitmapBoundaryTraversal"> pack.useBitmapBoundaryTraversal </dt> <dd> <p>When true, Git will use an experimental algorithm for computing reachability queries with bitmaps. Instead of building up complete bitmaps for all of the negated tips and then OR-ing them together, consider negated tips with existing bitmaps as additive (i.e. OR-ing them into the result if they exist, ignoring them otherwise), and build up a bitmap at the boundary instead.</p> <p>When using this algorithm, Git may include too many objects as a result of not opening up trees belonging to certain UNINTERESTING commits. This inexactness matches the non-bitmap traversal algorithm.</p> <p>In many cases, this can provide a speed-up over the exact algorithm, particularly when there is poor bitmap coverage of the negated side of the query.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packuseSparse"> pack.useSparse </dt> <dd> <p>When true, git will default to using the <code>--sparse</code> option in <code>git pack-objects</code> when the <code>--revs</code> option is present. This algorithm only walks trees that appear in paths that introduce new objects. This can have significant performance benefits when computing a pack to send a small change. However, it is possible that extra objects are added to the pack-file if the included commits contain certain types of direct renames. Default is <code>true</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packpreferBitmapTips"> pack.preferBitmapTips </dt> <dd> <p>When selecting which commits will receive bitmaps, prefer a commit at the tip of any reference that is a suffix of any value of this configuration over any other commits in the "selection window".</p> <p>Note that setting this configuration to <code>refs/foo</code> does not mean that the commits at the tips of <code>refs/foo/bar</code> and <code>refs/foo/baz</code> will necessarily be selected. This is because commits are selected for bitmaps from within a series of windows of variable length.</p> <p>If a commit at the tip of any reference which is a suffix of any value of this configuration is seen in a window, it is immediately given preference over any other commit in that window.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packwriteBitmapsdeprecated"> pack.writeBitmaps (deprecated) </dt> <dd> <p>This is a deprecated synonym for <code>repack.writeBitmaps</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packwriteBitmapHashCache"> pack.writeBitmapHashCache </dt> <dd> <p>When true, git will include a "hash cache" section in the bitmap index (if one is written). This cache can be used to feed git’s delta heuristics, potentially leading to better deltas between bitmapped and non-bitmapped objects (e.g., when serving a fetch between an older, bitmapped pack and objects that have been pushed since the last gc). The downside is that it consumes 4 bytes per object of disk space. Defaults to true.</p> <p>When writing a multi-pack reachability bitmap, no new namehashes are computed; instead, any namehashes stored in an existing bitmap are permuted into their appropriate location when writing a new bitmap.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packwriteBitmapLookupTable"> pack.writeBitmapLookupTable </dt> <dd> <p>When true, Git will include a "lookup table" section in the bitmap index (if one is written). This table is used to defer loading individual bitmaps as late as possible. This can be beneficial in repositories that have relatively large bitmap indexes. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packreadReverseIndex"> pack.readReverseIndex </dt> <dd> <p>When true, git will read any .rev file(s) that may be available (see: <a href="gitformat-pack">gitformat-pack[5]</a>). When false, the reverse index will be generated from scratch and stored in memory. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-packwriteReverseIndex"> pack.writeReverseIndex </dt> <dd> <p>When true, git will write a corresponding .rev file (see: <a href="gitformat-pack">gitformat-pack[5]</a>) for each new packfile that it writes in all places except for <a href="git-fast-import">git-fast-import[1]</a> and in the bulk checkin mechanism. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pagerltcmdgt"> pager.<cmd> </dt> <dd> <p>If the value is boolean, turns on or off pagination of the output of a particular Git subcommand when writing to a tty. Otherwise, turns on pagination for the subcommand using the pager specified by the value of <code>pager.<cmd></code>. If <code>--paginate</code> or <code>--no-pager</code> is specified on the command line, it takes precedence over this option. To disable pagination for all commands, set <code>core.pager</code> or <code>GIT_PAGER</code> to <code>cat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-prettyltnamegt"> pretty.<name> </dt> <dd> <p>Alias for a --pretty= format string, as specified in <a href="git-log">git-log[1]</a>. Any aliases defined here can be used just as the built-in pretty formats could. For example, running <code>git config pretty.changelog "format:* %H %s"</code> would cause the invocation <code>git log --pretty=changelog</code> to be equivalent to running <code>git log "--pretty=format:* %H %s"</code>. Note that an alias with the same name as a built-in format will be silently ignored.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-protocolallow"> protocol.allow </dt> <dd> <p>If set, provide a user defined default policy for all protocols which don’t explicitly have a policy (<code>protocol.<name>.allow</code>). By default, if unset, known-safe protocols (http, https, git, ssh) have a default policy of <code>always</code>, known-dangerous protocols (ext) have a default policy of <code>never</code>, and all other protocols (including file) have a default policy of <code>user</code>. Supported policies:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>always</code> - protocol is always able to be used.</p> </li> <li> <p><code>never</code> - protocol is never able to be used.</p> </li> <li> <p><code>user</code> - protocol is only able to be used when <code>GIT_PROTOCOL_FROM_USER</code> is either unset or has a value of 1. This policy should be used when you want a protocol to be directly usable by the user but don’t want it used by commands which execute clone/fetch/push commands without user input, e.g. recursive submodule initialization.</p> </li> </ul> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-protocolltnamegtallow"> protocol.<name>.allow </dt> <dd> <p>Set a policy to be used by protocol <code><name></code> with clone/fetch/push commands. See <code>protocol.allow</code> above for the available policies.</p> <p>The protocol names currently used by git are:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>file</code>: any local file-based path (including <code>file://</code> URLs, or local paths)</p> </li> <li> <p><code>git</code>: the anonymous git protocol over a direct TCP connection (or proxy, if configured)</p> </li> <li> <p><code>ssh</code>: git over ssh (including <code>host:path</code> syntax, <code>ssh://</code>, etc).</p> </li> <li> <p><code>http</code>: git over http, both "smart http" and "dumb http". Note that this does <code>not</code> include <code>https</code>; if you want to configure both, you must do so individually.</p> </li> <li> <p>any external helpers are named by their protocol (e.g., use <code>hg</code> to allow the <code>git-remote-hg</code> helper)</p> </li> </ul> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-protocolversion"> protocol.version </dt> <dd> <p>If set, clients will attempt to communicate with a server using the specified protocol version. If the server does not support it, communication falls back to version 0. If unset, the default is <code>2</code>. Supported versions:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>0</code> - the original wire protocol.</p> </li> <li> <p><code>1</code> - the original wire protocol with the addition of a version string in the initial response from the server.</p> </li> <li> <p><code>2</code> - Wire protocol version 2, see <a href="gitprotocol-v2">gitprotocol-v2[5]</a>.</p> </li> </ul> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pullff"> pull.ff </dt> <dd> <p>By default, Git does not create an extra merge commit when merging a commit that is a descendant of the current commit. Instead, the tip of the current branch is fast-forwarded. When set to <code>false</code>, this variable tells Git to create an extra merge commit in such a case (equivalent to giving the <code>--no-ff</code> option from the command line). When set to <code>only</code>, only such fast-forward merges are allowed (equivalent to giving the <code>--ff-only</code> option from the command line). This setting overrides <code>merge.ff</code> when pulling.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pullrebase"> pull.rebase </dt> <dd> <p>When true, rebase branches on top of the fetched branch, instead of merging the default branch from the default remote when "git pull" is run. See "branch.<name>.rebase" for setting this on a per-branch basis.</p> <p>When <code>merges</code> (or just <code>m</code>), pass the <code>--rebase-merges</code> option to <code>git rebase</code> so that the local merge commits are included in the rebase (see <a href="git-rebase">git-rebase[1]</a> for details).</p> <p>When the value is <code>interactive</code> (or just <code>i</code>), the rebase is run in interactive mode.</p> <p><strong>NOTE</strong>: this is a possibly dangerous operation; do <strong>not</strong> use it unless you understand the implications (see <a href="git-rebase">git-rebase[1]</a> for details).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pulloctopus"> pull.octopus </dt> <dd> <p>The default merge strategy to use when pulling multiple branches at once.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pulltwohead"> pull.twohead </dt> <dd> <p>The default merge strategy to use when pulling a single branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushautoSetupRemote"> push.autoSetupRemote </dt> <dd> <p>If set to "true" assume <code>--set-upstream</code> on default push when no upstream tracking exists for the current branch; this option takes effect with push.default options <code>simple</code>, <code>upstream</code>, and <code>current</code>. It is useful if by default you want new branches to be pushed to the default remote (like the behavior of <code>push.default=current</code>) and you also want the upstream tracking to be set. Workflows most likely to benefit from this option are <code>simple</code> central workflows where all branches are expected to have the same name on the remote.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushdefault"> push.default </dt> <dd> <p>Defines the action <code>git push</code> should take if no refspec is given (whether from the command-line, config, or elsewhere). Different values are well-suited for specific workflows; for instance, in a purely central workflow (i.e. the fetch source is equal to the push destination), <code>upstream</code> is probably what you want. Possible values are:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>nothing</code> - do not push anything (error out) unless a refspec is given. This is primarily meant for people who want to avoid mistakes by always being explicit.</p> </li> <li> <p><code>current</code> - push the current branch to update a branch with the same name on the receiving end. Works in both central and non-central workflows.</p> </li> <li> <p><code>upstream</code> - push the current branch back to the branch whose changes are usually integrated into the current branch (which is called <code>@{upstream}</code>). This mode only makes sense if you are pushing to the same repository you would normally pull from (i.e. central workflow).</p> </li> <li> <p><code>tracking</code> - This is a deprecated synonym for <code>upstream</code>.</p> </li> <li> <p><code>simple</code> - push the current branch with the same name on the remote.</p> <p>If you are working on a centralized workflow (pushing to the same repository you pull from, which is typically <code>origin</code>), then you need to configure an upstream branch with the same name.</p> <p>This mode is the default since Git 2.0, and is the safest option suited for beginners.</p> </li> <li> <p><code>matching</code> - push all branches having the same name on both ends. This makes the repository you are pushing to remember the set of branches that will be pushed out (e.g. if you always push <code>maint</code> and <code>master</code> there and no other branches, the repository you push to will have these two branches, and your local <code>maint</code> and <code>master</code> will be pushed there).</p> <p>To use this mode effectively, you have to make sure <code>all</code> the branches you would push out are ready to be pushed out before running <code>git push</code>, as the whole point of this mode is to allow you to push all of the branches in one go. If you usually finish work on only one branch and push out the result, while other branches are unfinished, this mode is not for you. Also this mode is not suitable for pushing into a shared central repository, as other people may add new branches there, or update the tip of existing branches outside your control.</p> <p>This used to be the default, but not since Git 2.0 (<code>simple</code> is the new default).</p> </li> </ul> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushfollowTags"> push.followTags </dt> <dd> <p>If set to true, enable <code>--follow-tags</code> option by default. You may override this configuration at time of push by specifying <code>--no-follow-tags</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushgpgSign"> push.gpgSign </dt> <dd> <p>May be set to a boolean value, or the string <code>if-asked</code>. A true value causes all pushes to be GPG signed, as if <code>--signed</code> is passed to <a href="git-push">git-push[1]</a>. The string <code>if-asked</code> causes pushes to be signed if the server supports it, as if <code>--signed=if-asked</code> is passed to <code>git push</code>. A false value may override a value from a lower-priority config file. An explicit command-line flag always overrides this config option.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushpushOption"> push.pushOption </dt> <dd> <p>When no <code>--push-option=<option></code> argument is given from the command line, <code>git push</code> behaves as if each <value> of this variable is given as <code>--push-option=<value></code>.</p> <p>This is a multi-valued variable, and an empty value can be used in a higher priority configuration file (e.g. <code>.git/config</code> in a repository) to clear the values inherited from a lower priority configuration files (e.g. <code>$HOME/.gitconfig</code>).</p> <div class="listingblock"> <div class="content"> <pre>Example: + +/etc/gitconfig + push.pushoption = a + push.pushoption = b + +~/.gitconfig + push.pushoption = c + +repo/.git/config + push.pushoption = + push.pushoption = b + +This will result in only b (a and c are cleared).</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushrecurseSubmodules"> push.recurseSubmodules </dt> <dd> <p>May be "check", "on-demand", "only", or "no", with the same behavior as that of "push --recurse-submodules". If not set, <code>no</code> is used by default, unless <code>submodule.recurse</code> is set (in which case a <code>true</code> value means <code>on-demand</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushuseForceIfIncludes"> push.useForceIfIncludes </dt> <dd> <p>If set to "true", it is equivalent to specifying <code>--force-if-includes</code> as an option to <a href="git-push">git-push[1]</a> in the command line. Adding <code>--no-force-if-includes</code> at the time of push overrides this configuration setting.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushnegotiate"> push.negotiate </dt> <dd> <p>If set to "true", attempt to reduce the size of the packfile sent by rounds of negotiation in which the client and the server attempt to find commits in common. If "false", Git will rely solely on the server’s ref advertisement to find commits in common.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-pushuseBitmaps"> push.useBitmaps </dt> <dd> <p>If set to "false", disable use of bitmaps for "git push" even if <code>pack.useBitmaps</code> is "true", without preventing other git operations from using bitmaps. Default is true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-rebasebackend"> rebase.backend </dt> <dd> <p>Default backend to use for rebasing. Possible choices are <code>apply</code> or <code>merge</code>. In the future, if the merge backend gains all remaining capabilities of the apply backend, this setting may become unused.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-rebasestat"> rebase.stat </dt> <dd> <p>Whether to show a diffstat of what changed upstream since the last rebase. False by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-rebaseautoSquash"> rebase.autoSquash </dt> <dd> <p>If set to true enable <code>--autosquash</code> option by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-rebaseautoStash"> rebase.autoStash </dt> <dd> <p>When set to true, automatically create a temporary stash entry before the operation begins, and apply it after the operation ends. This means that you can run rebase on a dirty worktree. However, use with care: the final stash application after a successful rebase might result in non-trivial conflicts. This option can be overridden by the <code>--no-autostash</code> and <code>--autostash</code> options of <a href="git-rebase">git-rebase[1]</a>. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-rebaseupdateRefs"> rebase.updateRefs </dt> <dd> <p>If set to true enable <code>--update-refs</code> option by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-rebasemissingCommitsCheck"> rebase.missingCommitsCheck </dt> <dd> <p>If set to "warn", git rebase -i will print a warning if some commits are removed (e.g. a line was deleted), however the rebase will still proceed. If set to "error", it will print the previous warning and stop the rebase, <code>git rebase --edit-todo</code> can then be used to correct the error. If set to "ignore", no checking is done. To drop a commit without warning or error, use the <code>drop</code> command in the todo list. Defaults to "ignore".</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-rebaseinstructionFormat"> rebase.instructionFormat </dt> <dd> <p>A format string, as specified in <a href="git-log">git-log[1]</a>, to be used for the todo list during an interactive rebase. The format will automatically have the commit hash prepended to the format.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-rebaseabbreviateCommands"> rebase.abbreviateCommands </dt> <dd> <p>If set to true, <code>git rebase</code> will use abbreviated command names in the todo list resulting in something like this:</p> <div class="listingblock"> <div class="content"> <pre> p deadbee The oneline of the commit + p fa1afe1 The oneline of the next commit + ...</pre> </div> </div> <p>instead of:</p> <div class="listingblock"> <div class="content"> <pre> pick deadbee The oneline of the commit + pick fa1afe1 The oneline of the next commit + ...</pre> </div> </div> <p>Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-rebaserescheduleFailedExec"> rebase.rescheduleFailedExec </dt> <dd> <p>Automatically reschedule <code>exec</code> commands that failed. This only makes sense in interactive mode (or when an <code>--exec</code> option was provided). This is the same as specifying the <code>--reschedule-failed-exec</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-rebaseforkPoint"> rebase.forkPoint </dt> <dd> <p>If set to false set <code>--no-fork-point</code> option by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-rebaserebaseMerges"> rebase.rebaseMerges </dt> <dd> <p>Whether and how to set the <code>--rebase-merges</code> option by default. Can be <code>rebase-cousins</code>, <code>no-rebase-cousins</code>, or a boolean. Setting to true or to <code>no-rebase-cousins</code> is equivalent to <code>--rebase-merges=no-rebase-cousins</code>, setting to <code>rebase-cousins</code> is equivalent to <code>--rebase-merges=rebase-cousins</code>, and setting to false is equivalent to <code>--no-rebase-merges</code>. Passing <code>--rebase-merges</code> on the command line, with or without an argument, overrides any <code>rebase.rebaseMerges</code> configuration.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-rebasemaxLabelLength"> rebase.maxLabelLength </dt> <dd> <p>When generating label names from commit subjects, truncate the names to this length. By default, the names are truncated to a little less than <code>NAME_MAX</code> (to allow e.g. <code>.lock</code> files to be written for the corresponding loose refs).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receiveadvertiseAtomic"> receive.advertiseAtomic </dt> <dd> <p>By default, git-receive-pack will advertise the atomic push capability to its clients. If you don’t want to advertise this capability, set this variable to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receiveadvertisePushOptions"> receive.advertisePushOptions </dt> <dd> <p>When set to true, git-receive-pack will advertise the push options capability to its clients. False by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receiveautogc"> receive.autogc </dt> <dd> <p>By default, git-receive-pack will run "git-gc --auto" after receiving data from git-push and updating refs. You can stop it by setting this variable to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receivecertNonceSeed"> receive.certNonceSeed </dt> <dd> <p>By setting this variable to a string, <code>git receive-pack</code> will accept a <code>git push --signed</code> and verify it by using a "nonce" protected by HMAC using this string as a secret key.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receivecertNonceSlop"> receive.certNonceSlop </dt> <dd> <p>When a <code>git push --signed</code> sends a push certificate with a "nonce" that was issued by a receive-pack serving the same repository within this many seconds, export the "nonce" found in the certificate to <code>GIT_PUSH_CERT_NONCE</code> to the hooks (instead of what the receive-pack asked the sending side to include). This may allow writing checks in <code>pre-receive</code> and <code>post-receive</code> a bit easier. Instead of checking <code>GIT_PUSH_CERT_NONCE_SLOP</code> environment variable that records by how many seconds the nonce is stale to decide if they want to accept the certificate, they only can check <code>GIT_PUSH_CERT_NONCE_STATUS</code> is <code>OK</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receivefsckObjects"> receive.fsckObjects </dt> <dd> <p>If it is set to true, git-receive-pack will check all received objects. See <code>transfer.fsckObjects</code> for what’s checked. Defaults to false. If not set, the value of <code>transfer.fsckObjects</code> is used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receivefsckltmsg-idgt"> receive.fsck.<msg-id> </dt> <dd> <p>Acts like <code>fsck.<msg-id></code>, but is used by <a href="git-receive-pack">git-receive-pack[1]</a> instead of <a href="git-fsck">git-fsck[1]</a>. See the <code>fsck.<msg-id></code> documentation for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receivefsckskipList"> receive.fsck.skipList </dt> <dd> <p>Acts like <code>fsck.skipList</code>, but is used by <a href="git-receive-pack">git-receive-pack[1]</a> instead of <a href="git-fsck">git-fsck[1]</a>. See the <code>fsck.skipList</code> documentation for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receivekeepAlive"> receive.keepAlive </dt> <dd> <p>After receiving the pack from the client, <code>receive-pack</code> may produce no output (if <code>--quiet</code> was specified) while processing the pack, causing some networks to drop the TCP connection. With this option set, if <code>receive-pack</code> does not transmit any data in this phase for <code>receive.keepAlive</code> seconds, it will send a short keepalive packet. The default is 5 seconds; set to 0 to disable keepalives entirely.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receiveunpackLimit"> receive.unpackLimit </dt> <dd> <p>If the number of objects received in a push is below this limit then the objects will be unpacked into loose object files. However if the number of received objects equals or exceeds this limit then the received pack will be stored as a pack, after adding any missing delta bases. Storing the pack from a push can make the push operation complete faster, especially on slow filesystems. If not set, the value of <code>transfer.unpackLimit</code> is used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receivemaxInputSize"> receive.maxInputSize </dt> <dd> <p>If the size of the incoming pack stream is larger than this limit, then git-receive-pack will error out, instead of accepting the pack file. If not set or set to 0, then the size is unlimited.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receivedenyDeletes"> receive.denyDeletes </dt> <dd> <p>If set to true, git-receive-pack will deny a ref update that deletes the ref. Use this to prevent such a ref deletion via a push.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receivedenyDeleteCurrent"> receive.denyDeleteCurrent </dt> <dd> <p>If set to true, git-receive-pack will deny a ref update that deletes the currently checked out branch of a non-bare repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receivedenyCurrentBranch"> receive.denyCurrentBranch </dt> <dd> <p>If set to true or "refuse", git-receive-pack will deny a ref update to the currently checked out branch of a non-bare repository. Such a push is potentially dangerous because it brings the HEAD out of sync with the index and working tree. If set to "warn", print a warning of such a push to stderr, but allow the push to proceed. If set to false or "ignore", allow such pushes with no message. Defaults to "refuse".</p> <p>Another option is "updateInstead" which will update the working tree if pushing into the current branch. This option is intended for synchronizing working directories when one side is not easily accessible via interactive ssh (e.g. a live web site, hence the requirement that the working directory be clean). This mode also comes in handy when developing inside a VM to test and fix code on different Operating Systems.</p> <p>By default, "updateInstead" will refuse the push if the working tree or the index have any difference from the HEAD, but the <code>push-to-checkout</code> hook can be used to customize this. See <a href="githooks">githooks[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receivedenyNonFastForwards"> receive.denyNonFastForwards </dt> <dd> <p>If set to true, git-receive-pack will deny a ref update which is not a fast-forward. Use this to prevent such an update via a push, even if that push is forced. This configuration variable is set when initializing a shared repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receivehideRefs"> receive.hideRefs </dt> <dd> <p>This variable is the same as <code>transfer.hideRefs</code>, but applies only to <code>receive-pack</code> (and so affects pushes, but not fetches). An attempt to update or delete a hidden ref by <code>git push</code> is rejected.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receiveprocReceiveRefs"> receive.procReceiveRefs </dt> <dd> <p>This is a multi-valued variable that defines reference prefixes to match the commands in <code>receive-pack</code>. Commands matching the prefixes will be executed by an external hook "proc-receive", instead of the internal <code>execute_commands</code> function. If this variable is not defined, the "proc-receive" hook will never be used, and all commands will be executed by the internal <code>execute_commands</code> function.</p> <p>For example, if this variable is set to "refs/for", pushing to reference such as "refs/for/master" will not create or update a reference named "refs/for/master", but may create or update a pull request directly by running the hook "proc-receive".</p> <p>Optional modifiers can be provided in the beginning of the value to filter commands for specific actions: create (a), modify (m), delete (d). A <code>!</code> can be included in the modifiers to negate the reference prefix entry. E.g.:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git config --system --add receive.procReceiveRefs ad:refs/heads +git config --system --add receive.procReceiveRefs !:refs/heads</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receiveupdateServerInfo"> receive.updateServerInfo </dt> <dd> <p>If set to true, git-receive-pack will run git-update-server-info after receiving data from git-push and updating refs.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-receiveshallowUpdate"> receive.shallowUpdate </dt> <dd> <p>If set to true, .git/shallow can be updated when new refs require new shallow roots. Otherwise those refs are rejected.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remotepushDefault"> remote.pushDefault </dt> <dd> <p>The remote to push to by default. Overrides <code>branch.<name>.remote</code> for all branches, and is overridden by <code>branch.<name>.pushRemote</code> for specific branches.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegturl"> remote.<name>.url </dt> <dd> <p>The URL of a remote repository. See <a href="git-fetch">git-fetch[1]</a> or <a href="git-push">git-push[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegtpushurl"> remote.<name>.pushurl </dt> <dd> <p>The push URL of a remote repository. See <a href="git-push">git-push[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegtproxy"> remote.<name>.proxy </dt> <dd> <p>For remotes that require curl (http, https and ftp), the URL to the proxy to use for that remote. Set to the empty string to disable proxying for that remote.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegtproxyAuthMethod"> remote.<name>.proxyAuthMethod </dt> <dd> <p>For remotes that require curl (http, https and ftp), the method to use for authenticating against the proxy in use (probably set in <code>remote.<name>.proxy</code>). See <code>http.proxyAuthMethod</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegtfetch"> remote.<name>.fetch </dt> <dd> <p>The default set of "refspec" for <a href="git-fetch">git-fetch[1]</a>. See <a href="git-fetch">git-fetch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegtpush"> remote.<name>.push </dt> <dd> <p>The default set of "refspec" for <a href="git-push">git-push[1]</a>. See <a href="git-push">git-push[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegtmirror"> remote.<name>.mirror </dt> <dd> <p>If true, pushing to this remote will automatically behave as if the <code>--mirror</code> option was given on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegtskipDefaultUpdate"> remote.<name>.skipDefaultUpdate </dt> <dd> <p>If true, this remote will be skipped by default when updating using <a href="git-fetch">git-fetch[1]</a> or the <code>update</code> subcommand of <a href="git-remote">git-remote[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegtskipFetchAll"> remote.<name>.skipFetchAll </dt> <dd> <p>If true, this remote will be skipped by default when updating using <a href="git-fetch">git-fetch[1]</a> or the <code>update</code> subcommand of <a href="git-remote">git-remote[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegtreceivepack"> remote.<name>.receivepack </dt> <dd> <p>The default program to execute on the remote side when pushing. See option --receive-pack of <a href="git-push">git-push[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegtuploadpack"> remote.<name>.uploadpack </dt> <dd> <p>The default program to execute on the remote side when fetching. See option --upload-pack of <a href="git-fetch-pack">git-fetch-pack[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegttagOpt"> remote.<name>.tagOpt </dt> <dd> <p>Setting this value to --no-tags disables automatic tag following when fetching from remote <name>. Setting it to --tags will fetch every tag from remote <name>, even if they are not reachable from remote branch heads. Passing these flags directly to <a href="git-fetch">git-fetch[1]</a> can override this setting. See options --tags and --no-tags of <a href="git-fetch">git-fetch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegtvcs"> remote.<name>.vcs </dt> <dd> <p>Setting this to a value <vcs> will cause Git to interact with the remote with the git-remote-<vcs> helper.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegtprune"> remote.<name>.prune </dt> <dd> <p>When set to true, fetching from this remote by default will also remove any remote-tracking references that no longer exist on the remote (as if the <code>--prune</code> option was given on the command line). Overrides <code>fetch.prune</code> settings, if any.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegtpruneTags"> remote.<name>.pruneTags </dt> <dd> <p>When set to true, fetching from this remote by default will also remove any local tags that no longer exist on the remote if pruning is activated in general via <code>remote.<name>.prune</code>, <code>fetch.prune</code> or <code>--prune</code>. Overrides <code>fetch.pruneTags</code> settings, if any.</p> <p>See also <code>remote.<name>.prune</code> and the PRUNING section of <a href="git-fetch">git-fetch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegtpromisor"> remote.<name>.promisor </dt> <dd> <p>When set to true, this remote will be used to fetch promisor objects.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remoteltnamegtpartialclonefilter"> remote.<name>.partialclonefilter </dt> <dd> <p>The filter that will be applied when fetching from this promisor remote. Changing or clearing this value will only affect fetches for new commits. To fetch associated objects for commits already present in the local object database, use the <code>--refetch</code> option of <a href="git-fetch">git-fetch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-remotesltgroupgt"> remotes.<group> </dt> <dd> <p>The list of remotes which are fetched by "git remote update <group>". See <a href="git-remote">git-remote[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-repackuseDeltaBaseOffset"> repack.useDeltaBaseOffset </dt> <dd> <p>By default, <a href="git-repack">git-repack[1]</a> creates packs that use delta-base offset. If you need to share your repository with Git older than version 1.4.4, either directly or via a dumb protocol such as http, then you need to set this option to "false" and repack. Access from old Git versions over the native protocol are unaffected by this option.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-repackpackKeptObjects"> repack.packKeptObjects </dt> <dd> <p>If set to true, makes <code>git repack</code> act as if <code>--pack-kept-objects</code> was passed. See <a href="git-repack">git-repack[1]</a> for details. Defaults to <code>false</code> normally, but <code>true</code> if a bitmap index is being written (either via <code>--write-bitmap-index</code> or <code>repack.writeBitmaps</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-repackuseDeltaIslands"> repack.useDeltaIslands </dt> <dd> <p>If set to true, makes <code>git repack</code> act as if <code>--delta-islands</code> was passed. Defaults to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-repackwriteBitmaps"> repack.writeBitmaps </dt> <dd> <p>When true, git will write a bitmap index when packing all objects to disk (e.g., when <code>git repack -a</code> is run). This index can speed up the "counting objects" phase of subsequent packs created for clones and fetches, at the cost of some disk space and extra time spent on the initial repack. This has no effect if multiple packfiles are created. Defaults to true on bare repos, false otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-repackupdateServerInfo"> repack.updateServerInfo </dt> <dd> <p>If set to false, <a href="git-repack">git-repack[1]</a> will not run <a href="git-update-server-info">git-update-server-info[1]</a>. Defaults to true. Can be overridden when true by the <code>-n</code> option of <a href="git-repack">git-repack[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-repackcruftWindow"> repack.cruftWindow </dt> <dt class="hdlist1" id="Documentation/git-config.txt-repackcruftWindowMemory"> repack.cruftWindowMemory </dt> <dt class="hdlist1" id="Documentation/git-config.txt-repackcruftDepth"> repack.cruftDepth </dt> <dt class="hdlist1" id="Documentation/git-config.txt-repackcruftThreads"> repack.cruftThreads </dt> <dd> <p>Parameters used by <a href="git-pack-objects">git-pack-objects[1]</a> when generating a cruft pack and the respective parameters are not given over the command line. See similarly named <code>pack.*</code> configuration variables for defaults and meaning.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-rerereautoUpdate"> rerere.autoUpdate </dt> <dd> <p>When set to true, <code>git-rerere</code> updates the index with the resulting contents after it cleanly resolves conflicts using previously recorded resolutions. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-rerereenabled"> rerere.enabled </dt> <dd> <p>Activate recording of resolved conflicts, so that identical conflict hunks can be resolved automatically, should they be encountered again. By default, <a href="git-rerere">git-rerere[1]</a> is enabled if there is an <code>rr-cache</code> directory under the <code>$GIT_DIR</code>, e.g. if "rerere" was previously used in the repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-revertreference"> revert.reference </dt> <dd> <p>Setting this variable to true makes <code>git revert</code> behave as if the <code>--reference</code> option is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-safebareRepository"> safe.bareRepository </dt> <dd> <p>Specifies which bare repositories Git will work with. The currently supported values are:</p> <div class="ulist"> <ul> <li> <p><code>all</code>: Git works with all bare repositories. This is the default.</p> </li> <li> <p><code>explicit</code>: Git only works with bare repositories specified via the top-level <code>--git-dir</code> command-line option, or the <code>GIT_DIR</code> environment variable (see <a href="git">git[1]</a>).</p> <p>If you do not use bare repositories in your workflow, then it may be beneficial to set <code>safe.bareRepository</code> to <code>explicit</code> in your global config. This will protect you from attacks that involve cloning a repository that contains a bare repository and running a Git command within that directory.</p> <p>This config setting is only respected in protected configuration (see <a href="#SCOPES">SCOPES</a>). This prevents untrusted repositories from tampering with this value.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-safedirectory"> safe.directory </dt> <dd> <p>These config entries specify Git-tracked directories that are considered safe even if they are owned by someone other than the current user. By default, Git will refuse to even parse a Git config of a repository owned by someone else, let alone run its hooks, and this config setting allows users to specify exceptions, e.g. for intentionally shared repositories (see the <code>--shared</code> option in <a href="git-init">git-init[1]</a>).</p> <p>This is a multi-valued setting, i.e. you can add more than one directory via <code>git config --add</code>. To reset the list of safe directories (e.g. to override any such directories specified in the system config), add a <code>safe.directory</code> entry with an empty value.</p> <p>This config setting is only respected in protected configuration (see <a href="#SCOPES">SCOPES</a>). This prevents untrusted repositories from tampering with this value.</p> <p>The value of this setting is interpolated, i.e. <code>~/<path></code> expands to a path relative to the home directory and <code>%(prefix)/<path></code> expands to a path relative to Git’s (runtime) prefix.</p> <p>To completely opt-out of this security check, set <code>safe.directory</code> to the string <code>*</code>. This will allow all repositories to be treated as if their directory was listed in the <code>safe.directory</code> list. If <code>safe.directory=*</code> is set in system config and you want to re-enable this protection, then initialize your list with an empty value before listing the repositories that you deem safe.</p> <p>As explained, Git only allows you to access repositories owned by yourself, i.e. the user who is running Git, by default. When Git is running as <code>root</code> in a non Windows platform that provides sudo, however, git checks the SUDO_UID environment variable that sudo creates and will allow access to the uid recorded as its value in addition to the id from <code>root</code>. This is to make it easy to perform a common sequence during installation "make && sudo make install". A git process running under <code>sudo</code> runs as <code>root</code> but the <code>sudo</code> command exports the environment variable to record which id the original user has. If that is not what you would prefer and want git to only trust repositories that are owned by root instead, then you can remove the <code>SUDO_UID</code> variable from root’s environment before invoking git.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailidentity"> sendemail.identity </dt> <dd> <p>A configuration identity. When given, causes values in the <code>sendemail.<identity></code> subsection to take precedence over values in the <code>sendemail</code> section. The default identity is the value of <code>sendemail.identity</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailsmtpEncryption"> sendemail.smtpEncryption </dt> <dd> <p>See <a href="git-send-email">git-send-email[1]</a> for description. Note that this setting is not subject to the <code>identity</code> mechanism.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailsmtpsslcertpath"> sendemail.smtpsslcertpath </dt> <dd> <p>Path to ca-certificates (either a directory or a single file). Set it to an empty string to disable certificate verification.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailltidentitygt"> sendemail.<identity>.* </dt> <dd> <p>Identity-specific versions of the <code>sendemail.*</code> parameters found below, taking precedence over those when this identity is selected, through either the command-line or <code>sendemail.identity</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailmultiEdit"> sendemail.multiEdit </dt> <dd> <p>If true (default), a single editor instance will be spawned to edit files you have to edit (patches when <code>--annotate</code> is used, and the summary when <code>--compose</code> is used). If false, files will be edited one after the other, spawning a new editor each time.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailconfirm"> sendemail.confirm </dt> <dd> <p>Sets the default for whether to confirm before sending. Must be one of <code>always</code>, <code>never</code>, <code>cc</code>, <code>compose</code>, or <code>auto</code>. See <code>--confirm</code> in the <a href="git-send-email">git-send-email[1]</a> documentation for the meaning of these values.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailaliasesFile"> sendemail.aliasesFile </dt> <dd> <p>To avoid typing long email addresses, point this to one or more email aliases files. You must also supply <code>sendemail.aliasFileType</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailaliasFileType"> sendemail.aliasFileType </dt> <dd> <p>Format of the file(s) specified in sendemail.aliasesFile. Must be one of <code>mutt</code>, <code>mailrc</code>, <code>pine</code>, <code>elm</code>, <code>gnus</code>, or <code>sendmail</code>.</p> <p>What an alias file in each format looks like can be found in the documentation of the email program of the same name. The differences and limitations from the standard formats are described below:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-sendmail"> sendmail </dt> <dd> <div class="ulist"> <ul> <li> <p>Quoted aliases and quoted addresses are not supported: lines that contain a <code>"</code> symbol are ignored.</p> </li> <li> <p>Redirection to a file (<code>/path/name</code>) or pipe (<code>|command</code>) is not supported.</p> </li> <li> <p>File inclusion (<code>:include: /path/name</code>) is not supported.</p> </li> <li> <p>Warnings are printed on the standard error output for any explicitly unsupported constructs, and any other lines that are not recognized by the parser.</p> </li> </ul> </div> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailannotate"> sendemail.annotate </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailbcc"> sendemail.bcc </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailcc"> sendemail.cc </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailccCmd"> sendemail.ccCmd </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailchainReplyTo"> sendemail.chainReplyTo </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailenvelopeSender"> sendemail.envelopeSender </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailfrom"> sendemail.from </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailheaderCmd"> sendemail.headerCmd </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailsignedoffbycc"> sendemail.signedoffbycc </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailsmtpPass"> sendemail.smtpPass </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailsuppresscc"> sendemail.suppresscc </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailsuppressFrom"> sendemail.suppressFrom </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailto"> sendemail.to </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailtocmd"> sendemail.tocmd </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailsmtpDomain"> sendemail.smtpDomain </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailsmtpServer"> sendemail.smtpServer </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailsmtpServerPort"> sendemail.smtpServerPort </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailsmtpServerOption"> sendemail.smtpServerOption </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailsmtpUser"> sendemail.smtpUser </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailthread"> sendemail.thread </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailtransferEncoding"> sendemail.transferEncoding </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailvalidate"> sendemail.validate </dt> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailxmailer"> sendemail.xmailer </dt> <dd> <p>These configuration variables all provide a default for <a href="git-send-email">git-send-email[1]</a> command-line options. See its documentation for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailsignedoffccdeprecated"> sendemail.signedoffcc (deprecated) </dt> <dd> <p>Deprecated alias for <code>sendemail.signedoffbycc</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailsmtpBatchSize"> sendemail.smtpBatchSize </dt> <dd> <p>Number of messages to be sent per connection, after that a relogin will happen. If the value is 0 or undefined, send all messages in one connection. See also the <code>--batch-size</code> option of <a href="git-send-email">git-send-email[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailsmtpReloginDelay"> sendemail.smtpReloginDelay </dt> <dd> <p>Seconds to wait before reconnecting to the smtp server. See also the <code>--relogin-delay</code> option of <a href="git-send-email">git-send-email[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sendemailforbidSendmailVariables"> sendemail.forbidSendmailVariables </dt> <dd> <p>To avoid common misconfiguration mistakes, <a href="git-send-email">git-send-email[1]</a> will abort with a warning if any configuration options for "sendmail" exist. Set this variable to bypass the check.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sequenceeditor"> sequence.editor </dt> <dd> <p>Text editor used by <code>git rebase -i</code> for editing the rebase instruction file. The value is meant to be interpreted by the shell when it is used. It can be overridden by the <code>GIT_SEQUENCE_EDITOR</code> environment variable. When not configured, the default commit message editor is used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-showBranchdefault"> showBranch.default </dt> <dd> <p>The default set of branches for <a href="git-show-branch">git-show-branch[1]</a>. See <a href="git-show-branch">git-show-branch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sparseexpectFilesOutsideOfPatterns"> sparse.expectFilesOutsideOfPatterns </dt> <dd> <p>Typically with sparse checkouts, files not matching any sparsity patterns are marked with a SKIP_WORKTREE bit in the index and are missing from the working tree. Accordingly, Git will ordinarily check whether files with the SKIP_WORKTREE bit are in fact present in the working tree contrary to expectations. If Git finds any, it marks those paths as present by clearing the relevant SKIP_WORKTREE bits. This option can be used to tell Git that such present-despite-skipped files are expected and to stop checking for them.</p> <p>The default is <code>false</code>, which allows Git to automatically recover from the list of files in the index and working tree falling out of sync.</p> <p>Set this to <code>true</code> if you are in a setup where some external factor relieves Git of the responsibility for maintaining the consistency between the presence of working tree files and sparsity patterns. For example, if you have a Git-aware virtual file system that has a robust mechanism for keeping the working tree and the sparsity patterns up to date based on access patterns.</p> <p>Regardless of this setting, Git does not check for present-despite-skipped files unless sparse checkout is enabled, so this config option has no effect unless <code>core.sparseCheckout</code> is <code>true</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-splitIndexmaxPercentChange"> splitIndex.maxPercentChange </dt> <dd> <p>When the split index feature is used, this specifies the percent of entries the split index can contain compared to the total number of entries in both the split index and the shared index before a new shared index is written. The value should be between 0 and 100. If the value is 0, then a new shared index is always written; if it is 100, a new shared index is never written. By default, the value is 20, so a new shared index is written if the number of entries in the split index would be greater than 20 percent of the total number of entries. See <a href="git-update-index">git-update-index[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-splitIndexsharedIndexExpire"> splitIndex.sharedIndexExpire </dt> <dd> <p>When the split index feature is used, shared index files that were not modified since the time this variable specifies will be removed when a new shared index file is created. The value "now" expires all entries immediately, and "never" suppresses expiration altogether. The default value is "2.weeks.ago". Note that a shared index file is considered modified (for the purpose of expiration) each time a new split-index file is either created based on it or read from it. See <a href="git-update-index">git-update-index[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-sshvariant"> ssh.variant </dt> <dd> <p>By default, Git determines the command line arguments to use based on the basename of the configured SSH command (configured using the environment variable <code>GIT_SSH</code> or <code>GIT_SSH_COMMAND</code> or the config setting <code>core.sshCommand</code>). If the basename is unrecognized, Git will attempt to detect support of OpenSSH options by first invoking the configured SSH command with the <code>-G</code> (print configuration) option and will subsequently use OpenSSH options (if that is successful) or no options besides the host and remote command (if it fails).</p> <p>The config variable <code>ssh.variant</code> can be set to override this detection. Valid values are <code>ssh</code> (to use OpenSSH options), <code>plink</code>, <code>putty</code>, <code>tortoiseplink</code>, <code>simple</code> (no options except the host and remote command). The default auto-detection can be explicitly requested using the value <code>auto</code>. Any other value is treated as <code>ssh</code>. This setting can also be overridden via the environment variable <code>GIT_SSH_VARIANT</code>.</p> <p>The current command-line parameters used for each variant are as follows:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>ssh</code> - [-p port] [-4] [-6] [-o option] [username@]host command</p> </li> <li> <p><code>simple</code> - [username@]host command</p> </li> <li> <p><code>plink</code> or <code>putty</code> - [-P port] [-4] [-6] [username@]host command</p> </li> <li> <p><code>tortoiseplink</code> - [-P port] [-4] [-6] -batch [username@]host command</p> </li> </ul> </div> </div> </div> <p>Except for the <code>simple</code> variant, command-line parameters are likely to change as git gains new features.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-statusrelativePaths"> status.relativePaths </dt> <dd> <p>By default, <a href="git-status">git-status[1]</a> shows paths relative to the current directory. Setting this variable to <code>false</code> shows paths relative to the repository root (this was the default for Git prior to v1.5.4).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-statusshort"> status.short </dt> <dd> <p>Set to true to enable --short by default in <a href="git-status">git-status[1]</a>. The option --no-short takes precedence over this variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-statusbranch"> status.branch </dt> <dd> <p>Set to true to enable --branch by default in <a href="git-status">git-status[1]</a>. The option --no-branch takes precedence over this variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-statusaheadBehind"> status.aheadBehind </dt> <dd> <p>Set to true to enable <code>--ahead-behind</code> and false to enable <code>--no-ahead-behind</code> by default in <a href="git-status">git-status[1]</a> for non-porcelain status formats. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-statusdisplayCommentPrefix"> status.displayCommentPrefix </dt> <dd> <p>If set to true, <a href="git-status">git-status[1]</a> will insert a comment prefix before each output line (starting with <code>core.commentChar</code>, i.e. <code>#</code> by default). This was the behavior of <a href="git-status">git-status[1]</a> in Git 1.8.4 and previous. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-statusrenameLimit"> status.renameLimit </dt> <dd> <p>The number of files to consider when performing rename detection in <a href="git-status">git-status[1]</a> and <a href="git-commit">git-commit[1]</a>. Defaults to the value of diff.renameLimit.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-statusrenames"> status.renames </dt> <dd> <p>Whether and how Git detects renames in <a href="git-status">git-status[1]</a> and <a href="git-commit">git-commit[1]</a> . If set to "false", rename detection is disabled. If set to "true", basic rename detection is enabled. If set to "copies" or "copy", Git will detect copies, as well. Defaults to the value of diff.renames.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-statusshowStash"> status.showStash </dt> <dd> <p>If set to true, <a href="git-status">git-status[1]</a> will display the number of entries currently stashed away. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-statusshowUntrackedFiles"> status.showUntrackedFiles </dt> <dd> <p>By default, <a href="git-status">git-status[1]</a> and <a href="git-commit">git-commit[1]</a> show files which are not currently tracked by Git. Directories which contain only untracked files, are shown with the directory name only. Showing untracked files means that Git needs to lstat() all the files in the whole repository, which might be slow on some systems. So, this variable controls how the commands display the untracked files. Possible values are:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>no</code> - Show no untracked files.</p> </li> <li> <p><code>normal</code> - Show untracked files and directories.</p> </li> <li> <p><code>all</code> - Show also individual files in untracked directories.</p> </li> </ul> </div> </div> </div> <p>If this variable is not specified, it defaults to <code>normal</code>. This variable can be overridden with the -u|--untracked-files option of <a href="git-status">git-status[1]</a> and <a href="git-commit">git-commit[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-statussubmoduleSummary"> status.submoduleSummary </dt> <dd> <p>Defaults to false. If this is set to a non-zero number or true (identical to -1 or an unlimited number), the submodule summary will be enabled and a summary of commits for modified submodules will be shown (see --summary-limit option of <a href="git-submodule">git-submodule[1]</a>). Please note that the summary output command will be suppressed for all submodules when <code>diff.ignoreSubmodules</code> is set to <code>all</code> or only for those submodules where <code>submodule.<name>.ignore=all</code>. The only exception to that rule is that status and commit will show staged submodule changes. To also view the summary for ignored submodules you can either use the --ignore-submodules=dirty command-line option or the <code>git submodule summary</code> command, which shows a similar output but does not honor these settings.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-stashshowIncludeUntracked"> stash.showIncludeUntracked </dt> <dd> <p>If this is set to true, the <code>git stash show</code> command will show the untracked files of a stash entry. Defaults to false. See the description of the <code>show</code> command in <a href="git-stash">git-stash[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-stashshowPatch"> stash.showPatch </dt> <dd> <p>If this is set to true, the <code>git stash show</code> command without an option will show the stash entry in patch form. Defaults to false. See the description of the <code>show</code> command in <a href="git-stash">git-stash[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-stashshowStat"> stash.showStat </dt> <dd> <p>If this is set to true, the <code>git stash show</code> command without an option will show a diffstat of the stash entry. Defaults to true. See the description of the <code>show</code> command in <a href="git-stash">git-stash[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-submoduleltnamegturl"> submodule.<name>.url </dt> <dd> <p>The URL for a submodule. This variable is copied from the .gitmodules file to the git config via <code>git submodule init</code>. The user can change the configured URL before obtaining the submodule via <code>git submodule update</code>. If neither submodule.<name>.active nor submodule.active are set, the presence of this variable is used as a fallback to indicate whether the submodule is of interest to git commands. See <a href="git-submodule">git-submodule[1]</a> and <a href="gitmodules">gitmodules[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-submoduleltnamegtupdate"> submodule.<name>.update </dt> <dd> <p>The method by which a submodule is updated by <code>git submodule update</code>, which is the only affected command, others such as <code>git checkout --recurse-submodules</code> are unaffected. It exists for historical reasons, when <code>git submodule</code> was the only command to interact with submodules; settings like <code>submodule.active</code> and <code>pull.rebase</code> are more specific. It is populated by <code>git submodule init</code> from the <a href="gitmodules">gitmodules[5]</a> file. See description of <code>update</code> command in <a href="git-submodule">git-submodule[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-submoduleltnamegtbranch"> submodule.<name>.branch </dt> <dd> <p>The remote branch name for a submodule, used by <code>git submodule +update --remote</code>. Set this option to override the value found in the <code>.gitmodules</code> file. See <a href="git-submodule">git-submodule[1]</a> and <a href="gitmodules">gitmodules[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-submoduleltnamegtfetchRecurseSubmodules"> submodule.<name>.fetchRecurseSubmodules </dt> <dd> <p>This option can be used to control recursive fetching of this submodule. It can be overridden by using the --[no-]recurse-submodules command-line option to "git fetch" and "git pull". This setting will override that from in the <a href="gitmodules">gitmodules[5]</a> file.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-submoduleltnamegtignore"> submodule.<name>.ignore </dt> <dd> <p>Defines under what circumstances "git status" and the diff family show a submodule as modified. When set to "all", it will never be considered modified (but it will nonetheless show up in the output of status and commit when it has been staged), "dirty" will ignore all changes to the submodule’s work tree and takes only differences between the HEAD of the submodule and the commit recorded in the superproject into account. "untracked" will additionally let submodules with modified tracked files in their work tree show up. Using "none" (the default when this option is not set) also shows submodules that have untracked files in their work tree as changed. This setting overrides any setting made in .gitmodules for this submodule, both settings can be overridden on the command line by using the "--ignore-submodules" option. The <code>git submodule</code> commands are not affected by this setting.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-submoduleltnamegtactive"> submodule.<name>.active </dt> <dd> <p>Boolean value indicating if the submodule is of interest to git commands. This config option takes precedence over the submodule.active config option. See <a href="gitsubmodules">gitsubmodules[7]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-submoduleactive"> submodule.active </dt> <dd> <p>A repeated field which contains a pathspec used to match against a submodule’s path to determine if the submodule is of interest to git commands. See <a href="gitsubmodules">gitsubmodules[7]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-submodulerecurse"> submodule.recurse </dt> <dd> <p>A boolean indicating if commands should enable the <code>--recurse-submodules</code> option by default. Defaults to false.</p> <p>When set to true, it can be deactivated via the <code>--no-recurse-submodules</code> option. Note that some Git commands lacking this option may call some of the above commands affected by <code>submodule.recurse</code>; for instance <code>git remote update</code> will call <code>git fetch</code> but does not have a <code>--no-recurse-submodules</code> option. For these commands a workaround is to temporarily change the configuration value by using <code>git -c submodule.recurse=0</code>.</p> <p>The following list shows the commands that accept <code>--recurse-submodules</code> and whether they are supported by this setting.</p> <div class="ulist"> <ul> <li> <p><code>checkout</code>, <code>fetch</code>, <code>grep</code>, <code>pull</code>, <code>push</code>, <code>read-tree</code>, <code>reset</code>, <code>restore</code> and <code>switch</code> are always supported.</p> </li> <li> <p><code>clone</code> and <code>ls-files</code> are not supported.</p> </li> <li> <p><code>branch</code> is supported only if <code>submodule.propagateBranches</code> is enabled</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-submodulepropagateBranches"> submodule.propagateBranches </dt> <dd> <p>[EXPERIMENTAL] A boolean that enables branching support when using <code>--recurse-submodules</code> or <code>submodule.recurse=true</code>. Enabling this will allow certain commands to accept <code>--recurse-submodules</code> and certain commands that already accept <code>--recurse-submodules</code> will now consider branches. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-submodulefetchJobs"> submodule.fetchJobs </dt> <dd> <p>Specifies how many submodules are fetched/cloned at the same time. A positive integer allows up to that number of submodules fetched in parallel. A value of 0 will give some reasonable default. If unset, it defaults to 1.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-submodulealternateLocation"> submodule.alternateLocation </dt> <dd> <p>Specifies how the submodules obtain alternates when submodules are cloned. Possible values are <code>no</code>, <code>superproject</code>. By default <code>no</code> is assumed, which doesn’t add references. When the value is set to <code>superproject</code> the submodule to be cloned computes its alternates location relative to the superprojects alternate.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-submodulealternateErrorStrategy"> submodule.alternateErrorStrategy </dt> <dd> <p>Specifies how to treat errors with the alternates for a submodule as computed via <code>submodule.alternateLocation</code>. Possible values are <code>ignore</code>, <code>info</code>, <code>die</code>. Default is <code>die</code>. Note that if set to <code>ignore</code> or <code>info</code>, and if there is an error with the computed alternate, the clone proceeds as if no alternate was specified.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-tagforceSignAnnotated"> tag.forceSignAnnotated </dt> <dd> <p>A boolean to specify whether annotated tags created should be GPG signed. If <code>--annotate</code> is specified on the command line, it takes precedence over this option.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-tagsort"> tag.sort </dt> <dd> <p>This variable controls the sort ordering of tags when displayed by <a href="git-tag">git-tag[1]</a>. Without the "--sort=<value>" option provided, the value of this variable will be used as the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-taggpgSign"> tag.gpgSign </dt> <dd> <p>A boolean to specify whether all tags should be GPG signed. Use of this option when running in an automated script can result in a large number of tags being signed. It is therefore convenient to use an agent to avoid typing your gpg passphrase several times. Note that this option doesn’t affect tag signing behavior enabled by "-u <keyid>" or "--local-user=<keyid>" options.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-tarumask"> tar.umask </dt> <dd> <p>This variable can be used to restrict the permission bits of tar archive entries. The default is 0002, which turns off the world write bit. The special value "user" indicates that the archiving user’s umask will be used instead. See umask(2) and <a href="git-archive">git-archive[1]</a>.</p> </dd> </dl> </div> <p>Trace2 config settings are only read from the system and global config files; repository local and worktree config files and <code>-c</code> command line arguments are not respected.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-config.txt-trace2normalTarget"> trace2.normalTarget </dt> <dd> <p>This variable controls the normal target destination. It may be overridden by the <code>GIT_TRACE2</code> environment variable. The following table shows possible values.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-trace2perfTarget"> trace2.perfTarget </dt> <dd> <p>This variable controls the performance target destination. It may be overridden by the <code>GIT_TRACE2_PERF</code> environment variable. The following table shows possible values.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-trace2eventTarget"> trace2.eventTarget </dt> <dd> <p>This variable controls the event target destination. It may be overridden by the <code>GIT_TRACE2_EVENT</code> environment variable. The following table shows possible values.</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>0</code> or <code>false</code> - Disables the target.</p> </li> <li> <p><code>1</code> or <code>true</code> - Writes to <code>STDERR</code>.</p> </li> <li> <p><code>[2-9]</code> - Writes to the already opened file descriptor.</p> </li> <li> <p><code><absolute-pathname></code> - Writes to the file in append mode. If the target already exists and is a directory, the traces will be written to files (one per process) underneath the given directory.</p> </li> <li> <p><code>af_unix:[<socket_type>:]<absolute-pathname></code> - Write to a Unix DomainSocket (on platforms that support them). Socket type can be either <code>stream</code> or <code>dgram</code>; if omitted Git will try both.</p> </li> </ul> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-trace2normalBrief"> trace2.normalBrief </dt> <dd> <p>Boolean. When true <code>time</code>, <code>filename</code>, and <code>line</code> fields are omitted from normal output. May be overridden by the <code>GIT_TRACE2_BRIEF</code> environment variable. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-trace2perfBrief"> trace2.perfBrief </dt> <dd> <p>Boolean. When true <code>time</code>, <code>filename</code>, and <code>line</code> fields are omitted from PERF output. May be overridden by the <code>GIT_TRACE2_PERF_BRIEF</code> environment variable. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-trace2eventBrief"> trace2.eventBrief </dt> <dd> <p>Boolean. When true <code>time</code>, <code>filename</code>, and <code>line</code> fields are omitted from event output. May be overridden by the <code>GIT_TRACE2_EVENT_BRIEF</code> environment variable. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-trace2eventNesting"> trace2.eventNesting </dt> <dd> <p>Integer. Specifies desired depth of nested regions in the event output. Regions deeper than this value will be omitted. May be overridden by the <code>GIT_TRACE2_EVENT_NESTING</code> environment variable. Defaults to 2.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-trace2configParams"> trace2.configParams </dt> <dd> <p>A comma-separated list of patterns of "important" config settings that should be recorded in the trace2 output. For example, <code>core.*,remote.*.url</code> would cause the trace2 output to contain events listing each configured remote. May be overridden by the <code>GIT_TRACE2_CONFIG_PARAMS</code> environment variable. Unset by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-trace2envVars"> trace2.envVars </dt> <dd> <p>A comma-separated list of "important" environment variables that should be recorded in the trace2 output. For example, <code>GIT_HTTP_USER_AGENT,GIT_CONFIG</code> would cause the trace2 output to contain events listing the overrides for HTTP user agent and the location of the Git configuration file (assuming any are set). May be overridden by the <code>GIT_TRACE2_ENV_VARS</code> environment variable. Unset by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-trace2destinationDebug"> trace2.destinationDebug </dt> <dd> <p>Boolean. When true Git will print error messages when a trace target destination cannot be opened for writing. By default, these errors are suppressed and tracing is silently disabled. May be overridden by the <code>GIT_TRACE2_DST_DEBUG</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-trace2maxFiles"> trace2.maxFiles </dt> <dd> <p>Integer. When writing trace files to a target directory, do not write additional traces if doing so would exceed this many files. Instead, write a sentinel file that will block further tracing to this directory. Defaults to 0, which disables this check.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-transfercredentialsInUrl"> transfer.credentialsInUrl </dt> <dd> <p>A configured URL can contain plaintext credentials in the form <code><protocol>://<user>:<password>@<domain>/<path></code>. You may want to warn or forbid the use of such configuration (in favor of using <a href="git-credential">git-credential[1]</a>). This will be used on <a href="git-clone">git-clone[1]</a>, <a href="git-fetch">git-fetch[1]</a>, <a href="git-push">git-push[1]</a>, and any other direct use of the configured URL.</p> <p>Note that this is currently limited to detecting credentials in <code>remote.<name>.url</code> configuration; it won’t detect credentials in <code>remote.<name>.pushurl</code> configuration.</p> <p>You might want to enable this to prevent inadvertent credentials exposure, e.g. because:</p> <div class="ulist"> <ul> <li> <p>The OS or system where you’re running git may not provide a way or otherwise allow you to configure the permissions of the configuration file where the username and/or password are stored.</p> </li> <li> <p>Even if it does, having such data stored "at rest" might expose you in other ways, e.g. a backup process might copy the data to another system.</p> </li> <li> <p>The git programs will pass the full URL to one another as arguments on the command-line, meaning the credentials will be exposed to other unprivileged users on systems that allow them to see the full process list of other users. On linux the "hidepid" setting documented in procfs(5) allows for configuring this behavior.</p> <p>If such concerns don’t apply to you then you probably don’t need to be concerned about credentials exposure due to storing sensitive data in git’s configuration files. If you do want to use this, set <code>transfer.credentialsInUrl</code> to one of these values:</p> </li> <li> <p><code>allow</code> (default): Git will proceed with its activity without warning.</p> </li> <li> <p><code>warn</code>: Git will write a warning message to <code>stderr</code> when parsing a URL with a plaintext credential.</p> </li> <li> <p><code>die</code>: Git will write a failure message to <code>stderr</code> when parsing a URL with a plaintext credential.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-transferfsckObjects"> transfer.fsckObjects </dt> <dd> <p>When <code>fetch.fsckObjects</code> or <code>receive.fsckObjects</code> are not set, the value of this variable is used instead. Defaults to false.</p> <p>When set, the fetch or receive will abort in the case of a malformed object or a link to a nonexistent object. In addition, various other issues are checked for, including legacy issues (see <code>fsck.<msg-id></code>), and potential security issues like the existence of a <code>.GIT</code> directory or a malicious <code>.gitmodules</code> file (see the release notes for v2.2.1 and v2.17.1 for details). Other sanity and security checks may be added in future releases.</p> <p>On the receiving side, failing fsckObjects will make those objects unreachable, see "QUARANTINE ENVIRONMENT" in <a href="git-receive-pack">git-receive-pack[1]</a>. On the fetch side, malformed objects will instead be left unreferenced in the repository.</p> <p>Due to the non-quarantine nature of the <code>fetch.fsckObjects</code> implementation it cannot be relied upon to leave the object store clean like <code>receive.fsckObjects</code> can.</p> <p>As objects are unpacked they’re written to the object store, so there can be cases where malicious objects get introduced even though the "fetch" failed, only to have a subsequent "fetch" succeed because only new incoming objects are checked, not those that have already been written to the object store. That difference in behavior should not be relied upon. In the future, such objects may be quarantined for "fetch" as well.</p> <p>For now, the paranoid need to find some way to emulate the quarantine environment if they’d like the same protection as "push". E.g. in the case of an internal mirror do the mirroring in two steps, one to fetch the untrusted objects, and then do a second "push" (which will use the quarantine) to another internal repo, and have internal clients consume this pushed-to repository, or embargo internal fetches and only allow them once a full "fsck" has run (and no new fetches have happened in the meantime).</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-transferhideRefs"> transfer.hideRefs </dt> <dd> <p>String(s) <code>receive-pack</code> and <code>upload-pack</code> use to decide which refs to omit from their initial advertisements. Use more than one definition to specify multiple prefix strings. A ref that is under the hierarchies listed in the value of this variable is excluded, and is hidden when responding to <code>git push</code> or <code>git +fetch</code>. See <code>receive.hideRefs</code> and <code>uploadpack.hideRefs</code> for program-specific versions of this config.</p> <p>You may also include a <code>!</code> in front of the ref name to negate the entry, explicitly exposing it, even if an earlier entry marked it as hidden. If you have multiple hideRefs values, later entries override earlier ones (and entries in more-specific config files override less-specific ones).</p> <p>If a namespace is in use, the namespace prefix is stripped from each reference before it is matched against <code>transfer.hiderefs</code> patterns. In order to match refs before stripping, add a <code>^</code> in front of the ref name. If you combine <code>!</code> and <code>^</code>, <code>!</code> must be specified first.</p> <p>For example, if <code>refs/heads/master</code> is specified in <code>transfer.hideRefs</code> and the current namespace is <code>foo</code>, then <code>refs/namespaces/foo/refs/heads/master</code> is omitted from the advertisements. If <code>uploadpack.allowRefInWant</code> is set, <code>upload-pack</code> will treat <code>want-ref refs/heads/master</code> in a protocol v2 <code>fetch</code> command as if <code>refs/namespaces/foo/refs/heads/master</code> did not exist. <code>receive-pack</code>, on the other hand, will still advertise the object id the ref is pointing to without mentioning its name (a so-called ".have" line).</p> <p>Even if you hide refs, a client may still be able to steal the target objects via the techniques described in the "SECURITY" section of the <a href="gitnamespaces">gitnamespaces[7]</a> man page; it’s best to keep private data in a separate repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-transferunpackLimit"> transfer.unpackLimit </dt> <dd> <p>When <code>fetch.unpackLimit</code> or <code>receive.unpackLimit</code> are not set, the value of this variable is used instead. The default value is 100.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-transferadvertiseSID"> transfer.advertiseSID </dt> <dd> <p>Boolean. When true, client and server processes will advertise their unique session IDs to their remote counterpart. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-transferbundleURI"> transfer.bundleURI </dt> <dd> <p>When <code>true</code>, local <code>git clone</code> commands will request bundle information from the remote server (if advertised) and download bundles before continuing the clone through the Git protocol. Defaults to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-uploadarchiveallowUnreachable"> uploadarchive.allowUnreachable </dt> <dd> <p>If true, allow clients to use <code>git archive --remote</code> to request any tree, whether reachable from the ref tips or not. See the discussion in the "SECURITY" section of <a href="git-upload-archive">git-upload-archive[1]</a> for more details. Defaults to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-uploadpackhideRefs"> uploadpack.hideRefs </dt> <dd> <p>This variable is the same as <code>transfer.hideRefs</code>, but applies only to <code>upload-pack</code> (and so affects only fetches, not pushes). An attempt to fetch a hidden ref by <code>git fetch</code> will fail. See also <code>uploadpack.allowTipSHA1InWant</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-uploadpackallowTipSHA1InWant"> uploadpack.allowTipSHA1InWant </dt> <dd> <p>When <code>uploadpack.hideRefs</code> is in effect, allow <code>upload-pack</code> to accept a fetch request that asks for an object at the tip of a hidden ref (by default, such a request is rejected). See also <code>uploadpack.hideRefs</code>. Even if this is false, a client may be able to steal objects via the techniques described in the "SECURITY" section of the <a href="gitnamespaces">gitnamespaces[7]</a> man page; it’s best to keep private data in a separate repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-uploadpackallowReachableSHA1InWant"> uploadpack.allowReachableSHA1InWant </dt> <dd> <p>Allow <code>upload-pack</code> to accept a fetch request that asks for an object that is reachable from any ref tip. However, note that calculating object reachability is computationally expensive. Defaults to <code>false</code>. Even if this is false, a client may be able to steal objects via the techniques described in the "SECURITY" section of the <a href="gitnamespaces">gitnamespaces[7]</a> man page; it’s best to keep private data in a separate repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-uploadpackallowAnySHA1InWant"> uploadpack.allowAnySHA1InWant </dt> <dd> <p>Allow <code>upload-pack</code> to accept a fetch request that asks for any object at all. Defaults to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-uploadpackkeepAlive"> uploadpack.keepAlive </dt> <dd> <p>When <code>upload-pack</code> has started <code>pack-objects</code>, there may be a quiet period while <code>pack-objects</code> prepares the pack. Normally it would output progress information, but if <code>--quiet</code> was used for the fetch, <code>pack-objects</code> will output nothing at all until the pack data begins. Some clients and networks may consider the server to be hung and give up. Setting this option instructs <code>upload-pack</code> to send an empty keepalive packet every <code>uploadpack.keepAlive</code> seconds. Setting this option to 0 disables keepalive packets entirely. The default is 5 seconds.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-uploadpackpackObjectsHook"> uploadpack.packObjectsHook </dt> <dd> <p>If this option is set, when <code>upload-pack</code> would run <code>git pack-objects</code> to create a packfile for a client, it will run this shell command instead. The <code>pack-objects</code> command and arguments it <code>would</code> have run (including the <code>git pack-objects</code> at the beginning) are appended to the shell command. The stdin and stdout of the hook are treated as if <code>pack-objects</code> itself was run. I.e., <code>upload-pack</code> will feed input intended for <code>pack-objects</code> to the hook, and expects a completed packfile on stdout.</p> <p>Note that this configuration variable is only respected when it is specified in protected configuration (see <a href="#SCOPES">SCOPES</a>). This is a safety measure against fetching from untrusted repositories.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-uploadpackallowFilter"> uploadpack.allowFilter </dt> <dd> <p>If this option is set, <code>upload-pack</code> will support partial clone and partial fetch object filtering.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-uploadpackfilterallow"> uploadpackfilter.allow </dt> <dd> <p>Provides a default value for unspecified object filters (see: the below configuration variable). If set to <code>true</code>, this will also enable all filters which get added in the future. Defaults to <code>true</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-uploadpackfilterltfiltergtallow"> uploadpackfilter.<filter>.allow </dt> <dd> <p>Explicitly allow or ban the object filter corresponding to <code><filter></code>, where <code><filter></code> may be one of: <code>blob:none</code>, <code>blob:limit</code>, <code>object:type</code>, <code>tree</code>, <code>sparse:oid</code>, or <code>combine</code>. If using combined filters, both <code>combine</code> and all of the nested filter kinds must be allowed. Defaults to <code>uploadpackfilter.allow</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-uploadpackfiltertreemaxDepth"> uploadpackfilter.tree.maxDepth </dt> <dd> <p>Only allow <code>--filter=tree:<n></code> when <code><n></code> is no more than the value of <code>uploadpackfilter.tree.maxDepth</code>. If set, this also implies <code>uploadpackfilter.tree.allow=true</code>, unless this configuration variable had already been set. Has no effect if unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-uploadpackallowRefInWant"> uploadpack.allowRefInWant </dt> <dd> <p>If this option is set, <code>upload-pack</code> will support the <code>ref-in-want</code> feature of the protocol version 2 <code>fetch</code> command. This feature is intended for the benefit of load-balanced servers which may not have the same view of what OIDs their refs point to due to replication delay.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-urlltbasegtinsteadOf"> url.<base>.insteadOf </dt> <dd> <p>Any URL that starts with this value will be rewritten to start, instead, with <base>. In cases where some site serves a large number of repositories, and serves them with multiple access methods, and some users need to use different access methods, this feature allows people to specify any of the equivalent URLs and have Git automatically rewrite the URL to the best alternative for the particular user, even for a never-before-seen repository on the site. When more than one insteadOf strings match a given URL, the longest match is used.</p> <p>Note that any protocol restrictions will be applied to the rewritten URL. If the rewrite changes the URL to use a custom protocol or remote helper, you may need to adjust the <code>protocol.*.allow</code> config to permit the request. In particular, protocols you expect to use for submodules must be set to <code>always</code> rather than the default of <code>user</code>. See the description of <code>protocol.allow</code> above.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-urlltbasegtpushInsteadOf"> url.<base>.pushInsteadOf </dt> <dd> <p>Any URL that starts with this value will not be pushed to; instead, it will be rewritten to start with <base>, and the resulting URL will be pushed to. In cases where some site serves a large number of repositories, and serves them with multiple access methods, some of which do not allow push, this feature allows people to specify a pull-only URL and have Git automatically use an appropriate URL to push, even for a never-before-seen repository on the site. When more than one pushInsteadOf strings match a given URL, the longest match is used. If a remote has an explicit pushurl, Git will ignore this setting for that remote.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-username"> user.name </dt> <dt class="hdlist1" id="Documentation/git-config.txt-useremail"> user.email </dt> <dt class="hdlist1" id="Documentation/git-config.txt-authorname"> author.name </dt> <dt class="hdlist1" id="Documentation/git-config.txt-authoremail"> author.email </dt> <dt class="hdlist1" id="Documentation/git-config.txt-committername"> committer.name </dt> <dt class="hdlist1" id="Documentation/git-config.txt-committeremail"> committer.email </dt> <dd> <p>The <code>user.name</code> and <code>user.email</code> variables determine what ends up in the <code>author</code> and <code>committer</code> fields of commit objects. If you need the <code>author</code> or <code>committer</code> to be different, the <code>author.name</code>, <code>author.email</code>, <code>committer.name</code>, or <code>committer.email</code> variables can be set. All of these can be overridden by the <code>GIT_AUTHOR_NAME</code>, <code>GIT_AUTHOR_EMAIL</code>, <code>GIT_COMMITTER_NAME</code>, <code>GIT_COMMITTER_EMAIL</code>, and <code>EMAIL</code> environment variables.</p> <p>Note that the <code>name</code> forms of these variables conventionally refer to some form of a personal name. See <a href="git-commit">git-commit[1]</a> and the environment variables section of <a href="git">git[1]</a> for more information on these settings and the <code>credential.username</code> option if you’re looking for authentication credentials instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-useruseConfigOnly"> user.useConfigOnly </dt> <dd> <p>Instruct Git to avoid trying to guess defaults for <code>user.email</code> and <code>user.name</code>, and instead retrieve the values only from the configuration. For example, if you have multiple email addresses and would like to use a different one for each repository, then with this configuration option set to <code>true</code> in the global config along with a name, Git will prompt you to set up an email before making new commits in a newly cloned repository. Defaults to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-usersigningKey"> user.signingKey </dt> <dd> <p>If <a href="git-tag">git-tag[1]</a> or <a href="git-commit">git-commit[1]</a> is not selecting the key you want it to automatically when creating a signed tag or commit, you can override the default selection with this variable. This option is passed unchanged to gpg’s --local-user parameter, so you may specify a key using any method that gpg supports. If gpg.format is set to <code>ssh</code> this can contain the path to either your private ssh key or the public key when ssh-agent is used. Alternatively it can contain a public key prefixed with <code>key::</code> directly (e.g.: "key::ssh-rsa XXXXXX identifier"). The private key needs to be available via ssh-agent. If not set Git will call gpg.ssh.defaultKeyCommand (e.g.: "ssh-add -L") and try to use the first key available. For backward compatibility, a raw key which begins with "ssh-", such as "ssh-rsa XXXXXX identifier", is treated as "key::ssh-rsa XXXXXX identifier", but this form is deprecated; use the <code>key::</code> form instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-versionsortprereleaseSuffixdeprecated"> versionsort.prereleaseSuffix (deprecated) </dt> <dd> <p>Deprecated alias for <code>versionsort.suffix</code>. Ignored if <code>versionsort.suffix</code> is set.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-versionsortsuffix"> versionsort.suffix </dt> <dd> <p>Even when version sort is used in <a href="git-tag">git-tag[1]</a>, tagnames with the same base version but different suffixes are still sorted lexicographically, resulting e.g. in prerelease tags appearing after the main release (e.g. "1.0-rc1" after "1.0"). This variable can be specified to determine the sorting order of tags with different suffixes.</p> <p>By specifying a single suffix in this variable, any tagname containing that suffix will appear before the corresponding main release. E.g. if the variable is set to "-rc", then all "1.0-rcX" tags will appear before "1.0". If specified multiple times, once per suffix, then the order of suffixes in the configuration will determine the sorting order of tagnames with those suffixes. E.g. if "-pre" appears before "-rc" in the configuration, then all "1.0-preX" tags will be listed before any "1.0-rcX" tags. The placement of the main release tag relative to tags with various suffixes can be determined by specifying the empty suffix among those other suffixes. E.g. if the suffixes "-rc", "", "-ck", and "-bfs" appear in the configuration in this order, then all "v4.8-rcX" tags are listed first, followed by "v4.8", then "v4.8-ckX" and finally "v4.8-bfsX".</p> <p>If more than one suffix matches the same tagname, then that tagname will be sorted according to the suffix which starts at the earliest position in the tagname. If more than one different matching suffix starts at that earliest position, then that tagname will be sorted according to the longest of those suffixes. The sorting order between different suffixes is undefined if they are in multiple config files.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-webbrowser"> web.browser </dt> <dd> <p>Specify a web browser that may be used by some commands. Currently only <a href="git-instaweb">git-instaweb[1]</a> and <a href="git-help">git-help[1]</a> may use it.</p> </dd> <dt class="hdlist1" id="Documentation/git-config.txt-worktreeguessRemote"> worktree.guessRemote </dt> <dd> <p>If no branch is specified and neither <code>-b</code> nor <code>-B</code> nor <code>--detach</code> is used, then <code>git worktree add</code> defaults to creating a new branch from HEAD. If <code>worktree.guessRemote</code> is set to true, <code>worktree add</code> tries to find a remote-tracking branch whose name uniquely matches the new branch name. If such a branch exists, it is checked out and set as "upstream" for the new branch. If no such match can be found, it falls back to creating a new branch from the current HEAD.</p> </dd> </dl> </div> </div> </div> <h2 id="_bugs">Bugs</h2> <div class="sectionbody"> <p>When using the deprecated <code>[section.subsection]</code> syntax, changing a value will result in adding a multi-line key instead of a change, if the subsection is given with at least one uppercase character. For example when the config looks like</p> <div class="listingblock"> <div class="content"> <pre> [section.subsection] + key = value1</pre> </div> </div> <p>and running <code>git config section.Subsection.key value2</code> will result in</p> <div class="listingblock"> <div class="content"> <pre> [section.subsection] + key = value1 + key = value2</pre> </div> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-config" class="_attribution-link">https://git-scm.com/docs/git-config</a> + </p> +</div> diff --git a/devdocs/git/git-count-objects.html b/devdocs/git/git-count-objects.html new file mode 100644 index 00000000..48b72a54 --- /dev/null +++ b/devdocs/git/git-count-objects.html @@ -0,0 +1,6 @@ +<h1>git-count-objects</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-count-objects - Count unpacked number of objects and their disk consumption</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git count-objects [-v] [-H | --human-readable]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Counts the number of unpacked object files and disk space consumed by them, to help you decide when it is a good time to repack.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-count-objects.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-count-objects.txt---verbose"> --verbose </dt> <dd> <p>Provide more detailed reports:</p> <p>count: the number of loose objects</p> <p>size: disk space consumed by loose objects, in KiB (unless -H is specified)</p> <p>in-pack: the number of in-pack objects</p> <p>size-pack: disk space consumed by the packs, in KiB (unless -H is specified)</p> <p>prune-packable: the number of loose objects that are also present in the packs. These objects could be pruned using <code>git prune-packed</code>.</p> <p>garbage: the number of files in the object database that are neither valid loose objects nor valid packs</p> <p>size-garbage: disk space consumed by garbage files, in KiB (unless -H is specified)</p> <p>alternate: absolute path of alternate object databases; may appear multiple times, one line per path. Note that if the path contains non-printable characters, it may be surrounded by double-quotes and contain C-style backslashed escape sequences.</p> </dd> <dt class="hdlist1" id="Documentation/git-count-objects.txt--H"> -H </dt> <dt class="hdlist1" id="Documentation/git-count-objects.txt---human-readable"> --human-readable </dt> <dd> <p>Print sizes in human readable format</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-count-objects" class="_attribution-link">https://git-scm.com/docs/git-count-objects</a> + </p> +</div> diff --git a/devdocs/git/git-credential-cache.html b/devdocs/git/git-credential-cache.html new file mode 100644 index 00000000..3c9312ec --- /dev/null +++ b/devdocs/git/git-credential-cache.html @@ -0,0 +1,13 @@ +<h1>git-credential-cache</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-credential-cache - Helper to temporarily store passwords in memory</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="listingblock"> <div class="content"> <pre data-language="shell">git config credential.helper 'cache [<options>]'</pre> </div> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This command caches credentials for use by future Git programs. The stored credentials are kept in memory of the cache-daemon process (instead of being written to a file) and are forgotten after a configurable timeout. Credentials are forgotten sooner if the cache-daemon dies, for example if the system restarts. The cache is accessible over a Unix domain socket, restricted to the current user by filesystem permissions.</p> <p>You probably don’t want to invoke this command directly; it is meant to be used as a credential helper by other parts of Git. See <a href="gitcredentials">gitcredentials[7]</a> or <code>EXAMPLES</code> below.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-credential-cache.txt---timeoutltsecondsgt"> --timeout <seconds> </dt> <dd> <p>Number of seconds to cache credentials (default: 900).</p> </dd> <dt class="hdlist1" id="Documentation/git-credential-cache.txt---socketltpathgt"> --socket <path> </dt> <dd> <p>Use <code><path></code> to contact a running cache daemon (or start a new cache daemon if one is not started). Defaults to <code>$XDG_CACHE_HOME/git/credential/socket</code> unless <code>~/.git-credential-cache/</code> exists in which case <code>~/.git-credential-cache/socket</code> is used instead. If your home directory is on a network-mounted filesystem, you may need to change this to a local filesystem. You must specify an absolute path.</p> </dd> </dl> </div> </div> <h2 id="_controlling_the_daemon">Controlling the daemon</h2> <div class="sectionbody"> <p>If you would like the daemon to exit early, forgetting all cached credentials before their timeout, you can issue an <code>exit</code> action:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git credential-cache exit</pre> </div> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>The point of this helper is to reduce the number of times you must type your username or password. For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config credential.helper cache +$ git push http://example.com/repo.git +Username: <type your username> +Password: <type your password> + +[work for 5 more minutes] +$ git push http://example.com/repo.git +[your credentials are used automatically]</pre> </div> </div> <p>You can provide options via the credential.helper configuration variable (this example increases the cache time to 1 hour):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config credential.helper 'cache --timeout=3600'</pre> </div> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-credential-cache" class="_attribution-link">https://git-scm.com/docs/git-credential-cache</a> + </p> +</div> diff --git a/devdocs/git/git-credential-store.html b/devdocs/git/git-credential-store.html new file mode 100644 index 00000000..72164368 --- /dev/null +++ b/devdocs/git/git-credential-store.html @@ -0,0 +1,13 @@ +<h1>git-credential-store</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-credential-store - Helper to store credentials on disk</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="listingblock"> <div class="content"> <pre data-language="shell">git config credential.helper 'store [<options>]'</pre> </div> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> Using this helper will store your passwords unencrypted on disk, protected only by filesystem permissions. If this is not an acceptable security tradeoff, try <a href="git-credential-cache">git-credential-cache[1]</a>, or find a helper that integrates with secure storage provided by your operating system. </td> </tr> </table> </div> <p>This command stores credentials indefinitely on disk for use by future Git programs.</p> <p>You probably don’t want to invoke this command directly; it is meant to be used as a credential helper by other parts of git. See <a href="gitcredentials">gitcredentials[7]</a> or <code>EXAMPLES</code> below.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-credential-store.txt---fileltpathgt"> --file=<path> </dt> <dd> <p>Use <code><path></code> to lookup and store credentials. The file will have its filesystem permissions set to prevent other users on the system from reading it, but it will not be encrypted or otherwise protected. If not specified, credentials will be searched for from <code>~/.git-credentials</code> and <code>$XDG_CONFIG_HOME/git/credentials</code>, and credentials will be written to <code>~/.git-credentials</code> if it exists, or <code>$XDG_CONFIG_HOME/git/credentials</code> if it exists and the former does not. See also <a href="#FILES">FILES</a>.</p> </dd> </dl> </div> </div> <h2 id="FILES">Files</h2> <div class="sectionbody"> <p>If not set explicitly with <code>--file</code>, there are two files where git-credential-store will search for credentials in order of precedence:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-credential-store.txt-git-credentials"> ~/.git-credentials </dt> <dd> <p>User-specific credentials file.</p> </dd> <dt class="hdlist1" id="Documentation/git-credential-store.txt-XDGCONFIGHOMEgitcredentials"> $XDG_CONFIG_HOME/git/credentials </dt> <dd> <p>Second user-specific credentials file. If <code>$XDG_CONFIG_HOME</code> is not set or empty, <code>$HOME/.config/git/credentials</code> will be used. Any credentials stored in this file will not be used if <code>~/.git-credentials</code> has a matching credential as well. It is a good idea not to create this file if you sometimes use older versions of Git that do not support it.</p> </dd> </dl> </div> <p>For credential lookups, the files are read in the order given above, with the first matching credential found taking precedence over credentials found in files further down the list.</p> <p>Credential storage will by default write to the first existing file in the list. If none of these files exist, <code>~/.git-credentials</code> will be created and written to.</p> <p>When erasing credentials, matching credentials will be erased from all files.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>The point of this helper is to reduce the number of times you must type your username or password. For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config credential.helper store +$ git push http://example.com/repo.git +Username: <type your username> +Password: <type your password> + +[several days later] +$ git push http://example.com/repo.git +[your credentials are used automatically]</pre> </div> </div> </div> <h2 id="_storage_format">Storage format</h2> <div class="sectionbody"> <p>The <code>.git-credentials</code> file is stored in plaintext. Each credential is stored on its own line as a URL like:</p> <div class="listingblock"> <div class="content"> <pre>https://user:pass@example.com</pre> </div> </div> <p>No other kinds of lines (e.g. empty lines or comment lines) are allowed in the file, even though some may be silently ignored. Do not view or edit the file with editors.</p> <p>When Git needs authentication for a particular URL context, credential-store will consider that context a pattern to match against each entry in the credentials file. If the protocol, hostname, and username (if we already have one) match, then the password is returned to Git. See the discussion of configuration in <a href="gitcredentials">gitcredentials[7]</a> for more information.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-credential-store" class="_attribution-link">https://git-scm.com/docs/git-credential-store</a> + </p> +</div> diff --git a/devdocs/git/git-credential.html b/devdocs/git/git-credential.html new file mode 100644 index 00000000..28142831 --- /dev/null +++ b/devdocs/git/git-credential.html @@ -0,0 +1,13 @@ +<h1>git-credential</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-credential - Retrieve and store user credentials</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="listingblock"> <div class="content"> <pre>'git credential' (fill|approve|reject)</pre> </div> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Git has an internal interface for storing and retrieving credentials from system-specific helpers, as well as prompting the user for usernames and passwords. The git-credential command exposes this interface to scripts which may want to retrieve, store, or prompt for credentials in the same manner as Git. The design of this scriptable interface models the internal C API; see credential.h for more background on the concepts.</p> <p>git-credential takes an "action" option on the command-line (one of <code>fill</code>, <code>approve</code>, or <code>reject</code>) and reads a credential description on stdin (see <a href="#IOFMT">INPUT/OUTPUT FORMAT</a>).</p> <p>If the action is <code>fill</code>, git-credential will attempt to add "username" and "password" attributes to the description by reading config files, by contacting any configured credential helpers, or by prompting the user. The username and password attributes of the credential description are then printed to stdout together with the attributes already provided.</p> <p>If the action is <code>approve</code>, git-credential will send the description to any configured credential helpers, which may store the credential for later use.</p> <p>If the action is <code>reject</code>, git-credential will send the description to any configured credential helpers, which may erase any stored credentials matching the description.</p> <p>If the action is <code>approve</code> or <code>reject</code>, no output should be emitted.</p> </div> <h2 id="_typical_use_of_git_credential">Typical use of git credential</h2> <div class="sectionbody"> <p>An application using git-credential will typically use <code>git +credential</code> following these steps:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Generate a credential description based on the context.</p> <p>For example, if we want a password for <code>https://example.com/foo.git</code>, we might generate the following credential description (don’t forget the blank line at the end; it tells <code>git credential</code> that the application finished feeding all the information it has):</p> <div class="literalblock"> <div class="content"> <pre>protocol=https +host=example.com +path=foo.git</pre> </div> </div> </li> <li> <p>Ask git-credential to give us a username and password for this description. This is done by running <code>git credential fill</code>, feeding the description from step (1) to its standard input. The complete credential description (including the credential per se, i.e. the login and password) will be produced on standard output, like:</p> <div class="literalblock"> <div class="content"> <pre>protocol=https +host=example.com +username=bob +password=secr3t</pre> </div> </div> <p>In most cases, this means the attributes given in the input will be repeated in the output, but Git may also modify the credential description, for example by removing the <code>path</code> attribute when the protocol is HTTP(s) and <code>credential.useHttpPath</code> is false.</p> <p>If the <code>git credential</code> knew about the password, this step may not have involved the user actually typing this password (the user may have typed a password to unlock the keychain instead, or no user interaction was done if the keychain was already unlocked) before it returned <code>password=secr3t</code>.</p> </li> <li> <p>Use the credential (e.g., access the URL with the username and password from step (2)), and see if it’s accepted.</p> </li> <li> <p>Report on the success or failure of the password. If the credential allowed the operation to complete successfully, then it can be marked with an "approve" action to tell <code>git +credential</code> to reuse it in its next invocation. If the credential was rejected during the operation, use the "reject" action so that <code>git credential</code> will ask for a new password in its next invocation. In either case, <code>git credential</code> should be fed with the credential description obtained from step (2) (which also contains the fields provided in step (1)).</p> </li> </ol> </div> </div> <h2 id="IOFMT">Input/output format</h2> <div class="sectionbody"> <p><code>git credential</code> reads and/or writes (depending on the action used) credential information in its standard input/output. This information can correspond either to keys for which <code>git credential</code> will obtain the login information (e.g. host, protocol, path), or to the actual credential data to be obtained (username/password).</p> <p>The credential is split into a set of named attributes, with one attribute per line. Each attribute is specified by a key-value pair, separated by an <code>=</code> (equals) sign, followed by a newline.</p> <p>The key may contain any bytes except <code>=</code>, newline, or NUL. The value may contain any bytes except newline or NUL.</p> <p>Attributes with keys that end with C-style array brackets <code>[]</code> can have multiple values. Each instance of a multi-valued attribute forms an ordered list of values - the order of the repeated attributes defines the order of the values. An empty multi-valued attribute (<code>key[]=\n</code>) acts to clear any previous entries and reset the list.</p> <p>In all cases, all bytes are treated as-is (i.e., there is no quoting, and one cannot transmit a value with newline or NUL in it). The list of attributes is terminated by a blank line or end-of-file.</p> <p>Git understands the following attributes:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-credential.txt-codeprotocolcode"> <code>protocol</code> </dt> <dd> <p>The protocol over which the credential will be used (e.g., <code>https</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-credential.txt-codehostcode"> <code>host</code> </dt> <dd> <p>The remote hostname for a network credential. This includes the port number if one was specified (e.g., "example.com:8088").</p> </dd> <dt class="hdlist1" id="Documentation/git-credential.txt-codepathcode"> <code>path</code> </dt> <dd> <p>The path with which the credential will be used. E.g., for accessing a remote https repository, this will be the repository’s path on the server.</p> </dd> <dt class="hdlist1" id="Documentation/git-credential.txt-codeusernamecode"> <code>username</code> </dt> <dd> <p>The credential’s username, if we already have one (e.g., from a URL, the configuration, the user, or from a previously run helper).</p> </dd> <dt class="hdlist1" id="Documentation/git-credential.txt-codepasswordcode"> <code>password</code> </dt> <dd> <p>The credential’s password, if we are asking it to be stored.</p> </dd> <dt class="hdlist1" id="Documentation/git-credential.txt-codepasswordexpiryutccode"> <code>password_expiry_utc</code> </dt> <dd> <p>Generated passwords such as an OAuth access token may have an expiry date. When reading credentials from helpers, <code>git credential fill</code> ignores expired passwords. Represented as Unix time UTC, seconds since 1970.</p> </dd> <dt class="hdlist1" id="Documentation/git-credential.txt-codeoauthrefreshtokencode"> <code>oauth_refresh_token</code> </dt> <dd> <p>An OAuth refresh token may accompany a password that is an OAuth access token. Helpers must treat this attribute as confidential like the password attribute. Git itself has no special behaviour for this attribute.</p> </dd> <dt class="hdlist1" id="Documentation/git-credential.txt-codeurlcode"> <code>url</code> </dt> <dd> <p>When this special attribute is read by <code>git credential</code>, the value is parsed as a URL and treated as if its constituent parts were read (e.g., <code>url=https://example.com</code> would behave as if <code>protocol=https</code> and <code>host=example.com</code> had been provided). This can help callers avoid parsing URLs themselves.</p> <p>Note that specifying a protocol is mandatory and if the URL doesn’t specify a hostname (e.g., "cert:///path/to/file") the credential will contain a hostname attribute whose value is an empty string.</p> <p>Components which are missing from the URL (e.g., there is no username in the example above) will be left unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-credential.txt-codewwwauthcode"> <code>wwwauth[]</code> </dt> <dd> <p>When an HTTP response is received by Git that includes one or more <code>WWW-Authenticate</code> authentication headers, these will be passed by Git to credential helpers.</p> <p>Each <code>WWW-Authenticate</code> header value is passed as a multi-valued attribute <code>wwwauth[]</code>, where the order of the attributes is the same as they appear in the HTTP response. This attribute is <code>one-way</code> from Git to pass additional information to credential helpers.</p> </dd> </dl> </div> <p>Unrecognised attributes are silently discarded.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-credential" class="_attribution-link">https://git-scm.com/docs/git-credential</a> + </p> +</div> diff --git a/devdocs/git/git-cvsexportcommit.html b/devdocs/git/git-cvsexportcommit.html new file mode 100644 index 00000000..d8692081 --- /dev/null +++ b/devdocs/git/git-cvsexportcommit.html @@ -0,0 +1,12 @@ +<h1>git-cvsexportcommit</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-cvsexportcommit - Export a single commit to a CVS checkout</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git cvsexportcommit [-h] [-u] [-v] [-c] [-P] [-p] [-a] [-d <cvsroot>] + [-w <cvs-workdir>] [-W] [-f] [-m <msgprefix>] [<parent-commit>] <commit-id></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Exports a commit from Git to a CVS checkout, making it easier to merge patches from a Git repository into a CVS repository.</p> <p>Specify the name of a CVS checkout using the -w switch or execute it from the root of the CVS working copy. In the latter case GIT_DIR must be defined. See examples below.</p> <p>It does its best to do the safe thing, it will check that the files are unchanged and up to date in the CVS checkout, and it will not autocommit by default.</p> <p>Supports file additions, removals, and commits that affect binary files.</p> <p>If the commit is a merge commit, you must tell <code>git cvsexportcommit</code> what parent the changeset should be done against.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt--c"> -c </dt> <dd> <p>Commit automatically if the patch applied cleanly. It will not commit if any hunks fail to apply or there were other problems.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt--p"> -p </dt> <dd> <p>Be pedantic (paranoid) when applying patches. Invokes patch with --fuzz=0</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt--a"> -a </dt> <dd> <p>Add authorship information. Adds Author line, and Committer (if different from Author) to the message.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt--d"> -d </dt> <dd> <p>Set an alternative CVSROOT to use. This corresponds to the CVS -d parameter. Usually users will not want to set this, except if using CVS in an asymmetric fashion.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt--f"> -f </dt> <dd> <p>Force the merge even if the files are not up to date.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt--P"> -P </dt> <dd> <p>Force the parent commit, even if it is not a direct parent.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt--m"> -m </dt> <dd> <p>Prepend the commit message with the provided prefix. Useful for patch series and the like.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt--u"> -u </dt> <dd> <p>Update affected files from CVS repository before attempting export.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt--k"> -k </dt> <dd> <p>Reverse CVS keyword expansion (e.g. $Revision: 1.2.3.4$ becomes $Revision$) in working CVS checkout before applying patch.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt--w"> -w </dt> <dd> <p>Specify the location of the CVS checkout to use for the export. This option does not require GIT_DIR to be set before execution if the current directory is within a Git repository. The default is the value of <code>cvsexportcommit.cvsdir</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt--W"> -W </dt> <dd> <p>Tell cvsexportcommit that the current working directory is not only a Git checkout, but also the CVS checkout. Therefore, Git will reset the working directory to the parent commit before proceeding.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt--v"> -v </dt> <dd> <p>Verbose.</p> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt-cvsexportcommitcvsdir"> cvsexportcommit.cvsdir </dt> <dd> <p>The default location of the CVS checkout to use for the export.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt-MergeonepatchintoCVS"> Merge one patch into CVS </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ export GIT_DIR=~/project/.git +$ cd ~/project_cvs_checkout +$ git cvsexportcommit -v <commit-sha1> +$ cvs commit -F .msg <files></pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt-MergeonepatchintoCVS-cand-woptionsTheworkingdirectoryiswithintheGitRepo"> Merge one patch into CVS (-c and -w options). The working directory is within the Git Repo </dt> <dd> <div class="listingblock"> <div class="content"> <pre> $ git cvsexportcommit -v -c -w ~/project_cvs_checkout <commit-sha1></pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-cvsexportcommit.txt-MergependingpatchesintoCVSautomatically820182128201onlyifyoureallyknowwhatyouaredoing"> Merge pending patches into CVS automatically — only if you really know what you are doing </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ export GIT_DIR=~/project/.git +$ cd ~/project_cvs_checkout +$ git cherry cvshead myhead | sed -n 's/^+ //p' | xargs -l1 git cvsexportcommit -c -p -v</pre> </div> </div> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-cvsexportcommit" class="_attribution-link">https://git-scm.com/docs/git-cvsexportcommit</a> + </p> +</div> diff --git a/devdocs/git/git-cvsimport.html b/devdocs/git/git-cvsimport.html new file mode 100644 index 00000000..277c37dc --- /dev/null +++ b/devdocs/git/git-cvsimport.html @@ -0,0 +1,11 @@ +<h1>git-cvsimport</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-cvsimport - Salvage your data out of another SCM people love to hate</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git cvsimport [-o <branch-for-HEAD>] [-h] [-v] [-d <CVSROOT>] + [-A <author-conv-file>] [-p <options-for-cvsps>] [-P <file>] + [-C <git-repository>] [-z <fuzz>] [-i] [-k] [-u] [-s <subst>] + [-a] [-m] [-M <regex>] [-S <regex>] [-L <commit-limit>] + [-r <remote>] [-R] [<CVS-module>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p><strong>WARNING:</strong> <code>git cvsimport</code> uses cvsps version 2, which is considered deprecated; it does not work with cvsps version 3 and later. If you are performing a one-shot import of a CVS repository consider using <a href="http://cvs2svn.tigris.org/cvs2git.html">cvs2git</a> or <a href="https://gitlab.com/esr/cvs-fast-export">cvs-fast-export</a>.</p> <p>Imports a CVS repository into Git. It will either create a new repository, or incrementally import into an existing one.</p> <p>Splitting the CVS log into patch sets is done by <code>cvsps</code>. At least version 2.1 is required.</p> <p><strong>WARNING:</strong> for certain situations the import leads to incorrect results. Please see the section <a href="#issues">ISSUES</a> for further reference.</p> <p>You should <strong>never</strong> do any work of your own on the branches that are created by <code>git cvsimport</code>. By default initial import will create and populate a "master" branch from the CVS repository’s main branch which you’re free to work with; after that, you need to <code>git merge</code> incremental imports, or any CVS branches, yourself. It is advisable to specify a named remote via -r to separate and protect the incoming branches.</p> <p>If you intend to set up a shared public repository that all developers can read/write, or if you want to use <a href="git-cvsserver">git-cvsserver[1]</a>, then you probably want to make a bare clone of the imported repository, and use the clone as the shared repository. See <a href="gitcvs-migration">gitcvs-migration[7]</a>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--v"> -v </dt> <dd> <p>Verbosity: let <code>cvsimport</code> report what it is doing.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--dltCVSROOTgt"> -d <CVSROOT> </dt> <dd> <p>The root of the CVS archive. May be local (a simple path) or remote; currently, only the :local:, :ext: and :pserver: access methods are supported. If not given, <code>git cvsimport</code> will try to read it from <code>CVS/Root</code>. If no such file exists, it checks for the <code>CVSROOT</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt-ltCVS-modulegt"> <CVS-module> </dt> <dd> <p>The CVS module you want to import. Relative to <CVSROOT>. If not given, <code>git cvsimport</code> tries to read it from <code>CVS/Repository</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--Clttarget-dirgt"> -C <target-dir> </dt> <dd> <p>The Git repository to import to. If the directory doesn’t exist, it will be created. Default is the current directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--rltremotegt"> -r <remote> </dt> <dd> <p>The Git remote to import this CVS repository into. Moves all CVS branches into remotes/<remote>/<branch> akin to the way <code>git clone</code> uses <code>origin</code> by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--oltbranch-for-HEADgt"> -o <branch-for-HEAD> </dt> <dd> <p>When no remote is specified (via -r) the <code>HEAD</code> branch from CVS is imported to the <code>origin</code> branch within the Git repository, as <code>HEAD</code> already has a special meaning for Git. When a remote is specified the <code>HEAD</code> branch is named remotes/<remote>/master mirroring <code>git clone</code> behaviour. Use this option if you want to import into a different branch.</p> <p>Use <code>-o master</code> for continuing an import that was initially done by the old cvs2git tool.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--i"> -i </dt> <dd> <p>Import-only: don’t perform a checkout after importing. This option ensures the working directory and index remain untouched and will not create them if they do not exist.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--k"> -k </dt> <dd> <p>Kill keywords: will extract files with <code>-kk</code> from the CVS archive to avoid noisy changesets. Highly recommended, but off by default to preserve compatibility with early imported trees.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--u"> -u </dt> <dd> <p>Convert underscores in tag and branch names to dots.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--sltsubstgt"> -s <subst> </dt> <dd> <p>Substitute the character "/" in branch names with <subst></p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--pltoptions-for-cvspsgt"> -p <options-for-cvsps> </dt> <dd> <p>Additional options for cvsps. The options <code>-u</code> and <code>-A</code> are implicit and should not be used here.</p> <p>If you need to pass multiple options, separate them with a comma.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--zltfuzzgt"> -z <fuzz> </dt> <dd> <p>Pass the timestamp fuzz factor to cvsps, in seconds. If unset, cvsps defaults to 300s.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--Pltcvsps-output-filegt"> -P <cvsps-output-file> </dt> <dd> <p>Instead of calling cvsps, read the provided cvsps output file. Useful for debugging or when cvsps is being handled outside cvsimport.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--m"> -m </dt> <dd> <p>Attempt to detect merges based on the commit message. This option will enable default regexes that try to capture the source branch name from the commit message.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--Mltregexgt"> -M <regex> </dt> <dd> <p>Attempt to detect merges based on the commit message with a custom regex. It can be used with <code>-m</code> to enable the default regexes as well. You must escape forward slashes.</p> <p>The regex must capture the source branch name in $1.</p> <p>This option can be used several times to provide several detection regexes.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--Sltregexgt"> -S <regex> </dt> <dd> <p>Skip paths matching the regex.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--a"> -a </dt> <dd> <p>Import all commits, including recent ones. cvsimport by default skips commits that have a timestamp less than 10 minutes ago.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--Lltlimitgt"> -L <limit> </dt> <dd> <p>Limit the number of commits imported. Workaround for cases where cvsimport leaks memory.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--Altauthor-conv-filegt"> -A <author-conv-file> </dt> <dd> <p>CVS by default uses the Unix username when writing its commit logs. Using this option and an author-conv-file maps the name recorded in CVS to author name, e-mail and optional time zone:</p> <div class="listingblock"> <div class="content"> <pre> exon=Andreas Ericsson <ae@op5.se> + spawn=Simon Pawn <spawn@frog-pond.org> America/Chicago</pre> </div> </div> <p><code>git cvsimport</code> will make it appear as those authors had their GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL set properly all along. If a time zone is specified, GIT_AUTHOR_DATE will have the corresponding offset applied.</p> <p>For convenience, this data is saved to <code>$GIT_DIR/cvs-authors</code> each time the <code>-A</code> option is provided and read from that same file each time <code>git cvsimport</code> is run.</p> <p>It is not recommended to use this feature if you intend to export changes back to CVS again later with <code>git cvsexportcommit</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--R"> -R </dt> <dd> <p>Generate a <code>$GIT_DIR/cvs-revisions</code> file containing a mapping from CVS revision numbers to newly-created Git commit IDs. The generated file will contain one line for each (filename, revision) pair imported; each line will look like</p> <div class="listingblock"> <div class="content"> <pre>src/widget.c 1.1 1d862f173cdc7325b6fa6d2ae1cfd61fd1b512b7</pre> </div> </div> <p>The revision data is appended to the file if it already exists, for use when doing incremental imports.</p> <p>This option may be useful if you have CVS revision numbers stored in commit messages, bug-tracking systems, email archives, and the like.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsimport.txt--h"> -h </dt> <dd> <p>Print a short usage message and exit.</p> </dd> </dl> </div> </div> <h2 id="_output">Output</h2> <div class="sectionbody"> <p>If <code>-v</code> is specified, the script reports what it is doing.</p> <p>Otherwise, success is indicated the Unix way, i.e. by simply exiting with a zero exit status.</p> </div> <h2 id="issues">Issues</h2> <div class="sectionbody"> <p>Problems related to timestamps:</p> <div class="ulist"> <ul> <li> <p>If timestamps of commits in the CVS repository are not stable enough to be used for ordering commits changes may show up in the wrong order.</p> </li> <li> <p>If any files were ever "cvs import"ed more than once (e.g., import of more than one vendor release) the HEAD contains the wrong content.</p> </li> <li> <p>If the timestamp order of different files cross the revision order within the commit matching time window the order of commits may be wrong.</p> </li> </ul> </div> <p>Problems related to branches:</p> <div class="ulist"> <ul> <li> <p>Branches on which no commits have been made are not imported.</p> </li> <li> <p>All files from the branching point are added to a branch even if never added in CVS.</p> </li> <li> <p>This applies to files added to the source branch <strong>after</strong> a daughter branch was created: if previously no commit was made on the daughter branch they will erroneously be added to the daughter branch in git.</p> </li> </ul> </div> <p>Problems related to tags:</p> <div class="ulist"> <ul> <li> <p>Multiple tags on the same revision are not imported.</p> </li> </ul> </div> <p>If you suspect that any of these issues may apply to the repository you want to import, consider using cvs2git:</p> <div class="ulist"> <ul> <li> <p>cvs2git (part of cvs2svn), <code>https://subversion.apache.org/</code></p> </li> </ul> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-cvsimport" class="_attribution-link">https://git-scm.com/docs/git-cvsimport</a> + </p> +</div> diff --git a/devdocs/git/git-cvsserver.html b/devdocs/git/git-cvsserver.html new file mode 100644 index 00000000..b70ce84e --- /dev/null +++ b/devdocs/git/git-cvsserver.html @@ -0,0 +1,21 @@ +<h1>git-cvsserver</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-cvsserver - A CVS server emulator for Git</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>SSH:</p> <div class="verseblock"> <pre class="content">export CVS_SERVER="git cvsserver" +cvs -d :ext:user@server/path/repo.git co <HEAD_name></pre> </div> <p>pserver (/etc/inetd.conf):</p> <div class="verseblock"> <pre class="content">cvspserver stream tcp nowait nobody /usr/bin/git-cvsserver git-cvsserver pserver</pre> </div> <p>Usage:</p> <div class="verseblock"> <pre class="content">git-cvsserver [<options>] [pserver|server] [<directory> …]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This application is a CVS emulation layer for Git.</p> <p>It is highly functional. However, not all methods are implemented, and for those methods that are implemented, not all switches are implemented.</p> <p>Testing has been done using both the CLI CVS client, and the Eclipse CVS plugin. Most functionality works fine with both of these clients.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <p>All these options obviously only make sense if enforced by the server side. They have been implemented to resemble the <a href="git-daemon">git-daemon[1]</a> options as closely as possible.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cvsserver.txt---base-pathltpathgt"> --base-path <path> </dt> <dd> <p>Prepend <code>path</code> to requested CVSROOT</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsserver.txt---strict-paths"> --strict-paths </dt> <dd> <p>Don’t allow recursing into subdirectories</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsserver.txt---export-all"> --export-all </dt> <dd> <p>Don’t check for <code>gitcvs.enabled</code> in config. You also have to specify a list of allowed directories (see below) if you want to use this option.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsserver.txt--V"> -V </dt> <dt class="hdlist1" id="Documentation/git-cvsserver.txt---version"> --version </dt> <dd> <p>Print version information and exit</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsserver.txt--h"> -h </dt> <dt class="hdlist1" id="Documentation/git-cvsserver.txt--H"> -H </dt> <dt class="hdlist1" id="Documentation/git-cvsserver.txt---help"> --help </dt> <dd> <p>Print usage information and exit</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsserver.txt-ltdirectorygt"> <directory> </dt> <dd> <p>The remaining arguments provide a list of directories. If no directories are given, then all are allowed. Repositories within these directories still require the <code>gitcvs.enabled</code> config option, unless <code>--export-all</code> is specified.</p> </dd> </dl> </div> </div> <h2 id="_limitations">Limitations</h2> <div class="sectionbody"> <p>CVS clients cannot tag, branch or perform Git merges.</p> <p><code>git-cvsserver</code> maps Git branches to CVS modules. This is very different from what most CVS users would expect since in CVS modules usually represent one or more directories.</p> </div> <h2 id="_installation">Installation</h2> <div class="sectionbody"> <div class="olist arabic"> <ol class="arabic"> <li> <p>If you are going to offer CVS access via pserver, add a line in /etc/inetd.conf like</p> <div class="openblock"> <div class="content"> <div class="listingblock"> <div class="content"> <pre> cvspserver stream tcp nowait nobody git-cvsserver pserver</pre> </div> </div> <p>Note: Some inetd servers let you specify the name of the executable independently of the value of argv[0] (i.e. the name the program assumes it was executed with). In this case the correct line in /etc/inetd.conf looks like</p> <div class="listingblock"> <div class="content"> <pre> cvspserver stream tcp nowait nobody /usr/bin/git-cvsserver git-cvsserver pserver</pre> </div> </div> <p>Only anonymous access is provided by pserver by default. To commit you will have to create pserver accounts, simply add a gitcvs.authdb setting in the config file of the repositories you want the cvsserver to allow writes to, for example:</p> <div class="listingblock"> <div class="content"> <pre> [gitcvs] + authdb = /etc/cvsserver/passwd</pre> </div> </div> <p>The format of these files is username followed by the encrypted password, for example:</p> <div class="listingblock"> <div class="content"> <pre> myuser:sqkNi8zPf01HI + myuser:$1$9K7FzU28$VfF6EoPYCJEYcVQwATgOP/ + myuser:$5$.NqmNH1vwfzGpV8B$znZIcumu1tNLATgV2l6e1/mY8RzhUDHMOaVOeL1cxV3</pre> </div> </div> <p>You can use the <code>htpasswd</code> facility that comes with Apache to make these files, but only with the -d option (or -B if your system supports it).</p> <p>Preferably use the system specific utility that manages password hash creation in your platform (e.g. mkpasswd in Linux, encrypt in OpenBSD or pwhash in NetBSD) and paste it in the right location.</p> <p>Then provide your password via the pserver method, for example:</p> <div class="listingblock"> <div class="content"> <pre> cvs -d:pserver:someuser:somepassword@server:/path/repo.git co <HEAD_name></pre> </div> </div> <p>No special setup is needed for SSH access, other than having Git tools in the PATH. If you have clients that do not accept the CVS_SERVER environment variable, you can rename <code>git-cvsserver</code> to <code>cvs</code>.</p> <p>Note: Newer CVS versions (>= 1.12.11) also support specifying CVS_SERVER directly in CVSROOT like</p> <div class="listingblock"> <div class="content"> <pre> cvs -d ":ext;CVS_SERVER=git cvsserver:user@server/path/repo.git" co <HEAD_name></pre> </div> </div> <p>This has the advantage that it will be saved in your <code>CVS/Root</code> files and you don’t need to worry about always setting the correct environment variable. SSH users restricted to <code>git-shell</code> don’t need to override the default with CVS_SERVER (and shouldn’t) as <code>git-shell</code> understands <code>cvs</code> to mean <code>git-cvsserver</code> and pretends that the other end runs the real <code>cvs</code> better.</p> </div> </div> </li> <li> <p>For each repo that you want accessible from CVS you need to edit config in the repo and add the following section.</p> <div class="openblock"> <div class="content"> <div class="listingblock"> <div class="content"> <pre> [gitcvs] + enabled=1 + # optional for debugging + logFile=/path/to/logfile</pre> </div> </div> <p>Note: you need to ensure each user that is going to invoke <code>git-cvsserver</code> has write access to the log file and to the database (see <a href="#dbbackend">Database Backend</a>. If you want to offer write access over SSH, the users of course also need write access to the Git repository itself.</p> <p>You also need to ensure that each repository is "bare" (without a Git index file) for <code>cvs commit</code> to work. See <a href="gitcvs-migration">gitcvs-migration[7]</a>.</p> <p>All configuration variables can also be overridden for a specific method of access. Valid method names are "ext" (for SSH access) and "pserver". The following example configuration would disable pserver access while still allowing access over SSH.</p> <div class="listingblock"> <div class="content"> <pre> [gitcvs] + enabled=0 + + [gitcvs "ext"] + enabled=1</pre> </div> </div> </div> </div> </li> <li> <p>If you didn’t specify the CVSROOT/CVS_SERVER directly in the checkout command, automatically saving it in your <code>CVS/Root</code> files, then you need to set them explicitly in your environment. CVSROOT should be set as per normal, but the directory should point at the appropriate Git repo. As above, for SSH clients <code>not</code> restricted to <code>git-shell</code>, CVS_SERVER should be set to <code>git-cvsserver</code>.</p> <div class="openblock"> <div class="content"> <div class="listingblock"> <div class="content"> <pre> export CVSROOT=:ext:user@server:/var/git/project.git + export CVS_SERVER="git cvsserver"</pre> </div> </div> </div> </div> </li> <li> <p>For SSH clients that will make commits, make sure their server-side .ssh/environment files (or .bashrc, etc., according to their specific shell) export appropriate values for GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, GIT_COMMITTER_NAME, and GIT_COMMITTER_EMAIL. For SSH clients whose login shell is bash, .bashrc may be a reasonable alternative.</p> </li> <li> <p>Clients should now be able to check out the project. Use the CVS <code>module</code> name to indicate what Git <code>head</code> you want to check out. This also sets the name of your newly checked-out directory, unless you tell it otherwise with <code>-d <dir_name></code>. For example, this checks out <code>master</code> branch to the <code>project-master</code> directory:</p> <div class="listingblock"> <div class="content"> <pre> cvs co -d project-master master</pre> </div> </div> </li> </ol> </div> </div> <h2 id="dbbackend">Database backend</h2> <div class="sectionbody"> <p><code>git-cvsserver</code> uses one database per Git head (i.e. CVS module) to store information about the repository to maintain consistent CVS revision numbers. The database needs to be updated (i.e. written to) after every commit.</p> <p>If the commit is done directly by using <code>git</code> (as opposed to using <code>git-cvsserver</code>) the update will need to happen on the next repository access by <code>git-cvsserver</code>, independent of access method and requested operation.</p> <p>That means that even if you offer only read access (e.g. by using the pserver method), <code>git-cvsserver</code> should have write access to the database to work reliably (otherwise you need to make sure that the database is up to date any time <code>git-cvsserver</code> is executed).</p> <p>By default it uses SQLite databases in the Git directory, named <code>gitcvs.<module_name>.sqlite</code>. Note that the SQLite backend creates temporary files in the same directory as the database file on write so it might not be enough to grant the users using <code>git-cvsserver</code> write access to the database file without granting them write access to the directory, too.</p> <p>The database cannot be reliably regenerated in a consistent form after the branch it is tracking has changed. Example: For merged branches, <code>git-cvsserver</code> only tracks one branch of development, and after a <code>git merge</code> an incrementally updated database may track a different branch than a database regenerated from scratch, causing inconsistent CVS revision numbers. <code>git-cvsserver</code> has no way of knowing which branch it would have picked if it had been run incrementally pre-merge. So if you have to fully or partially (from old backup) regenerate the database, you should be suspicious of pre-existing CVS sandboxes.</p> <p>You can configure the database backend with the following configuration variables:</p> <div class="sect2"> <h3 id="_configuring_database_backend"> +Configuring database backend</h3> <p><code>git-cvsserver</code> uses the Perl DBI module. Please also read its documentation if changing these variables, especially about <code>DBI->connect()</code>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cvsserver.txt-gitcvsdbName"> gitcvs.dbName </dt> <dd> <p>Database name. The exact meaning depends on the selected database driver, for SQLite this is a filename. Supports variable substitution (see below). May not contain semicolons (<code>;</code>). Default: <code>%Ggitcvs.%m.sqlite</code></p> </dd> <dt class="hdlist1" id="Documentation/git-cvsserver.txt-gitcvsdbDriver"> gitcvs.dbDriver </dt> <dd> <p>Used DBI driver. You can specify any available driver for this here, but it might not work. cvsserver is tested with <code>DBD::SQLite</code>, reported to work with <code>DBD::Pg</code>, and reported <strong>not</strong> to work with <code>DBD::mysql</code>. Please regard this as an experimental feature. May not contain colons (<code>:</code>). Default: <code>SQLite</code></p> </dd> <dt class="hdlist1" id="Documentation/git-cvsserver.txt-gitcvsdbuser"> gitcvs.dbuser </dt> <dd> <p>Database user. Only useful if setting <code>dbDriver</code>, since SQLite has no concept of database users. Supports variable substitution (see below).</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsserver.txt-gitcvsdbPass"> gitcvs.dbPass </dt> <dd> <p>Database password. Only useful if setting <code>dbDriver</code>, since SQLite has no concept of database passwords.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsserver.txt-gitcvsdbTableNamePrefix"> gitcvs.dbTableNamePrefix </dt> <dd> <p>Database table name prefix. Supports variable substitution (see below). Any non-alphabetic characters will be replaced with underscores.</p> </dd> </dl> </div> <p>All variables can also be set per access method, see <a href="#configaccessmethod">above</a>.</p> <div class="sect3"> <h4 id="_variable_substitution"> +Variable substitution</h4> <p>In <code>dbDriver</code> and <code>dbUser</code> you can use the following variables:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cvsserver.txt-G"> %G </dt> <dd> <p>Git directory name</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsserver.txt-g"> %g </dt> <dd> <p>Git directory name, where all characters except for alphanumeric ones, <code>.</code>, and <code>-</code> are replaced with <code>_</code> (this should make it easier to use the directory name in a filename if wanted)</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsserver.txt-m"> %m </dt> <dd> <p>CVS module/Git head name</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsserver.txt-a"> %a </dt> <dd> <p>access method (one of "ext" or "pserver")</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsserver.txt-u"> %u </dt> <dd> <p>Name of the user running <code>git-cvsserver</code>. If no name can be determined, the numeric uid is used.</p> </dd> </dl> </div> </div> </div> </div> <h2 id="_environment">Environment</h2> <div class="sectionbody"> <p>These variables obviate the need for command-line options in some circumstances, allowing easier restricted usage through git-shell.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-cvsserver.txt-GITCVSSERVERBASEPATH"> GIT_CVSSERVER_BASE_PATH </dt> <dd> <p>This variable replaces the argument to --base-path.</p> </dd> <dt class="hdlist1" id="Documentation/git-cvsserver.txt-GITCVSSERVERROOT"> GIT_CVSSERVER_ROOT </dt> <dd> <p>This variable specifies a single directory, replacing the <code><directory>...</code> argument list. The repository still requires the <code>gitcvs.enabled</code> config option, unless <code>--export-all</code> is specified.</p> </dd> </dl> </div> <p>When these environment variables are set, the corresponding command-line arguments may not be used.</p> </div> <h2 id="_eclipse_cvs_client_notes">Eclipse cvs client notes</h2> <div class="sectionbody"> <p>To get a checkout with the Eclipse CVS client:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Select "Create a new project → From CVS checkout"</p> </li> <li> <p>Create a new location. See the notes below for details on how to choose the right protocol.</p> </li> <li> <p>Browse the <code>modules</code> available. It will give you a list of the heads in the repository. You will not be able to browse the tree from there. Only the heads.</p> </li> <li> <p>Pick <code>HEAD</code> when it asks what branch/tag to check out. Untick the "launch commit wizard" to avoid committing the .project file.</p> </li> </ol> </div> <p>Protocol notes: If you are using anonymous access via pserver, just select that. Those using SSH access should choose the <code>ext</code> protocol, and configure <code>ext</code> access on the Preferences→Team→CVS→ExtConnection pane. Set CVS_SERVER to "<code>git cvsserver</code>". Note that password support is not good when using <code>ext</code>, you will definitely want to have SSH keys setup.</p> <p>Alternatively, you can just use the non-standard extssh protocol that Eclipse offer. In that case CVS_SERVER is ignored, and you will have to replace the cvs utility on the server with <code>git-cvsserver</code> or manipulate your <code>.bashrc</code> so that calling <code>cvs</code> effectively calls <code>git-cvsserver</code>.</p> </div> <h2 id="_clients_known_to_work">Clients known to work</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>CVS 1.12.9 on Debian</p> </li> <li> <p>CVS 1.11.17 on MacOSX (from Fink package)</p> </li> <li> <p>Eclipse 3.0, 3.1.2 on MacOSX (see Eclipse CVS Client Notes)</p> </li> <li> <p>TortoiseCVS</p> </li> </ul> </div> </div> <h2 id="_operations_supported">Operations supported</h2> <div class="sectionbody"> <p>All the operations required for normal use are supported, including checkout, diff, status, update, log, add, remove, commit.</p> <p>Most CVS command arguments that read CVS tags or revision numbers (typically -r) work, and also support any git refspec (tag, branch, commit ID, etc). However, CVS revision numbers for non-default branches are not well emulated, and cvs log does not show tags or branches at all. (Non-main-branch CVS revision numbers superficially resemble CVS revision numbers, but they actually encode a git commit ID directly, rather than represent the number of revisions since the branch point.)</p> <p>Note that there are two ways to checkout a particular branch. As described elsewhere on this page, the "module" parameter of cvs checkout is interpreted as a branch name, and it becomes the main branch. It remains the main branch for a given sandbox even if you temporarily make another branch sticky with cvs update -r. Alternatively, the -r argument can indicate some other branch to actually checkout, even though the module is still the "main" branch. Tradeoffs (as currently implemented): Each new "module" creates a new database on disk with a history for the given module, and after the database is created, operations against that main branch are fast. Or alternatively, -r doesn’t take any extra disk space, but may be significantly slower for many operations, like cvs update.</p> <p>If you want to refer to a git refspec that has characters that are not allowed by CVS, you have two options. First, it may just work to supply the git refspec directly to the appropriate CVS -r argument; some CVS clients don’t seem to do much sanity checking of the argument. Second, if that fails, you can use a special character escape mechanism that only uses characters that are valid in CVS tags. A sequence of 4 or 5 characters of the form (underscore (<code>"_"</code>), dash (<code>"-"</code>), one or two characters, and dash (<code>"-"</code>)) can encode various characters based on the one or two letters: <code>"s"</code> for slash (<code>"/"</code>), <code>"p"</code> for period (<code>"."</code>), <code>"u"</code> for underscore (<code>"_"</code>), or two hexadecimal digits for any byte value at all (typically an ASCII number, or perhaps a part of a UTF-8 encoded character).</p> <p>Legacy monitoring operations are not supported (edit, watch and related). Exports and tagging (tags and branches) are not supported at this stage.</p> <div class="sect2"> <h3 id="_crlf_line_ending_conversions"> +CRLF Line Ending Conversions</h3> <p>By default the server leaves the <code>-k</code> mode blank for all files, which causes the CVS client to treat them as a text files, subject to end-of-line conversion on some platforms.</p> <p>You can make the server use the end-of-line conversion attributes to set the <code>-k</code> modes for files by setting the <code>gitcvs.usecrlfattr</code> config variable. See <a href="gitattributes">gitattributes[5]</a> for more information about end-of-line conversion.</p> <p>Alternatively, if <code>gitcvs.usecrlfattr</code> config is not enabled or the attributes do not allow automatic detection for a filename, then the server uses the <code>gitcvs.allBinary</code> config for the default setting. If <code>gitcvs.allBinary</code> is set, then file not otherwise specified will default to <code>-kb</code> mode. Otherwise the <code>-k</code> mode is left blank. But if <code>gitcvs.allBinary</code> is set to "guess", then the correct <code>-k</code> mode will be guessed based on the contents of the file.</p> <p>For best consistency with <code>cvs</code>, it is probably best to override the defaults by setting <code>gitcvs.usecrlfattr</code> to true, and <code>gitcvs.allBinary</code> to "guess".</p> </div> </div> <h2 id="_dependencies">Dependencies</h2> <div class="sectionbody"> <p><code>git-cvsserver</code> depends on DBD::SQLite.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-cvsserver" class="_attribution-link">https://git-scm.com/docs/git-cvsserver</a> + </p> +</div> diff --git a/devdocs/git/git-daemon.html b/devdocs/git/git-daemon.html new file mode 100644 index 00000000..23b0cb08 --- /dev/null +++ b/devdocs/git/git-daemon.html @@ -0,0 +1,32 @@ +<h1>git-daemon</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-daemon - A really simple server for Git repositories</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git daemon [--verbose] [--syslog] [--export-all] + [--timeout=<n>] [--init-timeout=<n>] [--max-connections=<n>] + [--strict-paths] [--base-path=<path>] [--base-path-relaxed] + [--user-path | --user-path=<path>] + [--interpolated-path=<pathtemplate>] + [--reuseaddr] [--detach] [--pid-file=<file>] + [--enable=<service>] [--disable=<service>] + [--allow-override=<service>] [--forbid-override=<service>] + [--access-hook=<path>] [--[no-]informative-errors] + [--inetd | + [--listen=<host_or_ipaddr>] [--port=<n>] + [--user=<user> [--group=<group>]]] + [--log-destination=(stderr|syslog|none)] + [<directory>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>A really simple TCP Git daemon that normally listens on port "DEFAULT_GIT_PORT" aka 9418. It waits for a connection asking for a service, and will serve that service if it is enabled.</p> <p>It verifies that the directory has the magic file "git-daemon-export-ok", and it will refuse to export any Git directory that hasn’t explicitly been marked for export this way (unless the <code>--export-all</code> parameter is specified). If you pass some directory paths as <code>git daemon</code> arguments, the offers are limited to repositories within those directories.</p> <p>By default, only <code>upload-pack</code> service is enabled, which serves <code>git fetch-pack</code> and <code>git ls-remote</code> clients, which are invoked from <code>git fetch</code>, <code>git pull</code>, and <code>git clone</code>.</p> <p>This is ideally suited for read-only updates, i.e., pulling from Git repositories.</p> <p>An <code>upload-archive</code> also exists to serve <code>git archive</code>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-daemon.txt---strict-paths"> --strict-paths </dt> <dd> <p>Match paths exactly (i.e. don’t allow "/foo/repo" when the real path is "/foo/repo.git" or "/foo/repo/.git") and don’t do user-relative paths. <code>git daemon</code> will refuse to start when this option is enabled and no directory arguments are provided.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---base-pathltpathgt"> --base-path=<path> </dt> <dd> <p>Remap all the path requests as relative to the given path. This is sort of "Git root" - if you run <code>git daemon</code> with <code>--base-path=/srv/git</code> on example.com, then if you later try to pull <code>git://example.com/hello.git</code>, <code>git daemon</code> will interpret the path as <code>/srv/git/hello.git</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---base-path-relaxed"> --base-path-relaxed </dt> <dd> <p>If --base-path is enabled and repo lookup fails, with this option <code>git daemon</code> will attempt to lookup without prefixing the base path. This is useful for switching to --base-path usage, while still allowing the old paths.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---interpolated-pathltpathtemplategt"> --interpolated-path=<pathtemplate> </dt> <dd> <p>To support virtual hosting, an interpolated path template can be used to dynamically construct alternate paths. The template supports %H for the target hostname as supplied by the client but converted to all lowercase, %CH for the canonical hostname, %IP for the server’s IP address, %P for the port number, and %D for the absolute path of the named repository. After interpolation, the path is validated against the directory list.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---export-all"> --export-all </dt> <dd> <p>Allow pulling from all directories that look like Git repositories (have the <code>objects</code> and <code>refs</code> subdirectories), even if they do not have the <code>git-daemon-export-ok</code> file.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---inetd"> --inetd </dt> <dd> <p>Have the server run as an inetd service. Implies --syslog (may be overridden with <code>--log-destination=</code>). Incompatible with --detach, --port, --listen, --user and --group options.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---listenlthostoripaddrgt"> --listen=<host_or_ipaddr> </dt> <dd> <p>Listen on a specific IP address or hostname. IP addresses can be either an IPv4 address or an IPv6 address if supported. If IPv6 is not supported, then --listen=hostname is also not supported and --listen must be given an IPv4 address. Can be given more than once. Incompatible with <code>--inetd</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---portltngt"> --port=<n> </dt> <dd> <p>Listen on an alternative port. Incompatible with <code>--inetd</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---init-timeoutltngt"> --init-timeout=<n> </dt> <dd> <p>Timeout (in seconds) between the moment the connection is established and the client request is received (typically a rather low value, since that should be basically immediate).</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---timeoutltngt"> --timeout=<n> </dt> <dd> <p>Timeout (in seconds) for specific client sub-requests. This includes the time it takes for the server to process the sub-request and the time spent waiting for the next client’s request.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---max-connectionsltngt"> --max-connections=<n> </dt> <dd> <p>Maximum number of concurrent clients, defaults to 32. Set it to zero for no limit.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---syslog"> --syslog </dt> <dd> <p>Short for <code>--log-destination=syslog</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---log-destinationltdestinationgt"> --log-destination=<destination> </dt> <dd> <p>Send log messages to the specified destination. Note that this option does not imply --verbose, thus by default only error conditions will be logged. The <destination> must be one of:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-daemon.txt-stderr"> stderr </dt> <dd> <p>Write to standard error. Note that if <code>--detach</code> is specified, the process disconnects from the real standard error, making this destination effectively equivalent to <code>none</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt-syslog"> syslog </dt> <dd> <p>Write to syslog, using the <code>git-daemon</code> identifier.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt-none"> none </dt> <dd> <p>Disable all logging.</p> </dd> </dl> </div> </div> </div> <p>The default destination is <code>syslog</code> if <code>--inetd</code> or <code>--detach</code> is specified, otherwise <code>stderr</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---user-path"> --user-path </dt> <dt class="hdlist1" id="Documentation/git-daemon.txt---user-pathltpathgt"> --user-path=<path> </dt> <dd> <p>Allow ~user notation to be used in requests. When specified with no parameter, a request to git://host/~alice/foo is taken as a request to access <code>foo</code> repository in the home directory of user <code>alice</code>. If <code>--user-path=path</code> is specified, the same request is taken as a request to access <code>path/foo</code> repository in the home directory of user <code>alice</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---verbose"> --verbose </dt> <dd> <p>Log details about the incoming connections and requested files.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---reuseaddr"> --reuseaddr </dt> <dd> <p>Use SO_REUSEADDR when binding the listening socket. This allows the server to restart without waiting for old connections to time out.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---detach"> --detach </dt> <dd> <p>Detach from the shell. Implies --syslog.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---pid-fileltfilegt"> --pid-file=<file> </dt> <dd> <p>Save the process id in <code>file</code>. Ignored when the daemon is run under <code>--inetd</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---userltusergt"> --user=<user> </dt> <dt class="hdlist1" id="Documentation/git-daemon.txt---groupltgroupgt"> --group=<group> </dt> <dd> <p>Change daemon’s uid and gid before entering the service loop. When only <code>--user</code> is given without <code>--group</code>, the primary group ID for the user is used. The values of the option are given to <code>getpwnam(3)</code> and <code>getgrnam(3)</code> and numeric IDs are not supported.</p> <p>Giving these options is an error when used with <code>--inetd</code>; use the facility of inet daemon to achieve the same before spawning <code>git daemon</code> if needed.</p> <p>Like many programs that switch user id, the daemon does not reset environment variables such as <code>$HOME</code> when it runs git programs, e.g. <code>upload-pack</code> and <code>receive-pack</code>. When using this option, you may also want to set and export <code>HOME</code> to point at the home directory of <code><user></code> before starting the daemon, and make sure any Git configuration files in that directory are readable by <code><user></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---enableltservicegt"> --enable=<service> </dt> <dt class="hdlist1" id="Documentation/git-daemon.txt---disableltservicegt"> --disable=<service> </dt> <dd> <p>Enable/disable the service site-wide per default. Note that a service disabled site-wide can still be enabled per repository if it is marked overridable and the repository enables the service with a configuration item.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---allow-overrideltservicegt"> --allow-override=<service> </dt> <dt class="hdlist1" id="Documentation/git-daemon.txt---forbid-overrideltservicegt"> --forbid-override=<service> </dt> <dd> <p>Allow/forbid overriding the site-wide default with per repository configuration. By default, all the services may be overridden.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---no-informative-errors"> --[no-]informative-errors </dt> <dd> <p>When informative errors are turned on, git-daemon will report more verbose errors to the client, differentiating conditions like "no such repository" from "repository not exported". This is more convenient for clients, but may leak information about the existence of unexported repositories. When informative errors are not enabled, all errors report "access denied" to the client. The default is --no-informative-errors.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt---access-hookltpathgt"> --access-hook=<path> </dt> <dd> <p>Every time a client connects, first run an external command specified by the <path> with service name (e.g. "upload-pack"), path to the repository, hostname (%H), canonical hostname (%CH), IP address (%IP), and TCP port (%P) as its command-line arguments. The external command can decide to decline the service by exiting with a non-zero status (or to allow it by exiting with a zero status). It can also look at the $REMOTE_ADDR and <code>$REMOTE_PORT</code> environment variables to learn about the requestor when making this decision.</p> <p>The external command can optionally write a single line to its standard output to be sent to the requestor as an error message when it declines the service.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt-ltdirectorygt"> <directory> </dt> <dd> <p>The remaining arguments provide a list of directories. If any directories are specified, then the <code>git-daemon</code> process will serve a requested directory only if it is contained in one of these directories. If <code>--strict-paths</code> is specified, then the requested directory must match one of these directories exactly.</p> </dd> </dl> </div> </div> <h2 id="_services">Services</h2> <div class="sectionbody"> <p>These services can be globally enabled/disabled using the command-line options of this command. If finer-grained control is desired (e.g. to allow <code>git archive</code> to be run against only in a few selected repositories the daemon serves), the per-repository configuration file can be used to enable or disable them.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-daemon.txt-upload-pack"> upload-pack </dt> <dd> <p>This serves <code>git fetch-pack</code> and <code>git ls-remote</code> clients. It is enabled by default, but a repository can disable it by setting <code>daemon.uploadpack</code> configuration item to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt-upload-archive"> upload-archive </dt> <dd> <p>This serves <code>git archive --remote</code>. It is disabled by default, but a repository can enable it by setting <code>daemon.uploadarch</code> configuration item to <code>true</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt-receive-pack"> receive-pack </dt> <dd> <p>This serves <code>git send-pack</code> clients, allowing anonymous push. It is disabled by default, as there is <code>no</code> authentication in the protocol (in other words, anybody can push anything into the repository, including removal of refs). This is solely meant for a closed LAN setting where everybody is friendly. This service can be enabled by setting <code>daemon.receivepack</code> configuration item to <code>true</code>.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-daemon.txt-Weassumethefollowinginetcservices"> We assume the following in /etc/services </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ grep 9418 /etc/services +git 9418/tcp # Git Version Control System</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt-emgitdaemonemasinetdserver"> <em>git daemon</em> as inetd server </dt> <dd> <p>To set up <code>git daemon</code> as an inetd service that handles any repository within <code>/pub/foo</code> or <code>/pub/bar</code>, place an entry like the following into <code>/etc/inetd</code> all on one line:</p> <div class="listingblock"> <div class="content"> <pre> git stream tcp nowait nobody /usr/bin/git + git daemon --inetd --verbose --export-all + /pub/foo /pub/bar</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt-emgitdaemonemasinetdserverforvirtualhosts"> <em>git daemon</em> as inetd server for virtual hosts </dt> <dd> <p>To set up <code>git daemon</code> as an inetd service that handles repositories for different virtual hosts, <code>www.example.com</code> and <code>www.example.org</code>, place an entry like the following into <code>/etc/inetd</code> all on one line:</p> <div class="listingblock"> <div class="content"> <pre> git stream tcp nowait nobody /usr/bin/git + git daemon --inetd --verbose --export-all + --interpolated-path=/pub/%H%D + /pub/www.example.org/software + /pub/www.example.com/software + /software</pre> </div> </div> <p>In this example, the root-level directory <code>/pub</code> will contain a subdirectory for each virtual host name supported. Further, both hosts advertise repositories simply as <code>git://www.example.com/software/repo.git</code>. For pre-1.4.0 clients, a symlink from <code>/software</code> into the appropriate default repository could be made as well.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt-emgitdaemonemasregulardaemonforvirtualhosts"> <em>git daemon</em> as regular daemon for virtual hosts </dt> <dd> <p>To set up <code>git daemon</code> as a regular, non-inetd service that handles repositories for multiple virtual hosts based on their IP addresses, start the daemon like this:</p> <div class="listingblock"> <div class="content"> <pre> git daemon --verbose --export-all + --interpolated-path=/pub/%IP/%D + /pub/192.168.1.200/software + /pub/10.10.220.23/software</pre> </div> </div> <p>In this example, the root-level directory <code>/pub</code> will contain a subdirectory for each virtual host IP address supported. Repositories can still be accessed by hostname though, assuming they correspond to these IP addresses.</p> </dd> <dt class="hdlist1" id="Documentation/git-daemon.txt-selectivelyenabledisableservicesperrepository"> selectively enable/disable services per repository </dt> <dd> <p>To enable <code>git archive --remote</code> and disable <code>git fetch</code> against a repository, have the following in the configuration file in the repository (that is the file <code>config</code> next to <code>HEAD</code>, <code>refs</code> and <code>objects</code>).</p> <div class="listingblock"> <div class="content"> <pre> [daemon] + uploadpack = false + uploadarch = true</pre> </div> </div> </dd> </dl> </div> </div> <h2 id="_environment">Environment</h2> <div class="sectionbody"> <p><code>git daemon</code> will set REMOTE_ADDR to the IP address of the client that connected to it, if the IP address is available. REMOTE_ADDR will be available in the environment of hooks called when services are performed.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-daemon" class="_attribution-link">https://git-scm.com/docs/git-daemon</a> + </p> +</div> diff --git a/devdocs/git/git-describe.html b/devdocs/git/git-describe.html new file mode 100644 index 00000000..ca11ac27 --- /dev/null +++ b/devdocs/git/git-describe.html @@ -0,0 +1,13 @@ +<h1>git-describe</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-describe - Give an object a human readable name based on an available ref</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git describe [--all] [--tags] [--contains] [--abbrev=<n>] [<commit-ish>…] +git describe [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>] +git describe <blob></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>The command finds the most recent tag that is reachable from a commit. If the tag points to the commit, then only the tag is shown. Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object and the abbreviated object name of the most recent commit. The result is a "human-readable" object name which can also be used to identify the commit to other git commands.</p> <p>By default (without --all or --tags) <code>git describe</code> only shows annotated tags. For more information about creating annotated tags see the -a and -s options to <a href="git-tag">git-tag[1]</a>.</p> <p>If the given object refers to a blob, it will be described as <code><commit-ish>:<path></code>, such that the blob can be found at <code><path></code> in the <code><commit-ish></code>, which itself describes the first commit in which this blob occurs in a reverse revision walk from HEAD.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-describe.txt-ltcommit-ishgt82308203"> <commit-ish>… </dt> <dd> <p>Commit-ish object names to describe. Defaults to HEAD if omitted.</p> </dd> <dt class="hdlist1" id="Documentation/git-describe.txt---dirtyltmarkgt"> --dirty[=<mark>] </dt> <dt class="hdlist1" id="Documentation/git-describe.txt---brokenltmarkgt"> --broken[=<mark>] </dt> <dd> <p>Describe the state of the working tree. When the working tree matches HEAD, the output is the same as "git describe HEAD". If the working tree has local modification "-dirty" is appended to it. If a repository is corrupt and Git cannot determine if there is local modification, Git will error out, unless ‘--broken’ is given, which appends the suffix "-broken" instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-describe.txt---all"> --all </dt> <dd> <p>Instead of using only the annotated tags, use any ref found in <code>refs/</code> namespace. This option enables matching any known branch, remote-tracking branch, or lightweight tag.</p> </dd> <dt class="hdlist1" id="Documentation/git-describe.txt---tags"> --tags </dt> <dd> <p>Instead of using only the annotated tags, use any tag found in <code>refs/tags</code> namespace. This option enables matching a lightweight (non-annotated) tag.</p> </dd> <dt class="hdlist1" id="Documentation/git-describe.txt---contains"> --contains </dt> <dd> <p>Instead of finding the tag that predates the commit, find the tag that comes after the commit, and thus contains it. Automatically implies --tags.</p> </dd> <dt class="hdlist1" id="Documentation/git-describe.txt---abbrevltngt"> --abbrev=<n> </dt> <dd> <p>Instead of using the default number of hexadecimal digits (which will vary according to the number of objects in the repository with a default of 7) of the abbreviated object name, use <n> digits, or as many digits as needed to form a unique object name. An <n> of 0 will suppress long format, only showing the closest tag.</p> </dd> <dt class="hdlist1" id="Documentation/git-describe.txt---candidatesltngt"> --candidates=<n> </dt> <dd> <p>Instead of considering only the 10 most recent tags as candidates to describe the input commit-ish consider up to <n> candidates. Increasing <n> above 10 will take slightly longer but may produce a more accurate result. An <n> of 0 will cause only exact matches to be output.</p> </dd> <dt class="hdlist1" id="Documentation/git-describe.txt---exact-match"> --exact-match </dt> <dd> <p>Only output exact matches (a tag directly references the supplied commit). This is a synonym for --candidates=0.</p> </dd> <dt class="hdlist1" id="Documentation/git-describe.txt---debug"> --debug </dt> <dd> <p>Verbosely display information about the searching strategy being employed to standard error. The tag name will still be printed to standard out.</p> </dd> <dt class="hdlist1" id="Documentation/git-describe.txt---long"> --long </dt> <dd> <p>Always output the long format (the tag, the number of commits and the abbreviated commit name) even when it matches a tag. This is useful when you want to see parts of the commit object name in "describe" output, even when the commit in question happens to be a tagged version. Instead of just emitting the tag name, it will describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2 that points at object deadbee….).</p> </dd> <dt class="hdlist1" id="Documentation/git-describe.txt---matchltpatterngt"> --match <pattern> </dt> <dd> <p>Only consider tags matching the given <code>glob(7)</code> pattern, excluding the "refs/tags/" prefix. If used with <code>--all</code>, it also considers local branches and remote-tracking references matching the pattern, excluding respectively "refs/heads/" and "refs/remotes/" prefix; references of other types are never considered. If given multiple times, a list of patterns will be accumulated, and tags matching any of the patterns will be considered. Use <code>--no-match</code> to clear and reset the list of patterns.</p> </dd> <dt class="hdlist1" id="Documentation/git-describe.txt---excludeltpatterngt"> --exclude <pattern> </dt> <dd> <p>Do not consider tags matching the given <code>glob(7)</code> pattern, excluding the "refs/tags/" prefix. If used with <code>--all</code>, it also does not consider local branches and remote-tracking references matching the pattern, excluding respectively "refs/heads/" and "refs/remotes/" prefix; references of other types are never considered. If given multiple times, a list of patterns will be accumulated and tags matching any of the patterns will be excluded. When combined with --match a tag will be considered when it matches at least one --match pattern and does not match any of the --exclude patterns. Use <code>--no-exclude</code> to clear and reset the list of patterns.</p> </dd> <dt class="hdlist1" id="Documentation/git-describe.txt---always"> --always </dt> <dd> <p>Show uniquely abbreviated commit object as fallback.</p> </dd> <dt class="hdlist1" id="Documentation/git-describe.txt---first-parent"> --first-parent </dt> <dd> <p>Follow only the first parent commit upon seeing a merge commit. This is useful when you wish to not match tags on branches merged in the history of the target commit.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>With something like git.git current tree, I get:</p> <div class="literalblock"> <div class="content"> <pre>[torvalds@g5 git]$ git describe parent +v1.0.4-14-g2414721</pre> </div> </div> <p>i.e. the current head of my "parent" branch is based on v1.0.4, but since it has a few commits on top of that, describe has added the number of additional commits ("14") and an abbreviated object name for the commit itself ("2414721") at the end.</p> <p>The number of additional commits is the number of commits which would be displayed by "git log v1.0.4..parent". The hash suffix is "-g" + an unambiguous abbreviation for the tip commit of parent (which was <code>2414721b194453f058079d897d13c4e377f92dc6</code>). The length of the abbreviation scales as the repository grows, using the approximate number of objects in the repository and a bit of math around the birthday paradox, and defaults to a minimum of 7. The "g" prefix stands for "git" and is used to allow describing the version of a software depending on the SCM the software is managed with. This is useful in an environment where people may use different SCMs.</p> <p>Doing a <code>git describe</code> on a tag-name will just show the tag name:</p> <div class="literalblock"> <div class="content"> <pre>[torvalds@g5 git]$ git describe v1.0.4 +v1.0.4</pre> </div> </div> <p>With --all, the command can use branch heads as references, so the output shows the reference path as well:</p> <div class="literalblock"> <div class="content"> <pre>[torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2 +tags/v1.0.0-21-g975b</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>[torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^ +heads/lt/describe-7-g975b</pre> </div> </div> <p>With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:</p> <div class="literalblock"> <div class="content"> <pre>[torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2 +tags/v1.0.0</pre> </div> </div> <p>Note that the suffix you get if you type these commands today may be longer than what Linus saw above when he ran these commands, as your Git repository may have new commits whose object names begin with 975b that did not exist back then, and "-g975b" suffix alone may not be sufficient to disambiguate these commits.</p> </div> <h2 id="_search_strategy">Search strategy</h2> <div class="sectionbody"> <p>For each commit-ish supplied, <code>git describe</code> will first look for a tag which tags exactly that commit. Annotated tags will always be preferred over lightweight tags, and tags with newer dates will always be preferred over tags with older dates. If an exact match is found, its name will be output and searching will stop.</p> <p>If an exact match was not found, <code>git describe</code> will walk back through the commit history to locate an ancestor commit which has been tagged. The ancestor’s tag will be output along with an abbreviation of the input commit-ish’s SHA-1. If <code>--first-parent</code> was specified then the walk will only consider the first parent of each commit.</p> <p>If multiple tags were found during the walk then the tag which has the fewest commits different from the input commit-ish will be selected and output. Here fewest commits different is defined as the number of commits which would be shown by <code>git log tag..input</code> will be the smallest number of commits possible.</p> </div> <h2 id="_bugs">Bugs</h2> <div class="sectionbody"> <p>Tree objects as well as tag objects not pointing at commits, cannot be described. When describing blobs, the lightweight tags pointing at blobs are ignored, but the blob is still described as <commit-ish>:<path> despite the lightweight tag being favorable.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-describe" class="_attribution-link">https://git-scm.com/docs/git-describe</a> + </p> +</div> diff --git a/devdocs/git/git-diagnose.html b/devdocs/git/git-diagnose.html new file mode 100644 index 00000000..f4881c0d --- /dev/null +++ b/devdocs/git/git-diagnose.html @@ -0,0 +1,7 @@ +<h1>git-diagnose</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-diagnose - Generate a zip archive of diagnostic information</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git diagnose [(-o | --output-directory) <path>] [(-s | --suffix) <format>] + [--mode=<mode>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Collects detailed information about the user’s machine, Git client, and repository state and packages that information into a zip archive. The generated archive can then, for example, be shared with the Git mailing list to help debug an issue or serve as a reference for independent debugging.</p> <p>By default, the following information is captured in the archive:</p> <div class="ulist"> <ul> <li> <p><code>git version --build-options</code></p> </li> <li> <p>The path to the repository root</p> </li> <li> <p>The available disk space on the filesystem</p> </li> <li> <p>The name and size of each packfile, including those in alternate object stores</p> </li> <li> <p>The total count of loose objects, as well as counts broken down by <code>.git/objects</code> subdirectory</p> </li> </ul> </div> <p>Additional information can be collected by selecting a different diagnostic mode using the <code>--mode</code> option.</p> <p>This tool differs from <a href="git-bugreport">git-bugreport[1]</a> in that it collects much more detailed information with a greater focus on reporting the size and data shape of repository contents.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diagnose.txt--oltpathgt"> -o <path> </dt> <dt class="hdlist1" id="Documentation/git-diagnose.txt---output-directoryltpathgt"> --output-directory <path> </dt> <dd> <p>Place the resulting diagnostics archive in <code><path></code> instead of the current directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-diagnose.txt--sltformatgt"> -s <format> </dt> <dt class="hdlist1" id="Documentation/git-diagnose.txt---suffixltformatgt"> --suffix <format> </dt> <dd> <p>Specify an alternate suffix for the diagnostics archive name, to create a file named <code>git-diagnostics-<formatted suffix></code>. This should take the form of a strftime(3) format string; the current local time will be used.</p> </dd> <dt class="hdlist1" id="Documentation/git-diagnose.txt---modestatsall"> --mode=(stats|all) </dt> <dd> <p>Specify the type of diagnostics that should be collected. The default behavior of <code>git diagnose</code> is equivalent to <code>--mode=stats</code>.</p> <p>The <code>--mode=all</code> option collects everything included in <code>--mode=stats</code>, as well as copies of <code>.git</code>, <code>.git/hooks</code>, <code>.git/info</code>, <code>.git/logs</code>, and <code>.git/objects/info</code> directories. This additional information may be sensitive, as it can be used to reconstruct the full contents of the diagnosed repository. Users should exercise caution when sharing an archive generated with <code>--mode=all</code>.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-diagnose" class="_attribution-link">https://git-scm.com/docs/git-diagnose</a> + </p> +</div> diff --git a/devdocs/git/git-diff-files.html b/devdocs/git/git-diff-files.html new file mode 100644 index 00000000..70fc6b44 --- /dev/null +++ b/devdocs/git/git-diff-files.html @@ -0,0 +1,68 @@ +<h1>git-diff-files</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-diff-files - Compares files in the working tree and the index</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git diff-files [-q] [-0 | -1 | -2 | -3 | -c | --cc] [<common-diff-options>] [<path>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Compares the files in the working tree and the index. When paths are specified, compares only those named paths. Otherwise all entries in the index are compared. The output format is the same as for <code>git diff-index</code> and <code>git diff-tree</code>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-files.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt--u"> -u </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---patch"> --patch </dt> <dd> <p>Generate patch (see <a href="#generate_patch_text_with_p">Generating patch text with -p</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---no-patch"> --no-patch </dt> <dd> <p>Suppress all output from the diff machinery. Useful for commands like <code>git show</code> that show the patch by default to squelch their output, or to cancel the effect of options like <code>--patch</code>, <code>--stat</code> earlier on the command line in an alias.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--Ultngt"> -U<n> </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---unifiedltngt"> --unified=<n> </dt> <dd> <p>Generate diffs with <n> lines of context instead of the usual three. Implies <code>--patch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---outputltfilegt"> --output=<file> </dt> <dd> <p>Output to a specific file instead of stdout.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---output-indicator-newltchargt"> --output-indicator-new=<char> </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---output-indicator-oldltchargt"> --output-indicator-old=<char> </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---output-indicator-contextltchargt"> --output-indicator-context=<char> </dt> <dd> <p>Specify the character used to indicate new, old or context lines in the generated patch. Normally they are <code>+</code>, <code>-</code> and ' ' respectively.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---raw"> --raw </dt> <dd> <p>Generate the diff in raw format. This is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---patch-with-raw"> --patch-with-raw </dt> <dd> <p>Synonym for <code>-p --raw</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---indent-heuristic"> --indent-heuristic </dt> <dd> <p>Enable the heuristic that shifts diff hunk boundaries to make patches easier to read. This is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---no-indent-heuristic"> --no-indent-heuristic </dt> <dd> <p>Disable the indent heuristic.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---minimal"> --minimal </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---patience"> --patience </dt> <dd> <p>Generate a diff using the "patience diff" algorithm.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---histogram"> --histogram </dt> <dd> <p>Generate a diff using the "histogram diff" algorithm.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---anchoredlttextgt"> --anchored=<text> </dt> <dd> <p>Generate a diff using the "anchored diff" algorithm.</p> <p>This option may be specified more than once.</p> <p>If a line exists in both the source and destination, exists only once, and starts with this text, this algorithm attempts to prevent it from appearing as a deletion or addition in the output. It uses the "patience diff" algorithm internally.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---diff-algorithmpatienceminimalhistogrammyers"> --diff-algorithm={patience|minimal|histogram|myers} </dt> <dd> <p>Choose a diff algorithm. The variants are as follows:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-files.txt-codedefaultcodecodemyerscode"> <code>default</code>, <code>myers</code> </dt> <dd> <p>The basic greedy diff algorithm. Currently, this is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-codeminimalcode"> <code>minimal</code> </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-codepatiencecode"> <code>patience</code> </dt> <dd> <p>Use "patience diff" algorithm when generating patches.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-codehistogramcode"> <code>histogram</code> </dt> <dd> <p>This algorithm extends the patience algorithm to "support low-occurrence common elements".</p> </dd> </dl> </div> </div> </div> <p>For instance, if you configured the <code>diff.algorithm</code> variable to a non-default value and want to use the default one, then you have to use <code>--diff-algorithm=default</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---statltwidthgtltname-widthgtltcountgt"> --stat[=<width>[,<name-width>[,<count>]]] </dt> <dd> <p>Generate a diffstat. By default, as much space as necessary will be used for the filename part, and the rest for the graph part. Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden by <code><width></code>. The width of the filename part can be limited by giving another width <code><name-width></code> after a comma or by setting <code>diff.statNameWidth=<width></code>. The width of the graph part can be limited by using <code>--stat-graph-width=<width></code> or by setting <code>diff.statGraphWidth=<width></code>. Using <code>--stat</code> or <code>--stat-graph-width</code> affects all commands generating a stat graph, while setting <code>diff.statNameWidth</code> or <code>diff.statGraphWidth</code> does not affect <code>git format-patch</code>. By giving a third parameter <code><count></code>, you can limit the output to the first <code><count></code> lines, followed by <code>...</code> if there are more.</p> <p>These parameters can also be set individually with <code>--stat-width=<width></code>, <code>--stat-name-width=<name-width></code> and <code>--stat-count=<count></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---compact-summary"> --compact-summary </dt> <dd> <p>Output a condensed summary of extended header information such as file creations or deletions ("new" or "gone", optionally "+l" if it’s a symlink) and mode changes ("+x" or "-x" for adding or removing executable bit respectively) in diffstat. The information is put between the filename part and the graph part. Implies <code>--stat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---numstat"> --numstat </dt> <dd> <p>Similar to <code>--stat</code>, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly. For binary files, outputs two <code>-</code> instead of saying <code>0 0</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---shortstat"> --shortstat </dt> <dd> <p>Output only the last line of the <code>--stat</code> format containing total number of modified files, as well as number of added and deleted lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--Xltparam1param282308203gt"> -X[<param1,param2,…>] </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---dirstatltparam1param282308203gt"> --dirstat[=<param1,param2,…>] </dt> <dd> <p>Output the distribution of relative amount of changes for each sub-directory. The behavior of <code>--dirstat</code> can be customized by passing it a comma separated list of parameters. The defaults are controlled by the <code>diff.dirstat</code> configuration variable (see <a href="git-config">git-config[1]</a>). The following parameters are available:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-files.txt-codechangescode"> <code>changes</code> </dt> <dd> <p>Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination. This ignores the amount of pure code movements within a file. In other words, rearranging lines in a file is not counted as much as other changes. This is the default behavior when no parameter is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-codelinescode"> <code>lines</code> </dt> <dd> <p>Compute the dirstat numbers by doing the regular line-based diff analysis, and summing the removed/added line counts. (For binary files, count 64-byte chunks instead, since binary files have no natural concept of lines). This is a more expensive <code>--dirstat</code> behavior than the <code>changes</code> behavior, but it does count rearranged lines within a file as much as other changes. The resulting output is consistent with what you get from the other <code>--*stat</code> options.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-codefilescode"> <code>files</code> </dt> <dd> <p>Compute the dirstat numbers by counting the number of files changed. Each changed file counts equally in the dirstat analysis. This is the computationally cheapest <code>--dirstat</code> behavior, since it does not have to look at the file contents at all.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-codecumulativecode"> <code>cumulative</code> </dt> <dd> <p>Count changes in a child directory for the parent directory as well. Note that when using <code>cumulative</code>, the sum of the percentages reported may exceed 100%. The default (non-cumulative) behavior can be specified with the <code>noncumulative</code> parameter.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-ltlimitgt"> <limit> </dt> <dd> <p>An integer parameter specifies a cut-off percent (3% by default). Directories contributing less than this percentage of the changes are not shown in the output.</p> </dd> </dl> </div> </div> </div> <p>Example: The following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories: <code>--dirstat=files,10,cumulative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---cumulative"> --cumulative </dt> <dd> <p>Synonym for --dirstat=cumulative</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---dirstat-by-fileltparam1param2gt82308203"> --dirstat-by-file[=<param1,param2>…] </dt> <dd> <p>Synonym for --dirstat=files,param1,param2…</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---summary"> --summary </dt> <dd> <p>Output a condensed summary of extended header information such as creations, renames and mode changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---patch-with-stat"> --patch-with-stat </dt> <dd> <p>Synonym for <code>-p --stat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--z"> -z </dt> <dd> <p>When <code>--raw</code>, <code>--numstat</code>, <code>--name-only</code> or <code>--name-status</code> has been given, do not munge pathnames and use NULs as output field terminators.</p> <p>Without this option, pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---name-only"> --name-only </dt> <dd> <p>Show only names of changed files. The file names are often encoded in UTF-8. For more information see the discussion about encoding in the <a href="git-log">git-log[1]</a> manual page.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---name-status"> --name-status </dt> <dd> <p>Show only names and status of changed files. See the description of the <code>--diff-filter</code> option on what the status letters mean. Just like <code>--name-only</code> the file names are often encoded in UTF-8.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---submoduleltformatgt"> --submodule[=<format>] </dt> <dd> <p>Specify how differences in submodules are shown. When specifying <code>--submodule=short</code> the <code>short</code> format is used. This format just shows the names of the commits at the beginning and end of the range. When <code>--submodule</code> or <code>--submodule=log</code> is specified, the <code>log</code> format is used. This format lists the commits in the range like <a href="git-submodule">git-submodule[1]</a> <code>summary</code> does. When <code>--submodule=diff</code> is specified, the <code>diff</code> format is used. This format shows an inline diff of the changes in the submodule contents between the commit range. Defaults to <code>diff.submodule</code> or the <code>short</code> format if the config option is unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---colorltwhengt"> --color[=<when>] </dt> <dd> <p>Show colored diff. <code>--color</code> (i.e. without <code>=<when></code>) is the same as <code>--color=always</code>. <code><when></code> can be one of <code>always</code>, <code>never</code>, or <code>auto</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---no-color"> --no-color </dt> <dd> <p>Turn off colored diff. It is the same as <code>--color=never</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---color-movedltmodegt"> --color-moved[=<mode>] </dt> <dd> <p>Moved lines of code are colored differently. The <mode> defaults to <code>no</code> if the option is not given and to <code>zebra</code> if the option with no mode is given. The mode must be one of:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-files.txt-no"> no </dt> <dd> <p>Moved lines are not highlighted.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-default"> default </dt> <dd> <p>Is a synonym for <code>zebra</code>. This may change to a more sensible mode in the future.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-plain"> plain </dt> <dd> <p>Any line that is added in one location and was removed in another location will be colored with <code>color.diff.newMoved</code>. Similarly <code>color.diff.oldMoved</code> will be used for removed lines that are added somewhere else in the diff. This mode picks up any moved line, but it is not very useful in a review to determine if a block of code was moved without permutation.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-blocks"> blocks </dt> <dd> <p>Blocks of moved text of at least 20 alphanumeric characters are detected greedily. The detected blocks are painted using either the <code>color.diff.{old,new}Moved</code> color. Adjacent blocks cannot be told apart.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-zebra"> zebra </dt> <dd> <p>Blocks of moved text are detected as in <code>blocks</code> mode. The blocks are painted using either the <code>color.diff.{old,new}Moved</code> color or <code>color.diff.{old,new}MovedAlternative</code>. The change between the two colors indicates that a new block was detected.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-dimmed-zebra"> dimmed-zebra </dt> <dd> <p>Similar to <code>zebra</code>, but additional dimming of uninteresting parts of moved code is performed. The bordering lines of two adjacent blocks are considered interesting, the rest is uninteresting. <code>dimmed_zebra</code> is a deprecated synonym.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---no-color-moved"> --no-color-moved </dt> <dd> <p>Turn off move detection. This can be used to override configuration settings. It is the same as <code>--color-moved=no</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---color-moved-wsltmodesgt"> --color-moved-ws=<modes> </dt> <dd> <p>This configures how whitespace is ignored when performing the move detection for <code>--color-moved</code>. These modes can be given as a comma separated list:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-files.txt-no-1"> no </dt> <dd> <p>Do not ignore whitespace when performing move detection.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-ignore-space-at-eol"> ignore-space-at-eol </dt> <dd> <p>Ignore changes in whitespace at EOL.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-ignore-space-change"> ignore-space-change </dt> <dd> <p>Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-ignore-all-space"> ignore-all-space </dt> <dd> <p>Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-allow-indentation-change"> allow-indentation-change </dt> <dd> <p>Initially ignore any whitespace in the move detection, then group the moved code blocks only into a block if the change in whitespace is the same per line. This is incompatible with the other modes.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---no-color-moved-ws"> --no-color-moved-ws </dt> <dd> <p>Do not ignore whitespace when performing move detection. This can be used to override configuration settings. It is the same as <code>--color-moved-ws=no</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---word-diffltmodegt"> --word-diff[=<mode>] </dt> <dd> <p>Show a word diff, using the <mode> to delimit changed words. By default, words are delimited by whitespace; see <code>--word-diff-regex</code> below. The <mode> defaults to <code>plain</code>, and must be one of:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-files.txt-color"> color </dt> <dd> <p>Highlight changed words using only colors. Implies <code>--color</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-plain-1"> plain </dt> <dd> <p>Show words as <code>[-removed-]</code> and <code>{+added+}</code>. Makes no attempts to escape the delimiters if they appear in the input, so the output may be ambiguous.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-porcelain"> porcelain </dt> <dd> <p>Use a special line-based format intended for script consumption. Added/removed/unchanged runs are printed in the usual unified diff format, starting with a <code>+</code>/<code>-</code>/` ` character at the beginning of the line and extending to the end of the line. Newlines in the input are represented by a tilde <code>~</code> on a line of its own.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-none"> none </dt> <dd> <p>Disable word diff again.</p> </dd> </dl> </div> </div> </div> <p>Note that despite the name of the first mode, color is used to highlight the changed parts in all modes if enabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---word-diff-regexltregexgt"> --word-diff-regex=<regex> </dt> <dd> <p>Use <regex> to decide what a word is, instead of considering runs of non-whitespace to be a word. Also implies <code>--word-diff</code> unless it was already enabled.</p> <p>Every non-overlapping match of the <regex> is considered a word. Anything between these matches is considered whitespace and ignored(!) for the purposes of finding differences. You may want to append <code>|[^[:space:]]</code> to your regular expression to make sure that it matches all non-whitespace characters. A match that contains a newline is silently truncated(!) at the newline.</p> <p>For example, <code>--word-diff-regex=.</code> will treat each character as a word and, correspondingly, show differences character by character.</p> <p>The regex can also be set via a diff driver or configuration option, see <a href="gitattributes">gitattributes[5]</a> or <a href="git-config">git-config[1]</a>. Giving it explicitly overrides any diff driver or configuration setting. Diff drivers override configuration settings.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---color-wordsltregexgt"> --color-words[=<regex>] </dt> <dd> <p>Equivalent to <code>--word-diff=color</code> plus (if a regex was specified) <code>--word-diff-regex=<regex></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---no-renames"> --no-renames </dt> <dd> <p>Turn off rename detection, even when the configuration file gives the default to do so.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---no-rename-empty"> --[no-]rename-empty </dt> <dd> <p>Whether to use empty blobs as rename source.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---check"> --check </dt> <dd> <p>Warn if changes introduce conflict markers or whitespace errors. What are considered whitespace errors is controlled by <code>core.whitespace</code> configuration. By default, trailing whitespaces (including lines that consist solely of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors. Exits with non-zero status if problems are found. Not compatible with --exit-code.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---ws-error-highlightltkindgt"> --ws-error-highlight=<kind> </dt> <dd> <p>Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code> lines of the diff. Multiple values are separated by comma, <code>none</code> resets previous values, <code>default</code> reset the list to <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. When this option is not given, and the configuration variable <code>diff.wsErrorHighlight</code> is not set, only whitespace errors in <code>new</code> lines are highlighted. The whitespace errors are colored with <code>color.diff.whitespace</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---full-index"> --full-index </dt> <dd> <p>Instead of the first handful of characters, show the full pre- and post-image blob object names on the "index" line when generating patch format output.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---binary"> --binary </dt> <dd> <p>In addition to <code>--full-index</code>, output a binary diff that can be applied with <code>git-apply</code>. Implies <code>--patch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---abbrevltngt"> --abbrev[=<n>] </dt> <dd> <p>Instead of showing the full 40-byte hexadecimal object name in diff-raw format output and diff-tree header lines, show the shortest prefix that is at least <code><n></code> hexdigits long that uniquely refers the object. In diff-patch output format, <code>--full-index</code> takes higher precedence, i.e. if <code>--full-index</code> is specified, full blob names will be shown regardless of <code>--abbrev</code>. Non default number of digits can be specified with <code>--abbrev=<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--Bltngtltmgt"> -B[<n>][/<m>] </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---break-rewritesltngtltmgt"> --break-rewrites[=[<n>][/<m>]] </dt> <dd> <p>Break complete rewrite changes into pairs of delete and create. This serves two purposes:</p> <p>It affects the way a change that amounts to a total rewrite of a file not as a series of deletion and insertion mixed together with a very few lines that happen to match textually as the context, but as a single deletion of everything old followed by a single insertion of everything new, and the number <code>m</code> controls this aspect of the -B option (defaults to 60%). <code>-B/70%</code> specifies that less than 30% of the original should remain in the result for Git to consider it a total rewrite (i.e. otherwise the resulting patch will be a series of deletion and insertion mixed together with context lines).</p> <p>When used with -M, a totally-rewritten file is also considered as the source of a rename (usually -M only considers a file that disappeared as the source of a rename), and the number <code>n</code> controls this aspect of the -B option (defaults to 50%). <code>-B20%</code> specifies that a change with addition and deletion compared to 20% or more of the file’s size are eligible for being picked up as a possible source of a rename to another file.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--Mltngt"> -M[<n>] </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---find-renamesltngt"> --find-renames[=<n>] </dt> <dd> <p>Detect renames. If <code>n</code> is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file’s size). For example, <code>-M90%</code> means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn’t changed. Without a <code>%</code> sign, the number is to be read as a fraction, with a decimal point before it. I.e., <code>-M5</code> becomes 0.5, and is thus the same as <code>-M50%</code>. Similarly, <code>-M05</code> is the same as <code>-M5%</code>. To limit detection to exact renames, use <code>-M100%</code>. The default similarity index is 50%.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--Cltngt"> -C[<n>] </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---find-copiesltngt"> --find-copies[=<n>] </dt> <dd> <p>Detect copies as well as renames. See also <code>--find-copies-harder</code>. If <code>n</code> is specified, it has the same meaning as for <code>-M<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---find-copies-harder"> --find-copies-harder </dt> <dd> <p>For performance reasons, by default, <code>-C</code> option finds copies only if the original file of the copy was modified in the same changeset. This flag makes the command inspect unmodified files as candidates for the source of copy. This is a very expensive operation for large projects, so use it with caution. Giving more than one <code>-C</code> option has the same effect.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--D"> -D </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---irreversible-delete"> --irreversible-delete </dt> <dd> <p>Omit the preimage for deletes, i.e. print only the header but not the diff between the preimage and <code>/dev/null</code>. The resulting patch is not meant to be applied with <code>patch</code> or <code>git apply</code>; this is solely for people who want to just concentrate on reviewing the text after the change. In addition, the output obviously lacks enough information to apply such a patch in reverse, even manually, hence the name of the option.</p> <p>When used together with <code>-B</code>, omit also the preimage in the deletion part of a delete/create pair.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--lltnumgt"> -l<num> </dt> <dd> <p>The <code>-M</code> and <code>-C</code> options involve some preliminary steps that can detect subsets of renames/copies cheaply, followed by an exhaustive fallback portion that compares all remaining unpaired destinations to all relevant sources. (For renames, only remaining unpaired sources are relevant; for copies, all original sources are relevant.) For N sources and destinations, this exhaustive check is O(N^2). This option prevents the exhaustive portion of rename/copy detection from running if the number of source/destination files involved exceeds the specified number. Defaults to diff.renameLimit. Note that a value of 0 is treated as unlimited.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---diff-filterACDMRTUXB82308203"> --diff-filter=[(A|C|D|M|R|T|U|X|B)…[*]] </dt> <dd> <p>Select only files that are Added (<code>A</code>), Copied (<code>C</code>), Deleted (<code>D</code>), Modified (<code>M</code>), Renamed (<code>R</code>), have their type (i.e. regular file, symlink, submodule, …) changed (<code>T</code>), are Unmerged (<code>U</code>), are Unknown (<code>X</code>), or have had their pairing Broken (<code>B</code>). Any combination of the filter characters (including none) can be used. When <code>*</code> (All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.</p> <p>Also, these upper-case letters can be downcased to exclude. E.g. <code>--diff-filter=ad</code> excludes added and deleted paths.</p> <p>Note that not all diffs can feature all types. For instance, copied and renamed entries cannot appear if detection for those types is disabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--Sltstringgt"> -S<string> </dt> <dd> <p>Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file. Intended for the scripter’s use.</p> <p>It is useful when you’re looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting block in the preimage back into <code>-S</code>, and keep going until you get the very first version of the block.</p> <p>Binary files are searched as well.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--Gltregexgt"> -G<regex> </dt> <dd> <p>Look for differences whose patch text contains added/removed lines that match <regex>.</p> <p>To illustrate the difference between <code>-S<regex> --pickaxe-regex</code> and <code>-G<regex></code>, consider a commit with the following diff in the same file:</p> <div class="listingblock"> <div class="content"> <pre>+ return frotz(nitfol, two->ptr, 1, 0); +... +- hit = frotz(nitfol, mf2.ptr, 1, 0);</pre> </div> </div> <p>While <code>git log -G"frotz\(nitfol"</code> will show this commit, <code>git log +-S"frotz\(nitfol" --pickaxe-regex</code> will not (because the number of occurrences of that string did not change).</p> <p>Unless <code>--text</code> is supplied patches of binary files without a textconv filter will be ignored.</p> <p>See the <code>pickaxe</code> entry in <a href="gitdiffcore">gitdiffcore[7]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---find-objectltobject-idgt"> --find-object=<object-id> </dt> <dd> <p>Look for differences that change the number of occurrences of the specified object. Similar to <code>-S</code>, just the argument is different in that it doesn’t search for a specific string but for a specific object id.</p> <p>The object can be a blob or a submodule commit. It implies the <code>-t</code> option in <code>git-log</code> to also find trees.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---pickaxe-all"> --pickaxe-all </dt> <dd> <p>When <code>-S</code> or <code>-G</code> finds a change, show all the changes in that changeset, not just the files that contain the change in <string>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---pickaxe-regex"> --pickaxe-regex </dt> <dd> <p>Treat the <string> given to <code>-S</code> as an extended POSIX regular expression to match.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--Oltorderfilegt"> -O<orderfile> </dt> <dd> <p>Control the order in which files appear in the output. This overrides the <code>diff.orderFile</code> configuration variable (see <a href="git-config">git-config[1]</a>). To cancel <code>diff.orderFile</code>, use <code>-O/dev/null</code>.</p> <p>The output order is determined by the order of glob patterns in <orderfile>. All files with pathnames that match the first pattern are output first, all files with pathnames that match the second pattern (but not the first) are output next, and so on. All files with pathnames that do not match any pattern are output last, as if there was an implicit match-all pattern at the end of the file. If multiple pathnames have the same rank (they match the same pattern but no earlier patterns), their output order relative to each other is the normal order.</p> <p><orderfile> is parsed as follows:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>Blank lines are ignored, so they can be used as separators for readability.</p> </li> <li> <p>Lines starting with a hash ("<code>#</code>") are ignored, so they can be used for comments. Add a backslash ("<code>\</code>") to the beginning of the pattern if it starts with a hash.</p> </li> <li> <p>Each other line contains a single pattern.</p> </li> </ul> </div> </div> </div> <p>Patterns have the same syntax and semantics as patterns used for fnmatch(3) without the FNM_PATHNAME flag, except a pathname also matches a pattern if removing any number of the final pathname components matches the pattern. For example, the pattern "<code>foo*bar</code>" matches "<code>fooasdfbar</code>" and "<code>foo/bar/baz/asdf</code>" but not "<code>foobarx</code>".</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---skip-toltfilegt"> --skip-to=<file> </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---rotate-toltfilegt"> --rotate-to=<file> </dt> <dd> <p>Discard the files before the named <file> from the output (i.e. <code>skip to</code>), or move them to the end of the output (i.e. <code>rotate to</code>). These options were invented primarily for the use of the <code>git difftool</code> command, and may not be very useful otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--R"> -R </dt> <dd> <p>Swap two inputs; that is, show differences from index or on-disk file to tree contents.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---relativeltpathgt"> --relative[=<path>] </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---no-relative"> --no-relative </dt> <dd> <p>When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option. When you are not in a subdirectory (e.g. in a bare repository), you can name which subdirectory to make the output relative to by giving a <path> as an argument. <code>--no-relative</code> can be used to countermand both <code>diff.relative</code> config option and previous <code>--relative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---text"> --text </dt> <dd> <p>Treat all files as text.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---ignore-cr-at-eol"> --ignore-cr-at-eol </dt> <dd> <p>Ignore carriage-return at the end of line when doing a comparison.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---ignore-space-at-eol"> --ignore-space-at-eol </dt> <dd> <p>Ignore changes in whitespace at EOL.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--b"> -b </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---ignore-space-change"> --ignore-space-change </dt> <dd> <p>Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--w"> -w </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---ignore-all-space"> --ignore-all-space </dt> <dd> <p>Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---ignore-blank-lines"> --ignore-blank-lines </dt> <dd> <p>Ignore changes whose lines are all blank.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--Iltregexgt"> -I<regex> </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---ignore-matching-linesltregexgt"> --ignore-matching-lines=<regex> </dt> <dd> <p>Ignore changes whose all lines match <regex>. This option may be specified more than once.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---inter-hunk-contextltlinesgt"> --inter-hunk-context=<lines> </dt> <dd> <p>Show the context between diff hunks, up to the specified number of lines, thereby fusing hunks that are close to each other. Defaults to <code>diff.interHunkContext</code> or 0 if the config option is unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--W"> -W </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---function-context"> --function-context </dt> <dd> <p>Show whole function as context lines for each change. The function names are determined in the same way as <code>git diff</code> works out patch hunk headers (see <code>Defining a custom hunk-header</code> in <a href="gitattributes">gitattributes[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---exit-code"> --exit-code </dt> <dd> <p>Make the program exit with codes similar to diff(1). That is, it exits with 1 if there were differences and 0 means no differences.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---quiet"> --quiet </dt> <dd> <p>Disable all output of the program. Implies <code>--exit-code</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---ext-diff"> --ext-diff </dt> <dd> <p>Allow an external diff helper to be executed. If you set an external diff driver with <a href="gitattributes">gitattributes[5]</a>, you need to use this option with <a href="git-log">git-log[1]</a> and friends.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---no-ext-diff"> --no-ext-diff </dt> <dd> <p>Disallow external diff drivers.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---textconv"> --textconv </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---no-textconv"> --no-textconv </dt> <dd> <p>Allow (or disallow) external text conversion filters to be run when comparing binary files. See <a href="gitattributes">gitattributes[5]</a> for details. Because textconv filters are typically a one-way conversion, the resulting diff is suitable for human consumption, but cannot be applied. For this reason, textconv filters are enabled by default only for <a href="git-diff">git-diff[1]</a> and <a href="git-log">git-log[1]</a>, but not for <a href="git-format-patch">git-format-patch[1]</a> or diff plumbing commands.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---ignore-submodulesltwhengt"> --ignore-submodules[=<when>] </dt> <dd> <p>Ignore changes to submodules in the diff generation. <when> can be either "none", "untracked", "dirty" or "all", which is the default. Using "none" will consider the submodule modified when it either contains untracked or modified files or its HEAD differs from the commit recorded in the superproject and can be used to override any settings of the <code>ignore</code> option in <a href="git-config">git-config[1]</a> or <a href="gitmodules">gitmodules[5]</a>. When "untracked" is used submodules are not considered dirty when they only contain untracked content (but they are still scanned for modified content). Using "dirty" ignores all changes to the work tree of submodules, only changes to the commits stored in the superproject are shown (this was the behavior until 1.7.0). Using "all" hides all changes to submodules.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---src-prefixltprefixgt"> --src-prefix=<prefix> </dt> <dd> <p>Show the given source prefix instead of "a/".</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---dst-prefixltprefixgt"> --dst-prefix=<prefix> </dt> <dd> <p>Show the given destination prefix instead of "b/".</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---no-prefix"> --no-prefix </dt> <dd> <p>Do not show any source or destination prefix.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---default-prefix"> --default-prefix </dt> <dd> <p>Use the default source and destination prefixes ("a/" and "b/"). This is usually the default already, but may be used to override config such as <code>diff.noprefix</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---line-prefixltprefixgt"> --line-prefix=<prefix> </dt> <dd> <p>Prepend an additional prefix to every line of output.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt---ita-invisible-in-index"> --ita-invisible-in-index </dt> <dd> <p>By default entries added by "git add -N" appear as an existing empty file in "git diff" and a new file in "git diff --cached". This option makes the entry appear as a new file in "git diff" and non-existent in "git diff --cached". This option could be reverted with <code>--ita-visible-in-index</code>. Both options are experimental and could be removed in future.</p> </dd> </dl> </div> <p>For more detailed explanation on these common options, see also <a href="gitdiffcore">gitdiffcore[7]</a>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-files.txt--1--base"> -1 --base </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt--2--ours"> -2 --ours </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt--3--theirs"> -3 --theirs </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt--0"> -0 </dt> <dd> <p>Diff against the "base" version, "our branch", or "their branch" respectively. With these options, diffs for merged entries are not shown.</p> <p>The default is to diff against our branch (-2) and the cleanly resolved paths. The option -0 can be given to omit diff output for unmerged entries and just show "Unmerged".</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--c"> -c </dt> <dt class="hdlist1" id="Documentation/git-diff-files.txt---cc"> --cc </dt> <dd> <p>This compares stage 2 (our branch), stage 3 (their branch), and the working tree file and outputs a combined diff, similar to the way <code>diff-tree</code> shows a merge commit with these flags.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt--q"> -q </dt> <dd> <p>Remain silent even for nonexistent files</p> </dd> </dl> </div> </div> <h2 id="_raw_output_format">Raw output format</h2> <div class="sectionbody"> <p>The raw output format from "git-diff-index", "git-diff-tree", "git-diff-files" and "git diff --raw" are very similar.</p> <p>These commands all compare two sets of things; what is compared differs:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-files.txt-git-diff-indexlttree-ishgt"> git-diff-index <tree-ish> </dt> <dd> <p>compares the <tree-ish> and the files on the filesystem.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-git-diff-index--cachedlttree-ishgt"> git-diff-index --cached <tree-ish> </dt> <dd> <p>compares the <tree-ish> and the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-git-diff-tree-rlttree-ish-1gtlttree-ish-2gtltpatterngt82308203"> git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…] </dt> <dd> <p>compares the trees named by the two arguments.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-files.txt-git-diff-filesltpatterngt82308203"> git-diff-files [<pattern>…] </dt> <dd> <p>compares the index and the files on the filesystem.</p> </dd> </dl> </div> <p>The "git-diff-tree" command begins its output by printing the hash of what is being compared. After that, all the commands print one output line per changed file.</p> <p>An output line is formatted this way:</p> <div class="listingblock"> <div class="content"> <pre>in-place edit :100644 100644 bcd1234 0123456 M file0 +copy-edit :100644 100644 abcd123 1234567 C68 file1 file2 +rename-edit :100644 100644 abcd123 1234567 R86 file1 file3 +create :000000 100644 0000000 1234567 A file4 +delete :100644 000000 1234567 0000000 D file5 +unmerged :000000 000000 0000000 0000000 U file6</pre> </div> </div> <p>That is, from the left to the right:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>a colon.</p> </li> <li> <p>mode for "src"; 000000 if creation or unmerged.</p> </li> <li> <p>a space.</p> </li> <li> <p>mode for "dst"; 000000 if deletion or unmerged.</p> </li> <li> <p>a space.</p> </li> <li> <p>sha1 for "src"; 0{40} if creation or unmerged.</p> </li> <li> <p>a space.</p> </li> <li> <p>sha1 for "dst"; 0{40} if deletion, unmerged or "work tree out of sync with the index".</p> </li> <li> <p>a space.</p> </li> <li> <p>status, followed by optional "score" number.</p> </li> <li> <p>a tab or a NUL when <code>-z</code> option is used.</p> </li> <li> <p>path for "src"</p> </li> <li> <p>a tab or a NUL when <code>-z</code> option is used; only exists for C or R.</p> </li> <li> <p>path for "dst"; only exists for C or R.</p> </li> <li> <p>an LF or a NUL when <code>-z</code> option is used, to terminate the record.</p> </li> </ol> </div> <p>Possible status letters are:</p> <div class="ulist"> <ul> <li> <p>A: addition of a file</p> </li> <li> <p>C: copy of a file into a new one</p> </li> <li> <p>D: deletion of a file</p> </li> <li> <p>M: modification of the contents or mode of a file</p> </li> <li> <p>R: renaming of a file</p> </li> <li> <p>T: change in the type of the file (regular file, symbolic link or submodule)</p> </li> <li> <p>U: file is unmerged (you must complete the merge before it can be committed)</p> </li> <li> <p>X: "unknown" change type (most probably a bug, please report it)</p> </li> </ul> </div> <p>Status letters C and R are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy). Status letter M may be followed by a score (denoting the percentage of dissimilarity) for file rewrites.</p> <p>The sha1 for "dst" is shown as all 0’s if a file on the filesystem is out of sync with the index.</p> <p>Example:</p> <div class="listingblock"> <div class="content"> <pre>:100644 100644 5be4a4a 0000000 M file.c</pre> </div> </div> <p>Without the <code>-z</code> option, pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>). Using <code>-z</code> the filename is output verbatim and the line is terminated by a NUL byte.</p> </div> <h2 id="_diff_format_for_merges">Diff format for merges</h2> <div class="sectionbody"> <p>"git-diff-tree", "git-diff-files" and "git-diff --raw" can take <code>-c</code> or <code>--cc</code> option to generate diff output also for merge commits. The output differs from the format described above in the following way:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>there is a colon for each parent</p> </li> <li> <p>there are more "src" modes and "src" sha1</p> </li> <li> <p>status is concatenated status characters for each parent</p> </li> <li> <p>no optional "score" number</p> </li> <li> <p>tab-separated pathname(s) of the file</p> </li> </ol> </div> <p>For <code>-c</code> and <code>--cc</code>, only the destination or final path is shown even if the file was renamed on any side of history. With <code>--combined-all-paths</code>, the name of the path in each parent is shown followed by the name of the path in the merge commit.</p> <p>Examples for <code>-c</code> and <code>--cc</code> without <code>--combined-all-paths</code>:</p> <div class="listingblock"> <div class="content"> <pre>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c +::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM bar.sh +::100644 100644 100644 e07d6c5 9042e82 ee91881 RR phooey.c</pre> </div> </div> <p>Examples when <code>--combined-all-paths</code> added to either <code>-c</code> or <code>--cc</code>:</p> <div class="listingblock"> <div class="content"> <pre>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c desc.c desc.c +::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM foo.sh bar.sh bar.sh +::100644 100644 100644 e07d6c5 9042e82 ee91881 RR fooey.c fuey.c phooey.c</pre> </div> </div> <p>Note that <code>combined diff</code> lists only files which were modified from all parents.</p> </div> <h2 id="generate_patch_text_with_p">Generating patch text with -p</h2> <div class="sectionbody"> <p>Running <a href="git-diff">git-diff[1]</a>, <a href="git-log">git-log[1]</a>, <a href="git-show">git-show[1]</a>, <a href="git-diff-index">git-diff-index[1]</a>, <a href="git-diff-tree">git-diff-tree[1]</a>, or <a href="git-diff-files">git-diff-files[1]</a> with the <code>-p</code> option produces patch text. You can customize the creation of patch text via the <code>GIT_EXTERNAL_DIFF</code> and the <code>GIT_DIFF_OPTS</code> environment variables (see <a href="git">git[1]</a>), and the <code>diff</code> attribute (see <a href="gitattributes">gitattributes[5]</a>).</p> <p>What the -p option produces is slightly different from the traditional diff format:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>It is preceded by a "git diff" header that looks like this:</p> <div class="literalblock"> <div class="content"> <pre>diff --git a/file1 b/file2</pre> </div> </div> <p>The <code>a/</code> and <code>b/</code> filenames are the same unless rename/copy is involved. Especially, even for a creation or a deletion, <code>/dev/null</code> is <code>not</code> used in place of the <code>a/</code> or <code>b/</code> filenames.</p> <p>When a rename/copy is involved, <code>file1</code> and <code>file2</code> show the name of the source file of the rename/copy and the name of the file that the rename/copy produces, respectively.</p> </li> <li> <p>It is followed by one or more extended header lines:</p> <div class="literalblock"> <div class="content"> <pre>old mode <mode> +new mode <mode> +deleted file mode <mode> +new file mode <mode> +copy from <path> +copy to <path> +rename from <path> +rename to <path> +similarity index <number> +dissimilarity index <number> +index <hash>..<hash> <mode></pre> </div> </div> <p>File modes are printed as 6-digit octal numbers including the file type and file permission bits.</p> <p>Path names in extended headers do not include the <code>a/</code> and <code>b/</code> prefixes.</p> <p>The similarity index is the percentage of unchanged lines, and the dissimilarity index is the percentage of changed lines. It is a rounded down integer, followed by a percent sign. The similarity index value of 100% is thus reserved for two equal files, while 100% dissimilarity means that no line from the old file made it into the new one.</p> <p>The index line includes the blob object names before and after the change. The <mode> is included if the file mode does not change; otherwise, separate lines indicate the old and the new mode.</p> </li> <li> <p>Pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>).</p> </li> <li> <p>All the <code>file1</code> files in the output refer to files before the commit, and all the <code>file2</code> files refer to files after the commit. It is incorrect to apply each change to each file sequentially. For example, this patch will swap a and b:</p> <div class="literalblock"> <div class="content"> <pre>diff --git a/a b/b +rename from a +rename to b +diff --git a/b b/a +rename from b +rename to a</pre> </div> </div> </li> <li> <p>Hunk headers mention the name of the function to which the hunk applies. See "Defining a custom hunk-header" in <a href="gitattributes">gitattributes[5]</a> for details of how to tailor this to specific languages.</p> </li> </ol> </div> </div> <h2 id="_combined_diff_format">Combined diff format</h2> <div class="sectionbody"> <p>Any diff-generating command can take the <code>-c</code> or <code>--cc</code> option to produce a <code>combined diff</code> when showing a merge. This is the default format when showing merges with <a href="git-diff">git-diff[1]</a> or <a href="git-show">git-show[1]</a>. Note also that you can give suitable <code>--diff-merges</code> option to any of these commands to force generation of diffs in a specific format.</p> <p>A "combined diff" format looks like this:</p> <div class="listingblock"> <div class="content"> <pre>diff --combined describe.c +index fabadb8,cc95eb0..4866510 +--- a/describe.c ++++ b/describe.c +@@@ -98,20 -98,12 +98,20 @@@ + return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; + } + +- static void describe(char *arg) + -static void describe(struct commit *cmit, int last_one) +++static void describe(char *arg, int last_one) + { + + unsigned char sha1[20]; + + struct commit *cmit; + struct commit_list *list; + static int initialized = 0; + struct commit_name *n; + + + if (get_sha1(arg, sha1) < 0) + + usage(describe_usage); + + cmit = lookup_commit_reference(sha1); + + if (!cmit) + + usage(describe_usage); + + + if (!initialized) { + initialized = 1; + for_each_ref(get_name);</pre> </div> </div> <div class="olist arabic"> <ol class="arabic"> <li> <p>It is preceded by a "git diff" header, that looks like this (when the <code>-c</code> option is used):</p> <div class="literalblock"> <div class="content"> <pre>diff --combined file</pre> </div> </div> <p>or like this (when the <code>--cc</code> option is used):</p> <div class="literalblock"> <div class="content"> <pre>diff --cc file</pre> </div> </div> </li> <li> <p>It is followed by one or more extended header lines (this example shows a merge with two parents):</p> <div class="literalblock"> <div class="content"> <pre>index <hash>,<hash>..<hash> +mode <mode>,<mode>..<mode> +new file mode <mode> +deleted file mode <mode>,<mode></pre> </div> </div> <p>The <code>mode <mode>,<mode>..<mode></code> line appears only if at least one of the <mode> is different from the rest. Extended headers with information about detected content movement (renames and copying detection) are designed to work with the diff of two <tree-ish> and are not used by combined diff format.</p> </li> <li> <p>It is followed by a two-line from-file/to-file header:</p> <div class="literalblock"> <div class="content"> <pre>--- a/file ++++ b/file</pre> </div> </div> <p>Similar to the two-line header for the traditional <code>unified</code> diff format, <code>/dev/null</code> is used to signal created or deleted files.</p> <p>However, if the --combined-all-paths option is provided, instead of a two-line from-file/to-file, you get an N+1 line from-file/to-file header, where N is the number of parents in the merge commit:</p> <div class="literalblock"> <div class="content"> <pre>--- a/file +--- a/file +--- a/file ++++ b/file</pre> </div> </div> <p>This extended format can be useful if rename or copy detection is active, to allow you to see the original name of the file in different parents.</p> </li> <li> <p>Chunk header format is modified to prevent people from accidentally feeding it to <code>patch -p1</code>. Combined diff format was created for review of merge commit changes, and was not meant to be applied. The change is similar to the change in the extended <code>index</code> header:</p> <div class="literalblock"> <div class="content"> <pre>@@@ <from-file-range> <from-file-range> <to-file-range> @@@</pre> </div> </div> <p>There are (number of parents + 1) <code>@</code> characters in the chunk header for combined diff format.</p> </li> </ol> </div> <p>Unlike the traditional <code>unified</code> diff format, which shows two files A and B with a single column that has <code>-</code> (minus — appears in A but removed in B), <code>+</code> (plus — missing in A but added to B), or <code>" "</code> (space — unchanged) prefix, this format compares two or more files file1, file2,… with one file X, and shows how X differs from each of fileN. One column for each of fileN is prepended to the output line to note how X’s line is different from it.</p> <p>A <code>-</code> character in the column N means that the line appears in fileN but it does not appear in the result. A <code>+</code> character in the column N means that the line appears in the result, and fileN does not have that line (in other words, the line was added, from the point of view of that parent).</p> <p>In the above example output, the function signature was changed from both files (hence two <code>-</code> removals from both file1 and file2, plus <code>++</code> to mean one line that was added does not appear in either file1 or file2). Also, eight other lines are the same from file1 but do not appear in file2 (hence prefixed with <code>+</code>).</p> <p>When shown by <code>git diff-tree -c</code>, it compares the parents of a merge commit with the merge result (i.e. file1..fileN are the parents). When shown by <code>git diff-files -c</code>, it compares the two unresolved merge parents with the working tree file (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka "their version").</p> </div> <h2 id="_other_diff_formats">Other diff formats</h2> <div class="sectionbody"> <p>The <code>--summary</code> option describes newly added, deleted, renamed and copied files. The <code>--stat</code> option adds diffstat(1) graph to the output. These options can be combined with other options, such as <code>-p</code>, and are meant for human consumption.</p> <p>When showing a change that involves a rename or a copy, <code>--stat</code> output formats the pathnames compactly by combining common prefix and suffix of the pathnames. For example, a change that moves <code>arch/i386/Makefile</code> to <code>arch/x86/Makefile</code> while modifying 4 lines will be shown like this:</p> <div class="listingblock"> <div class="content"> <pre>arch/{i386 => x86}/Makefile | 4 +--</pre> </div> </div> <p>The <code>--numstat</code> option gives the diffstat(1) information but is designed for easier machine consumption. An entry in <code>--numstat</code> output looks like this:</p> <div class="listingblock"> <div class="content"> <pre>1 2 README +3 1 arch/{i386 => x86}/Makefile</pre> </div> </div> <p>That is, from left to right:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>the number of added lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>the number of deleted lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>pathname (possibly with rename/copy information);</p> </li> <li> <p>a newline.</p> </li> </ol> </div> <p>When <code>-z</code> output option is in effect, the output is formatted this way:</p> <div class="listingblock"> <div class="content"> <pre>1 2 README NUL +3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</pre> </div> </div> <p>That is:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>the number of added lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>the number of deleted lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>a NUL (only exists if renamed/copied);</p> </li> <li> <p>pathname in preimage;</p> </li> <li> <p>a NUL (only exists if renamed/copied);</p> </li> <li> <p>pathname in postimage (only exists if renamed/copied);</p> </li> <li> <p>a NUL.</p> </li> </ol> </div> <p>The extra <code>NUL</code> before the preimage path in renamed case is to allow scripts that read the output to tell if the current record being read is a single-path record or a rename/copy record without reading ahead. After reading added and deleted lines, reading up to <code>NUL</code> would yield the pathname, but if that is <code>NUL</code>, the record will show two paths.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-diff-files" class="_attribution-link">https://git-scm.com/docs/git-diff-files</a> + </p> +</div> diff --git a/devdocs/git/git-diff-index.html b/devdocs/git/git-diff-index.html new file mode 100644 index 00000000..bf043f0d --- /dev/null +++ b/devdocs/git/git-diff-index.html @@ -0,0 +1,73 @@ +<h1>git-diff-index</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-diff-index - Compare a tree to the working tree or index</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git diff-index [-m] [--cached] [--merge-base] [<common-diff-options>] <tree-ish> [<path>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Compare the content and mode of the blobs found in a tree object with the corresponding tracked files in the working tree, or with the corresponding paths in the index. When <path> arguments are present, compare only paths matching those patterns. Otherwise all tracked files are compared.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-index.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt--u"> -u </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---patch"> --patch </dt> <dd> <p>Generate patch (see <a href="#generate_patch_text_with_p">Generating patch text with -p</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---no-patch"> --no-patch </dt> <dd> <p>Suppress all output from the diff machinery. Useful for commands like <code>git show</code> that show the patch by default to squelch their output, or to cancel the effect of options like <code>--patch</code>, <code>--stat</code> earlier on the command line in an alias.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--Ultngt"> -U<n> </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---unifiedltngt"> --unified=<n> </dt> <dd> <p>Generate diffs with <n> lines of context instead of the usual three. Implies <code>--patch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---outputltfilegt"> --output=<file> </dt> <dd> <p>Output to a specific file instead of stdout.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---output-indicator-newltchargt"> --output-indicator-new=<char> </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---output-indicator-oldltchargt"> --output-indicator-old=<char> </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---output-indicator-contextltchargt"> --output-indicator-context=<char> </dt> <dd> <p>Specify the character used to indicate new, old or context lines in the generated patch. Normally they are <code>+</code>, <code>-</code> and ' ' respectively.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---raw"> --raw </dt> <dd> <p>Generate the diff in raw format. This is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---patch-with-raw"> --patch-with-raw </dt> <dd> <p>Synonym for <code>-p --raw</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---indent-heuristic"> --indent-heuristic </dt> <dd> <p>Enable the heuristic that shifts diff hunk boundaries to make patches easier to read. This is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---no-indent-heuristic"> --no-indent-heuristic </dt> <dd> <p>Disable the indent heuristic.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---minimal"> --minimal </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---patience"> --patience </dt> <dd> <p>Generate a diff using the "patience diff" algorithm.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---histogram"> --histogram </dt> <dd> <p>Generate a diff using the "histogram diff" algorithm.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---anchoredlttextgt"> --anchored=<text> </dt> <dd> <p>Generate a diff using the "anchored diff" algorithm.</p> <p>This option may be specified more than once.</p> <p>If a line exists in both the source and destination, exists only once, and starts with this text, this algorithm attempts to prevent it from appearing as a deletion or addition in the output. It uses the "patience diff" algorithm internally.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---diff-algorithmpatienceminimalhistogrammyers"> --diff-algorithm={patience|minimal|histogram|myers} </dt> <dd> <p>Choose a diff algorithm. The variants are as follows:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-index.txt-codedefaultcodecodemyerscode"> <code>default</code>, <code>myers</code> </dt> <dd> <p>The basic greedy diff algorithm. Currently, this is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-codeminimalcode"> <code>minimal</code> </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-codepatiencecode"> <code>patience</code> </dt> <dd> <p>Use "patience diff" algorithm when generating patches.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-codehistogramcode"> <code>histogram</code> </dt> <dd> <p>This algorithm extends the patience algorithm to "support low-occurrence common elements".</p> </dd> </dl> </div> </div> </div> <p>For instance, if you configured the <code>diff.algorithm</code> variable to a non-default value and want to use the default one, then you have to use <code>--diff-algorithm=default</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---statltwidthgtltname-widthgtltcountgt"> --stat[=<width>[,<name-width>[,<count>]]] </dt> <dd> <p>Generate a diffstat. By default, as much space as necessary will be used for the filename part, and the rest for the graph part. Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden by <code><width></code>. The width of the filename part can be limited by giving another width <code><name-width></code> after a comma or by setting <code>diff.statNameWidth=<width></code>. The width of the graph part can be limited by using <code>--stat-graph-width=<width></code> or by setting <code>diff.statGraphWidth=<width></code>. Using <code>--stat</code> or <code>--stat-graph-width</code> affects all commands generating a stat graph, while setting <code>diff.statNameWidth</code> or <code>diff.statGraphWidth</code> does not affect <code>git format-patch</code>. By giving a third parameter <code><count></code>, you can limit the output to the first <code><count></code> lines, followed by <code>...</code> if there are more.</p> <p>These parameters can also be set individually with <code>--stat-width=<width></code>, <code>--stat-name-width=<name-width></code> and <code>--stat-count=<count></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---compact-summary"> --compact-summary </dt> <dd> <p>Output a condensed summary of extended header information such as file creations or deletions ("new" or "gone", optionally "+l" if it’s a symlink) and mode changes ("+x" or "-x" for adding or removing executable bit respectively) in diffstat. The information is put between the filename part and the graph part. Implies <code>--stat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---numstat"> --numstat </dt> <dd> <p>Similar to <code>--stat</code>, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly. For binary files, outputs two <code>-</code> instead of saying <code>0 0</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---shortstat"> --shortstat </dt> <dd> <p>Output only the last line of the <code>--stat</code> format containing total number of modified files, as well as number of added and deleted lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--Xltparam1param282308203gt"> -X[<param1,param2,…>] </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---dirstatltparam1param282308203gt"> --dirstat[=<param1,param2,…>] </dt> <dd> <p>Output the distribution of relative amount of changes for each sub-directory. The behavior of <code>--dirstat</code> can be customized by passing it a comma separated list of parameters. The defaults are controlled by the <code>diff.dirstat</code> configuration variable (see <a href="git-config">git-config[1]</a>). The following parameters are available:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-index.txt-codechangescode"> <code>changes</code> </dt> <dd> <p>Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination. This ignores the amount of pure code movements within a file. In other words, rearranging lines in a file is not counted as much as other changes. This is the default behavior when no parameter is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-codelinescode"> <code>lines</code> </dt> <dd> <p>Compute the dirstat numbers by doing the regular line-based diff analysis, and summing the removed/added line counts. (For binary files, count 64-byte chunks instead, since binary files have no natural concept of lines). This is a more expensive <code>--dirstat</code> behavior than the <code>changes</code> behavior, but it does count rearranged lines within a file as much as other changes. The resulting output is consistent with what you get from the other <code>--*stat</code> options.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-codefilescode"> <code>files</code> </dt> <dd> <p>Compute the dirstat numbers by counting the number of files changed. Each changed file counts equally in the dirstat analysis. This is the computationally cheapest <code>--dirstat</code> behavior, since it does not have to look at the file contents at all.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-codecumulativecode"> <code>cumulative</code> </dt> <dd> <p>Count changes in a child directory for the parent directory as well. Note that when using <code>cumulative</code>, the sum of the percentages reported may exceed 100%. The default (non-cumulative) behavior can be specified with the <code>noncumulative</code> parameter.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-ltlimitgt"> <limit> </dt> <dd> <p>An integer parameter specifies a cut-off percent (3% by default). Directories contributing less than this percentage of the changes are not shown in the output.</p> </dd> </dl> </div> </div> </div> <p>Example: The following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories: <code>--dirstat=files,10,cumulative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---cumulative"> --cumulative </dt> <dd> <p>Synonym for --dirstat=cumulative</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---dirstat-by-fileltparam1param2gt82308203"> --dirstat-by-file[=<param1,param2>…] </dt> <dd> <p>Synonym for --dirstat=files,param1,param2…</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---summary"> --summary </dt> <dd> <p>Output a condensed summary of extended header information such as creations, renames and mode changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---patch-with-stat"> --patch-with-stat </dt> <dd> <p>Synonym for <code>-p --stat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--z"> -z </dt> <dd> <p>When <code>--raw</code>, <code>--numstat</code>, <code>--name-only</code> or <code>--name-status</code> has been given, do not munge pathnames and use NULs as output field terminators.</p> <p>Without this option, pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---name-only"> --name-only </dt> <dd> <p>Show only names of changed files. The file names are often encoded in UTF-8. For more information see the discussion about encoding in the <a href="git-log">git-log[1]</a> manual page.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---name-status"> --name-status </dt> <dd> <p>Show only names and status of changed files. See the description of the <code>--diff-filter</code> option on what the status letters mean. Just like <code>--name-only</code> the file names are often encoded in UTF-8.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---submoduleltformatgt"> --submodule[=<format>] </dt> <dd> <p>Specify how differences in submodules are shown. When specifying <code>--submodule=short</code> the <code>short</code> format is used. This format just shows the names of the commits at the beginning and end of the range. When <code>--submodule</code> or <code>--submodule=log</code> is specified, the <code>log</code> format is used. This format lists the commits in the range like <a href="git-submodule">git-submodule[1]</a> <code>summary</code> does. When <code>--submodule=diff</code> is specified, the <code>diff</code> format is used. This format shows an inline diff of the changes in the submodule contents between the commit range. Defaults to <code>diff.submodule</code> or the <code>short</code> format if the config option is unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---colorltwhengt"> --color[=<when>] </dt> <dd> <p>Show colored diff. <code>--color</code> (i.e. without <code>=<when></code>) is the same as <code>--color=always</code>. <code><when></code> can be one of <code>always</code>, <code>never</code>, or <code>auto</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---no-color"> --no-color </dt> <dd> <p>Turn off colored diff. It is the same as <code>--color=never</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---color-movedltmodegt"> --color-moved[=<mode>] </dt> <dd> <p>Moved lines of code are colored differently. The <mode> defaults to <code>no</code> if the option is not given and to <code>zebra</code> if the option with no mode is given. The mode must be one of:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-index.txt-no"> no </dt> <dd> <p>Moved lines are not highlighted.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-default"> default </dt> <dd> <p>Is a synonym for <code>zebra</code>. This may change to a more sensible mode in the future.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-plain"> plain </dt> <dd> <p>Any line that is added in one location and was removed in another location will be colored with <code>color.diff.newMoved</code>. Similarly <code>color.diff.oldMoved</code> will be used for removed lines that are added somewhere else in the diff. This mode picks up any moved line, but it is not very useful in a review to determine if a block of code was moved without permutation.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-blocks"> blocks </dt> <dd> <p>Blocks of moved text of at least 20 alphanumeric characters are detected greedily. The detected blocks are painted using either the <code>color.diff.{old,new}Moved</code> color. Adjacent blocks cannot be told apart.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-zebra"> zebra </dt> <dd> <p>Blocks of moved text are detected as in <code>blocks</code> mode. The blocks are painted using either the <code>color.diff.{old,new}Moved</code> color or <code>color.diff.{old,new}MovedAlternative</code>. The change between the two colors indicates that a new block was detected.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-dimmed-zebra"> dimmed-zebra </dt> <dd> <p>Similar to <code>zebra</code>, but additional dimming of uninteresting parts of moved code is performed. The bordering lines of two adjacent blocks are considered interesting, the rest is uninteresting. <code>dimmed_zebra</code> is a deprecated synonym.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---no-color-moved"> --no-color-moved </dt> <dd> <p>Turn off move detection. This can be used to override configuration settings. It is the same as <code>--color-moved=no</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---color-moved-wsltmodesgt"> --color-moved-ws=<modes> </dt> <dd> <p>This configures how whitespace is ignored when performing the move detection for <code>--color-moved</code>. These modes can be given as a comma separated list:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-index.txt-no-1"> no </dt> <dd> <p>Do not ignore whitespace when performing move detection.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-ignore-space-at-eol"> ignore-space-at-eol </dt> <dd> <p>Ignore changes in whitespace at EOL.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-ignore-space-change"> ignore-space-change </dt> <dd> <p>Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-ignore-all-space"> ignore-all-space </dt> <dd> <p>Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-allow-indentation-change"> allow-indentation-change </dt> <dd> <p>Initially ignore any whitespace in the move detection, then group the moved code blocks only into a block if the change in whitespace is the same per line. This is incompatible with the other modes.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---no-color-moved-ws"> --no-color-moved-ws </dt> <dd> <p>Do not ignore whitespace when performing move detection. This can be used to override configuration settings. It is the same as <code>--color-moved-ws=no</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---word-diffltmodegt"> --word-diff[=<mode>] </dt> <dd> <p>Show a word diff, using the <mode> to delimit changed words. By default, words are delimited by whitespace; see <code>--word-diff-regex</code> below. The <mode> defaults to <code>plain</code>, and must be one of:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-index.txt-color"> color </dt> <dd> <p>Highlight changed words using only colors. Implies <code>--color</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-plain-1"> plain </dt> <dd> <p>Show words as <code>[-removed-]</code> and <code>{+added+}</code>. Makes no attempts to escape the delimiters if they appear in the input, so the output may be ambiguous.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-porcelain"> porcelain </dt> <dd> <p>Use a special line-based format intended for script consumption. Added/removed/unchanged runs are printed in the usual unified diff format, starting with a <code>+</code>/<code>-</code>/` ` character at the beginning of the line and extending to the end of the line. Newlines in the input are represented by a tilde <code>~</code> on a line of its own.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-none"> none </dt> <dd> <p>Disable word diff again.</p> </dd> </dl> </div> </div> </div> <p>Note that despite the name of the first mode, color is used to highlight the changed parts in all modes if enabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---word-diff-regexltregexgt"> --word-diff-regex=<regex> </dt> <dd> <p>Use <regex> to decide what a word is, instead of considering runs of non-whitespace to be a word. Also implies <code>--word-diff</code> unless it was already enabled.</p> <p>Every non-overlapping match of the <regex> is considered a word. Anything between these matches is considered whitespace and ignored(!) for the purposes of finding differences. You may want to append <code>|[^[:space:]]</code> to your regular expression to make sure that it matches all non-whitespace characters. A match that contains a newline is silently truncated(!) at the newline.</p> <p>For example, <code>--word-diff-regex=.</code> will treat each character as a word and, correspondingly, show differences character by character.</p> <p>The regex can also be set via a diff driver or configuration option, see <a href="gitattributes">gitattributes[5]</a> or <a href="git-config">git-config[1]</a>. Giving it explicitly overrides any diff driver or configuration setting. Diff drivers override configuration settings.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---color-wordsltregexgt"> --color-words[=<regex>] </dt> <dd> <p>Equivalent to <code>--word-diff=color</code> plus (if a regex was specified) <code>--word-diff-regex=<regex></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---no-renames"> --no-renames </dt> <dd> <p>Turn off rename detection, even when the configuration file gives the default to do so.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---no-rename-empty"> --[no-]rename-empty </dt> <dd> <p>Whether to use empty blobs as rename source.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---check"> --check </dt> <dd> <p>Warn if changes introduce conflict markers or whitespace errors. What are considered whitespace errors is controlled by <code>core.whitespace</code> configuration. By default, trailing whitespaces (including lines that consist solely of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors. Exits with non-zero status if problems are found. Not compatible with --exit-code.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---ws-error-highlightltkindgt"> --ws-error-highlight=<kind> </dt> <dd> <p>Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code> lines of the diff. Multiple values are separated by comma, <code>none</code> resets previous values, <code>default</code> reset the list to <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. When this option is not given, and the configuration variable <code>diff.wsErrorHighlight</code> is not set, only whitespace errors in <code>new</code> lines are highlighted. The whitespace errors are colored with <code>color.diff.whitespace</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---full-index"> --full-index </dt> <dd> <p>Instead of the first handful of characters, show the full pre- and post-image blob object names on the "index" line when generating patch format output.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---binary"> --binary </dt> <dd> <p>In addition to <code>--full-index</code>, output a binary diff that can be applied with <code>git-apply</code>. Implies <code>--patch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---abbrevltngt"> --abbrev[=<n>] </dt> <dd> <p>Instead of showing the full 40-byte hexadecimal object name in diff-raw format output and diff-tree header lines, show the shortest prefix that is at least <code><n></code> hexdigits long that uniquely refers the object. In diff-patch output format, <code>--full-index</code> takes higher precedence, i.e. if <code>--full-index</code> is specified, full blob names will be shown regardless of <code>--abbrev</code>. Non default number of digits can be specified with <code>--abbrev=<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--Bltngtltmgt"> -B[<n>][/<m>] </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---break-rewritesltngtltmgt"> --break-rewrites[=[<n>][/<m>]] </dt> <dd> <p>Break complete rewrite changes into pairs of delete and create. This serves two purposes:</p> <p>It affects the way a change that amounts to a total rewrite of a file not as a series of deletion and insertion mixed together with a very few lines that happen to match textually as the context, but as a single deletion of everything old followed by a single insertion of everything new, and the number <code>m</code> controls this aspect of the -B option (defaults to 60%). <code>-B/70%</code> specifies that less than 30% of the original should remain in the result for Git to consider it a total rewrite (i.e. otherwise the resulting patch will be a series of deletion and insertion mixed together with context lines).</p> <p>When used with -M, a totally-rewritten file is also considered as the source of a rename (usually -M only considers a file that disappeared as the source of a rename), and the number <code>n</code> controls this aspect of the -B option (defaults to 50%). <code>-B20%</code> specifies that a change with addition and deletion compared to 20% or more of the file’s size are eligible for being picked up as a possible source of a rename to another file.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--Mltngt"> -M[<n>] </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---find-renamesltngt"> --find-renames[=<n>] </dt> <dd> <p>Detect renames. If <code>n</code> is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file’s size). For example, <code>-M90%</code> means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn’t changed. Without a <code>%</code> sign, the number is to be read as a fraction, with a decimal point before it. I.e., <code>-M5</code> becomes 0.5, and is thus the same as <code>-M50%</code>. Similarly, <code>-M05</code> is the same as <code>-M5%</code>. To limit detection to exact renames, use <code>-M100%</code>. The default similarity index is 50%.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--Cltngt"> -C[<n>] </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---find-copiesltngt"> --find-copies[=<n>] </dt> <dd> <p>Detect copies as well as renames. See also <code>--find-copies-harder</code>. If <code>n</code> is specified, it has the same meaning as for <code>-M<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---find-copies-harder"> --find-copies-harder </dt> <dd> <p>For performance reasons, by default, <code>-C</code> option finds copies only if the original file of the copy was modified in the same changeset. This flag makes the command inspect unmodified files as candidates for the source of copy. This is a very expensive operation for large projects, so use it with caution. Giving more than one <code>-C</code> option has the same effect.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--D"> -D </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---irreversible-delete"> --irreversible-delete </dt> <dd> <p>Omit the preimage for deletes, i.e. print only the header but not the diff between the preimage and <code>/dev/null</code>. The resulting patch is not meant to be applied with <code>patch</code> or <code>git apply</code>; this is solely for people who want to just concentrate on reviewing the text after the change. In addition, the output obviously lacks enough information to apply such a patch in reverse, even manually, hence the name of the option.</p> <p>When used together with <code>-B</code>, omit also the preimage in the deletion part of a delete/create pair.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--lltnumgt"> -l<num> </dt> <dd> <p>The <code>-M</code> and <code>-C</code> options involve some preliminary steps that can detect subsets of renames/copies cheaply, followed by an exhaustive fallback portion that compares all remaining unpaired destinations to all relevant sources. (For renames, only remaining unpaired sources are relevant; for copies, all original sources are relevant.) For N sources and destinations, this exhaustive check is O(N^2). This option prevents the exhaustive portion of rename/copy detection from running if the number of source/destination files involved exceeds the specified number. Defaults to diff.renameLimit. Note that a value of 0 is treated as unlimited.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---diff-filterACDMRTUXB82308203"> --diff-filter=[(A|C|D|M|R|T|U|X|B)…[*]] </dt> <dd> <p>Select only files that are Added (<code>A</code>), Copied (<code>C</code>), Deleted (<code>D</code>), Modified (<code>M</code>), Renamed (<code>R</code>), have their type (i.e. regular file, symlink, submodule, …) changed (<code>T</code>), are Unmerged (<code>U</code>), are Unknown (<code>X</code>), or have had their pairing Broken (<code>B</code>). Any combination of the filter characters (including none) can be used. When <code>*</code> (All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.</p> <p>Also, these upper-case letters can be downcased to exclude. E.g. <code>--diff-filter=ad</code> excludes added and deleted paths.</p> <p>Note that not all diffs can feature all types. For instance, copied and renamed entries cannot appear if detection for those types is disabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--Sltstringgt"> -S<string> </dt> <dd> <p>Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file. Intended for the scripter’s use.</p> <p>It is useful when you’re looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting block in the preimage back into <code>-S</code>, and keep going until you get the very first version of the block.</p> <p>Binary files are searched as well.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--Gltregexgt"> -G<regex> </dt> <dd> <p>Look for differences whose patch text contains added/removed lines that match <regex>.</p> <p>To illustrate the difference between <code>-S<regex> --pickaxe-regex</code> and <code>-G<regex></code>, consider a commit with the following diff in the same file:</p> <div class="listingblock"> <div class="content"> <pre>+ return frotz(nitfol, two->ptr, 1, 0); +... +- hit = frotz(nitfol, mf2.ptr, 1, 0);</pre> </div> </div> <p>While <code>git log -G"frotz\(nitfol"</code> will show this commit, <code>git log +-S"frotz\(nitfol" --pickaxe-regex</code> will not (because the number of occurrences of that string did not change).</p> <p>Unless <code>--text</code> is supplied patches of binary files without a textconv filter will be ignored.</p> <p>See the <code>pickaxe</code> entry in <a href="gitdiffcore">gitdiffcore[7]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---find-objectltobject-idgt"> --find-object=<object-id> </dt> <dd> <p>Look for differences that change the number of occurrences of the specified object. Similar to <code>-S</code>, just the argument is different in that it doesn’t search for a specific string but for a specific object id.</p> <p>The object can be a blob or a submodule commit. It implies the <code>-t</code> option in <code>git-log</code> to also find trees.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---pickaxe-all"> --pickaxe-all </dt> <dd> <p>When <code>-S</code> or <code>-G</code> finds a change, show all the changes in that changeset, not just the files that contain the change in <string>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---pickaxe-regex"> --pickaxe-regex </dt> <dd> <p>Treat the <string> given to <code>-S</code> as an extended POSIX regular expression to match.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--Oltorderfilegt"> -O<orderfile> </dt> <dd> <p>Control the order in which files appear in the output. This overrides the <code>diff.orderFile</code> configuration variable (see <a href="git-config">git-config[1]</a>). To cancel <code>diff.orderFile</code>, use <code>-O/dev/null</code>.</p> <p>The output order is determined by the order of glob patterns in <orderfile>. All files with pathnames that match the first pattern are output first, all files with pathnames that match the second pattern (but not the first) are output next, and so on. All files with pathnames that do not match any pattern are output last, as if there was an implicit match-all pattern at the end of the file. If multiple pathnames have the same rank (they match the same pattern but no earlier patterns), their output order relative to each other is the normal order.</p> <p><orderfile> is parsed as follows:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>Blank lines are ignored, so they can be used as separators for readability.</p> </li> <li> <p>Lines starting with a hash ("<code>#</code>") are ignored, so they can be used for comments. Add a backslash ("<code>\</code>") to the beginning of the pattern if it starts with a hash.</p> </li> <li> <p>Each other line contains a single pattern.</p> </li> </ul> </div> </div> </div> <p>Patterns have the same syntax and semantics as patterns used for fnmatch(3) without the FNM_PATHNAME flag, except a pathname also matches a pattern if removing any number of the final pathname components matches the pattern. For example, the pattern "<code>foo*bar</code>" matches "<code>fooasdfbar</code>" and "<code>foo/bar/baz/asdf</code>" but not "<code>foobarx</code>".</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---skip-toltfilegt"> --skip-to=<file> </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---rotate-toltfilegt"> --rotate-to=<file> </dt> <dd> <p>Discard the files before the named <file> from the output (i.e. <code>skip to</code>), or move them to the end of the output (i.e. <code>rotate to</code>). These options were invented primarily for the use of the <code>git difftool</code> command, and may not be very useful otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--R"> -R </dt> <dd> <p>Swap two inputs; that is, show differences from index or on-disk file to tree contents.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---relativeltpathgt"> --relative[=<path>] </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---no-relative"> --no-relative </dt> <dd> <p>When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option. When you are not in a subdirectory (e.g. in a bare repository), you can name which subdirectory to make the output relative to by giving a <path> as an argument. <code>--no-relative</code> can be used to countermand both <code>diff.relative</code> config option and previous <code>--relative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---text"> --text </dt> <dd> <p>Treat all files as text.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---ignore-cr-at-eol"> --ignore-cr-at-eol </dt> <dd> <p>Ignore carriage-return at the end of line when doing a comparison.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---ignore-space-at-eol"> --ignore-space-at-eol </dt> <dd> <p>Ignore changes in whitespace at EOL.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--b"> -b </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---ignore-space-change"> --ignore-space-change </dt> <dd> <p>Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--w"> -w </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---ignore-all-space"> --ignore-all-space </dt> <dd> <p>Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---ignore-blank-lines"> --ignore-blank-lines </dt> <dd> <p>Ignore changes whose lines are all blank.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--Iltregexgt"> -I<regex> </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---ignore-matching-linesltregexgt"> --ignore-matching-lines=<regex> </dt> <dd> <p>Ignore changes whose all lines match <regex>. This option may be specified more than once.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---inter-hunk-contextltlinesgt"> --inter-hunk-context=<lines> </dt> <dd> <p>Show the context between diff hunks, up to the specified number of lines, thereby fusing hunks that are close to each other. Defaults to <code>diff.interHunkContext</code> or 0 if the config option is unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--W"> -W </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---function-context"> --function-context </dt> <dd> <p>Show whole function as context lines for each change. The function names are determined in the same way as <code>git diff</code> works out patch hunk headers (see <code>Defining a custom hunk-header</code> in <a href="gitattributes">gitattributes[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---exit-code"> --exit-code </dt> <dd> <p>Make the program exit with codes similar to diff(1). That is, it exits with 1 if there were differences and 0 means no differences.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---quiet"> --quiet </dt> <dd> <p>Disable all output of the program. Implies <code>--exit-code</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---ext-diff"> --ext-diff </dt> <dd> <p>Allow an external diff helper to be executed. If you set an external diff driver with <a href="gitattributes">gitattributes[5]</a>, you need to use this option with <a href="git-log">git-log[1]</a> and friends.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---no-ext-diff"> --no-ext-diff </dt> <dd> <p>Disallow external diff drivers.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---textconv"> --textconv </dt> <dt class="hdlist1" id="Documentation/git-diff-index.txt---no-textconv"> --no-textconv </dt> <dd> <p>Allow (or disallow) external text conversion filters to be run when comparing binary files. See <a href="gitattributes">gitattributes[5]</a> for details. Because textconv filters are typically a one-way conversion, the resulting diff is suitable for human consumption, but cannot be applied. For this reason, textconv filters are enabled by default only for <a href="git-diff">git-diff[1]</a> and <a href="git-log">git-log[1]</a>, but not for <a href="git-format-patch">git-format-patch[1]</a> or diff plumbing commands.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---ignore-submodulesltwhengt"> --ignore-submodules[=<when>] </dt> <dd> <p>Ignore changes to submodules in the diff generation. <when> can be either "none", "untracked", "dirty" or "all", which is the default. Using "none" will consider the submodule modified when it either contains untracked or modified files or its HEAD differs from the commit recorded in the superproject and can be used to override any settings of the <code>ignore</code> option in <a href="git-config">git-config[1]</a> or <a href="gitmodules">gitmodules[5]</a>. When "untracked" is used submodules are not considered dirty when they only contain untracked content (but they are still scanned for modified content). Using "dirty" ignores all changes to the work tree of submodules, only changes to the commits stored in the superproject are shown (this was the behavior until 1.7.0). Using "all" hides all changes to submodules.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---src-prefixltprefixgt"> --src-prefix=<prefix> </dt> <dd> <p>Show the given source prefix instead of "a/".</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---dst-prefixltprefixgt"> --dst-prefix=<prefix> </dt> <dd> <p>Show the given destination prefix instead of "b/".</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---no-prefix"> --no-prefix </dt> <dd> <p>Do not show any source or destination prefix.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---default-prefix"> --default-prefix </dt> <dd> <p>Use the default source and destination prefixes ("a/" and "b/"). This is usually the default already, but may be used to override config such as <code>diff.noprefix</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---line-prefixltprefixgt"> --line-prefix=<prefix> </dt> <dd> <p>Prepend an additional prefix to every line of output.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---ita-invisible-in-index"> --ita-invisible-in-index </dt> <dd> <p>By default entries added by "git add -N" appear as an existing empty file in "git diff" and a new file in "git diff --cached". This option makes the entry appear as a new file in "git diff" and non-existent in "git diff --cached". This option could be reverted with <code>--ita-visible-in-index</code>. Both options are experimental and could be removed in future.</p> </dd> </dl> </div> <p>For more detailed explanation on these common options, see also <a href="gitdiffcore">gitdiffcore[7]</a>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-index.txt-lttree-ishgt"> <tree-ish> </dt> <dd> <p>The id of a tree object to diff against.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---cached"> --cached </dt> <dd> <p>Do not consider the on-disk file at all.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt---merge-base"> --merge-base </dt> <dd> <p>Instead of comparing <tree-ish> directly, use the merge base between <tree-ish> and HEAD instead. <tree-ish> must be a commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt--m"> -m </dt> <dd> <p>By default, files recorded in the index but not checked out are reported as deleted. This flag makes <code>git diff-index</code> say that all non-checked-out files are up to date.</p> </dd> </dl> </div> </div> <h2 id="_raw_output_format">Raw output format</h2> <div class="sectionbody"> <p>The raw output format from "git-diff-index", "git-diff-tree", "git-diff-files" and "git diff --raw" are very similar.</p> <p>These commands all compare two sets of things; what is compared differs:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-index.txt-git-diff-indexlttree-ishgt"> git-diff-index <tree-ish> </dt> <dd> <p>compares the <tree-ish> and the files on the filesystem.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-git-diff-index--cachedlttree-ishgt"> git-diff-index --cached <tree-ish> </dt> <dd> <p>compares the <tree-ish> and the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-git-diff-tree-rlttree-ish-1gtlttree-ish-2gtltpatterngt82308203"> git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…] </dt> <dd> <p>compares the trees named by the two arguments.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-index.txt-git-diff-filesltpatterngt82308203"> git-diff-files [<pattern>…] </dt> <dd> <p>compares the index and the files on the filesystem.</p> </dd> </dl> </div> <p>The "git-diff-tree" command begins its output by printing the hash of what is being compared. After that, all the commands print one output line per changed file.</p> <p>An output line is formatted this way:</p> <div class="listingblock"> <div class="content"> <pre>in-place edit :100644 100644 bcd1234 0123456 M file0 +copy-edit :100644 100644 abcd123 1234567 C68 file1 file2 +rename-edit :100644 100644 abcd123 1234567 R86 file1 file3 +create :000000 100644 0000000 1234567 A file4 +delete :100644 000000 1234567 0000000 D file5 +unmerged :000000 000000 0000000 0000000 U file6</pre> </div> </div> <p>That is, from the left to the right:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>a colon.</p> </li> <li> <p>mode for "src"; 000000 if creation or unmerged.</p> </li> <li> <p>a space.</p> </li> <li> <p>mode for "dst"; 000000 if deletion or unmerged.</p> </li> <li> <p>a space.</p> </li> <li> <p>sha1 for "src"; 0{40} if creation or unmerged.</p> </li> <li> <p>a space.</p> </li> <li> <p>sha1 for "dst"; 0{40} if deletion, unmerged or "work tree out of sync with the index".</p> </li> <li> <p>a space.</p> </li> <li> <p>status, followed by optional "score" number.</p> </li> <li> <p>a tab or a NUL when <code>-z</code> option is used.</p> </li> <li> <p>path for "src"</p> </li> <li> <p>a tab or a NUL when <code>-z</code> option is used; only exists for C or R.</p> </li> <li> <p>path for "dst"; only exists for C or R.</p> </li> <li> <p>an LF or a NUL when <code>-z</code> option is used, to terminate the record.</p> </li> </ol> </div> <p>Possible status letters are:</p> <div class="ulist"> <ul> <li> <p>A: addition of a file</p> </li> <li> <p>C: copy of a file into a new one</p> </li> <li> <p>D: deletion of a file</p> </li> <li> <p>M: modification of the contents or mode of a file</p> </li> <li> <p>R: renaming of a file</p> </li> <li> <p>T: change in the type of the file (regular file, symbolic link or submodule)</p> </li> <li> <p>U: file is unmerged (you must complete the merge before it can be committed)</p> </li> <li> <p>X: "unknown" change type (most probably a bug, please report it)</p> </li> </ul> </div> <p>Status letters C and R are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy). Status letter M may be followed by a score (denoting the percentage of dissimilarity) for file rewrites.</p> <p>The sha1 for "dst" is shown as all 0’s if a file on the filesystem is out of sync with the index.</p> <p>Example:</p> <div class="listingblock"> <div class="content"> <pre>:100644 100644 5be4a4a 0000000 M file.c</pre> </div> </div> <p>Without the <code>-z</code> option, pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>). Using <code>-z</code> the filename is output verbatim and the line is terminated by a NUL byte.</p> </div> <h2 id="_diff_format_for_merges">Diff format for merges</h2> <div class="sectionbody"> <p>"git-diff-tree", "git-diff-files" and "git-diff --raw" can take <code>-c</code> or <code>--cc</code> option to generate diff output also for merge commits. The output differs from the format described above in the following way:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>there is a colon for each parent</p> </li> <li> <p>there are more "src" modes and "src" sha1</p> </li> <li> <p>status is concatenated status characters for each parent</p> </li> <li> <p>no optional "score" number</p> </li> <li> <p>tab-separated pathname(s) of the file</p> </li> </ol> </div> <p>For <code>-c</code> and <code>--cc</code>, only the destination or final path is shown even if the file was renamed on any side of history. With <code>--combined-all-paths</code>, the name of the path in each parent is shown followed by the name of the path in the merge commit.</p> <p>Examples for <code>-c</code> and <code>--cc</code> without <code>--combined-all-paths</code>:</p> <div class="listingblock"> <div class="content"> <pre>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c +::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM bar.sh +::100644 100644 100644 e07d6c5 9042e82 ee91881 RR phooey.c</pre> </div> </div> <p>Examples when <code>--combined-all-paths</code> added to either <code>-c</code> or <code>--cc</code>:</p> <div class="listingblock"> <div class="content"> <pre>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c desc.c desc.c +::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM foo.sh bar.sh bar.sh +::100644 100644 100644 e07d6c5 9042e82 ee91881 RR fooey.c fuey.c phooey.c</pre> </div> </div> <p>Note that <code>combined diff</code> lists only files which were modified from all parents.</p> </div> <h2 id="generate_patch_text_with_p">Generating patch text with -p</h2> <div class="sectionbody"> <p>Running <a href="git-diff">git-diff[1]</a>, <a href="git-log">git-log[1]</a>, <a href="git-show">git-show[1]</a>, <a href="git-diff-index">git-diff-index[1]</a>, <a href="git-diff-tree">git-diff-tree[1]</a>, or <a href="git-diff-files">git-diff-files[1]</a> with the <code>-p</code> option produces patch text. You can customize the creation of patch text via the <code>GIT_EXTERNAL_DIFF</code> and the <code>GIT_DIFF_OPTS</code> environment variables (see <a href="git">git[1]</a>), and the <code>diff</code> attribute (see <a href="gitattributes">gitattributes[5]</a>).</p> <p>What the -p option produces is slightly different from the traditional diff format:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>It is preceded by a "git diff" header that looks like this:</p> <div class="literalblock"> <div class="content"> <pre>diff --git a/file1 b/file2</pre> </div> </div> <p>The <code>a/</code> and <code>b/</code> filenames are the same unless rename/copy is involved. Especially, even for a creation or a deletion, <code>/dev/null</code> is <code>not</code> used in place of the <code>a/</code> or <code>b/</code> filenames.</p> <p>When a rename/copy is involved, <code>file1</code> and <code>file2</code> show the name of the source file of the rename/copy and the name of the file that the rename/copy produces, respectively.</p> </li> <li> <p>It is followed by one or more extended header lines:</p> <div class="literalblock"> <div class="content"> <pre>old mode <mode> +new mode <mode> +deleted file mode <mode> +new file mode <mode> +copy from <path> +copy to <path> +rename from <path> +rename to <path> +similarity index <number> +dissimilarity index <number> +index <hash>..<hash> <mode></pre> </div> </div> <p>File modes are printed as 6-digit octal numbers including the file type and file permission bits.</p> <p>Path names in extended headers do not include the <code>a/</code> and <code>b/</code> prefixes.</p> <p>The similarity index is the percentage of unchanged lines, and the dissimilarity index is the percentage of changed lines. It is a rounded down integer, followed by a percent sign. The similarity index value of 100% is thus reserved for two equal files, while 100% dissimilarity means that no line from the old file made it into the new one.</p> <p>The index line includes the blob object names before and after the change. The <mode> is included if the file mode does not change; otherwise, separate lines indicate the old and the new mode.</p> </li> <li> <p>Pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>).</p> </li> <li> <p>All the <code>file1</code> files in the output refer to files before the commit, and all the <code>file2</code> files refer to files after the commit. It is incorrect to apply each change to each file sequentially. For example, this patch will swap a and b:</p> <div class="literalblock"> <div class="content"> <pre>diff --git a/a b/b +rename from a +rename to b +diff --git a/b b/a +rename from b +rename to a</pre> </div> </div> </li> <li> <p>Hunk headers mention the name of the function to which the hunk applies. See "Defining a custom hunk-header" in <a href="gitattributes">gitattributes[5]</a> for details of how to tailor this to specific languages.</p> </li> </ol> </div> </div> <h2 id="_combined_diff_format">Combined diff format</h2> <div class="sectionbody"> <p>Any diff-generating command can take the <code>-c</code> or <code>--cc</code> option to produce a <code>combined diff</code> when showing a merge. This is the default format when showing merges with <a href="git-diff">git-diff[1]</a> or <a href="git-show">git-show[1]</a>. Note also that you can give suitable <code>--diff-merges</code> option to any of these commands to force generation of diffs in a specific format.</p> <p>A "combined diff" format looks like this:</p> <div class="listingblock"> <div class="content"> <pre>diff --combined describe.c +index fabadb8,cc95eb0..4866510 +--- a/describe.c ++++ b/describe.c +@@@ -98,20 -98,12 +98,20 @@@ + return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; + } + +- static void describe(char *arg) + -static void describe(struct commit *cmit, int last_one) +++static void describe(char *arg, int last_one) + { + + unsigned char sha1[20]; + + struct commit *cmit; + struct commit_list *list; + static int initialized = 0; + struct commit_name *n; + + + if (get_sha1(arg, sha1) < 0) + + usage(describe_usage); + + cmit = lookup_commit_reference(sha1); + + if (!cmit) + + usage(describe_usage); + + + if (!initialized) { + initialized = 1; + for_each_ref(get_name);</pre> </div> </div> <div class="olist arabic"> <ol class="arabic"> <li> <p>It is preceded by a "git diff" header, that looks like this (when the <code>-c</code> option is used):</p> <div class="literalblock"> <div class="content"> <pre>diff --combined file</pre> </div> </div> <p>or like this (when the <code>--cc</code> option is used):</p> <div class="literalblock"> <div class="content"> <pre>diff --cc file</pre> </div> </div> </li> <li> <p>It is followed by one or more extended header lines (this example shows a merge with two parents):</p> <div class="literalblock"> <div class="content"> <pre>index <hash>,<hash>..<hash> +mode <mode>,<mode>..<mode> +new file mode <mode> +deleted file mode <mode>,<mode></pre> </div> </div> <p>The <code>mode <mode>,<mode>..<mode></code> line appears only if at least one of the <mode> is different from the rest. Extended headers with information about detected content movement (renames and copying detection) are designed to work with the diff of two <tree-ish> and are not used by combined diff format.</p> </li> <li> <p>It is followed by a two-line from-file/to-file header:</p> <div class="literalblock"> <div class="content"> <pre>--- a/file ++++ b/file</pre> </div> </div> <p>Similar to the two-line header for the traditional <code>unified</code> diff format, <code>/dev/null</code> is used to signal created or deleted files.</p> <p>However, if the --combined-all-paths option is provided, instead of a two-line from-file/to-file, you get an N+1 line from-file/to-file header, where N is the number of parents in the merge commit:</p> <div class="literalblock"> <div class="content"> <pre>--- a/file +--- a/file +--- a/file ++++ b/file</pre> </div> </div> <p>This extended format can be useful if rename or copy detection is active, to allow you to see the original name of the file in different parents.</p> </li> <li> <p>Chunk header format is modified to prevent people from accidentally feeding it to <code>patch -p1</code>. Combined diff format was created for review of merge commit changes, and was not meant to be applied. The change is similar to the change in the extended <code>index</code> header:</p> <div class="literalblock"> <div class="content"> <pre>@@@ <from-file-range> <from-file-range> <to-file-range> @@@</pre> </div> </div> <p>There are (number of parents + 1) <code>@</code> characters in the chunk header for combined diff format.</p> </li> </ol> </div> <p>Unlike the traditional <code>unified</code> diff format, which shows two files A and B with a single column that has <code>-</code> (minus — appears in A but removed in B), <code>+</code> (plus — missing in A but added to B), or <code>" "</code> (space — unchanged) prefix, this format compares two or more files file1, file2,… with one file X, and shows how X differs from each of fileN. One column for each of fileN is prepended to the output line to note how X’s line is different from it.</p> <p>A <code>-</code> character in the column N means that the line appears in fileN but it does not appear in the result. A <code>+</code> character in the column N means that the line appears in the result, and fileN does not have that line (in other words, the line was added, from the point of view of that parent).</p> <p>In the above example output, the function signature was changed from both files (hence two <code>-</code> removals from both file1 and file2, plus <code>++</code> to mean one line that was added does not appear in either file1 or file2). Also, eight other lines are the same from file1 but do not appear in file2 (hence prefixed with <code>+</code>).</p> <p>When shown by <code>git diff-tree -c</code>, it compares the parents of a merge commit with the merge result (i.e. file1..fileN are the parents). When shown by <code>git diff-files -c</code>, it compares the two unresolved merge parents with the working tree file (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka "their version").</p> </div> <h2 id="_other_diff_formats">Other diff formats</h2> <div class="sectionbody"> <p>The <code>--summary</code> option describes newly added, deleted, renamed and copied files. The <code>--stat</code> option adds diffstat(1) graph to the output. These options can be combined with other options, such as <code>-p</code>, and are meant for human consumption.</p> <p>When showing a change that involves a rename or a copy, <code>--stat</code> output formats the pathnames compactly by combining common prefix and suffix of the pathnames. For example, a change that moves <code>arch/i386/Makefile</code> to <code>arch/x86/Makefile</code> while modifying 4 lines will be shown like this:</p> <div class="listingblock"> <div class="content"> <pre>arch/{i386 => x86}/Makefile | 4 +--</pre> </div> </div> <p>The <code>--numstat</code> option gives the diffstat(1) information but is designed for easier machine consumption. An entry in <code>--numstat</code> output looks like this:</p> <div class="listingblock"> <div class="content"> <pre>1 2 README +3 1 arch/{i386 => x86}/Makefile</pre> </div> </div> <p>That is, from left to right:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>the number of added lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>the number of deleted lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>pathname (possibly with rename/copy information);</p> </li> <li> <p>a newline.</p> </li> </ol> </div> <p>When <code>-z</code> output option is in effect, the output is formatted this way:</p> <div class="listingblock"> <div class="content"> <pre>1 2 README NUL +3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</pre> </div> </div> <p>That is:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>the number of added lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>the number of deleted lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>a NUL (only exists if renamed/copied);</p> </li> <li> <p>pathname in preimage;</p> </li> <li> <p>a NUL (only exists if renamed/copied);</p> </li> <li> <p>pathname in postimage (only exists if renamed/copied);</p> </li> <li> <p>a NUL.</p> </li> </ol> </div> <p>The extra <code>NUL</code> before the preimage path in renamed case is to allow scripts that read the output to tell if the current record being read is a single-path record or a rename/copy record without reading ahead. After reading added and deleted lines, reading up to <code>NUL</code> would yield the pathname, but if that is <code>NUL</code>, the record will show two paths.</p> </div> <h2 id="_operating_modes">Operating modes</h2> <div class="sectionbody"> <p>You can choose whether you want to trust the index file entirely (using the <code>--cached</code> flag) or ask the diff logic to show any files that don’t match the stat state as being "tentatively changed". Both of these operations are very useful indeed.</p> </div> <h2 id="_cached_mode">Cached mode</h2> <div class="sectionbody"> <p>If <code>--cached</code> is specified, it allows you to ask:</p> <div class="literalblock"> <div class="content"> <pre>show me the differences between HEAD and the current index +contents (the ones I'd write using 'git write-tree')</pre> </div> </div> <p>For example, let’s say that you have worked on your working directory, updated some files in the index and are ready to commit. You want to see exactly <strong>what</strong> you are going to commit, without having to write a new tree object and compare it that way, and to do that, you just do</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git diff-index --cached HEAD</pre> </div> </div> <p>Example: let’s say I had renamed <code>commit.c</code> to <code>git-commit.c</code>, and I had done an <code>update-index</code> to make that effective in the index file. <code>git diff-files</code> wouldn’t show anything at all, since the index file matches my working directory. But doing a <code>git diff-index</code> does:</p> <div class="literalblock"> <div class="content"> <pre>torvalds@ppc970:~/git> git diff-index --cached HEAD +:100644 000000 4161aecc6700a2eb579e842af0b7f22b98443f74 0000000000000000000000000000000000000000 D commit.c +:000000 100644 0000000000000000000000000000000000000000 4161aecc6700a2eb579e842af0b7f22b98443f74 A git-commit.c</pre> </div> </div> <p>You can see easily that the above is a rename.</p> <p>In fact, <code>git diff-index --cached</code> <strong>should</strong> always be entirely equivalent to actually doing a <code>git write-tree</code> and comparing that. Except this one is much nicer for the case where you just want to check where you are.</p> <p>So doing a <code>git diff-index --cached</code> is basically very useful when you are asking yourself "what have I already marked for being committed, and what’s the difference to a previous tree".</p> </div> <h2 id="_non_cached_mode">Non-cached mode</h2> <div class="sectionbody"> <p>The "non-cached" mode takes a different approach, and is potentially the more useful of the two in that what it does can’t be emulated with a <code>git write-tree</code> + <code>git diff-tree</code>. Thus that’s the default mode. The non-cached version asks the question:</p> <div class="literalblock"> <div class="content"> <pre>show me the differences between HEAD and the currently checked out +tree - index contents _and_ files that aren't up to date</pre> </div> </div> <p>which is obviously a very useful question too, since that tells you what you <strong>could</strong> commit. Again, the output matches the <code>git diff-tree -r</code> output to a tee, but with a twist.</p> <p>The twist is that if some file doesn’t match the index, we don’t have a backing store thing for it, and we use the magic "all-zero" sha1 to show that. So let’s say that you have edited <code>kernel/sched.c</code>, but have not actually done a <code>git update-index</code> on it yet - there is no "object" associated with the new state, and you get:</p> <div class="literalblock"> <div class="content"> <pre>torvalds@ppc970:~/v2.6/linux> git diff-index --abbrev HEAD +:100644 100644 7476bb5ba 000000000 M kernel/sched.c</pre> </div> </div> <p>i.e., it shows that the tree has changed, and that <code>kernel/sched.c</code> is not up to date and may contain new stuff. The all-zero sha1 means that to get the real diff, you need to look at the object in the working directory directly rather than do an object-to-object diff.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> As with other commands of this type, <em>git diff-index</em> does not actually look at the contents of the file at all. So maybe <code>kernel/sched.c</code> hasn’t actually changed, and it’s just that you touched it. In either case, it’s a note that you need to <em>git update-index</em> it to make the index be in sync. </td> </tr> </table> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> You can have a mixture of files show up as "has been updated" and "is still dirty in the working directory" together. You can always tell which file is in which state, since the "has been updated" ones show a valid sha1, and the "not in sync with the index" ones will always have the special all-zero sha1. </td> </tr> </table> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-diff-index" class="_attribution-link">https://git-scm.com/docs/git-diff-index</a> + </p> +</div> diff --git a/devdocs/git/git-diff-tree.html b/devdocs/git/git-diff-tree.html new file mode 100644 index 00000000..8047054e --- /dev/null +++ b/devdocs/git/git-diff-tree.html @@ -0,0 +1,93 @@ +<h1>git-diff-tree</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-diff-tree - Compares the content and mode of blobs found via two tree objects</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git diff-tree [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty] + [-t] [-r] [-c | --cc] [--combined-all-paths] [--root] [--merge-base] + [<common-diff-options>] <tree-ish> [<tree-ish>] [<path>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Compare the content and mode of blobs found via two tree objects.</p> <p>If there is only one <tree-ish> given, the commit is compared with its parents (see --stdin below).</p> <p>Note that <code>git diff-tree</code> can use the tree encapsulated in a commit object.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--u"> -u </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---patch"> --patch </dt> <dd> <p>Generate patch (see <a href="#generate_patch_text_with_p">Generating patch text with -p</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-patch"> --no-patch </dt> <dd> <p>Suppress all output from the diff machinery. Useful for commands like <code>git show</code> that show the patch by default to squelch their output, or to cancel the effect of options like <code>--patch</code>, <code>--stat</code> earlier on the command line in an alias.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--Ultngt"> -U<n> </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---unifiedltngt"> --unified=<n> </dt> <dd> <p>Generate diffs with <n> lines of context instead of the usual three. Implies <code>--patch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---outputltfilegt"> --output=<file> </dt> <dd> <p>Output to a specific file instead of stdout.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---output-indicator-newltchargt"> --output-indicator-new=<char> </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---output-indicator-oldltchargt"> --output-indicator-old=<char> </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---output-indicator-contextltchargt"> --output-indicator-context=<char> </dt> <dd> <p>Specify the character used to indicate new, old or context lines in the generated patch. Normally they are <code>+</code>, <code>-</code> and ' ' respectively.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---raw"> --raw </dt> <dd> <p>Generate the diff in raw format. This is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---patch-with-raw"> --patch-with-raw </dt> <dd> <p>Synonym for <code>-p --raw</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---indent-heuristic"> --indent-heuristic </dt> <dd> <p>Enable the heuristic that shifts diff hunk boundaries to make patches easier to read. This is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-indent-heuristic"> --no-indent-heuristic </dt> <dd> <p>Disable the indent heuristic.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---minimal"> --minimal </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---patience"> --patience </dt> <dd> <p>Generate a diff using the "patience diff" algorithm.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---histogram"> --histogram </dt> <dd> <p>Generate a diff using the "histogram diff" algorithm.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---anchoredlttextgt"> --anchored=<text> </dt> <dd> <p>Generate a diff using the "anchored diff" algorithm.</p> <p>This option may be specified more than once.</p> <p>If a line exists in both the source and destination, exists only once, and starts with this text, this algorithm attempts to prevent it from appearing as a deletion or addition in the output. It uses the "patience diff" algorithm internally.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---diff-algorithmpatienceminimalhistogrammyers"> --diff-algorithm={patience|minimal|histogram|myers} </dt> <dd> <p>Choose a diff algorithm. The variants are as follows:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-codedefaultcodecodemyerscode"> <code>default</code>, <code>myers</code> </dt> <dd> <p>The basic greedy diff algorithm. Currently, this is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-codeminimalcode"> <code>minimal</code> </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-codepatiencecode"> <code>patience</code> </dt> <dd> <p>Use "patience diff" algorithm when generating patches.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-codehistogramcode"> <code>histogram</code> </dt> <dd> <p>This algorithm extends the patience algorithm to "support low-occurrence common elements".</p> </dd> </dl> </div> </div> </div> <p>For instance, if you configured the <code>diff.algorithm</code> variable to a non-default value and want to use the default one, then you have to use <code>--diff-algorithm=default</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---statltwidthgtltname-widthgtltcountgt"> --stat[=<width>[,<name-width>[,<count>]]] </dt> <dd> <p>Generate a diffstat. By default, as much space as necessary will be used for the filename part, and the rest for the graph part. Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden by <code><width></code>. The width of the filename part can be limited by giving another width <code><name-width></code> after a comma or by setting <code>diff.statNameWidth=<width></code>. The width of the graph part can be limited by using <code>--stat-graph-width=<width></code> or by setting <code>diff.statGraphWidth=<width></code>. Using <code>--stat</code> or <code>--stat-graph-width</code> affects all commands generating a stat graph, while setting <code>diff.statNameWidth</code> or <code>diff.statGraphWidth</code> does not affect <code>git format-patch</code>. By giving a third parameter <code><count></code>, you can limit the output to the first <code><count></code> lines, followed by <code>...</code> if there are more.</p> <p>These parameters can also be set individually with <code>--stat-width=<width></code>, <code>--stat-name-width=<name-width></code> and <code>--stat-count=<count></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---compact-summary"> --compact-summary </dt> <dd> <p>Output a condensed summary of extended header information such as file creations or deletions ("new" or "gone", optionally "+l" if it’s a symlink) and mode changes ("+x" or "-x" for adding or removing executable bit respectively) in diffstat. The information is put between the filename part and the graph part. Implies <code>--stat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---numstat"> --numstat </dt> <dd> <p>Similar to <code>--stat</code>, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly. For binary files, outputs two <code>-</code> instead of saying <code>0 0</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---shortstat"> --shortstat </dt> <dd> <p>Output only the last line of the <code>--stat</code> format containing total number of modified files, as well as number of added and deleted lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--Xltparam1param282308203gt"> -X[<param1,param2,…>] </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---dirstatltparam1param282308203gt"> --dirstat[=<param1,param2,…>] </dt> <dd> <p>Output the distribution of relative amount of changes for each sub-directory. The behavior of <code>--dirstat</code> can be customized by passing it a comma separated list of parameters. The defaults are controlled by the <code>diff.dirstat</code> configuration variable (see <a href="git-config">git-config[1]</a>). The following parameters are available:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-codechangescode"> <code>changes</code> </dt> <dd> <p>Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination. This ignores the amount of pure code movements within a file. In other words, rearranging lines in a file is not counted as much as other changes. This is the default behavior when no parameter is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-codelinescode"> <code>lines</code> </dt> <dd> <p>Compute the dirstat numbers by doing the regular line-based diff analysis, and summing the removed/added line counts. (For binary files, count 64-byte chunks instead, since binary files have no natural concept of lines). This is a more expensive <code>--dirstat</code> behavior than the <code>changes</code> behavior, but it does count rearranged lines within a file as much as other changes. The resulting output is consistent with what you get from the other <code>--*stat</code> options.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-codefilescode"> <code>files</code> </dt> <dd> <p>Compute the dirstat numbers by counting the number of files changed. Each changed file counts equally in the dirstat analysis. This is the computationally cheapest <code>--dirstat</code> behavior, since it does not have to look at the file contents at all.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-codecumulativecode"> <code>cumulative</code> </dt> <dd> <p>Count changes in a child directory for the parent directory as well. Note that when using <code>cumulative</code>, the sum of the percentages reported may exceed 100%. The default (non-cumulative) behavior can be specified with the <code>noncumulative</code> parameter.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-ltlimitgt"> <limit> </dt> <dd> <p>An integer parameter specifies a cut-off percent (3% by default). Directories contributing less than this percentage of the changes are not shown in the output.</p> </dd> </dl> </div> </div> </div> <p>Example: The following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories: <code>--dirstat=files,10,cumulative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---cumulative"> --cumulative </dt> <dd> <p>Synonym for --dirstat=cumulative</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---dirstat-by-fileltparam1param2gt82308203"> --dirstat-by-file[=<param1,param2>…] </dt> <dd> <p>Synonym for --dirstat=files,param1,param2…</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---summary"> --summary </dt> <dd> <p>Output a condensed summary of extended header information such as creations, renames and mode changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---patch-with-stat"> --patch-with-stat </dt> <dd> <p>Synonym for <code>-p --stat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--z"> -z </dt> <dd> <p>When <code>--raw</code>, <code>--numstat</code>, <code>--name-only</code> or <code>--name-status</code> has been given, do not munge pathnames and use NULs as output field terminators.</p> <p>Without this option, pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---name-only"> --name-only </dt> <dd> <p>Show only names of changed files. The file names are often encoded in UTF-8. For more information see the discussion about encoding in the <a href="git-log">git-log[1]</a> manual page.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---name-status"> --name-status </dt> <dd> <p>Show only names and status of changed files. See the description of the <code>--diff-filter</code> option on what the status letters mean. Just like <code>--name-only</code> the file names are often encoded in UTF-8.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---submoduleltformatgt"> --submodule[=<format>] </dt> <dd> <p>Specify how differences in submodules are shown. When specifying <code>--submodule=short</code> the <code>short</code> format is used. This format just shows the names of the commits at the beginning and end of the range. When <code>--submodule</code> or <code>--submodule=log</code> is specified, the <code>log</code> format is used. This format lists the commits in the range like <a href="git-submodule">git-submodule[1]</a> <code>summary</code> does. When <code>--submodule=diff</code> is specified, the <code>diff</code> format is used. This format shows an inline diff of the changes in the submodule contents between the commit range. Defaults to <code>diff.submodule</code> or the <code>short</code> format if the config option is unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---colorltwhengt"> --color[=<when>] </dt> <dd> <p>Show colored diff. <code>--color</code> (i.e. without <code>=<when></code>) is the same as <code>--color=always</code>. <code><when></code> can be one of <code>always</code>, <code>never</code>, or <code>auto</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-color"> --no-color </dt> <dd> <p>Turn off colored diff. It is the same as <code>--color=never</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---color-movedltmodegt"> --color-moved[=<mode>] </dt> <dd> <p>Moved lines of code are colored differently. The <mode> defaults to <code>no</code> if the option is not given and to <code>zebra</code> if the option with no mode is given. The mode must be one of:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-no"> no </dt> <dd> <p>Moved lines are not highlighted.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-default"> default </dt> <dd> <p>Is a synonym for <code>zebra</code>. This may change to a more sensible mode in the future.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-plain"> plain </dt> <dd> <p>Any line that is added in one location and was removed in another location will be colored with <code>color.diff.newMoved</code>. Similarly <code>color.diff.oldMoved</code> will be used for removed lines that are added somewhere else in the diff. This mode picks up any moved line, but it is not very useful in a review to determine if a block of code was moved without permutation.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-blocks"> blocks </dt> <dd> <p>Blocks of moved text of at least 20 alphanumeric characters are detected greedily. The detected blocks are painted using either the <code>color.diff.{old,new}Moved</code> color. Adjacent blocks cannot be told apart.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-zebra"> zebra </dt> <dd> <p>Blocks of moved text are detected as in <code>blocks</code> mode. The blocks are painted using either the <code>color.diff.{old,new}Moved</code> color or <code>color.diff.{old,new}MovedAlternative</code>. The change between the two colors indicates that a new block was detected.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-dimmed-zebra"> dimmed-zebra </dt> <dd> <p>Similar to <code>zebra</code>, but additional dimming of uninteresting parts of moved code is performed. The bordering lines of two adjacent blocks are considered interesting, the rest is uninteresting. <code>dimmed_zebra</code> is a deprecated synonym.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-color-moved"> --no-color-moved </dt> <dd> <p>Turn off move detection. This can be used to override configuration settings. It is the same as <code>--color-moved=no</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---color-moved-wsltmodesgt"> --color-moved-ws=<modes> </dt> <dd> <p>This configures how whitespace is ignored when performing the move detection for <code>--color-moved</code>. These modes can be given as a comma separated list:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-no-1"> no </dt> <dd> <p>Do not ignore whitespace when performing move detection.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-ignore-space-at-eol"> ignore-space-at-eol </dt> <dd> <p>Ignore changes in whitespace at EOL.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-ignore-space-change"> ignore-space-change </dt> <dd> <p>Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-ignore-all-space"> ignore-all-space </dt> <dd> <p>Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-allow-indentation-change"> allow-indentation-change </dt> <dd> <p>Initially ignore any whitespace in the move detection, then group the moved code blocks only into a block if the change in whitespace is the same per line. This is incompatible with the other modes.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-color-moved-ws"> --no-color-moved-ws </dt> <dd> <p>Do not ignore whitespace when performing move detection. This can be used to override configuration settings. It is the same as <code>--color-moved-ws=no</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---word-diffltmodegt"> --word-diff[=<mode>] </dt> <dd> <p>Show a word diff, using the <mode> to delimit changed words. By default, words are delimited by whitespace; see <code>--word-diff-regex</code> below. The <mode> defaults to <code>plain</code>, and must be one of:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-color"> color </dt> <dd> <p>Highlight changed words using only colors. Implies <code>--color</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-plain-1"> plain </dt> <dd> <p>Show words as <code>[-removed-]</code> and <code>{+added+}</code>. Makes no attempts to escape the delimiters if they appear in the input, so the output may be ambiguous.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-porcelain"> porcelain </dt> <dd> <p>Use a special line-based format intended for script consumption. Added/removed/unchanged runs are printed in the usual unified diff format, starting with a <code>+</code>/<code>-</code>/` ` character at the beginning of the line and extending to the end of the line. Newlines in the input are represented by a tilde <code>~</code> on a line of its own.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-none"> none </dt> <dd> <p>Disable word diff again.</p> </dd> </dl> </div> </div> </div> <p>Note that despite the name of the first mode, color is used to highlight the changed parts in all modes if enabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---word-diff-regexltregexgt"> --word-diff-regex=<regex> </dt> <dd> <p>Use <regex> to decide what a word is, instead of considering runs of non-whitespace to be a word. Also implies <code>--word-diff</code> unless it was already enabled.</p> <p>Every non-overlapping match of the <regex> is considered a word. Anything between these matches is considered whitespace and ignored(!) for the purposes of finding differences. You may want to append <code>|[^[:space:]]</code> to your regular expression to make sure that it matches all non-whitespace characters. A match that contains a newline is silently truncated(!) at the newline.</p> <p>For example, <code>--word-diff-regex=.</code> will treat each character as a word and, correspondingly, show differences character by character.</p> <p>The regex can also be set via a diff driver or configuration option, see <a href="gitattributes">gitattributes[5]</a> or <a href="git-config">git-config[1]</a>. Giving it explicitly overrides any diff driver or configuration setting. Diff drivers override configuration settings.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---color-wordsltregexgt"> --color-words[=<regex>] </dt> <dd> <p>Equivalent to <code>--word-diff=color</code> plus (if a regex was specified) <code>--word-diff-regex=<regex></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-renames"> --no-renames </dt> <dd> <p>Turn off rename detection, even when the configuration file gives the default to do so.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-rename-empty"> --[no-]rename-empty </dt> <dd> <p>Whether to use empty blobs as rename source.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---check"> --check </dt> <dd> <p>Warn if changes introduce conflict markers or whitespace errors. What are considered whitespace errors is controlled by <code>core.whitespace</code> configuration. By default, trailing whitespaces (including lines that consist solely of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors. Exits with non-zero status if problems are found. Not compatible with --exit-code.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---ws-error-highlightltkindgt"> --ws-error-highlight=<kind> </dt> <dd> <p>Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code> lines of the diff. Multiple values are separated by comma, <code>none</code> resets previous values, <code>default</code> reset the list to <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. When this option is not given, and the configuration variable <code>diff.wsErrorHighlight</code> is not set, only whitespace errors in <code>new</code> lines are highlighted. The whitespace errors are colored with <code>color.diff.whitespace</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---full-index"> --full-index </dt> <dd> <p>Instead of the first handful of characters, show the full pre- and post-image blob object names on the "index" line when generating patch format output.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---binary"> --binary </dt> <dd> <p>In addition to <code>--full-index</code>, output a binary diff that can be applied with <code>git-apply</code>. Implies <code>--patch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---abbrevltngt"> --abbrev[=<n>] </dt> <dd> <p>Instead of showing the full 40-byte hexadecimal object name in diff-raw format output and diff-tree header lines, show the shortest prefix that is at least <code><n></code> hexdigits long that uniquely refers the object. In diff-patch output format, <code>--full-index</code> takes higher precedence, i.e. if <code>--full-index</code> is specified, full blob names will be shown regardless of <code>--abbrev</code>. Non default number of digits can be specified with <code>--abbrev=<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--Bltngtltmgt"> -B[<n>][/<m>] </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---break-rewritesltngtltmgt"> --break-rewrites[=[<n>][/<m>]] </dt> <dd> <p>Break complete rewrite changes into pairs of delete and create. This serves two purposes:</p> <p>It affects the way a change that amounts to a total rewrite of a file not as a series of deletion and insertion mixed together with a very few lines that happen to match textually as the context, but as a single deletion of everything old followed by a single insertion of everything new, and the number <code>m</code> controls this aspect of the -B option (defaults to 60%). <code>-B/70%</code> specifies that less than 30% of the original should remain in the result for Git to consider it a total rewrite (i.e. otherwise the resulting patch will be a series of deletion and insertion mixed together with context lines).</p> <p>When used with -M, a totally-rewritten file is also considered as the source of a rename (usually -M only considers a file that disappeared as the source of a rename), and the number <code>n</code> controls this aspect of the -B option (defaults to 50%). <code>-B20%</code> specifies that a change with addition and deletion compared to 20% or more of the file’s size are eligible for being picked up as a possible source of a rename to another file.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--Mltngt"> -M[<n>] </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---find-renamesltngt"> --find-renames[=<n>] </dt> <dd> <p>Detect renames. If <code>n</code> is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file’s size). For example, <code>-M90%</code> means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn’t changed. Without a <code>%</code> sign, the number is to be read as a fraction, with a decimal point before it. I.e., <code>-M5</code> becomes 0.5, and is thus the same as <code>-M50%</code>. Similarly, <code>-M05</code> is the same as <code>-M5%</code>. To limit detection to exact renames, use <code>-M100%</code>. The default similarity index is 50%.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--Cltngt"> -C[<n>] </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---find-copiesltngt"> --find-copies[=<n>] </dt> <dd> <p>Detect copies as well as renames. See also <code>--find-copies-harder</code>. If <code>n</code> is specified, it has the same meaning as for <code>-M<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---find-copies-harder"> --find-copies-harder </dt> <dd> <p>For performance reasons, by default, <code>-C</code> option finds copies only if the original file of the copy was modified in the same changeset. This flag makes the command inspect unmodified files as candidates for the source of copy. This is a very expensive operation for large projects, so use it with caution. Giving more than one <code>-C</code> option has the same effect.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--D"> -D </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---irreversible-delete"> --irreversible-delete </dt> <dd> <p>Omit the preimage for deletes, i.e. print only the header but not the diff between the preimage and <code>/dev/null</code>. The resulting patch is not meant to be applied with <code>patch</code> or <code>git apply</code>; this is solely for people who want to just concentrate on reviewing the text after the change. In addition, the output obviously lacks enough information to apply such a patch in reverse, even manually, hence the name of the option.</p> <p>When used together with <code>-B</code>, omit also the preimage in the deletion part of a delete/create pair.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--lltnumgt"> -l<num> </dt> <dd> <p>The <code>-M</code> and <code>-C</code> options involve some preliminary steps that can detect subsets of renames/copies cheaply, followed by an exhaustive fallback portion that compares all remaining unpaired destinations to all relevant sources. (For renames, only remaining unpaired sources are relevant; for copies, all original sources are relevant.) For N sources and destinations, this exhaustive check is O(N^2). This option prevents the exhaustive portion of rename/copy detection from running if the number of source/destination files involved exceeds the specified number. Defaults to diff.renameLimit. Note that a value of 0 is treated as unlimited.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---diff-filterACDMRTUXB82308203"> --diff-filter=[(A|C|D|M|R|T|U|X|B)…[*]] </dt> <dd> <p>Select only files that are Added (<code>A</code>), Copied (<code>C</code>), Deleted (<code>D</code>), Modified (<code>M</code>), Renamed (<code>R</code>), have their type (i.e. regular file, symlink, submodule, …) changed (<code>T</code>), are Unmerged (<code>U</code>), are Unknown (<code>X</code>), or have had their pairing Broken (<code>B</code>). Any combination of the filter characters (including none) can be used. When <code>*</code> (All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.</p> <p>Also, these upper-case letters can be downcased to exclude. E.g. <code>--diff-filter=ad</code> excludes added and deleted paths.</p> <p>Note that not all diffs can feature all types. For instance, copied and renamed entries cannot appear if detection for those types is disabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--Sltstringgt"> -S<string> </dt> <dd> <p>Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file. Intended for the scripter’s use.</p> <p>It is useful when you’re looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting block in the preimage back into <code>-S</code>, and keep going until you get the very first version of the block.</p> <p>Binary files are searched as well.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--Gltregexgt"> -G<regex> </dt> <dd> <p>Look for differences whose patch text contains added/removed lines that match <regex>.</p> <p>To illustrate the difference between <code>-S<regex> --pickaxe-regex</code> and <code>-G<regex></code>, consider a commit with the following diff in the same file:</p> <div class="listingblock"> <div class="content"> <pre>+ return frotz(nitfol, two->ptr, 1, 0); +... +- hit = frotz(nitfol, mf2.ptr, 1, 0);</pre> </div> </div> <p>While <code>git log -G"frotz\(nitfol"</code> will show this commit, <code>git log +-S"frotz\(nitfol" --pickaxe-regex</code> will not (because the number of occurrences of that string did not change).</p> <p>Unless <code>--text</code> is supplied patches of binary files without a textconv filter will be ignored.</p> <p>See the <code>pickaxe</code> entry in <a href="gitdiffcore">gitdiffcore[7]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---find-objectltobject-idgt"> --find-object=<object-id> </dt> <dd> <p>Look for differences that change the number of occurrences of the specified object. Similar to <code>-S</code>, just the argument is different in that it doesn’t search for a specific string but for a specific object id.</p> <p>The object can be a blob or a submodule commit. It implies the <code>-t</code> option in <code>git-log</code> to also find trees.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---pickaxe-all"> --pickaxe-all </dt> <dd> <p>When <code>-S</code> or <code>-G</code> finds a change, show all the changes in that changeset, not just the files that contain the change in <string>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---pickaxe-regex"> --pickaxe-regex </dt> <dd> <p>Treat the <string> given to <code>-S</code> as an extended POSIX regular expression to match.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--Oltorderfilegt"> -O<orderfile> </dt> <dd> <p>Control the order in which files appear in the output. This overrides the <code>diff.orderFile</code> configuration variable (see <a href="git-config">git-config[1]</a>). To cancel <code>diff.orderFile</code>, use <code>-O/dev/null</code>.</p> <p>The output order is determined by the order of glob patterns in <orderfile>. All files with pathnames that match the first pattern are output first, all files with pathnames that match the second pattern (but not the first) are output next, and so on. All files with pathnames that do not match any pattern are output last, as if there was an implicit match-all pattern at the end of the file. If multiple pathnames have the same rank (they match the same pattern but no earlier patterns), their output order relative to each other is the normal order.</p> <p><orderfile> is parsed as follows:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>Blank lines are ignored, so they can be used as separators for readability.</p> </li> <li> <p>Lines starting with a hash ("<code>#</code>") are ignored, so they can be used for comments. Add a backslash ("<code>\</code>") to the beginning of the pattern if it starts with a hash.</p> </li> <li> <p>Each other line contains a single pattern.</p> </li> </ul> </div> </div> </div> <p>Patterns have the same syntax and semantics as patterns used for fnmatch(3) without the FNM_PATHNAME flag, except a pathname also matches a pattern if removing any number of the final pathname components matches the pattern. For example, the pattern "<code>foo*bar</code>" matches "<code>fooasdfbar</code>" and "<code>foo/bar/baz/asdf</code>" but not "<code>foobarx</code>".</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---skip-toltfilegt"> --skip-to=<file> </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---rotate-toltfilegt"> --rotate-to=<file> </dt> <dd> <p>Discard the files before the named <file> from the output (i.e. <code>skip to</code>), or move them to the end of the output (i.e. <code>rotate to</code>). These options were invented primarily for the use of the <code>git difftool</code> command, and may not be very useful otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--R"> -R </dt> <dd> <p>Swap two inputs; that is, show differences from index or on-disk file to tree contents.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---relativeltpathgt"> --relative[=<path>] </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-relative"> --no-relative </dt> <dd> <p>When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option. When you are not in a subdirectory (e.g. in a bare repository), you can name which subdirectory to make the output relative to by giving a <path> as an argument. <code>--no-relative</code> can be used to countermand both <code>diff.relative</code> config option and previous <code>--relative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---text"> --text </dt> <dd> <p>Treat all files as text.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---ignore-cr-at-eol"> --ignore-cr-at-eol </dt> <dd> <p>Ignore carriage-return at the end of line when doing a comparison.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---ignore-space-at-eol"> --ignore-space-at-eol </dt> <dd> <p>Ignore changes in whitespace at EOL.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--b"> -b </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---ignore-space-change"> --ignore-space-change </dt> <dd> <p>Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--w"> -w </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---ignore-all-space"> --ignore-all-space </dt> <dd> <p>Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---ignore-blank-lines"> --ignore-blank-lines </dt> <dd> <p>Ignore changes whose lines are all blank.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--Iltregexgt"> -I<regex> </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---ignore-matching-linesltregexgt"> --ignore-matching-lines=<regex> </dt> <dd> <p>Ignore changes whose all lines match <regex>. This option may be specified more than once.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---inter-hunk-contextltlinesgt"> --inter-hunk-context=<lines> </dt> <dd> <p>Show the context between diff hunks, up to the specified number of lines, thereby fusing hunks that are close to each other. Defaults to <code>diff.interHunkContext</code> or 0 if the config option is unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--W"> -W </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---function-context"> --function-context </dt> <dd> <p>Show whole function as context lines for each change. The function names are determined in the same way as <code>git diff</code> works out patch hunk headers (see <code>Defining a custom hunk-header</code> in <a href="gitattributes">gitattributes[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---exit-code"> --exit-code </dt> <dd> <p>Make the program exit with codes similar to diff(1). That is, it exits with 1 if there were differences and 0 means no differences.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---quiet"> --quiet </dt> <dd> <p>Disable all output of the program. Implies <code>--exit-code</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---ext-diff"> --ext-diff </dt> <dd> <p>Allow an external diff helper to be executed. If you set an external diff driver with <a href="gitattributes">gitattributes[5]</a>, you need to use this option with <a href="git-log">git-log[1]</a> and friends.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-ext-diff"> --no-ext-diff </dt> <dd> <p>Disallow external diff drivers.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---textconv"> --textconv </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-textconv"> --no-textconv </dt> <dd> <p>Allow (or disallow) external text conversion filters to be run when comparing binary files. See <a href="gitattributes">gitattributes[5]</a> for details. Because textconv filters are typically a one-way conversion, the resulting diff is suitable for human consumption, but cannot be applied. For this reason, textconv filters are enabled by default only for <a href="git-diff">git-diff[1]</a> and <a href="git-log">git-log[1]</a>, but not for <a href="git-format-patch">git-format-patch[1]</a> or diff plumbing commands.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---ignore-submodulesltwhengt"> --ignore-submodules[=<when>] </dt> <dd> <p>Ignore changes to submodules in the diff generation. <when> can be either "none", "untracked", "dirty" or "all", which is the default. Using "none" will consider the submodule modified when it either contains untracked or modified files or its HEAD differs from the commit recorded in the superproject and can be used to override any settings of the <code>ignore</code> option in <a href="git-config">git-config[1]</a> or <a href="gitmodules">gitmodules[5]</a>. When "untracked" is used submodules are not considered dirty when they only contain untracked content (but they are still scanned for modified content). Using "dirty" ignores all changes to the work tree of submodules, only changes to the commits stored in the superproject are shown (this was the behavior until 1.7.0). Using "all" hides all changes to submodules.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---src-prefixltprefixgt"> --src-prefix=<prefix> </dt> <dd> <p>Show the given source prefix instead of "a/".</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---dst-prefixltprefixgt"> --dst-prefix=<prefix> </dt> <dd> <p>Show the given destination prefix instead of "b/".</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-prefix"> --no-prefix </dt> <dd> <p>Do not show any source or destination prefix.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---default-prefix"> --default-prefix </dt> <dd> <p>Use the default source and destination prefixes ("a/" and "b/"). This is usually the default already, but may be used to override config such as <code>diff.noprefix</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---line-prefixltprefixgt"> --line-prefix=<prefix> </dt> <dd> <p>Prepend an additional prefix to every line of output.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---ita-invisible-in-index"> --ita-invisible-in-index </dt> <dd> <p>By default entries added by "git add -N" appear as an existing empty file in "git diff" and a new file in "git diff --cached". This option makes the entry appear as a new file in "git diff" and non-existent in "git diff --cached". This option could be reverted with <code>--ita-visible-in-index</code>. Both options are experimental and could be removed in future.</p> </dd> </dl> </div> <p>For more detailed explanation on these common options, see also <a href="gitdiffcore">gitdiffcore[7]</a>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-lttree-ishgt"> <tree-ish> </dt> <dd> <p>The id of a tree object.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-ltpathgt82308203"> <path>… </dt> <dd> <p>If provided, the results are limited to a subset of files matching one of the provided pathspecs.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--r"> -r </dt> <dd> <p>Recurse into sub-trees.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--t"> -t </dt> <dd> <p>Show tree entry itself as well as subtrees. Implies -r.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---root"> --root </dt> <dd> <p>When <code>--root</code> is specified the initial commit will be shown as a big creation event. This is equivalent to a diff against the NULL tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---merge-base"> --merge-base </dt> <dd> <p>Instead of comparing the <tree-ish>s directly, use the merge base between the two <tree-ish>s as the "before" side. There must be two <tree-ish>s given and they must both be commits.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---stdin"> --stdin </dt> <dd> <p>When <code>--stdin</code> is specified, the command does not take <tree-ish> arguments from the command line. Instead, it reads lines containing either two <tree>, one <commit>, or a list of <commit> from its standard input. (Use a single space as separator.)</p> <p>When two trees are given, it compares the first tree with the second. When a single commit is given, it compares the commit with its parents. The remaining commits, when given, are used as if they are parents of the first commit.</p> <p>When comparing two trees, the ID of both trees (separated by a space and terminated by a newline) is printed before the difference. When comparing commits, the ID of the first (or only) commit, followed by a newline, is printed.</p> <p>The following flags further affect the behavior when comparing commits (but not trees).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--m"> -m </dt> <dd> <p>By default, <code>git diff-tree --stdin</code> does not show differences for merge commits. With this flag, it shows differences to that commit from all of its parents. See also <code>-c</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--s-1"> -s </dt> <dd> <p>By default, <code>git diff-tree --stdin</code> shows differences, either in machine-readable form (without <code>-p</code>) or in patch form (with <code>-p</code>). This output can be suppressed. It is only useful with the <code>-v</code> flag.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--v"> -v </dt> <dd> <p>This flag causes <code>git diff-tree --stdin</code> to also show the commit message before the differences.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---prettyltformatgt"> --pretty[=<format>] </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---formatltformatgt"> --format=<format> </dt> <dd> <p>Pretty-print the contents of the commit logs in a given format, where <code><format></code> can be one of <code>oneline</code>, <code>short</code>, <code>medium</code>, <code>full</code>, <code>fuller</code>, <code>reference</code>, <code>email</code>, <code>raw</code>, <code>format:<string></code> and <code>tformat:<string></code>. When <code><format></code> is none of the above, and has <code>%placeholder</code> in it, it acts as if <code>--pretty=tformat:<format></code> were given.</p> <p>See the "PRETTY FORMATS" section for some additional details for each format. When <code>=<format></code> part is omitted, it defaults to <code>medium</code>.</p> <p>Note: you can specify the default pretty format in the repository configuration (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---abbrev-commit"> --abbrev-commit </dt> <dd> <p>Instead of showing the full 40-byte hexadecimal commit object name, show a prefix that names the object uniquely. "--abbrev=<n>" (which also modifies diff output, if it is displayed) option can be used to specify the minimum length of the prefix.</p> <p>This should make "--pretty=oneline" a whole lot more readable for people using 80-column terminals.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-abbrev-commit"> --no-abbrev-commit </dt> <dd> <p>Show the full 40-byte hexadecimal commit object name. This negates <code>--abbrev-commit</code>, either explicit or implied by other options such as "--oneline". It also overrides the <code>log.abbrevCommit</code> variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---oneline"> --oneline </dt> <dd> <p>This is a shorthand for "--pretty=oneline --abbrev-commit" used together.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---encodingltencodinggt"> --encoding=<encoding> </dt> <dd> <p>Commit objects record the character encoding used for the log message in their encoding header; this option can be used to tell the command to re-code the commit log message in the encoding preferred by the user. For non plumbing commands this defaults to UTF-8. Note that if an object claims to be encoded in <code>X</code> and we are outputting in <code>X</code>, we will output the object verbatim; this means that invalid sequences in the original commit may be copied to the output. Likewise, if iconv(3) fails to convert the commit, we will quietly output the original object verbatim.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---expand-tabsltngt"> --expand-tabs=<n> </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---expand-tabs"> --expand-tabs </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-expand-tabs"> --no-expand-tabs </dt> <dd> <p>Perform a tab expansion (replace each tab with enough spaces to fill to the next display column that is a multiple of <code><n></code>) in the log message before showing it in the output. <code>--expand-tabs</code> is a short-hand for <code>--expand-tabs=8</code>, and <code>--no-expand-tabs</code> is a short-hand for <code>--expand-tabs=0</code>, which disables tab expansion.</p> <p>By default, tabs are expanded in pretty formats that indent the log message by 4 spaces (i.e. <code>medium</code>, which is the default, <code>full</code>, and <code>fuller</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---notesltrefgt"> --notes[=<ref>] </dt> <dd> <p>Show the notes (see <a href="git-notes">git-notes[1]</a>) that annotate the commit, when showing the commit log message. This is the default for <code>git log</code>, <code>git show</code> and <code>git whatchanged</code> commands when there is no <code>--pretty</code>, <code>--format</code>, or <code>--oneline</code> option given on the command line.</p> <p>By default, the notes shown are from the notes refs listed in the <code>core.notesRef</code> and <code>notes.displayRef</code> variables (or corresponding environment overrides). See <a href="git-config">git-config[1]</a> for more details.</p> <p>With an optional <code><ref></code> argument, use the ref to find the notes to display. The ref can specify the full refname when it begins with <code>refs/notes/</code>; when it begins with <code>notes/</code>, <code>refs/</code> and otherwise <code>refs/notes/</code> is prefixed to form the full name of the ref.</p> <p>Multiple --notes options can be combined to control which notes are being displayed. Examples: "--notes=foo" will show only notes from "refs/notes/foo"; "--notes=foo --notes" will show both notes from "refs/notes/foo" and from the default notes ref(s).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-notes"> --no-notes </dt> <dd> <p>Do not show notes. This negates the above <code>--notes</code> option, by resetting the list of notes refs from which notes are shown. Options are parsed in the order given on the command line, so e.g. "--notes --notes=foo --no-notes --notes=bar" will only show notes from "refs/notes/bar".</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---show-notes-by-default"> --show-notes-by-default </dt> <dd> <p>Show the default notes unless options for displaying specific notes are given.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---show-notesltrefgt"> --show-notes[=<ref>] </dt> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-standard-notes"> --[no-]standard-notes </dt> <dd> <p>These options are deprecated. Use the above --notes/--no-notes options instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---show-signature"> --show-signature </dt> <dd> <p>Check the validity of a signed commit object by passing the signature to <code>gpg --verify</code> and show the output.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---no-commit-id"> --no-commit-id </dt> <dd> <p><code>git diff-tree</code> outputs a line with the commit ID when applicable. This flag suppressed the commit ID output.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt--c"> -c </dt> <dd> <p>This flag changes the way a merge commit is displayed (which means it is useful only when the command is given one <tree-ish>, or <code>--stdin</code>). It shows the differences from each of the parents to the merge result simultaneously instead of showing pairwise diff between a parent and the result one at a time (which is what the <code>-m</code> option does). Furthermore, it lists only files which were modified from all parents.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---cc"> --cc </dt> <dd> <p>This flag changes the way a merge commit patch is displayed, in a similar way to the <code>-c</code> option. It implies the <code>-c</code> and <code>-p</code> options and further compresses the patch output by omitting uninteresting hunks whose contents in the parents have only two variants and the merge result picks one of them without modification. When all hunks are uninteresting, the commit itself and the commit log message are not shown, just like in any other "empty diff" case.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---combined-all-paths"> --combined-all-paths </dt> <dd> <p>This flag causes combined diffs (used for merge commits) to list the name of the file from all parents. It thus only has effect when -c or --cc are specified, and is likely only useful if filename changes are detected (i.e. when either rename or copy detection have been requested).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt---always"> --always </dt> <dd> <p>Show the commit itself and the commit log message even if the diff itself is empty.</p> </dd> </dl> </div> </div> <h2 id="_pretty_formats">Pretty formats</h2> <div class="sectionbody"> <p>If the commit is a merge, and if the pretty-format is not <code>oneline</code>, <code>email</code> or <code>raw</code>, an additional line is inserted before the <code>Author:</code> line. This line begins with "Merge: " and the hashes of ancestral commits are printed, separated by spaces. Note that the listed commits may not necessarily be the list of the <strong>direct</strong> parent commits if you have limited your view of history: for example, if you are only interested in changes related to a certain directory or file.</p> <p>There are several built-in formats, and you can define additional formats by setting a pretty.<name> config option to either another format name, or a <code>format:</code> string, as described below (see <a href="git-config">git-config[1]</a>). Here are the details of the built-in formats:</p> <div class="ulist"> <ul> <li> <p><code>oneline</code></p> <div class="literalblock"> <div class="content"> <pre><hash> <title-line></pre> </div> </div> <p>This is designed to be as compact as possible.</p> </li> <li> <p><code>short</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> </li> <li> <p><code>medium</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author> +Date: <author-date></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>full</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author> +Commit: <committer></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>fuller</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author> +AuthorDate: <author-date> +Commit: <committer> +CommitDate: <committer-date></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>reference</code></p> <div class="literalblock"> <div class="content"> <pre><abbrev-hash> (<title-line>, <short-author-date>)</pre> </div> </div> <p>This format is used to refer to another commit in a commit message and is the same as <code>--pretty='format:%C(auto)%h (%s, %ad)'</code>. By default, the date is formatted with <code>--date=short</code> unless another <code>--date</code> option is explicitly specified. As with any <code>format:</code> with format placeholders, its output is not affected by other options like <code>--decorate</code> and <code>--walk-reflogs</code>.</p> </li> <li> <p><code>email</code></p> <div class="literalblock"> <div class="content"> <pre>From <hash> <date> +From: <author> +Date: <author-date> +Subject: [PATCH] <title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>mboxrd</code></p> <p>Like <code>email</code>, but lines in the commit message starting with "From " (preceded by zero or more ">") are quoted with ">" so they aren’t confused as starting a new commit.</p> </li> <li> <p><code>raw</code></p> <p>The <code>raw</code> format shows the entire commit exactly as stored in the commit object. Notably, the hashes are displayed in full, regardless of whether --abbrev or --no-abbrev are used, and <code>parents</code> information show the true parent commits, without taking grafts or history simplification into account. Note that this format affects the way commits are displayed, but not the way the diff is shown e.g. with <code>git log --raw</code>. To get full object names in a raw diff format, use <code>--no-abbrev</code>.</p> </li> <li> <p><code>format:<format-string></code></p> <p>The <code>format:<format-string></code> format allows you to specify which information you want to show. It works a little bit like printf format, with the notable exception that you get a newline with <code>%n</code> instead of <code>\n</code>.</p> <p>E.g, <code>format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"</code> would show something like this:</p> <div class="listingblock"> <div class="content"> <pre>The author of fe6e0ee was Junio C Hamano, 23 hours ago +The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<</pre> </div> </div> <p>The placeholders are:</p> <div class="ulist"> <ul> <li> <p>Placeholders that expand to a single literal character:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emnem"> <em>%n</em> </dt> <dd> <p>newline</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emem"> <em>%%</em> </dt> <dd> <p>a raw <code>%</code></p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emx00em"> <em>%x00</em> </dt> <dd> <p><code>%x</code> followed by two hexadecimal digits is replaced with a byte with the hexadecimal digits' value (we will call this "literal formatting code" in the rest of this document).</p> </dd> </dl> </div> </li> <li> <p>Placeholders that affect formatting of later placeholders:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emCredem"> <em>%Cred</em> </dt> <dd> <p>switch color to red</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emCgreenem"> <em>%Cgreen</em> </dt> <dd> <p>switch color to green</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emCblueem"> <em>%Cblue</em> </dt> <dd> <p>switch color to blue</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emCresetem"> <em>%Creset</em> </dt> <dd> <p>reset color</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emC82308203em"> <em>%C(…)</em> </dt> <dd> <p>color specification, as described under Values in the "CONFIGURATION FILE" section of <a href="git-config">git-config[1]</a>. By default, colors are shown only when enabled for log output (by <code>color.diff</code>, <code>color.ui</code>, or <code>--color</code>, and respecting the <code>auto</code> settings of the former if we are going to a terminal). <code>%C(auto,...)</code> is accepted as a historical synonym for the default (e.g., <code>%C(auto,red)</code>). Specifying <code>%C(always,...)</code> will show the colors even when color is not otherwise enabled (though consider just using <code>--color=always</code> to enable color for the whole output, including this format and anything else git might color). <code>auto</code> alone (i.e. <code>%C(auto)</code>) will turn on auto coloring on the next placeholders until the color is switched again.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emmem"> <em>%m</em> </dt> <dd> <p>left (<code><</code>), right (<code>></code>) or boundary (<code>-</code>) mark</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emwltwgtlti1gtlti2gtem"> <em>%w([<w>[,<i1>[,<i2>]]])</em> </dt> <dd> <p>switch line wrapping, like the -w option of <a href="git-shortlog">git-shortlog[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emltltNgttruncltruncmtruncem"> <em>%<( <N> [,trunc|ltrunc|mtrunc])</em> </dt> <dd> <p>make the next placeholder take at least N column widths, padding spaces on the right if necessary. Optionally truncate (with ellipsis <code>..</code>) at the left (ltrunc) <code>..ft</code>, the middle (mtrunc) <code>mi..le</code>, or the end (trunc) <code>rig..</code>, if the output is longer than N columns. Note 1: that truncating only works correctly with N >= 2. Note 2: spaces around the N and M (see below) values are optional. Note 3: Emojis and other wide characters will take two display columns, which may over-run column boundaries. Note 4: decomposed character combining marks may be misplaced at padding boundaries.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emltltMgtem"> <em>%<|( <M> )</em> </dt> <dd> <p>make the next placeholder take at least until Mth display column, padding spaces on the right if necessary. Use negative M values for column positions measured from the right hand edge of the terminal window.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emgtltNgtememgtltMgtem"> <em>%>( <N> )</em>, <em>%>|( <M> )</em> </dt> <dd> <p>similar to <code>%<( <N> )</code>, <code>%<|( <M> )</code> respectively, but padding spaces on the left</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emgtgtltNgtememgtgtltMgtem"> <em>%>>( <N> )</em>, <em>%>>|( <M> )</em> </dt> <dd> <p>similar to <code>%>( <N> )</code>, <code>%>|( <M> )</code> respectively, except that if the next placeholder takes more spaces than given and there are spaces on its left, use those spaces</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emgtltltNgtememgtltltMgtem"> <em>%><( <N> )</em>, <em>%><|( <M> )</em> </dt> <dd> <p>similar to <code>%<( <N> )</code>, <code>%<|( <M> )</code> respectively, but padding both sides (i.e. the text is centered)</p> </dd> </dl> </div> </li> <li> <p>Placeholders that expand to information extracted from the commit:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emHem"> <em>%H</em> </dt> <dd> <p>commit hash</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emhem"> <em>%h</em> </dt> <dd> <p>abbreviated commit hash</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emTem"> <em>%T</em> </dt> <dd> <p>tree hash</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emtem"> <em>%t</em> </dt> <dd> <p>abbreviated tree hash</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emPem"> <em>%P</em> </dt> <dd> <p>parent hashes</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-empem"> <em>%p</em> </dt> <dd> <p>abbreviated parent hashes</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emanem"> <em>%an</em> </dt> <dd> <p>author name</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emaNem"> <em>%aN</em> </dt> <dd> <p>author name (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emaeem"> <em>%ae</em> </dt> <dd> <p>author email</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emaEem"> <em>%aE</em> </dt> <dd> <p>author email (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emalem"> <em>%al</em> </dt> <dd> <p>author email local-part (the part before the <code>@</code> sign)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emaLem"> <em>%aL</em> </dt> <dd> <p>author local-part (see <code>%al</code>) respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emadem"> <em>%ad</em> </dt> <dd> <p>author date (format respects --date= option)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emaDem"> <em>%aD</em> </dt> <dd> <p>author date, RFC2822 style</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emarem"> <em>%ar</em> </dt> <dd> <p>author date, relative</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-ematem"> <em>%at</em> </dt> <dd> <p>author date, UNIX timestamp</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emaiem"> <em>%ai</em> </dt> <dd> <p>author date, ISO 8601-like format</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emaIem"> <em>%aI</em> </dt> <dd> <p>author date, strict ISO 8601 format</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emasem"> <em>%as</em> </dt> <dd> <p>author date, short format (<code>YYYY-MM-DD</code>)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emahem"> <em>%ah</em> </dt> <dd> <p>author date, human style (like the <code>--date=human</code> option of <a href="git-rev-list">git-rev-list[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emcnem"> <em>%cn</em> </dt> <dd> <p>committer name</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emcNem"> <em>%cN</em> </dt> <dd> <p>committer name (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emceem"> <em>%ce</em> </dt> <dd> <p>committer email</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emcEem"> <em>%cE</em> </dt> <dd> <p>committer email (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emclem"> <em>%cl</em> </dt> <dd> <p>committer email local-part (the part before the <code>@</code> sign)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emcLem"> <em>%cL</em> </dt> <dd> <p>committer local-part (see <code>%cl</code>) respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emcdem"> <em>%cd</em> </dt> <dd> <p>committer date (format respects --date= option)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emcDem"> <em>%cD</em> </dt> <dd> <p>committer date, RFC2822 style</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emcrem"> <em>%cr</em> </dt> <dd> <p>committer date, relative</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emctem"> <em>%ct</em> </dt> <dd> <p>committer date, UNIX timestamp</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emciem"> <em>%ci</em> </dt> <dd> <p>committer date, ISO 8601-like format</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emcIem"> <em>%cI</em> </dt> <dd> <p>committer date, strict ISO 8601 format</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emcsem"> <em>%cs</em> </dt> <dd> <p>committer date, short format (<code>YYYY-MM-DD</code>)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emchem"> <em>%ch</em> </dt> <dd> <p>committer date, human style (like the <code>--date=human</code> option of <a href="git-rev-list">git-rev-list[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emdem"> <em>%d</em> </dt> <dd> <p>ref names, like the --decorate option of <a href="git-log">git-log[1]</a></p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emDem"> <em>%D</em> </dt> <dd> <p>ref names without the " (", ")" wrapping.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emdecorateltoptionsgtem"> <em>%(decorate[:<options>])</em> </dt> <dd> <p>ref names with custom decorations. The <code>decorate</code> string may be followed by a colon and zero or more comma-separated options. Option values may contain literal formatting codes. These must be used for commas (<code>%x2C</code>) and closing parentheses (<code>%x29</code>), due to their role in the option syntax.</p> <div class="ulist"> <ul> <li> <p><code>prefix=<value></code>: Shown before the list of ref names. Defaults to " <code>(</code>".</p> </li> <li> <p><code>suffix=<value></code>: Shown after the list of ref names. Defaults to "<code>)</code>".</p> </li> <li> <p><code>separator=<value></code>: Shown between ref names. Defaults to "<code>,</code> ".</p> </li> <li> <p><code>pointer=<value></code>: Shown between HEAD and the branch it points to, if any. Defaults to " <code>-></code> ".</p> </li> <li> <p><code>tag=<value></code>: Shown before tag names. Defaults to "<code>tag:</code> ".</p> </li> </ul> </div> </dd> </dl> </div> </li> </ul> </div> <p>For example, to produce decorations with no wrapping or tag annotations, and spaces as separators:</p> <p>+ <code>%(decorate:prefix=,suffix=,tag=,separator= )</code></p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emdescribeltoptionsgtem"> <em>%(describe[:<options>])</em> </dt> <dd> <p>human-readable name, like <a href="git-describe">git-describe[1]</a>; empty string for undescribable commits. The <code>describe</code> string may be followed by a colon and zero or more comma-separated options. Descriptions can be inconsistent when tags are added or removed at the same time.</p> <div class="ulist"> <ul> <li> <p><code>tags[=<bool-value>]</code>: Instead of only considering annotated tags, consider lightweight tags as well.</p> </li> <li> <p><code>abbrev=<number></code>: Instead of using the default number of hexadecimal digits (which will vary according to the number of objects in the repository with a default of 7) of the abbreviated object name, use <number> digits, or as many digits as needed to form a unique object name.</p> </li> <li> <p><code>match=<pattern></code>: Only consider tags matching the given <code>glob(7)</code> pattern, excluding the "refs/tags/" prefix.</p> </li> <li> <p><code>exclude=<pattern></code>: Do not consider tags matching the given <code>glob(7)</code> pattern, excluding the "refs/tags/" prefix.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emSem"> <em>%S</em> </dt> <dd> <p>ref name given on the command line by which the commit was reached (like <code>git log --source</code>), only works with <code>git log</code></p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emeem"> <em>%e</em> </dt> <dd> <p>encoding</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emsem"> <em>%s</em> </dt> <dd> <p>subject</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emfem"> <em>%f</em> </dt> <dd> <p>sanitized subject line, suitable for a filename</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-embem"> <em>%b</em> </dt> <dd> <p>body</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emBem"> <em>%B</em> </dt> <dd> <p>raw body (unwrapped subject and body)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emNem"> <em>%N</em> </dt> <dd> <p>commit notes</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emGGem"> <em>%GG</em> </dt> <dd> <p>raw verification message from GPG for a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emGem"> <em>%G?</em> </dt> <dd> <p>show "G" for a good (valid) signature, "B" for a bad signature, "U" for a good signature with unknown validity, "X" for a good signature that has expired, "Y" for a good signature made by an expired key, "R" for a good signature made by a revoked key, "E" if the signature cannot be checked (e.g. missing key) and "N" for no signature</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emGSem"> <em>%GS</em> </dt> <dd> <p>show the name of the signer for a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emGKem"> <em>%GK</em> </dt> <dd> <p>show the key used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emGFem"> <em>%GF</em> </dt> <dd> <p>show the fingerprint of the key used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emGPem"> <em>%GP</em> </dt> <dd> <p>show the fingerprint of the primary key whose subkey was used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emGTem"> <em>%GT</em> </dt> <dd> <p>show the trust level for the key used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emgDem"> <em>%gD</em> </dt> <dd> <p>reflog selector, e.g., <code>refs/stash@{1}</code> or <code>refs/stash@{2 +minutes ago}</code>; the format follows the rules described for the <code>-g</code> option. The portion before the <code>@</code> is the refname as given on the command line (so <code>git log -g refs/heads/master</code> would yield <code>refs/heads/master@{0}</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emgdem"> <em>%gd</em> </dt> <dd> <p>shortened reflog selector; same as <code>%gD</code>, but the refname portion is shortened for human readability (so <code>refs/heads/master</code> becomes just <code>master</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emgnem"> <em>%gn</em> </dt> <dd> <p>reflog identity name</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emgNem"> <em>%gN</em> </dt> <dd> <p>reflog identity name (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emgeem"> <em>%ge</em> </dt> <dd> <p>reflog identity email</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emgEem"> <em>%gE</em> </dt> <dd> <p>reflog identity email (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emgsem"> <em>%gs</em> </dt> <dd> <p>reflog subject</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-emtrailersltoptionsgtem"> <em>%(trailers[:<options>])</em> </dt> <dd> <p>display the trailers of the body as interpreted by <a href="git-interpret-trailers">git-interpret-trailers[1]</a>. The <code>trailers</code> string may be followed by a colon and zero or more comma-separated options. If any option is provided multiple times, the last occurrence wins.</p> <div class="ulist"> <ul> <li> <p><code>key=<key></code>: only show trailers with specified <key>. Matching is done case-insensitively and trailing colon is optional. If option is given multiple times trailer lines matching any of the keys are shown. This option automatically enables the <code>only</code> option so that non-trailer lines in the trailer block are hidden. If that is not desired it can be disabled with <code>only=false</code>. E.g., <code>%(trailers:key=Reviewed-by)</code> shows trailer lines with key <code>Reviewed-by</code>.</p> </li> <li> <p><code>only[=<bool>]</code>: select whether non-trailer lines from the trailer block should be included.</p> </li> <li> <p><code>separator=<sep></code>: specify a separator inserted between trailer lines. When this option is not given each trailer line is terminated with a line feed character. The string <sep> may contain the literal formatting codes described above. To use comma as separator one must use <code>%x2C</code> as it would otherwise be parsed as next option. E.g., <code>%(trailers:key=Ticket,separator=%x2C )</code> shows all trailer lines whose key is "Ticket" separated by a comma and a space.</p> </li> <li> <p><code>unfold[=<bool>]</code>: make it behave as if interpret-trailer’s <code>--unfold</code> option was given. E.g., <code>%(trailers:only,unfold=true)</code> unfolds and shows all trailer lines.</p> </li> <li> <p><code>keyonly[=<bool>]</code>: only show the key part of the trailer.</p> </li> <li> <p><code>valueonly[=<bool>]</code>: only show the value part of the trailer.</p> </li> <li> <p><code>key_value_separator=<sep></code>: specify a separator inserted between trailer lines. When this option is not given each trailer key-value pair is separated by ": ". Otherwise it shares the same semantics as <code>separator=<sep></code> above.</p> </li> </ul> </div> </dd> </dl> </div> </li> </ul> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> Some placeholders may depend on other options given to the revision traversal engine. For example, the <code>%g*</code> reflog options will insert an empty string unless we are traversing reflog entries (e.g., by <code>git log -g</code>). The <code>%d</code> and <code>%D</code> placeholders will use the "short" decoration format if <code>--decorate</code> was not already provided on the command line. </td> </tr> </table> </div> <p>The boolean options accept an optional value <code>[=<bool-value>]</code>. The values <code>true</code>, <code>false</code>, <code>on</code>, <code>off</code> etc. are all accepted. See the "boolean" sub-section in "EXAMPLES" in <a href="git-config">git-config[1]</a>. If a boolean option is given with no value, it’s enabled.</p> <p>If you add a <code>+</code> (plus sign) after <code>%</code> of a placeholder, a line-feed is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.</p> <p>If you add a <code>-</code> (minus sign) after <code>%</code> of a placeholder, all consecutive line-feeds immediately preceding the expansion are deleted if and only if the placeholder expands to an empty string.</p> <p>If you add a ` ` (space) after <code>%</code> of a placeholder, a space is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.</p> <div class="ulist"> <ul> <li> <p><code>tformat:</code></p> <p>The <code>tformat:</code> format works exactly like <code>format:</code>, except that it provides "terminator" semantics instead of "separator" semantics. In other words, each commit has the message terminator character (usually a newline) appended, rather than a separator placed between entries. This means that the final entry of a single-line format will be properly terminated with a new line, just as the "oneline" format does. For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log -2 --pretty=format:%h 4da45bef \ + | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/' +4da45be +7134973 -- NO NEWLINE + +$ git log -2 --pretty=tformat:%h 4da45bef \ + | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/' +4da45be +7134973</pre> </div> </div> <p>In addition, any unrecognized string that has a <code>%</code> in it is interpreted as if it has <code>tformat:</code> in front of it. For example, these two are equivalent:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log -2 --pretty=tformat:%h 4da45bef +$ git log -2 --pretty=%h 4da45bef</pre> </div> </div> </li> </ul> </div> </div> <h2 id="_raw_output_format">Raw output format</h2> <div class="sectionbody"> <p>The raw output format from "git-diff-index", "git-diff-tree", "git-diff-files" and "git diff --raw" are very similar.</p> <p>These commands all compare two sets of things; what is compared differs:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-git-diff-indexlttree-ishgt"> git-diff-index <tree-ish> </dt> <dd> <p>compares the <tree-ish> and the files on the filesystem.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-git-diff-index--cachedlttree-ishgt"> git-diff-index --cached <tree-ish> </dt> <dd> <p>compares the <tree-ish> and the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-git-diff-tree-rlttree-ish-1gtlttree-ish-2gtltpatterngt82308203"> git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…] </dt> <dd> <p>compares the trees named by the two arguments.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff-tree.txt-git-diff-filesltpatterngt82308203"> git-diff-files [<pattern>…] </dt> <dd> <p>compares the index and the files on the filesystem.</p> </dd> </dl> </div> <p>The "git-diff-tree" command begins its output by printing the hash of what is being compared. After that, all the commands print one output line per changed file.</p> <p>An output line is formatted this way:</p> <div class="listingblock"> <div class="content"> <pre>in-place edit :100644 100644 bcd1234 0123456 M file0 +copy-edit :100644 100644 abcd123 1234567 C68 file1 file2 +rename-edit :100644 100644 abcd123 1234567 R86 file1 file3 +create :000000 100644 0000000 1234567 A file4 +delete :100644 000000 1234567 0000000 D file5 +unmerged :000000 000000 0000000 0000000 U file6</pre> </div> </div> <p>That is, from the left to the right:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>a colon.</p> </li> <li> <p>mode for "src"; 000000 if creation or unmerged.</p> </li> <li> <p>a space.</p> </li> <li> <p>mode for "dst"; 000000 if deletion or unmerged.</p> </li> <li> <p>a space.</p> </li> <li> <p>sha1 for "src"; 0{40} if creation or unmerged.</p> </li> <li> <p>a space.</p> </li> <li> <p>sha1 for "dst"; 0{40} if deletion, unmerged or "work tree out of sync with the index".</p> </li> <li> <p>a space.</p> </li> <li> <p>status, followed by optional "score" number.</p> </li> <li> <p>a tab or a NUL when <code>-z</code> option is used.</p> </li> <li> <p>path for "src"</p> </li> <li> <p>a tab or a NUL when <code>-z</code> option is used; only exists for C or R.</p> </li> <li> <p>path for "dst"; only exists for C or R.</p> </li> <li> <p>an LF or a NUL when <code>-z</code> option is used, to terminate the record.</p> </li> </ol> </div> <p>Possible status letters are:</p> <div class="ulist"> <ul> <li> <p>A: addition of a file</p> </li> <li> <p>C: copy of a file into a new one</p> </li> <li> <p>D: deletion of a file</p> </li> <li> <p>M: modification of the contents or mode of a file</p> </li> <li> <p>R: renaming of a file</p> </li> <li> <p>T: change in the type of the file (regular file, symbolic link or submodule)</p> </li> <li> <p>U: file is unmerged (you must complete the merge before it can be committed)</p> </li> <li> <p>X: "unknown" change type (most probably a bug, please report it)</p> </li> </ul> </div> <p>Status letters C and R are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy). Status letter M may be followed by a score (denoting the percentage of dissimilarity) for file rewrites.</p> <p>The sha1 for "dst" is shown as all 0’s if a file on the filesystem is out of sync with the index.</p> <p>Example:</p> <div class="listingblock"> <div class="content"> <pre>:100644 100644 5be4a4a 0000000 M file.c</pre> </div> </div> <p>Without the <code>-z</code> option, pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>). Using <code>-z</code> the filename is output verbatim and the line is terminated by a NUL byte.</p> </div> <h2 id="_diff_format_for_merges">Diff format for merges</h2> <div class="sectionbody"> <p>"git-diff-tree", "git-diff-files" and "git-diff --raw" can take <code>-c</code> or <code>--cc</code> option to generate diff output also for merge commits. The output differs from the format described above in the following way:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>there is a colon for each parent</p> </li> <li> <p>there are more "src" modes and "src" sha1</p> </li> <li> <p>status is concatenated status characters for each parent</p> </li> <li> <p>no optional "score" number</p> </li> <li> <p>tab-separated pathname(s) of the file</p> </li> </ol> </div> <p>For <code>-c</code> and <code>--cc</code>, only the destination or final path is shown even if the file was renamed on any side of history. With <code>--combined-all-paths</code>, the name of the path in each parent is shown followed by the name of the path in the merge commit.</p> <p>Examples for <code>-c</code> and <code>--cc</code> without <code>--combined-all-paths</code>:</p> <div class="listingblock"> <div class="content"> <pre>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c +::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM bar.sh +::100644 100644 100644 e07d6c5 9042e82 ee91881 RR phooey.c</pre> </div> </div> <p>Examples when <code>--combined-all-paths</code> added to either <code>-c</code> or <code>--cc</code>:</p> <div class="listingblock"> <div class="content"> <pre>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c desc.c desc.c +::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM foo.sh bar.sh bar.sh +::100644 100644 100644 e07d6c5 9042e82 ee91881 RR fooey.c fuey.c phooey.c</pre> </div> </div> <p>Note that <code>combined diff</code> lists only files which were modified from all parents.</p> </div> <h2 id="generate_patch_text_with_p">Generating patch text with -p</h2> <div class="sectionbody"> <p>Running <a href="git-diff">git-diff[1]</a>, <a href="git-log">git-log[1]</a>, <a href="git-show">git-show[1]</a>, <a href="git-diff-index">git-diff-index[1]</a>, <a href="git-diff-tree">git-diff-tree[1]</a>, or <a href="git-diff-files">git-diff-files[1]</a> with the <code>-p</code> option produces patch text. You can customize the creation of patch text via the <code>GIT_EXTERNAL_DIFF</code> and the <code>GIT_DIFF_OPTS</code> environment variables (see <a href="git">git[1]</a>), and the <code>diff</code> attribute (see <a href="gitattributes">gitattributes[5]</a>).</p> <p>What the -p option produces is slightly different from the traditional diff format:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>It is preceded by a "git diff" header that looks like this:</p> <div class="literalblock"> <div class="content"> <pre>diff --git a/file1 b/file2</pre> </div> </div> <p>The <code>a/</code> and <code>b/</code> filenames are the same unless rename/copy is involved. Especially, even for a creation or a deletion, <code>/dev/null</code> is <code>not</code> used in place of the <code>a/</code> or <code>b/</code> filenames.</p> <p>When a rename/copy is involved, <code>file1</code> and <code>file2</code> show the name of the source file of the rename/copy and the name of the file that the rename/copy produces, respectively.</p> </li> <li> <p>It is followed by one or more extended header lines:</p> <div class="literalblock"> <div class="content"> <pre>old mode <mode> +new mode <mode> +deleted file mode <mode> +new file mode <mode> +copy from <path> +copy to <path> +rename from <path> +rename to <path> +similarity index <number> +dissimilarity index <number> +index <hash>..<hash> <mode></pre> </div> </div> <p>File modes are printed as 6-digit octal numbers including the file type and file permission bits.</p> <p>Path names in extended headers do not include the <code>a/</code> and <code>b/</code> prefixes.</p> <p>The similarity index is the percentage of unchanged lines, and the dissimilarity index is the percentage of changed lines. It is a rounded down integer, followed by a percent sign. The similarity index value of 100% is thus reserved for two equal files, while 100% dissimilarity means that no line from the old file made it into the new one.</p> <p>The index line includes the blob object names before and after the change. The <mode> is included if the file mode does not change; otherwise, separate lines indicate the old and the new mode.</p> </li> <li> <p>Pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>).</p> </li> <li> <p>All the <code>file1</code> files in the output refer to files before the commit, and all the <code>file2</code> files refer to files after the commit. It is incorrect to apply each change to each file sequentially. For example, this patch will swap a and b:</p> <div class="literalblock"> <div class="content"> <pre>diff --git a/a b/b +rename from a +rename to b +diff --git a/b b/a +rename from b +rename to a</pre> </div> </div> </li> <li> <p>Hunk headers mention the name of the function to which the hunk applies. See "Defining a custom hunk-header" in <a href="gitattributes">gitattributes[5]</a> for details of how to tailor this to specific languages.</p> </li> </ol> </div> </div> <h2 id="_combined_diff_format">Combined diff format</h2> <div class="sectionbody"> <p>Any diff-generating command can take the <code>-c</code> or <code>--cc</code> option to produce a <code>combined diff</code> when showing a merge. This is the default format when showing merges with <a href="git-diff">git-diff[1]</a> or <a href="git-show">git-show[1]</a>. Note also that you can give suitable <code>--diff-merges</code> option to any of these commands to force generation of diffs in a specific format.</p> <p>A "combined diff" format looks like this:</p> <div class="listingblock"> <div class="content"> <pre>diff --combined describe.c +index fabadb8,cc95eb0..4866510 +--- a/describe.c ++++ b/describe.c +@@@ -98,20 -98,12 +98,20 @@@ + return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; + } + +- static void describe(char *arg) + -static void describe(struct commit *cmit, int last_one) +++static void describe(char *arg, int last_one) + { + + unsigned char sha1[20]; + + struct commit *cmit; + struct commit_list *list; + static int initialized = 0; + struct commit_name *n; + + + if (get_sha1(arg, sha1) < 0) + + usage(describe_usage); + + cmit = lookup_commit_reference(sha1); + + if (!cmit) + + usage(describe_usage); + + + if (!initialized) { + initialized = 1; + for_each_ref(get_name);</pre> </div> </div> <div class="olist arabic"> <ol class="arabic"> <li> <p>It is preceded by a "git diff" header, that looks like this (when the <code>-c</code> option is used):</p> <div class="literalblock"> <div class="content"> <pre>diff --combined file</pre> </div> </div> <p>or like this (when the <code>--cc</code> option is used):</p> <div class="literalblock"> <div class="content"> <pre>diff --cc file</pre> </div> </div> </li> <li> <p>It is followed by one or more extended header lines (this example shows a merge with two parents):</p> <div class="literalblock"> <div class="content"> <pre>index <hash>,<hash>..<hash> +mode <mode>,<mode>..<mode> +new file mode <mode> +deleted file mode <mode>,<mode></pre> </div> </div> <p>The <code>mode <mode>,<mode>..<mode></code> line appears only if at least one of the <mode> is different from the rest. Extended headers with information about detected content movement (renames and copying detection) are designed to work with the diff of two <tree-ish> and are not used by combined diff format.</p> </li> <li> <p>It is followed by a two-line from-file/to-file header:</p> <div class="literalblock"> <div class="content"> <pre>--- a/file ++++ b/file</pre> </div> </div> <p>Similar to the two-line header for the traditional <code>unified</code> diff format, <code>/dev/null</code> is used to signal created or deleted files.</p> <p>However, if the --combined-all-paths option is provided, instead of a two-line from-file/to-file, you get an N+1 line from-file/to-file header, where N is the number of parents in the merge commit:</p> <div class="literalblock"> <div class="content"> <pre>--- a/file +--- a/file +--- a/file ++++ b/file</pre> </div> </div> <p>This extended format can be useful if rename or copy detection is active, to allow you to see the original name of the file in different parents.</p> </li> <li> <p>Chunk header format is modified to prevent people from accidentally feeding it to <code>patch -p1</code>. Combined diff format was created for review of merge commit changes, and was not meant to be applied. The change is similar to the change in the extended <code>index</code> header:</p> <div class="literalblock"> <div class="content"> <pre>@@@ <from-file-range> <from-file-range> <to-file-range> @@@</pre> </div> </div> <p>There are (number of parents + 1) <code>@</code> characters in the chunk header for combined diff format.</p> </li> </ol> </div> <p>Unlike the traditional <code>unified</code> diff format, which shows two files A and B with a single column that has <code>-</code> (minus — appears in A but removed in B), <code>+</code> (plus — missing in A but added to B), or <code>" "</code> (space — unchanged) prefix, this format compares two or more files file1, file2,… with one file X, and shows how X differs from each of fileN. One column for each of fileN is prepended to the output line to note how X’s line is different from it.</p> <p>A <code>-</code> character in the column N means that the line appears in fileN but it does not appear in the result. A <code>+</code> character in the column N means that the line appears in the result, and fileN does not have that line (in other words, the line was added, from the point of view of that parent).</p> <p>In the above example output, the function signature was changed from both files (hence two <code>-</code> removals from both file1 and file2, plus <code>++</code> to mean one line that was added does not appear in either file1 or file2). Also, eight other lines are the same from file1 but do not appear in file2 (hence prefixed with <code>+</code>).</p> <p>When shown by <code>git diff-tree -c</code>, it compares the parents of a merge commit with the merge result (i.e. file1..fileN are the parents). When shown by <code>git diff-files -c</code>, it compares the two unresolved merge parents with the working tree file (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka "their version").</p> </div> <h2 id="_other_diff_formats">Other diff formats</h2> <div class="sectionbody"> <p>The <code>--summary</code> option describes newly added, deleted, renamed and copied files. The <code>--stat</code> option adds diffstat(1) graph to the output. These options can be combined with other options, such as <code>-p</code>, and are meant for human consumption.</p> <p>When showing a change that involves a rename or a copy, <code>--stat</code> output formats the pathnames compactly by combining common prefix and suffix of the pathnames. For example, a change that moves <code>arch/i386/Makefile</code> to <code>arch/x86/Makefile</code> while modifying 4 lines will be shown like this:</p> <div class="listingblock"> <div class="content"> <pre>arch/{i386 => x86}/Makefile | 4 +--</pre> </div> </div> <p>The <code>--numstat</code> option gives the diffstat(1) information but is designed for easier machine consumption. An entry in <code>--numstat</code> output looks like this:</p> <div class="listingblock"> <div class="content"> <pre>1 2 README +3 1 arch/{i386 => x86}/Makefile</pre> </div> </div> <p>That is, from left to right:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>the number of added lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>the number of deleted lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>pathname (possibly with rename/copy information);</p> </li> <li> <p>a newline.</p> </li> </ol> </div> <p>When <code>-z</code> output option is in effect, the output is formatted this way:</p> <div class="listingblock"> <div class="content"> <pre>1 2 README NUL +3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</pre> </div> </div> <p>That is:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>the number of added lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>the number of deleted lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>a NUL (only exists if renamed/copied);</p> </li> <li> <p>pathname in preimage;</p> </li> <li> <p>a NUL (only exists if renamed/copied);</p> </li> <li> <p>pathname in postimage (only exists if renamed/copied);</p> </li> <li> <p>a NUL.</p> </li> </ol> </div> <p>The extra <code>NUL</code> before the preimage path in renamed case is to allow scripts that read the output to tell if the current record being read is a single-path record or a rename/copy record without reading ahead. After reading added and deleted lines, reading up to <code>NUL</code> would yield the pathname, but if that is <code>NUL</code>, the record will show two paths.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-diff-tree" class="_attribution-link">https://git-scm.com/docs/git-diff-tree</a> + </p> +</div> diff --git a/devdocs/git/git-diff.html b/devdocs/git/git-diff.html new file mode 100644 index 00000000..f6d6d5be --- /dev/null +++ b/devdocs/git/git-diff.html @@ -0,0 +1,83 @@ +<h1>git-diff</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-diff - Show changes between commits, commit and working tree, etc</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git diff [<options>] [<commit>] [--] [<path>…] +git diff [<options>] --cached [--merge-base] [<commit>] [--] [<path>…] +git diff [<options>] [--merge-base] <commit> [<commit>…] <commit> [--] [<path>…] +git diff [<options>] <commit>…<commit> [--] [<path>…] +git diff [<options>] <blob> <blob> +git diff [<options>] --no-index [--] <path> <path></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, changes resulting from a merge, changes between two blob objects, or changes between two files on disk.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff.txt-emgitdiffemltoptionsgt--ltpathgt82308203"> <em>git diff</em> [<options>] [--] [<path>…] </dt> <dd> <p>This form is to view the changes you made relative to the index (staging area for the next commit). In other words, the differences are what you <code>could</code> tell Git to further add to the index but you still haven’t. You can stage these changes by using <a href="git-add">git-add[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-emgitdiffemltoptionsgt--no-index--ltpathgtltpathgt"> <em>git diff</em> [<options>] --no-index [--] <path> <path> </dt> <dd> <p>This form is to compare the given two paths on the filesystem. You can omit the <code>--no-index</code> option when running the command in a working tree controlled by Git and at least one of the paths points outside the working tree, or when running the command outside a working tree controlled by Git. This form implies <code>--exit-code</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-emgitdiffemltoptionsgt--cached--merge-baseltcommitgt--ltpathgt82308203"> <em>git diff</em> [<options>] --cached [--merge-base] [<commit>] [--] [<path>…] </dt> <dd> <p>This form is to view the changes you staged for the next commit relative to the named <commit>. Typically you would want comparison with the latest commit, so if you do not give <commit>, it defaults to HEAD. If HEAD does not exist (e.g. unborn branches) and <commit> is not given, it shows all staged changes. --staged is a synonym of --cached.</p> <p>If --merge-base is given, instead of using <commit>, use the merge base of <commit> and HEAD. <code>git diff --cached --merge-base A</code> is equivalent to <code>git diff --cached $(git merge-base A HEAD)</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-emgitdiffemltoptionsgt--merge-baseltcommitgt--ltpathgt82308203"> <em>git diff</em> [<options>] [--merge-base] <commit> [--] [<path>…] </dt> <dd> <p>This form is to view the changes you have in your working tree relative to the named <commit>. You can use HEAD to compare it with the latest commit, or a branch name to compare with the tip of a different branch.</p> <p>If --merge-base is given, instead of using <commit>, use the merge base of <commit> and HEAD. <code>git diff --merge-base A</code> is equivalent to <code>git diff $(git merge-base A HEAD)</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-emgitdiffemltoptionsgt--merge-baseltcommitgtltcommitgt--ltpathgt82308203"> <em>git diff</em> [<options>] [--merge-base] <commit> <commit> [--] [<path>…] </dt> <dd> <p>This is to view the changes between two arbitrary <commit>.</p> <p>If --merge-base is given, use the merge base of the two commits for the "before" side. <code>git diff --merge-base A B</code> is equivalent to <code>git diff $(git merge-base A B) B</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-emgitdiffemltoptionsgtltcommitgtltcommitgt82308203ltcommitgt--ltpathgt82308203"> <em>git diff</em> [<options>] <commit> <commit>… <commit> [--] [<path>…] </dt> <dd> <p>This form is to view the results of a merge commit. The first listed <commit> must be the merge itself; the remaining two or more commits should be its parents. Convenient ways to produce the desired set of revisions are to use the suffixes <code>^@</code> and <code>^!</code>. If A is a merge commit, then <code>git diff A A^@</code>, <code>git diff A^!</code> and <code>git show A</code> all give the same combined diff.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-emgitdiffemltoptionsgtltcommitgtltcommitgt--ltpathgt82308203"> <em>git diff</em> [<options>] <commit>..<commit> [--] [<path>…] </dt> <dd> <p>This is synonymous to the earlier form (without the <code>..</code>) for viewing the changes between two arbitrary <commit>. If <commit> on one side is omitted, it will have the same effect as using HEAD instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-emgitdiffemltoptionsgtltcommitgtltcommitgt--ltpathgt82308203-1"> <em>git diff</em> [<options>] <commit>...<commit> [--] [<path>…] </dt> <dd> <p>This form is to view the changes on the branch containing and up to the second <commit>, starting at a common ancestor of both <commit>. <code>git diff A...B</code> is equivalent to <code>git diff $(git merge-base A B) B</code>. You can omit any one of <commit>, which has the same effect as using HEAD instead.</p> </dd> </dl> </div> <p>Just in case you are doing something exotic, it should be noted that all of the <commit> in the above description, except in the <code>--merge-base</code> case and in the last two forms that use <code>..</code> notations, can be any <tree>. A tree of interest is the one pointed to by the ref named <code>AUTO_MERGE</code>, which is written by the <code>ort</code> merge strategy upon hitting merge conflicts (see <a href="git-merge">git-merge[1]</a>). Comparing the working tree with <code>AUTO_MERGE</code> shows changes you’ve made so far to resolve textual conflicts (see the examples below).</p> <p>For a more complete list of ways to spell <commit>, see "SPECIFYING REVISIONS" section in <a href="gitrevisions">gitrevisions[7]</a>. However, "diff" is about comparing two <code>endpoints</code>, not ranges, and the range notations (<code><commit>..<commit></code> and <code><commit>...<commit></code>) do not mean a range as defined in the "SPECIFYING RANGES" section in <a href="gitrevisions">gitrevisions[7]</a>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff.txt-emgitdiffemltoptionsgtltblobgtltblobgt"> <em>git diff</em> [<options>] <blob> <blob> </dt> <dd> <p>This form is to view the differences between the raw contents of two blob objects.</p> </dd> </dl> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-diff.txt--u"> -u </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---patch"> --patch </dt> <dd> <p>Generate patch (see <a href="#generate_patch_text_with_p">Generating patch text with -p</a>). This is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---no-patch"> --no-patch </dt> <dd> <p>Suppress all output from the diff machinery. Useful for commands like <code>git show</code> that show the patch by default to squelch their output, or to cancel the effect of options like <code>--patch</code>, <code>--stat</code> earlier on the command line in an alias.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--Ultngt"> -U<n> </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---unifiedltngt"> --unified=<n> </dt> <dd> <p>Generate diffs with <n> lines of context instead of the usual three. Implies <code>--patch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---outputltfilegt"> --output=<file> </dt> <dd> <p>Output to a specific file instead of stdout.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---output-indicator-newltchargt"> --output-indicator-new=<char> </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---output-indicator-oldltchargt"> --output-indicator-old=<char> </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---output-indicator-contextltchargt"> --output-indicator-context=<char> </dt> <dd> <p>Specify the character used to indicate new, old or context lines in the generated patch. Normally they are <code>+</code>, <code>-</code> and ' ' respectively.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---raw"> --raw </dt> <dd> <p>Generate the diff in raw format.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---patch-with-raw"> --patch-with-raw </dt> <dd> <p>Synonym for <code>-p --raw</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---indent-heuristic"> --indent-heuristic </dt> <dd> <p>Enable the heuristic that shifts diff hunk boundaries to make patches easier to read. This is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---no-indent-heuristic"> --no-indent-heuristic </dt> <dd> <p>Disable the indent heuristic.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---minimal"> --minimal </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---patience"> --patience </dt> <dd> <p>Generate a diff using the "patience diff" algorithm.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---histogram"> --histogram </dt> <dd> <p>Generate a diff using the "histogram diff" algorithm.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---anchoredlttextgt"> --anchored=<text> </dt> <dd> <p>Generate a diff using the "anchored diff" algorithm.</p> <p>This option may be specified more than once.</p> <p>If a line exists in both the source and destination, exists only once, and starts with this text, this algorithm attempts to prevent it from appearing as a deletion or addition in the output. It uses the "patience diff" algorithm internally.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---diff-algorithmpatienceminimalhistogrammyers"> --diff-algorithm={patience|minimal|histogram|myers} </dt> <dd> <p>Choose a diff algorithm. The variants are as follows:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff.txt-codedefaultcodecodemyerscode"> <code>default</code>, <code>myers</code> </dt> <dd> <p>The basic greedy diff algorithm. Currently, this is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codeminimalcode"> <code>minimal</code> </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codepatiencecode"> <code>patience</code> </dt> <dd> <p>Use "patience diff" algorithm when generating patches.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codehistogramcode"> <code>histogram</code> </dt> <dd> <p>This algorithm extends the patience algorithm to "support low-occurrence common elements".</p> </dd> </dl> </div> </div> </div> <p>For instance, if you configured the <code>diff.algorithm</code> variable to a non-default value and want to use the default one, then you have to use <code>--diff-algorithm=default</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---statltwidthgtltname-widthgtltcountgt"> --stat[=<width>[,<name-width>[,<count>]]] </dt> <dd> <p>Generate a diffstat. By default, as much space as necessary will be used for the filename part, and the rest for the graph part. Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden by <code><width></code>. The width of the filename part can be limited by giving another width <code><name-width></code> after a comma or by setting <code>diff.statNameWidth=<width></code>. The width of the graph part can be limited by using <code>--stat-graph-width=<width></code> or by setting <code>diff.statGraphWidth=<width></code>. Using <code>--stat</code> or <code>--stat-graph-width</code> affects all commands generating a stat graph, while setting <code>diff.statNameWidth</code> or <code>diff.statGraphWidth</code> does not affect <code>git format-patch</code>. By giving a third parameter <code><count></code>, you can limit the output to the first <code><count></code> lines, followed by <code>...</code> if there are more.</p> <p>These parameters can also be set individually with <code>--stat-width=<width></code>, <code>--stat-name-width=<name-width></code> and <code>--stat-count=<count></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---compact-summary"> --compact-summary </dt> <dd> <p>Output a condensed summary of extended header information such as file creations or deletions ("new" or "gone", optionally "+l" if it’s a symlink) and mode changes ("+x" or "-x" for adding or removing executable bit respectively) in diffstat. The information is put between the filename part and the graph part. Implies <code>--stat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---numstat"> --numstat </dt> <dd> <p>Similar to <code>--stat</code>, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly. For binary files, outputs two <code>-</code> instead of saying <code>0 0</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---shortstat"> --shortstat </dt> <dd> <p>Output only the last line of the <code>--stat</code> format containing total number of modified files, as well as number of added and deleted lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--Xltparam1param282308203gt"> -X[<param1,param2,…>] </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---dirstatltparam1param282308203gt"> --dirstat[=<param1,param2,…>] </dt> <dd> <p>Output the distribution of relative amount of changes for each sub-directory. The behavior of <code>--dirstat</code> can be customized by passing it a comma separated list of parameters. The defaults are controlled by the <code>diff.dirstat</code> configuration variable (see <a href="git-config">git-config[1]</a>). The following parameters are available:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff.txt-codechangescode"> <code>changes</code> </dt> <dd> <p>Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination. This ignores the amount of pure code movements within a file. In other words, rearranging lines in a file is not counted as much as other changes. This is the default behavior when no parameter is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codelinescode"> <code>lines</code> </dt> <dd> <p>Compute the dirstat numbers by doing the regular line-based diff analysis, and summing the removed/added line counts. (For binary files, count 64-byte chunks instead, since binary files have no natural concept of lines). This is a more expensive <code>--dirstat</code> behavior than the <code>changes</code> behavior, but it does count rearranged lines within a file as much as other changes. The resulting output is consistent with what you get from the other <code>--*stat</code> options.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codefilescode"> <code>files</code> </dt> <dd> <p>Compute the dirstat numbers by counting the number of files changed. Each changed file counts equally in the dirstat analysis. This is the computationally cheapest <code>--dirstat</code> behavior, since it does not have to look at the file contents at all.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codecumulativecode"> <code>cumulative</code> </dt> <dd> <p>Count changes in a child directory for the parent directory as well. Note that when using <code>cumulative</code>, the sum of the percentages reported may exceed 100%. The default (non-cumulative) behavior can be specified with the <code>noncumulative</code> parameter.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-ltlimitgt"> <limit> </dt> <dd> <p>An integer parameter specifies a cut-off percent (3% by default). Directories contributing less than this percentage of the changes are not shown in the output.</p> </dd> </dl> </div> </div> </div> <p>Example: The following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories: <code>--dirstat=files,10,cumulative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---cumulative"> --cumulative </dt> <dd> <p>Synonym for --dirstat=cumulative</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---dirstat-by-fileltparam1param2gt82308203"> --dirstat-by-file[=<param1,param2>…] </dt> <dd> <p>Synonym for --dirstat=files,param1,param2…</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---summary"> --summary </dt> <dd> <p>Output a condensed summary of extended header information such as creations, renames and mode changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---patch-with-stat"> --patch-with-stat </dt> <dd> <p>Synonym for <code>-p --stat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--z"> -z </dt> <dd> <p>When <code>--raw</code>, <code>--numstat</code>, <code>--name-only</code> or <code>--name-status</code> has been given, do not munge pathnames and use NULs as output field terminators.</p> <p>Without this option, pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---name-only"> --name-only </dt> <dd> <p>Show only names of changed files. The file names are often encoded in UTF-8. For more information see the discussion about encoding in the <a href="git-log">git-log[1]</a> manual page.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---name-status"> --name-status </dt> <dd> <p>Show only names and status of changed files. See the description of the <code>--diff-filter</code> option on what the status letters mean. Just like <code>--name-only</code> the file names are often encoded in UTF-8.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---submoduleltformatgt"> --submodule[=<format>] </dt> <dd> <p>Specify how differences in submodules are shown. When specifying <code>--submodule=short</code> the <code>short</code> format is used. This format just shows the names of the commits at the beginning and end of the range. When <code>--submodule</code> or <code>--submodule=log</code> is specified, the <code>log</code> format is used. This format lists the commits in the range like <a href="git-submodule">git-submodule[1]</a> <code>summary</code> does. When <code>--submodule=diff</code> is specified, the <code>diff</code> format is used. This format shows an inline diff of the changes in the submodule contents between the commit range. Defaults to <code>diff.submodule</code> or the <code>short</code> format if the config option is unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---colorltwhengt"> --color[=<when>] </dt> <dd> <p>Show colored diff. <code>--color</code> (i.e. without <code>=<when></code>) is the same as <code>--color=always</code>. <code><when></code> can be one of <code>always</code>, <code>never</code>, or <code>auto</code>. It can be changed by the <code>color.ui</code> and <code>color.diff</code> configuration settings.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---no-color"> --no-color </dt> <dd> <p>Turn off colored diff. This can be used to override configuration settings. It is the same as <code>--color=never</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---color-movedltmodegt"> --color-moved[=<mode>] </dt> <dd> <p>Moved lines of code are colored differently. It can be changed by the <code>diff.colorMoved</code> configuration setting. The <mode> defaults to <code>no</code> if the option is not given and to <code>zebra</code> if the option with no mode is given. The mode must be one of:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff.txt-no"> no </dt> <dd> <p>Moved lines are not highlighted.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-default"> default </dt> <dd> <p>Is a synonym for <code>zebra</code>. This may change to a more sensible mode in the future.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-plain"> plain </dt> <dd> <p>Any line that is added in one location and was removed in another location will be colored with <code>color.diff.newMoved</code>. Similarly <code>color.diff.oldMoved</code> will be used for removed lines that are added somewhere else in the diff. This mode picks up any moved line, but it is not very useful in a review to determine if a block of code was moved without permutation.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-blocks"> blocks </dt> <dd> <p>Blocks of moved text of at least 20 alphanumeric characters are detected greedily. The detected blocks are painted using either the <code>color.diff.{old,new}Moved</code> color. Adjacent blocks cannot be told apart.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-zebra"> zebra </dt> <dd> <p>Blocks of moved text are detected as in <code>blocks</code> mode. The blocks are painted using either the <code>color.diff.{old,new}Moved</code> color or <code>color.diff.{old,new}MovedAlternative</code>. The change between the two colors indicates that a new block was detected.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-dimmed-zebra"> dimmed-zebra </dt> <dd> <p>Similar to <code>zebra</code>, but additional dimming of uninteresting parts of moved code is performed. The bordering lines of two adjacent blocks are considered interesting, the rest is uninteresting. <code>dimmed_zebra</code> is a deprecated synonym.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---no-color-moved"> --no-color-moved </dt> <dd> <p>Turn off move detection. This can be used to override configuration settings. It is the same as <code>--color-moved=no</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---color-moved-wsltmodesgt"> --color-moved-ws=<modes> </dt> <dd> <p>This configures how whitespace is ignored when performing the move detection for <code>--color-moved</code>. It can be set by the <code>diff.colorMovedWS</code> configuration setting. These modes can be given as a comma separated list:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff.txt-no-1"> no </dt> <dd> <p>Do not ignore whitespace when performing move detection.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-ignore-space-at-eol"> ignore-space-at-eol </dt> <dd> <p>Ignore changes in whitespace at EOL.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-ignore-space-change"> ignore-space-change </dt> <dd> <p>Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-ignore-all-space"> ignore-all-space </dt> <dd> <p>Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-allow-indentation-change"> allow-indentation-change </dt> <dd> <p>Initially ignore any whitespace in the move detection, then group the moved code blocks only into a block if the change in whitespace is the same per line. This is incompatible with the other modes.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---no-color-moved-ws"> --no-color-moved-ws </dt> <dd> <p>Do not ignore whitespace when performing move detection. This can be used to override configuration settings. It is the same as <code>--color-moved-ws=no</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---word-diffltmodegt"> --word-diff[=<mode>] </dt> <dd> <p>Show a word diff, using the <mode> to delimit changed words. By default, words are delimited by whitespace; see <code>--word-diff-regex</code> below. The <mode> defaults to <code>plain</code>, and must be one of:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff.txt-color"> color </dt> <dd> <p>Highlight changed words using only colors. Implies <code>--color</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-plain-1"> plain </dt> <dd> <p>Show words as <code>[-removed-]</code> and <code>{+added+}</code>. Makes no attempts to escape the delimiters if they appear in the input, so the output may be ambiguous.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-porcelain"> porcelain </dt> <dd> <p>Use a special line-based format intended for script consumption. Added/removed/unchanged runs are printed in the usual unified diff format, starting with a <code>+</code>/<code>-</code>/` ` character at the beginning of the line and extending to the end of the line. Newlines in the input are represented by a tilde <code>~</code> on a line of its own.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-none"> none </dt> <dd> <p>Disable word diff again.</p> </dd> </dl> </div> </div> </div> <p>Note that despite the name of the first mode, color is used to highlight the changed parts in all modes if enabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---word-diff-regexltregexgt"> --word-diff-regex=<regex> </dt> <dd> <p>Use <regex> to decide what a word is, instead of considering runs of non-whitespace to be a word. Also implies <code>--word-diff</code> unless it was already enabled.</p> <p>Every non-overlapping match of the <regex> is considered a word. Anything between these matches is considered whitespace and ignored(!) for the purposes of finding differences. You may want to append <code>|[^[:space:]]</code> to your regular expression to make sure that it matches all non-whitespace characters. A match that contains a newline is silently truncated(!) at the newline.</p> <p>For example, <code>--word-diff-regex=.</code> will treat each character as a word and, correspondingly, show differences character by character.</p> <p>The regex can also be set via a diff driver or configuration option, see <a href="gitattributes">gitattributes[5]</a> or <a href="git-config">git-config[1]</a>. Giving it explicitly overrides any diff driver or configuration setting. Diff drivers override configuration settings.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---color-wordsltregexgt"> --color-words[=<regex>] </dt> <dd> <p>Equivalent to <code>--word-diff=color</code> plus (if a regex was specified) <code>--word-diff-regex=<regex></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---no-renames"> --no-renames </dt> <dd> <p>Turn off rename detection, even when the configuration file gives the default to do so.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---no-rename-empty"> --[no-]rename-empty </dt> <dd> <p>Whether to use empty blobs as rename source.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---check"> --check </dt> <dd> <p>Warn if changes introduce conflict markers or whitespace errors. What are considered whitespace errors is controlled by <code>core.whitespace</code> configuration. By default, trailing whitespaces (including lines that consist solely of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors. Exits with non-zero status if problems are found. Not compatible with --exit-code.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---ws-error-highlightltkindgt"> --ws-error-highlight=<kind> </dt> <dd> <p>Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code> lines of the diff. Multiple values are separated by comma, <code>none</code> resets previous values, <code>default</code> reset the list to <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. When this option is not given, and the configuration variable <code>diff.wsErrorHighlight</code> is not set, only whitespace errors in <code>new</code> lines are highlighted. The whitespace errors are colored with <code>color.diff.whitespace</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---full-index"> --full-index </dt> <dd> <p>Instead of the first handful of characters, show the full pre- and post-image blob object names on the "index" line when generating patch format output.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---binary"> --binary </dt> <dd> <p>In addition to <code>--full-index</code>, output a binary diff that can be applied with <code>git-apply</code>. Implies <code>--patch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---abbrevltngt"> --abbrev[=<n>] </dt> <dd> <p>Instead of showing the full 40-byte hexadecimal object name in diff-raw format output and diff-tree header lines, show the shortest prefix that is at least <code><n></code> hexdigits long that uniquely refers the object. In diff-patch output format, <code>--full-index</code> takes higher precedence, i.e. if <code>--full-index</code> is specified, full blob names will be shown regardless of <code>--abbrev</code>. Non default number of digits can be specified with <code>--abbrev=<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--Bltngtltmgt"> -B[<n>][/<m>] </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---break-rewritesltngtltmgt"> --break-rewrites[=[<n>][/<m>]] </dt> <dd> <p>Break complete rewrite changes into pairs of delete and create. This serves two purposes:</p> <p>It affects the way a change that amounts to a total rewrite of a file not as a series of deletion and insertion mixed together with a very few lines that happen to match textually as the context, but as a single deletion of everything old followed by a single insertion of everything new, and the number <code>m</code> controls this aspect of the -B option (defaults to 60%). <code>-B/70%</code> specifies that less than 30% of the original should remain in the result for Git to consider it a total rewrite (i.e. otherwise the resulting patch will be a series of deletion and insertion mixed together with context lines).</p> <p>When used with -M, a totally-rewritten file is also considered as the source of a rename (usually -M only considers a file that disappeared as the source of a rename), and the number <code>n</code> controls this aspect of the -B option (defaults to 50%). <code>-B20%</code> specifies that a change with addition and deletion compared to 20% or more of the file’s size are eligible for being picked up as a possible source of a rename to another file.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--Mltngt"> -M[<n>] </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---find-renamesltngt"> --find-renames[=<n>] </dt> <dd> <p>Detect renames. If <code>n</code> is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file’s size). For example, <code>-M90%</code> means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn’t changed. Without a <code>%</code> sign, the number is to be read as a fraction, with a decimal point before it. I.e., <code>-M5</code> becomes 0.5, and is thus the same as <code>-M50%</code>. Similarly, <code>-M05</code> is the same as <code>-M5%</code>. To limit detection to exact renames, use <code>-M100%</code>. The default similarity index is 50%.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--Cltngt"> -C[<n>] </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---find-copiesltngt"> --find-copies[=<n>] </dt> <dd> <p>Detect copies as well as renames. See also <code>--find-copies-harder</code>. If <code>n</code> is specified, it has the same meaning as for <code>-M<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---find-copies-harder"> --find-copies-harder </dt> <dd> <p>For performance reasons, by default, <code>-C</code> option finds copies only if the original file of the copy was modified in the same changeset. This flag makes the command inspect unmodified files as candidates for the source of copy. This is a very expensive operation for large projects, so use it with caution. Giving more than one <code>-C</code> option has the same effect.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--D"> -D </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---irreversible-delete"> --irreversible-delete </dt> <dd> <p>Omit the preimage for deletes, i.e. print only the header but not the diff between the preimage and <code>/dev/null</code>. The resulting patch is not meant to be applied with <code>patch</code> or <code>git apply</code>; this is solely for people who want to just concentrate on reviewing the text after the change. In addition, the output obviously lacks enough information to apply such a patch in reverse, even manually, hence the name of the option.</p> <p>When used together with <code>-B</code>, omit also the preimage in the deletion part of a delete/create pair.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--lltnumgt"> -l<num> </dt> <dd> <p>The <code>-M</code> and <code>-C</code> options involve some preliminary steps that can detect subsets of renames/copies cheaply, followed by an exhaustive fallback portion that compares all remaining unpaired destinations to all relevant sources. (For renames, only remaining unpaired sources are relevant; for copies, all original sources are relevant.) For N sources and destinations, this exhaustive check is O(N^2). This option prevents the exhaustive portion of rename/copy detection from running if the number of source/destination files involved exceeds the specified number. Defaults to diff.renameLimit. Note that a value of 0 is treated as unlimited.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---diff-filterACDMRTUXB82308203"> --diff-filter=[(A|C|D|M|R|T|U|X|B)…[*]] </dt> <dd> <p>Select only files that are Added (<code>A</code>), Copied (<code>C</code>), Deleted (<code>D</code>), Modified (<code>M</code>), Renamed (<code>R</code>), have their type (i.e. regular file, symlink, submodule, …) changed (<code>T</code>), are Unmerged (<code>U</code>), are Unknown (<code>X</code>), or have had their pairing Broken (<code>B</code>). Any combination of the filter characters (including none) can be used. When <code>*</code> (All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.</p> <p>Also, these upper-case letters can be downcased to exclude. E.g. <code>--diff-filter=ad</code> excludes added and deleted paths.</p> <p>Note that not all diffs can feature all types. For instance, copied and renamed entries cannot appear if detection for those types is disabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--Sltstringgt"> -S<string> </dt> <dd> <p>Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file. Intended for the scripter’s use.</p> <p>It is useful when you’re looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting block in the preimage back into <code>-S</code>, and keep going until you get the very first version of the block.</p> <p>Binary files are searched as well.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--Gltregexgt"> -G<regex> </dt> <dd> <p>Look for differences whose patch text contains added/removed lines that match <regex>.</p> <p>To illustrate the difference between <code>-S<regex> --pickaxe-regex</code> and <code>-G<regex></code>, consider a commit with the following diff in the same file:</p> <div class="listingblock"> <div class="content"> <pre>+ return frotz(nitfol, two->ptr, 1, 0); +... +- hit = frotz(nitfol, mf2.ptr, 1, 0);</pre> </div> </div> <p>While <code>git log -G"frotz\(nitfol"</code> will show this commit, <code>git log +-S"frotz\(nitfol" --pickaxe-regex</code> will not (because the number of occurrences of that string did not change).</p> <p>Unless <code>--text</code> is supplied patches of binary files without a textconv filter will be ignored.</p> <p>See the <code>pickaxe</code> entry in <a href="gitdiffcore">gitdiffcore[7]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---find-objectltobject-idgt"> --find-object=<object-id> </dt> <dd> <p>Look for differences that change the number of occurrences of the specified object. Similar to <code>-S</code>, just the argument is different in that it doesn’t search for a specific string but for a specific object id.</p> <p>The object can be a blob or a submodule commit. It implies the <code>-t</code> option in <code>git-log</code> to also find trees.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---pickaxe-all"> --pickaxe-all </dt> <dd> <p>When <code>-S</code> or <code>-G</code> finds a change, show all the changes in that changeset, not just the files that contain the change in <string>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---pickaxe-regex"> --pickaxe-regex </dt> <dd> <p>Treat the <string> given to <code>-S</code> as an extended POSIX regular expression to match.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--Oltorderfilegt"> -O<orderfile> </dt> <dd> <p>Control the order in which files appear in the output. This overrides the <code>diff.orderFile</code> configuration variable (see <a href="git-config">git-config[1]</a>). To cancel <code>diff.orderFile</code>, use <code>-O/dev/null</code>.</p> <p>The output order is determined by the order of glob patterns in <orderfile>. All files with pathnames that match the first pattern are output first, all files with pathnames that match the second pattern (but not the first) are output next, and so on. All files with pathnames that do not match any pattern are output last, as if there was an implicit match-all pattern at the end of the file. If multiple pathnames have the same rank (they match the same pattern but no earlier patterns), their output order relative to each other is the normal order.</p> <p><orderfile> is parsed as follows:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>Blank lines are ignored, so they can be used as separators for readability.</p> </li> <li> <p>Lines starting with a hash ("<code>#</code>") are ignored, so they can be used for comments. Add a backslash ("<code>\</code>") to the beginning of the pattern if it starts with a hash.</p> </li> <li> <p>Each other line contains a single pattern.</p> </li> </ul> </div> </div> </div> <p>Patterns have the same syntax and semantics as patterns used for fnmatch(3) without the FNM_PATHNAME flag, except a pathname also matches a pattern if removing any number of the final pathname components matches the pattern. For example, the pattern "<code>foo*bar</code>" matches "<code>fooasdfbar</code>" and "<code>foo/bar/baz/asdf</code>" but not "<code>foobarx</code>".</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---skip-toltfilegt"> --skip-to=<file> </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---rotate-toltfilegt"> --rotate-to=<file> </dt> <dd> <p>Discard the files before the named <file> from the output (i.e. <code>skip to</code>), or move them to the end of the output (i.e. <code>rotate to</code>). These options were invented primarily for the use of the <code>git difftool</code> command, and may not be very useful otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--R"> -R </dt> <dd> <p>Swap two inputs; that is, show differences from index or on-disk file to tree contents.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---relativeltpathgt"> --relative[=<path>] </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---no-relative"> --no-relative </dt> <dd> <p>When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option. When you are not in a subdirectory (e.g. in a bare repository), you can name which subdirectory to make the output relative to by giving a <path> as an argument. <code>--no-relative</code> can be used to countermand both <code>diff.relative</code> config option and previous <code>--relative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---text"> --text </dt> <dd> <p>Treat all files as text.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---ignore-cr-at-eol"> --ignore-cr-at-eol </dt> <dd> <p>Ignore carriage-return at the end of line when doing a comparison.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---ignore-space-at-eol"> --ignore-space-at-eol </dt> <dd> <p>Ignore changes in whitespace at EOL.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--b"> -b </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---ignore-space-change"> --ignore-space-change </dt> <dd> <p>Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--w"> -w </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---ignore-all-space"> --ignore-all-space </dt> <dd> <p>Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---ignore-blank-lines"> --ignore-blank-lines </dt> <dd> <p>Ignore changes whose lines are all blank.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--Iltregexgt"> -I<regex> </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---ignore-matching-linesltregexgt"> --ignore-matching-lines=<regex> </dt> <dd> <p>Ignore changes whose all lines match <regex>. This option may be specified more than once.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---inter-hunk-contextltlinesgt"> --inter-hunk-context=<lines> </dt> <dd> <p>Show the context between diff hunks, up to the specified number of lines, thereby fusing hunks that are close to each other. Defaults to <code>diff.interHunkContext</code> or 0 if the config option is unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--W"> -W </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---function-context"> --function-context </dt> <dd> <p>Show whole function as context lines for each change. The function names are determined in the same way as <code>git diff</code> works out patch hunk headers (see <code>Defining a custom hunk-header</code> in <a href="gitattributes">gitattributes[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---exit-code"> --exit-code </dt> <dd> <p>Make the program exit with codes similar to diff(1). That is, it exits with 1 if there were differences and 0 means no differences.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---quiet"> --quiet </dt> <dd> <p>Disable all output of the program. Implies <code>--exit-code</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---ext-diff"> --ext-diff </dt> <dd> <p>Allow an external diff helper to be executed. If you set an external diff driver with <a href="gitattributes">gitattributes[5]</a>, you need to use this option with <a href="git-log">git-log[1]</a> and friends.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---no-ext-diff"> --no-ext-diff </dt> <dd> <p>Disallow external diff drivers.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---textconv"> --textconv </dt> <dt class="hdlist1" id="Documentation/git-diff.txt---no-textconv"> --no-textconv </dt> <dd> <p>Allow (or disallow) external text conversion filters to be run when comparing binary files. See <a href="gitattributes">gitattributes[5]</a> for details. Because textconv filters are typically a one-way conversion, the resulting diff is suitable for human consumption, but cannot be applied. For this reason, textconv filters are enabled by default only for <a href="git-diff">git-diff[1]</a> and <a href="git-log">git-log[1]</a>, but not for <a href="git-format-patch">git-format-patch[1]</a> or diff plumbing commands.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---ignore-submodulesltwhengt"> --ignore-submodules[=<when>] </dt> <dd> <p>Ignore changes to submodules in the diff generation. <when> can be either "none", "untracked", "dirty" or "all", which is the default. Using "none" will consider the submodule modified when it either contains untracked or modified files or its HEAD differs from the commit recorded in the superproject and can be used to override any settings of the <code>ignore</code> option in <a href="git-config">git-config[1]</a> or <a href="gitmodules">gitmodules[5]</a>. When "untracked" is used submodules are not considered dirty when they only contain untracked content (but they are still scanned for modified content). Using "dirty" ignores all changes to the work tree of submodules, only changes to the commits stored in the superproject are shown (this was the behavior until 1.7.0). Using "all" hides all changes to submodules.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---src-prefixltprefixgt"> --src-prefix=<prefix> </dt> <dd> <p>Show the given source prefix instead of "a/".</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---dst-prefixltprefixgt"> --dst-prefix=<prefix> </dt> <dd> <p>Show the given destination prefix instead of "b/".</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---no-prefix"> --no-prefix </dt> <dd> <p>Do not show any source or destination prefix.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---default-prefix"> --default-prefix </dt> <dd> <p>Use the default source and destination prefixes ("a/" and "b/"). This is usually the default already, but may be used to override config such as <code>diff.noprefix</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---line-prefixltprefixgt"> --line-prefix=<prefix> </dt> <dd> <p>Prepend an additional prefix to every line of output.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt---ita-invisible-in-index"> --ita-invisible-in-index </dt> <dd> <p>By default entries added by "git add -N" appear as an existing empty file in "git diff" and a new file in "git diff --cached". This option makes the entry appear as a new file in "git diff" and non-existent in "git diff --cached". This option could be reverted with <code>--ita-visible-in-index</code>. Both options are experimental and could be removed in future.</p> </dd> </dl> </div> <p>For more detailed explanation on these common options, see also <a href="gitdiffcore">gitdiffcore[7]</a>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff.txt--1--base"> -1 --base </dt> <dt class="hdlist1" id="Documentation/git-diff.txt--2--ours"> -2 --ours </dt> <dt class="hdlist1" id="Documentation/git-diff.txt--3--theirs"> -3 --theirs </dt> <dd> <p>Compare the working tree with the "base" version (stage #1), "our branch" (stage #2) or "their branch" (stage #3). The index contains these stages only for unmerged entries i.e. while resolving conflicts. See <a href="git-read-tree">git-read-tree[1]</a> section "3-Way Merge" for detailed information.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt--0"> -0 </dt> <dd> <p>Omit diff output for unmerged entries and just show "Unmerged". Can be used only when comparing the working tree with the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-ltpathgt82308203"> <path>… </dt> <dd> <p>The <paths> parameters, when given, are used to limit the diff to the named paths (you can give directory names and get diff for all files under them).</p> </dd> </dl> </div> </div> <h2 id="_raw_output_format">Raw output format</h2> <div class="sectionbody"> <p>The raw output format from "git-diff-index", "git-diff-tree", "git-diff-files" and "git diff --raw" are very similar.</p> <p>These commands all compare two sets of things; what is compared differs:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff.txt-git-diff-indexlttree-ishgt"> git-diff-index <tree-ish> </dt> <dd> <p>compares the <tree-ish> and the files on the filesystem.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-git-diff-index--cachedlttree-ishgt"> git-diff-index --cached <tree-ish> </dt> <dd> <p>compares the <tree-ish> and the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-git-diff-tree-rlttree-ish-1gtlttree-ish-2gtltpatterngt82308203"> git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…] </dt> <dd> <p>compares the trees named by the two arguments.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-git-diff-filesltpatterngt82308203"> git-diff-files [<pattern>…] </dt> <dd> <p>compares the index and the files on the filesystem.</p> </dd> </dl> </div> <p>The "git-diff-tree" command begins its output by printing the hash of what is being compared. After that, all the commands print one output line per changed file.</p> <p>An output line is formatted this way:</p> <div class="listingblock"> <div class="content"> <pre>in-place edit :100644 100644 bcd1234 0123456 M file0 +copy-edit :100644 100644 abcd123 1234567 C68 file1 file2 +rename-edit :100644 100644 abcd123 1234567 R86 file1 file3 +create :000000 100644 0000000 1234567 A file4 +delete :100644 000000 1234567 0000000 D file5 +unmerged :000000 000000 0000000 0000000 U file6</pre> </div> </div> <p>That is, from the left to the right:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>a colon.</p> </li> <li> <p>mode for "src"; 000000 if creation or unmerged.</p> </li> <li> <p>a space.</p> </li> <li> <p>mode for "dst"; 000000 if deletion or unmerged.</p> </li> <li> <p>a space.</p> </li> <li> <p>sha1 for "src"; 0{40} if creation or unmerged.</p> </li> <li> <p>a space.</p> </li> <li> <p>sha1 for "dst"; 0{40} if deletion, unmerged or "work tree out of sync with the index".</p> </li> <li> <p>a space.</p> </li> <li> <p>status, followed by optional "score" number.</p> </li> <li> <p>a tab or a NUL when <code>-z</code> option is used.</p> </li> <li> <p>path for "src"</p> </li> <li> <p>a tab or a NUL when <code>-z</code> option is used; only exists for C or R.</p> </li> <li> <p>path for "dst"; only exists for C or R.</p> </li> <li> <p>an LF or a NUL when <code>-z</code> option is used, to terminate the record.</p> </li> </ol> </div> <p>Possible status letters are:</p> <div class="ulist"> <ul> <li> <p>A: addition of a file</p> </li> <li> <p>C: copy of a file into a new one</p> </li> <li> <p>D: deletion of a file</p> </li> <li> <p>M: modification of the contents or mode of a file</p> </li> <li> <p>R: renaming of a file</p> </li> <li> <p>T: change in the type of the file (regular file, symbolic link or submodule)</p> </li> <li> <p>U: file is unmerged (you must complete the merge before it can be committed)</p> </li> <li> <p>X: "unknown" change type (most probably a bug, please report it)</p> </li> </ul> </div> <p>Status letters C and R are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy). Status letter M may be followed by a score (denoting the percentage of dissimilarity) for file rewrites.</p> <p>The sha1 for "dst" is shown as all 0’s if a file on the filesystem is out of sync with the index.</p> <p>Example:</p> <div class="listingblock"> <div class="content"> <pre>:100644 100644 5be4a4a 0000000 M file.c</pre> </div> </div> <p>Without the <code>-z</code> option, pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>). Using <code>-z</code> the filename is output verbatim and the line is terminated by a NUL byte.</p> </div> <h2 id="_diff_format_for_merges">Diff format for merges</h2> <div class="sectionbody"> <p>"git-diff-tree", "git-diff-files" and "git-diff --raw" can take <code>-c</code> or <code>--cc</code> option to generate diff output also for merge commits. The output differs from the format described above in the following way:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>there is a colon for each parent</p> </li> <li> <p>there are more "src" modes and "src" sha1</p> </li> <li> <p>status is concatenated status characters for each parent</p> </li> <li> <p>no optional "score" number</p> </li> <li> <p>tab-separated pathname(s) of the file</p> </li> </ol> </div> <p>For <code>-c</code> and <code>--cc</code>, only the destination or final path is shown even if the file was renamed on any side of history. With <code>--combined-all-paths</code>, the name of the path in each parent is shown followed by the name of the path in the merge commit.</p> <p>Examples for <code>-c</code> and <code>--cc</code> without <code>--combined-all-paths</code>:</p> <div class="listingblock"> <div class="content"> <pre>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c +::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM bar.sh +::100644 100644 100644 e07d6c5 9042e82 ee91881 RR phooey.c</pre> </div> </div> <p>Examples when <code>--combined-all-paths</code> added to either <code>-c</code> or <code>--cc</code>:</p> <div class="listingblock"> <div class="content"> <pre>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c desc.c desc.c +::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM foo.sh bar.sh bar.sh +::100644 100644 100644 e07d6c5 9042e82 ee91881 RR fooey.c fuey.c phooey.c</pre> </div> </div> <p>Note that <code>combined diff</code> lists only files which were modified from all parents.</p> </div> <h2 id="generate_patch_text_with_p">Generating patch text with -p</h2> <div class="sectionbody"> <p>Running <a href="git-diff">git-diff[1]</a>, <a href="git-log">git-log[1]</a>, <a href="git-show">git-show[1]</a>, <a href="git-diff-index">git-diff-index[1]</a>, <a href="git-diff-tree">git-diff-tree[1]</a>, or <a href="git-diff-files">git-diff-files[1]</a> with the <code>-p</code> option produces patch text. You can customize the creation of patch text via the <code>GIT_EXTERNAL_DIFF</code> and the <code>GIT_DIFF_OPTS</code> environment variables (see <a href="git">git[1]</a>), and the <code>diff</code> attribute (see <a href="gitattributes">gitattributes[5]</a>).</p> <p>What the -p option produces is slightly different from the traditional diff format:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>It is preceded by a "git diff" header that looks like this:</p> <div class="literalblock"> <div class="content"> <pre>diff --git a/file1 b/file2</pre> </div> </div> <p>The <code>a/</code> and <code>b/</code> filenames are the same unless rename/copy is involved. Especially, even for a creation or a deletion, <code>/dev/null</code> is <code>not</code> used in place of the <code>a/</code> or <code>b/</code> filenames.</p> <p>When a rename/copy is involved, <code>file1</code> and <code>file2</code> show the name of the source file of the rename/copy and the name of the file that the rename/copy produces, respectively.</p> </li> <li> <p>It is followed by one or more extended header lines:</p> <div class="literalblock"> <div class="content"> <pre>old mode <mode> +new mode <mode> +deleted file mode <mode> +new file mode <mode> +copy from <path> +copy to <path> +rename from <path> +rename to <path> +similarity index <number> +dissimilarity index <number> +index <hash>..<hash> <mode></pre> </div> </div> <p>File modes are printed as 6-digit octal numbers including the file type and file permission bits.</p> <p>Path names in extended headers do not include the <code>a/</code> and <code>b/</code> prefixes.</p> <p>The similarity index is the percentage of unchanged lines, and the dissimilarity index is the percentage of changed lines. It is a rounded down integer, followed by a percent sign. The similarity index value of 100% is thus reserved for two equal files, while 100% dissimilarity means that no line from the old file made it into the new one.</p> <p>The index line includes the blob object names before and after the change. The <mode> is included if the file mode does not change; otherwise, separate lines indicate the old and the new mode.</p> </li> <li> <p>Pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>).</p> </li> <li> <p>All the <code>file1</code> files in the output refer to files before the commit, and all the <code>file2</code> files refer to files after the commit. It is incorrect to apply each change to each file sequentially. For example, this patch will swap a and b:</p> <div class="literalblock"> <div class="content"> <pre>diff --git a/a b/b +rename from a +rename to b +diff --git a/b b/a +rename from b +rename to a</pre> </div> </div> </li> <li> <p>Hunk headers mention the name of the function to which the hunk applies. See "Defining a custom hunk-header" in <a href="gitattributes">gitattributes[5]</a> for details of how to tailor this to specific languages.</p> </li> </ol> </div> </div> <h2 id="_combined_diff_format">Combined diff format</h2> <div class="sectionbody"> <p>Any diff-generating command can take the <code>-c</code> or <code>--cc</code> option to produce a <code>combined diff</code> when showing a merge. This is the default format when showing merges with <a href="git-diff">git-diff[1]</a> or <a href="git-show">git-show[1]</a>. Note also that you can give suitable <code>--diff-merges</code> option to any of these commands to force generation of diffs in a specific format.</p> <p>A "combined diff" format looks like this:</p> <div class="listingblock"> <div class="content"> <pre>diff --combined describe.c +index fabadb8,cc95eb0..4866510 +--- a/describe.c ++++ b/describe.c +@@@ -98,20 -98,12 +98,20 @@@ + return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; + } + +- static void describe(char *arg) + -static void describe(struct commit *cmit, int last_one) +++static void describe(char *arg, int last_one) + { + + unsigned char sha1[20]; + + struct commit *cmit; + struct commit_list *list; + static int initialized = 0; + struct commit_name *n; + + + if (get_sha1(arg, sha1) < 0) + + usage(describe_usage); + + cmit = lookup_commit_reference(sha1); + + if (!cmit) + + usage(describe_usage); + + + if (!initialized) { + initialized = 1; + for_each_ref(get_name);</pre> </div> </div> <div class="olist arabic"> <ol class="arabic"> <li> <p>It is preceded by a "git diff" header, that looks like this (when the <code>-c</code> option is used):</p> <div class="literalblock"> <div class="content"> <pre>diff --combined file</pre> </div> </div> <p>or like this (when the <code>--cc</code> option is used):</p> <div class="literalblock"> <div class="content"> <pre>diff --cc file</pre> </div> </div> </li> <li> <p>It is followed by one or more extended header lines (this example shows a merge with two parents):</p> <div class="literalblock"> <div class="content"> <pre>index <hash>,<hash>..<hash> +mode <mode>,<mode>..<mode> +new file mode <mode> +deleted file mode <mode>,<mode></pre> </div> </div> <p>The <code>mode <mode>,<mode>..<mode></code> line appears only if at least one of the <mode> is different from the rest. Extended headers with information about detected content movement (renames and copying detection) are designed to work with the diff of two <tree-ish> and are not used by combined diff format.</p> </li> <li> <p>It is followed by a two-line from-file/to-file header:</p> <div class="literalblock"> <div class="content"> <pre>--- a/file ++++ b/file</pre> </div> </div> <p>Similar to the two-line header for the traditional <code>unified</code> diff format, <code>/dev/null</code> is used to signal created or deleted files.</p> <p>However, if the --combined-all-paths option is provided, instead of a two-line from-file/to-file, you get an N+1 line from-file/to-file header, where N is the number of parents in the merge commit:</p> <div class="literalblock"> <div class="content"> <pre>--- a/file +--- a/file +--- a/file ++++ b/file</pre> </div> </div> <p>This extended format can be useful if rename or copy detection is active, to allow you to see the original name of the file in different parents.</p> </li> <li> <p>Chunk header format is modified to prevent people from accidentally feeding it to <code>patch -p1</code>. Combined diff format was created for review of merge commit changes, and was not meant to be applied. The change is similar to the change in the extended <code>index</code> header:</p> <div class="literalblock"> <div class="content"> <pre>@@@ <from-file-range> <from-file-range> <to-file-range> @@@</pre> </div> </div> <p>There are (number of parents + 1) <code>@</code> characters in the chunk header for combined diff format.</p> </li> </ol> </div> <p>Unlike the traditional <code>unified</code> diff format, which shows two files A and B with a single column that has <code>-</code> (minus — appears in A but removed in B), <code>+</code> (plus — missing in A but added to B), or <code>" "</code> (space — unchanged) prefix, this format compares two or more files file1, file2,… with one file X, and shows how X differs from each of fileN. One column for each of fileN is prepended to the output line to note how X’s line is different from it.</p> <p>A <code>-</code> character in the column N means that the line appears in fileN but it does not appear in the result. A <code>+</code> character in the column N means that the line appears in the result, and fileN does not have that line (in other words, the line was added, from the point of view of that parent).</p> <p>In the above example output, the function signature was changed from both files (hence two <code>-</code> removals from both file1 and file2, plus <code>++</code> to mean one line that was added does not appear in either file1 or file2). Also, eight other lines are the same from file1 but do not appear in file2 (hence prefixed with <code>+</code>).</p> <p>When shown by <code>git diff-tree -c</code>, it compares the parents of a merge commit with the merge result (i.e. file1..fileN are the parents). When shown by <code>git diff-files -c</code>, it compares the two unresolved merge parents with the working tree file (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka "their version").</p> </div> <h2 id="_other_diff_formats">Other diff formats</h2> <div class="sectionbody"> <p>The <code>--summary</code> option describes newly added, deleted, renamed and copied files. The <code>--stat</code> option adds diffstat(1) graph to the output. These options can be combined with other options, such as <code>-p</code>, and are meant for human consumption.</p> <p>When showing a change that involves a rename or a copy, <code>--stat</code> output formats the pathnames compactly by combining common prefix and suffix of the pathnames. For example, a change that moves <code>arch/i386/Makefile</code> to <code>arch/x86/Makefile</code> while modifying 4 lines will be shown like this:</p> <div class="listingblock"> <div class="content"> <pre>arch/{i386 => x86}/Makefile | 4 +--</pre> </div> </div> <p>The <code>--numstat</code> option gives the diffstat(1) information but is designed for easier machine consumption. An entry in <code>--numstat</code> output looks like this:</p> <div class="listingblock"> <div class="content"> <pre>1 2 README +3 1 arch/{i386 => x86}/Makefile</pre> </div> </div> <p>That is, from left to right:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>the number of added lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>the number of deleted lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>pathname (possibly with rename/copy information);</p> </li> <li> <p>a newline.</p> </li> </ol> </div> <p>When <code>-z</code> output option is in effect, the output is formatted this way:</p> <div class="listingblock"> <div class="content"> <pre>1 2 README NUL +3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</pre> </div> </div> <p>That is:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>the number of added lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>the number of deleted lines;</p> </li> <li> <p>a tab;</p> </li> <li> <p>a NUL (only exists if renamed/copied);</p> </li> <li> <p>pathname in preimage;</p> </li> <li> <p>a NUL (only exists if renamed/copied);</p> </li> <li> <p>pathname in postimage (only exists if renamed/copied);</p> </li> <li> <p>a NUL.</p> </li> </ol> </div> <p>The extra <code>NUL</code> before the preimage path in renamed case is to allow scripts that read the output to tell if the current record being read is a single-path record or a rename/copy record without reading ahead. After reading added and deleted lines, reading up to <code>NUL</code> would yield the pathname, but if that is <code>NUL</code>, the record will show two paths.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff.txt-Variouswaystocheckyourworkingtree"> Various ways to check your working tree </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff (1) +$ git diff --cached (2) +$ git diff HEAD (3) +$ git diff AUTO_MERGE (4)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>Changes in the working tree not yet staged for the next commit.</p> </li> <li> <p>Changes between the index and your last commit; what you would be committing if you run <code>git commit</code> without <code>-a</code> option.</p> </li> <li> <p>Changes in the working tree since your last commit; what you would be committing if you run <code>git commit -a</code></p> </li> <li> <p>Changes in the working tree you’ve made to resolve textual conflicts so far.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-Comparingwitharbitrarycommits"> Comparing with arbitrary commits </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff test (1) +$ git diff HEAD -- ./test (2) +$ git diff HEAD^ HEAD (3)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>Instead of using the tip of the current branch, compare with the tip of "test" branch.</p> </li> <li> <p>Instead of comparing with the tip of "test" branch, compare with the tip of the current branch, but limit the comparison to the file "test".</p> </li> <li> <p>Compare the version before the last commit and the last commit.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-Comparingbranches"> Comparing branches </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff topic master (1) +$ git diff topic..master (2) +$ git diff topic...master (3)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>Changes between the tips of the topic and the master branches.</p> </li> <li> <p>Same as above.</p> </li> <li> <p>Changes that occurred on the master branch since when the topic branch was started off it.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-Limitingthediffoutput"> Limiting the diff output </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff --diff-filter=MRC (1) +$ git diff --name-status (2) +$ git diff arch/i386 include/asm-i386 (3)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>Show only modification, rename, and copy, but not addition or deletion.</p> </li> <li> <p>Show only names and the nature of change, but not actual diff output.</p> </li> <li> <p>Limit diff output to named subtrees.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-Mungingthediffoutput"> Munging the diff output </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff --find-copies-harder -B -C (1) +$ git diff -R (2)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>Spend extra cycles to find renames, copies and complete rewrites (very expensive).</p> </li> <li> <p>Output diff in reverse.</p> </li> </ol> </div> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff.txt-diffautoRefreshIndex"> diff.autoRefreshIndex </dt> <dd> <p>When using <code>git diff</code> to compare with work tree files, do not consider stat-only changes as changed. Instead, silently run <code>git update-index --refresh</code> to update the cached stat information for paths whose contents in the work tree match the contents in the index. This option defaults to true. Note that this affects only <code>git diff</code> Porcelain, and not lower level <code>diff</code> commands such as <code>git diff-files</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffdirstat"> diff.dirstat </dt> <dd> <p>A comma separated list of <code>--dirstat</code> parameters specifying the default behavior of the <code>--dirstat</code> option to <a href="git-diff">git-diff[1]</a> and friends. The defaults can be overridden on the command line (using <code>--dirstat=<param1,param2,...></code>). The fallback defaults (when not changed by <code>diff.dirstat</code>) are <code>changes,noncumulative,3</code>. The following parameters are available:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff.txt-codechangescode-1"> <code>changes</code> </dt> <dd> <p>Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination. This ignores the amount of pure code movements within a file. In other words, rearranging lines in a file is not counted as much as other changes. This is the default behavior when no parameter is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codelinescode-1"> <code>lines</code> </dt> <dd> <p>Compute the dirstat numbers by doing the regular line-based diff analysis, and summing the removed/added line counts. (For binary files, count 64-byte chunks instead, since binary files have no natural concept of lines). This is a more expensive <code>--dirstat</code> behavior than the <code>changes</code> behavior, but it does count rearranged lines within a file as much as other changes. The resulting output is consistent with what you get from the other <code>--*stat</code> options.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codefilescode-1"> <code>files</code> </dt> <dd> <p>Compute the dirstat numbers by counting the number of files changed. Each changed file counts equally in the dirstat analysis. This is the computationally cheapest <code>--dirstat</code> behavior, since it does not have to look at the file contents at all.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codecumulativecode-1"> <code>cumulative</code> </dt> <dd> <p>Count changes in a child directory for the parent directory as well. Note that when using <code>cumulative</code>, the sum of the percentages reported may exceed 100%. The default (non-cumulative) behavior can be specified with the <code>noncumulative</code> parameter.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-ltlimitgt-1"> <limit> </dt> <dd> <p>An integer parameter specifies a cut-off percent (3% by default). Directories contributing less than this percentage of the changes are not shown in the output.</p> </dd> </dl> </div> </div> </div> <p>Example: The following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories: <code>files,10,cumulative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffstatNameWidth"> diff.statNameWidth </dt> <dd> <p>Limit the width of the filename part in --stat output. If set, applies to all commands generating --stat output except format-patch.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffstatGraphWidth"> diff.statGraphWidth </dt> <dd> <p>Limit the width of the graph part in --stat output. If set, applies to all commands generating --stat output except format-patch.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffcontext"> diff.context </dt> <dd> <p>Generate diffs with <n> lines of context instead of the default of 3. This value is overridden by the -U option.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffinterHunkContext"> diff.interHunkContext </dt> <dd> <p>Show the context between diff hunks, up to the specified number of lines, thereby fusing the hunks that are close to each other. This value serves as the default for the <code>--inter-hunk-context</code> command line option.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffexternal"> diff.external </dt> <dd> <p>If this config variable is set, diff generation is not performed using the internal diff machinery, but using the given command. Can be overridden with the ‘GIT_EXTERNAL_DIFF’ environment variable. The command is called with parameters as described under "git Diffs" in <a href="git">git[1]</a>. Note: if you want to use an external diff program only on a subset of your files, you might want to use <a href="gitattributes">gitattributes[5]</a> instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffignoreSubmodules"> diff.ignoreSubmodules </dt> <dd> <p>Sets the default value of --ignore-submodules. Note that this affects only <code>git diff</code> Porcelain, and not lower level <code>diff</code> commands such as <code>git diff-files</code>. <code>git checkout</code> and <code>git switch</code> also honor this setting when reporting uncommitted changes. Setting it to <code>all</code> disables the submodule summary normally shown by <code>git commit</code> and <code>git status</code> when <code>status.submoduleSummary</code> is set unless it is overridden by using the --ignore-submodules command-line option. The <code>git submodule</code> commands are not affected by this setting. By default this is set to untracked so that any untracked submodules are ignored.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffmnemonicPrefix"> diff.mnemonicPrefix </dt> <dd> <p>If set, <code>git diff</code> uses a prefix pair that is different from the standard "a/" and "b/" depending on what is being compared. When this configuration is in effect, reverse diff output also swaps the order of the prefixes:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff.txt-codegitdiffcode"> <code>git diff</code> </dt> <dd> <p>compares the (i)ndex and the (w)ork tree;</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codegitdiffHEADcode"> <code>git diff HEAD</code> </dt> <dd> <p>compares a (c)ommit and the (w)ork tree;</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codegitdiff--cachedcode"> <code>git diff --cached</code> </dt> <dd> <p>compares a (c)ommit and the (i)ndex;</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codegitdiffHEADfile1file2code"> <code>git diff HEAD:file1 file2</code> </dt> <dd> <p>compares an (o)bject and a (w)ork tree entity;</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codegitdiff--no-indexabcode"> <code>git diff --no-index a b</code> </dt> <dd> <p>compares two non-git things (1) and (2).</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffnoprefix"> diff.noprefix </dt> <dd> <p>If set, <code>git diff</code> does not show any source or destination prefix.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffrelative"> diff.relative </dt> <dd> <p>If set to <code>true</code>, <code>git diff</code> does not show changes outside of the directory and show pathnames relative to the current directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-difforderFile"> diff.orderFile </dt> <dd> <p>File indicating how to order files within a diff. See the <code>-O</code> option to <a href="git-diff">git-diff[1]</a> for details. If <code>diff.orderFile</code> is a relative pathname, it is treated as relative to the top of the working tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffrenameLimit"> diff.renameLimit </dt> <dd> <p>The number of files to consider in the exhaustive portion of copy/rename detection; equivalent to the <code>git diff</code> option <code>-l</code>. If not set, the default value is currently 1000. This setting has no effect if rename detection is turned off.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffrenames"> diff.renames </dt> <dd> <p>Whether and how Git detects renames. If set to "false", rename detection is disabled. If set to "true", basic rename detection is enabled. If set to "copies" or "copy", Git will detect copies, as well. Defaults to true. Note that this affects only <code>git diff</code> Porcelain like <a href="git-diff">git-diff[1]</a> and <a href="git-log">git-log[1]</a>, and not lower level commands such as <a href="git-diff-files">git-diff-files[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffsuppressBlankEmpty"> diff.suppressBlankEmpty </dt> <dd> <p>A boolean to inhibit the standard behavior of printing a space before each empty output line. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffsubmodule"> diff.submodule </dt> <dd> <p>Specify the format in which differences in submodules are shown. The "short" format just shows the names of the commits at the beginning and end of the range. The "log" format lists the commits in the range like <a href="git-submodule">git-submodule[1]</a> <code>summary</code> does. The "diff" format shows an inline diff of the changed contents of the submodule. Defaults to "short".</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffwordRegex"> diff.wordRegex </dt> <dd> <p>A POSIX Extended Regular Expression used to determine what is a "word" when performing word-by-word difference calculations. Character sequences that match the regular expression are "words", all other characters are <strong>ignorable</strong> whitespace.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffltdrivergtcommand"> diff.<driver>.command </dt> <dd> <p>The custom diff driver command. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffltdrivergtxfuncname"> diff.<driver>.xfuncname </dt> <dd> <p>The regular expression that the diff driver should use to recognize the hunk header. A built-in pattern may also be used. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffltdrivergtbinary"> diff.<driver>.binary </dt> <dd> <p>Set this option to true to make the diff driver treat files as binary. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffltdrivergttextconv"> diff.<driver>.textconv </dt> <dd> <p>The command that the diff driver should call to generate the text-converted version of a file. The result of the conversion is used to generate a human-readable diff. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffltdrivergtwordRegex"> diff.<driver>.wordRegex </dt> <dd> <p>The regular expression that the diff driver should use to split words in a line. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffltdrivergtcachetextconv"> diff.<driver>.cachetextconv </dt> <dd> <p>Set this option to true to make the diff driver cache the text conversion outputs. See <a href="gitattributes">gitattributes[5]</a> for details.</p> <div class="ulist"> <ul> <li> <p>araxis</p> </li> <li> <p>bc</p> </li> <li> <p>codecompare</p> </li> <li> <p>deltawalker</p> </li> <li> <p>diffmerge</p> </li> <li> <p>diffuse</p> </li> <li> <p>ecmerge</p> </li> <li> <p>emerge</p> </li> <li> <p>examdiff</p> </li> <li> <p>guiffy</p> </li> <li> <p>gvimdiff</p> </li> <li> <p>kdiff3</p> </li> <li> <p>kompare</p> </li> <li> <p>meld</p> </li> <li> <p>nvimdiff</p> </li> <li> <p>opendiff</p> </li> <li> <p>p4merge</p> </li> <li> <p>smerge</p> </li> <li> <p>tkdiff</p> </li> <li> <p>vimdiff</p> </li> <li> <p>winmerge</p> </li> <li> <p>xxdiff</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffindentHeuristic"> diff.indentHeuristic </dt> <dd> <p>Set this option to <code>false</code> to disable the default heuristics that shift diff hunk boundaries to make patches easier to read.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffalgorithm"> diff.algorithm </dt> <dd> <p>Choose a diff algorithm. The variants are as follows:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-diff.txt-codedefaultcodecodemyerscode-1"> <code>default</code>, <code>myers</code> </dt> <dd> <p>The basic greedy diff algorithm. Currently, this is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codeminimalcode-1"> <code>minimal</code> </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codepatiencecode-1"> <code>patience</code> </dt> <dd> <p>Use "patience diff" algorithm when generating patches.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-codehistogramcode-1"> <code>histogram</code> </dt> <dd> <p>This algorithm extends the patience algorithm to "support low-occurrence common elements".</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffwsErrorHighlight"> diff.wsErrorHighlight </dt> <dd> <p>Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code> lines of the diff. Multiple values are separated by comma, <code>none</code> resets previous values, <code>default</code> reset the list to <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. The whitespace errors are colored with <code>color.diff.whitespace</code>. The command line option <code>--ws-error-highlight=<kind></code> overrides this setting.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffcolorMoved"> diff.colorMoved </dt> <dd> <p>If set to either a valid <code><mode></code> or a true value, moved lines in a diff are colored differently, for details of valid modes see <code>--color-moved</code> in <a href="git-diff">git-diff[1]</a>. If simply set to true the default color mode will be used. When set to false, moved lines are not colored.</p> </dd> <dt class="hdlist1" id="Documentation/git-diff.txt-diffcolorMovedWS"> diff.colorMovedWS </dt> <dd> <p>When moved lines are colored using e.g. the <code>diff.colorMoved</code> setting, this option controls the <code><mode></code> how spaces are treated for details of valid modes see <code>--color-moved-ws</code> in <a href="git-diff">git-diff[1]</a>.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p>diff(1), <a href="git-difftool">git-difftool[1]</a>, <a href="git-log">git-log[1]</a>, <a href="gitdiffcore">gitdiffcore[7]</a>, <a href="git-format-patch">git-format-patch[1]</a>, <a href="git-apply">git-apply[1]</a>, <a href="git-show">git-show[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-diff" class="_attribution-link">https://git-scm.com/docs/git-diff</a> + </p> +</div> diff --git a/devdocs/git/git-difftool.html b/devdocs/git/git-difftool.html new file mode 100644 index 00000000..317ef144 --- /dev/null +++ b/devdocs/git/git-difftool.html @@ -0,0 +1,6 @@ +<h1>git-difftool</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-difftool - Show changes using common diff tools</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git difftool [<options>] [<commit> [<commit>]] [--] [<path>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p><code>git difftool</code> is a Git command that allows you to compare and edit files between revisions using common diff tools. <code>git difftool</code> is a frontend to <code>git diff</code> and accepts the same options and arguments. See <a href="git-diff">git-diff[1]</a>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-difftool.txt--d"> -d </dt> <dt class="hdlist1" id="Documentation/git-difftool.txt---dir-diff"> --dir-diff </dt> <dd> <p>Copy the modified files to a temporary location and perform a directory diff on them. This mode never prompts before launching the diff tool.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt--y"> -y </dt> <dt class="hdlist1" id="Documentation/git-difftool.txt---no-prompt"> --no-prompt </dt> <dd> <p>Do not prompt before launching a diff tool.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt---prompt"> --prompt </dt> <dd> <p>Prompt before each invocation of the diff tool. This is the default behaviour; the option is provided to override any configuration settings.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt---rotate-toltfilegt"> --rotate-to=<file> </dt> <dd> <p>Start showing the diff for the given path, the paths before it will move to the end and output.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt---skip-toltfilegt"> --skip-to=<file> </dt> <dd> <p>Start showing the diff for the given path, skipping all the paths before it.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt--tlttoolgt"> -t <tool> </dt> <dt class="hdlist1" id="Documentation/git-difftool.txt---toollttoolgt"> --tool=<tool> </dt> <dd> <p>Use the diff tool specified by <tool>. Valid values include emerge, kompare, meld, and vimdiff. Run <code>git difftool --tool-help</code> for the list of valid <tool> settings.</p> <p>If a diff tool is not specified, <code>git difftool</code> will use the configuration variable <code>diff.tool</code>. If the configuration variable <code>diff.tool</code> is not set, <code>git difftool</code> will pick a suitable default.</p> <p>You can explicitly provide a full path to the tool by setting the configuration variable <code>difftool.<tool>.path</code>. For example, you can configure the absolute path to kdiff3 by setting <code>difftool.kdiff3.path</code>. Otherwise, <code>git difftool</code> assumes the tool is available in PATH.</p> <p>Instead of running one of the known diff tools, <code>git difftool</code> can be customized to run an alternative program by specifying the command line to invoke in a configuration variable <code>difftool.<tool>.cmd</code>.</p> <p>When <code>git difftool</code> is invoked with this tool (either through the <code>-t</code> or <code>--tool</code> option or the <code>diff.tool</code> configuration variable) the configured command line will be invoked with the following variables available: <code>$LOCAL</code> is set to the name of the temporary file containing the contents of the diff pre-image and <code>$REMOTE</code> is set to the name of the temporary file containing the contents of the diff post-image. <code>$MERGED</code> is the name of the file which is being compared. <code>$BASE</code> is provided for compatibility with custom merge tool commands and has the same value as <code>$MERGED</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt---tool-help"> --tool-help </dt> <dd> <p>Print a list of diff tools that may be used with <code>--tool</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt---no-symlinks"> --[no-]symlinks </dt> <dd> <p><code>git difftool</code>'s default behavior is to create symlinks to the working tree when run in <code>--dir-diff</code> mode and the right-hand side of the comparison yields the same content as the file in the working tree.</p> <p>Specifying <code>--no-symlinks</code> instructs <code>git difftool</code> to create copies instead. <code>--no-symlinks</code> is the default on Windows.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt--xltcommandgt"> -x <command> </dt> <dt class="hdlist1" id="Documentation/git-difftool.txt---extcmdltcommandgt"> --extcmd=<command> </dt> <dd> <p>Specify a custom command for viewing diffs. <code>git-difftool</code> ignores the configured defaults and runs <code>$command $LOCAL $REMOTE</code> when this option is specified. Additionally, <code>$BASE</code> is set in the environment.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt--g"> -g </dt> <dt class="hdlist1" id="Documentation/git-difftool.txt---no-gui"> --[no-]gui </dt> <dd> <p>When <code>git-difftool</code> is invoked with the <code>-g</code> or <code>--gui</code> option the default diff tool will be read from the configured <code>diff.guitool</code> variable instead of <code>diff.tool</code>. This may be selected automatically using the configuration variable <code>difftool.guiDefault</code>. The <code>--no-gui</code> option can be used to override these settings. If <code>diff.guitool</code> is not set, we will fallback in the order of <code>merge.guitool</code>, <code>diff.tool</code>, <code>merge.tool</code> until a tool is found.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt---no-trust-exit-code"> --[no-]trust-exit-code </dt> <dd> <p><code>git-difftool</code> invokes a diff tool individually on each file. Errors reported by the diff tool are ignored by default. Use <code>--trust-exit-code</code> to make <code>git-difftool</code> exit when an invoked diff tool returns a non-zero exit code.</p> <p><code>git-difftool</code> will forward the exit code of the invoked tool when <code>--trust-exit-code</code> is used.</p> </dd> </dl> </div> <p>See <a href="git-diff">git-diff[1]</a> for the full list of supported options.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p><code>git difftool</code> falls back to <code>git mergetool</code> config variables when the difftool equivalents have not been defined.</p> <p>Everything above this line in this section isn’t included from the <a href="git-config">git-config[1]</a> documentation. The content that follows is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-difftool.txt-difftool"> diff.tool </dt> <dd> <p>Controls which diff tool is used by <a href="git-difftool">git-difftool[1]</a>. This variable overrides the value configured in <code>merge.tool</code>. The list below shows the valid built-in values. Any other value is treated as a custom diff tool and requires that a corresponding difftool.<tool>.cmd variable is defined.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt-diffguitool"> diff.guitool </dt> <dd> <p>Controls which diff tool is used by <a href="git-difftool">git-difftool[1]</a> when the -g/--gui flag is specified. This variable overrides the value configured in <code>merge.guitool</code>. The list below shows the valid built-in values. Any other value is treated as a custom diff tool and requires that a corresponding difftool.<guitool>.cmd variable is defined.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt-difftoollttoolgtcmd"> difftool.<tool>.cmd </dt> <dd> <p>Specify the command to invoke the specified diff tool. The specified command is evaluated in shell with the following variables available: <code>LOCAL</code> is set to the name of the temporary file containing the contents of the diff pre-image and <code>REMOTE</code> is set to the name of the temporary file containing the contents of the diff post-image.</p> <p>See the <code>--tool=<tool></code> option in <a href="git-difftool">git-difftool[1]</a> for more details.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt-difftoollttoolgtpath"> difftool.<tool>.path </dt> <dd> <p>Override the path for the given tool. This is useful in case your tool is not in the PATH.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt-difftooltrustExitCode"> difftool.trustExitCode </dt> <dd> <p>Exit difftool if the invoked diff tool returns a non-zero exit status.</p> <p>See the <code>--trust-exit-code</code> option in <a href="git-difftool">git-difftool[1]</a> for more details.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt-difftoolprompt"> difftool.prompt </dt> <dd> <p>Prompt before each invocation of the diff tool.</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt-difftoolguiDefault"> difftool.guiDefault </dt> <dd> <p>Set <code>true</code> to use the <code>diff.guitool</code> by default (equivalent to specifying the <code>--gui</code> argument), or <code>auto</code> to select <code>diff.guitool</code> or <code>diff.tool</code> depending on the presence of a <code>DISPLAY</code> environment variable value. The default is <code>false</code>, where the <code>--gui</code> argument must be provided explicitly for the <code>diff.guitool</code> to be used.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-difftool.txt-ahrefdocsgit-diffgit-diff1a"> <a href="git-diff">git-diff[1]</a> </dt> <dd> <p>Show changes between commits, commit and working tree, etc</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt-ahrefdocsgit-mergetoolgit-mergetool1a"> <a href="git-mergetool">git-mergetool[1]</a> </dt> <dd> <p>Run merge conflict resolution tools to resolve merge conflicts</p> </dd> <dt class="hdlist1" id="Documentation/git-difftool.txt-ahrefdocsgit-configgit-config1a"> <a href="git-config">git-config[1]</a> </dt> <dd> <p>Get and set repository or global options</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-difftool" class="_attribution-link">https://git-scm.com/docs/git-difftool</a> + </p> +</div> diff --git a/devdocs/git/git-fast-export.html b/devdocs/git/git-fast-export.html new file mode 100644 index 00000000..eeca86ea --- /dev/null +++ b/devdocs/git/git-fast-export.html @@ -0,0 +1,15 @@ +<h1>git-fast-export</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-fast-export - Git data exporter</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git fast-export [<options>] | git fast-import</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This program dumps the given revisions in a form suitable to be piped into <code>git fast-import</code>.</p> <p>You can use it as a human-readable bundle replacement (see <a href="git-bundle">git-bundle[1]</a>), or as a format that can be edited before being fed to <code>git fast-import</code> in order to do history rewrites (an ability relied on by tools like <code>git filter-repo</code>).</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fast-export.txt---progressltngt"> --progress=<n> </dt> <dd> <p>Insert <code>progress</code> statements every <n> objects, to be shown by <code>git fast-import</code> during import.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt---signed-tagsverbatimwarnwarn-stripstripabort"> --signed-tags=(verbatim|warn|warn-strip|strip|abort) </dt> <dd> <p>Specify how to handle signed tags. Since any transformation after the export can change the tag names (which can also happen when excluding revisions) the signatures will not match.</p> <p>When asking to <code>abort</code> (which is the default), this program will die when encountering a signed tag. With <code>strip</code>, the tags will silently be made unsigned, with <code>warn-strip</code> they will be made unsigned but a warning will be displayed, with <code>verbatim</code>, they will be silently exported and with <code>warn</code>, they will be exported, but you will see a warning.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt---tag-of-filtered-objectabortdroprewrite"> --tag-of-filtered-object=(abort|drop|rewrite) </dt> <dd> <p>Specify how to handle tags whose tagged object is filtered out. Since revisions and files to export can be limited by path, tagged objects may be filtered completely.</p> <p>When asking to <code>abort</code> (which is the default), this program will die when encountering such a tag. With <code>drop</code> it will omit such tags from the output. With <code>rewrite</code>, if the tagged object is a commit, it will rewrite the tag to tag an ancestor commit (via parent rewriting; see <a href="git-rev-list">git-rev-list[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt--M"> -M </dt> <dt class="hdlist1" id="Documentation/git-fast-export.txt--C"> -C </dt> <dd> <p>Perform move and/or copy detection, as described in the <a href="git-diff">git-diff[1]</a> manual page, and use it to generate rename and copy commands in the output dump.</p> <p>Note that earlier versions of this command did not complain and produced incorrect results if you gave these options.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt---export-marksltfilegt"> --export-marks=<file> </dt> <dd> <p>Dumps the internal marks table to <file> when complete. Marks are written one per line as <code>:markid SHA-1</code>. Only marks for revisions are dumped; marks for blobs are ignored. Backends can use this file to validate imports after they have been completed, or to save the marks table across incremental runs. As <file> is only opened and truncated at completion, the same path can also be safely given to --import-marks. The file will not be written if no new object has been marked/exported.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt---import-marksltfilegt"> --import-marks=<file> </dt> <dd> <p>Before processing any input, load the marks specified in <file>. The input file must exist, must be readable, and must use the same format as produced by --export-marks.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt---mark-tags"> --mark-tags </dt> <dd> <p>In addition to labelling blobs and commits with mark ids, also label tags. This is useful in conjunction with <code>--export-marks</code> and <code>--import-marks</code>, and is also useful (and necessary) for exporting of nested tags. It does not hurt other cases and would be the default, but many fast-import frontends are not prepared to accept tags with mark identifiers.</p> <p>Any commits (or tags) that have already been marked will not be exported again. If the backend uses a similar --import-marks file, this allows for incremental bidirectional exporting of the repository by keeping the marks the same across runs.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt---fake-missing-tagger"> --fake-missing-tagger </dt> <dd> <p>Some old repositories have tags without a tagger. The fast-import protocol was pretty strict about that, and did not allow that. So fake a tagger to be able to fast-import the output.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt---use-done-feature"> --use-done-feature </dt> <dd> <p>Start the stream with a <code>feature done</code> stanza, and terminate it with a <code>done</code> command.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt---no-data"> --no-data </dt> <dd> <p>Skip output of blob objects and instead refer to blobs via their original SHA-1 hash. This is useful when rewriting the directory structure or history of a repository without touching the contents of individual files. Note that the resulting stream can only be used by a repository which already contains the necessary objects.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt---full-tree"> --full-tree </dt> <dd> <p>This option will cause fast-export to issue a "deleteall" directive for each commit followed by a full list of all files in the commit (as opposed to just listing the files which are different from the commit’s first parent).</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt---anonymize"> --anonymize </dt> <dd> <p>Anonymize the contents of the repository while still retaining the shape of the history and stored tree. See the section on <code>ANONYMIZING</code> below.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt---anonymize-mapltfromgtlttogt"> --anonymize-map=<from>[:<to>] </dt> <dd> <p>Convert token <code><from></code> to <code><to></code> in the anonymized output. If <code><to></code> is omitted, map <code><from></code> to itself (i.e., do not anonymize it). See the section on <code>ANONYMIZING</code> below.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt---reference-excluded-parents"> --reference-excluded-parents </dt> <dd> <p>By default, running a command such as <code>git fast-export +master~5..master</code> will not include the commit master~5 and will make master~4 no longer have master~5 as a parent (though both the old master~4 and new master~4 will have all the same files). Use --reference-excluded-parents to instead have the stream refer to commits in the excluded range of history by their sha1sum. Note that the resulting stream can only be used by a repository which already contains the necessary parent commits.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt---show-original-ids"> --show-original-ids </dt> <dd> <p>Add an extra directive to the output for commits and blobs, <code>original-oid <SHA1SUM></code>. While such directives will likely be ignored by importers such as git-fast-import, it may be useful for intermediary filters (e.g. for rewriting commit messages which refer to older commits, or for stripping blobs by id).</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt---reencodeyesnoabort"> --reencode=(yes|no|abort) </dt> <dd> <p>Specify how to handle <code>encoding</code> header in commit objects. When asking to <code>abort</code> (which is the default), this program will die when encountering such a commit object. With <code>yes</code>, the commit message will be re-encoded into UTF-8. With <code>no</code>, the original encoding will be preserved.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt---refspec"> --refspec </dt> <dd> <p>Apply the specified refspec to each ref exported. Multiple of them can be specified.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-export.txt-ltgit-rev-list-argsgt82308203"> [<git-rev-list-args>…] </dt> <dd> <p>A list of arguments, acceptable to <code>git rev-parse</code> and <code>git rev-list</code>, that specifies the specific objects and references to export. For example, <code>master~10..master</code> causes the current master reference to be exported along with all objects added since its 10th ancestor commit and (unless the --reference-excluded-parents option is specified) all files common to master~9 and master~10.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fast-export --all | (cd /empty/repository && git fast-import)</pre> </div> </div> <p>This will export the whole repository and import it into the existing empty repository. Except for reencoding commits that are not in UTF-8, it would be a one-to-one mirror.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fast-export master~5..master | + sed "s|refs/heads/master|refs/heads/other|" | + git fast-import</pre> </div> </div> <p>This makes a new branch called <code>other</code> from <code>master~5..master</code> (i.e. if <code>master</code> has linear history, it will take the last 5 commits).</p> <p>Note that this assumes that none of the blobs and commit messages referenced by that revision range contains the string <code>refs/heads/master</code>.</p> </div> <h2 id="_anonymizing">Anonymizing</h2> <div class="sectionbody"> <p>If the <code>--anonymize</code> option is given, git will attempt to remove all identifying information from the repository while still retaining enough of the original tree and history patterns to reproduce some bugs. The goal is that a git bug which is found on a private repository will persist in the anonymized repository, and the latter can be shared with git developers to help solve the bug.</p> <p>With this option, git will replace all refnames, paths, blob contents, commit and tag messages, names, and email addresses in the output with anonymized data. Two instances of the same string will be replaced equivalently (e.g., two commits with the same author will have the same anonymized author in the output, but bear no resemblance to the original author string). The relationship between commits, branches, and tags is retained, as well as the commit timestamps (but the commit messages and refnames bear no resemblance to the originals). The relative makeup of the tree is retained (e.g., if you have a root tree with 10 files and 3 trees, so will the output), but their names and the contents of the files will be replaced.</p> <p>If you think you have found a git bug, you can start by exporting an anonymized stream of the whole repository:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fast-export --anonymize --all >anon-stream</pre> </div> </div> <p>Then confirm that the bug persists in a repository created from that stream (many bugs will not, as they really do depend on the exact repository contents):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git init anon-repo +$ cd anon-repo +$ git fast-import <../anon-stream +$ ... test your bug ...</pre> </div> </div> <p>If the anonymized repository shows the bug, it may be worth sharing <code>anon-stream</code> along with a regular bug report. Note that the anonymized stream compresses very well, so gzipping it is encouraged. If you want to examine the stream to see that it does not contain any private data, you can peruse it directly before sending. You may also want to try:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ perl -pe 's/\d+/X/g' <anon-stream | sort -u | less</pre> </div> </div> <p>which shows all of the unique lines (with numbers converted to "X", to collapse "User 0", "User 1", etc into "User X"). This produces a much smaller output, and it is usually easy to quickly confirm that there is no private data in the stream.</p> <p>Reproducing some bugs may require referencing particular commits or paths, which becomes challenging after refnames and paths have been anonymized. You can ask for a particular token to be left as-is or mapped to a new value. For example, if you have a bug which reproduces with <code>git rev-list sensitive -- secret.c</code>, you can run:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fast-export --anonymize --all \ + --anonymize-map=sensitive:foo \ + --anonymize-map=secret.c:bar.c \ + >stream</pre> </div> </div> <p>After importing the stream, you can then run <code>git rev-list foo -- bar.c</code> in the anonymized repository.</p> <p>Note that paths and refnames are split into tokens at slash boundaries. The command above would anonymize <code>subdir/secret.c</code> as something like <code>path123/bar.c</code>; you could then search for <code>bar.c</code> in the anonymized repository to determine the final pathname.</p> <p>To make referencing the final pathname simpler, you can map each path component; so if you also anonymize <code>subdir</code> to <code>publicdir</code>, then the final pathname would be <code>publicdir/bar.c</code>.</p> </div> <h2 id="_limitations">Limitations</h2> <div class="sectionbody"> <p>Since <code>git fast-import</code> cannot tag trees, you will not be able to export the linux.git repository completely, as it contains a tag referencing a tree instead of a commit.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-fast-import">git-fast-import[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-fast-export" class="_attribution-link">https://git-scm.com/docs/git-fast-export</a> + </p> +</div> diff --git a/devdocs/git/git-fast-import.html b/devdocs/git/git-fast-import.html new file mode 100644 index 00000000..a4de72a0 --- /dev/null +++ b/devdocs/git/git-fast-import.html @@ -0,0 +1,159 @@ +<h1>git-fast-import</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-fast-import - Backend for fast Git data importers</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content">frontend | git fast-import [<options>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This program is usually not what the end user wants to run directly. Most end users want to use one of the existing frontend programs, which parses a specific type of foreign source and feeds the contents stored there to <code>git fast-import</code>.</p> <p>fast-import reads a mixed command/data stream from standard input and writes one or more packfiles directly into the current repository. When EOF is received on standard input, fast import writes out updated branch and tag refs, fully updating the current repository with the newly imported data.</p> <p>The fast-import backend itself can import into an empty repository (one that has already been initialized by <code>git init</code>) or incrementally update an existing populated repository. Whether or not incremental imports are supported from a particular foreign source depends on the frontend program in use.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fast-import.txt---force"> --force </dt> <dd> <p>Force updating modified existing branches, even if doing so would cause commits to be lost (as the new commit does not contain the old commit).</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt---quiet"> --quiet </dt> <dd> <p>Disable the output shown by --stats, making fast-import usually be silent when it is successful. However, if the import stream has directives intended to show user output (e.g. <code>progress</code> directives), the corresponding messages will still be shown.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt---stats"> --stats </dt> <dd> <p>Display some basic statistics about the objects fast-import has created, the packfiles they were stored into, and the memory used by fast-import during this run. Showing this output is currently the default, but can be disabled with --quiet.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt---allow-unsafe-features"> --allow-unsafe-features </dt> <dd> <p>Many command-line options can be provided as part of the fast-import stream itself by using the <code>feature</code> or <code>option</code> commands. However, some of these options are unsafe (e.g., allowing fast-import to access the filesystem outside of the repository). These options are disabled by default, but can be allowed by providing this option on the command line. This currently impacts only the <code>export-marks</code>, <code>import-marks</code>, and <code>import-marks-if-exists</code> feature commands.</p> <div class="literalblock"> <div class="content"> <pre>Only enable this option if you trust the program generating the +fast-import stream! This option is enabled automatically for +remote-helpers that use the `import` capability, as they are +already trusted to run their own code.</pre> </div> </div> </dd> </dl> </div> <div class="sect2"> <h3 id="_options_for_frontends"> +Options for Frontends</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fast-import.txt---cat-blob-fdltfdgt"> --cat-blob-fd=<fd> </dt> <dd> <p>Write responses to <code>get-mark</code>, <code>cat-blob</code>, and <code>ls</code> queries to the file descriptor <fd> instead of <code>stdout</code>. Allows <code>progress</code> output intended for the end-user to be separated from other output.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt---date-formatltfmtgt"> --date-format=<fmt> </dt> <dd> <p>Specify the type of dates the frontend will supply to fast-import within <code>author</code>, <code>committer</code> and <code>tagger</code> commands. See “Date Formats” below for details about which formats are supported, and their syntax.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt---done"> --done </dt> <dd> <p>Terminate with error if there is no <code>done</code> command at the end of the stream. This option might be useful for detecting errors that cause the frontend to terminate before it has started to write a stream.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_locations_of_marks_files"> +Locations of Marks Files</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fast-import.txt---export-marksltfilegt"> --export-marks=<file> </dt> <dd> <p>Dumps the internal marks table to <file> when complete. Marks are written one per line as <code>:markid SHA-1</code>. Frontends can use this file to validate imports after they have been completed, or to save the marks table across incremental runs. As <file> is only opened and truncated at checkpoint (or completion) the same path can also be safely given to --import-marks.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt---import-marksltfilegt"> --import-marks=<file> </dt> <dd> <p>Before processing any input, load the marks specified in <file>. The input file must exist, must be readable, and must use the same format as produced by --export-marks. Multiple options may be supplied to import more than one set of marks. If a mark is defined to different values, the last file wins.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt---import-marks-if-existsltfilegt"> --import-marks-if-exists=<file> </dt> <dd> <p>Like --import-marks but instead of erroring out, silently skips the file if it does not exist.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt---no-relative-marks"> --[no-]relative-marks </dt> <dd> <p>After specifying --relative-marks the paths specified with --import-marks= and --export-marks= are relative to an internal directory in the current repository. In git-fast-import this means that the paths are relative to the .git/info/fast-import directory. However, other importers may use a different location.</p> <p>Relative and non-relative marks may be combined by interweaving --(no-)-relative-marks with the --(import|export)-marks= options.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_submodule_rewriting"> +Submodule Rewriting</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fast-import.txt---rewrite-submodules-fromltnamegtltfilegt"> --rewrite-submodules-from=<name>:<file> </dt> <dt class="hdlist1" id="Documentation/git-fast-import.txt---rewrite-submodules-toltnamegtltfilegt"> --rewrite-submodules-to=<name>:<file> </dt> <dd> <p> Rewrite the object IDs for the submodule specified by <name> from the values used in the from <file> to those used in the to <file>. The from marks should have been created by <code>git fast-export</code>, and the to marks should have been created by <code>git fast-import</code> when importing that same submodule.</p> <p><name> may be any arbitrary string not containing a colon character, but the same value must be used with both options when specifying corresponding marks. Multiple submodules may be specified with different values for <name>. It is an error not to use these options in corresponding pairs.</p> <p>These options are primarily useful when converting a repository from one hash algorithm to another; without them, fast-import will fail if it encounters a submodule because it has no way of writing the object ID into the new hash algorithm.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_performance_and_compression_tuning"> +Performance and Compression Tuning</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fast-import.txt---active-branchesltngt"> --active-branches=<n> </dt> <dd> <p>Maximum number of branches to maintain active at once. See “Memory Utilization” below for details. Default is 5.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt---big-file-thresholdltngt"> --big-file-threshold=<n> </dt> <dd> <p>Maximum size of a blob that fast-import will attempt to create a delta for, expressed in bytes. The default is 512m (512 MiB). Some importers may wish to lower this on systems with constrained memory.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt---depthltngt"> --depth=<n> </dt> <dd> <p>Maximum delta depth, for blob and tree deltification. Default is 50.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt---export-pack-edgesltfilegt"> --export-pack-edges=<file> </dt> <dd> <p>After creating a packfile, print a line of data to <file> listing the filename of the packfile and the last commit on each branch that was written to that packfile. This information may be useful after importing projects whose total object set exceeds the 4 GiB packfile limit, as these commits can be used as edge points during calls to <code>git pack-objects</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt---max-pack-sizeltngt"> --max-pack-size=<n> </dt> <dd> <p>Maximum size of each output packfile. The default is unlimited.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-fastimportunpackLimit"> fastimport.unpackLimit </dt> <dd> <p>See <a href="git-config">git-config[1]</a></p> </dd> </dl> </div> </div> </div> <h2 id="_performance">Performance</h2> <div class="sectionbody"> <p>The design of fast-import allows it to import large projects in a minimum amount of memory usage and processing time. Assuming the frontend is able to keep up with fast-import and feed it a constant stream of data, import times for projects holding 10+ years of history and containing 100,000+ individual commits are generally completed in just 1-2 hours on quite modest (~$2,000 USD) hardware.</p> <p>Most bottlenecks appear to be in foreign source data access (the source just cannot extract revisions fast enough) or disk IO (fast-import writes as fast as the disk will take the data). Imports will run faster if the source data is stored on a different drive than the destination Git repository (due to less IO contention).</p> </div> <h2 id="_development_cost">Development cost</h2> <div class="sectionbody"> <p>A typical frontend for fast-import tends to weigh in at approximately 200 lines of Perl/Python/Ruby code. Most developers have been able to create working importers in just a couple of hours, even though it is their first exposure to fast-import, and sometimes even to Git. This is an ideal situation, given that most conversion tools are throw-away (use once, and never look back).</p> </div> <h2 id="_parallel_operation">Parallel operation</h2> <div class="sectionbody"> <p>Like <code>git push</code> or <code>git fetch</code>, imports handled by fast-import are safe to run alongside parallel <code>git repack -a -d</code> or <code>git gc</code> invocations, or any other Git operation (including <code>git prune</code>, as loose objects are never used by fast-import).</p> <p>fast-import does not lock the branch or tag refs it is actively importing. After the import, during its ref update phase, fast-import tests each existing branch ref to verify the update will be a fast-forward update (the commit stored in the ref is contained in the new history of the commit to be written). If the update is not a fast-forward update, fast-import will skip updating that ref and instead prints a warning message. fast-import will always attempt to update all branch refs, and does not stop on the first failure.</p> <p>Branch updates can be forced with --force, but it’s recommended that this only be used on an otherwise quiet repository. Using --force is not necessary for an initial import into an empty repository.</p> </div> <h2 id="_technical_discussion">Technical discussion</h2> <div class="sectionbody"> <p>fast-import tracks a set of branches in memory. Any branch can be created or modified at any point during the import process by sending a <code>commit</code> command on the input stream. This design allows a frontend program to process an unlimited number of branches simultaneously, generating commits in the order they are available from the source data. It also simplifies the frontend programs considerably.</p> <p>fast-import does not use or alter the current working directory, or any file within it. (It does however update the current Git repository, as referenced by <code>GIT_DIR</code>.) Therefore an import frontend may use the working directory for its own purposes, such as extracting file revisions from the foreign source. This ignorance of the working directory also allows fast-import to run very quickly, as it does not need to perform any costly file update operations when switching between branches.</p> </div> <h2 id="_input_format">Input format</h2> <div class="sectionbody"> <p>With the exception of raw file data (which Git does not interpret) the fast-import input format is text (ASCII) based. This text based format simplifies development and debugging of frontend programs, especially when a higher level language such as Perl, Python or Ruby is being used.</p> <p>fast-import is very strict about its input. Where we say SP below we mean <strong>exactly</strong> one space. Likewise LF means one (and only one) linefeed and HT one (and only one) horizontal tab. Supplying additional whitespace characters will cause unexpected results, such as branch names or file names with leading or trailing spaces in their name, or early termination of fast-import when it encounters unexpected input.</p> <div class="sect2"> <h3 id="_stream_comments"> +Stream Comments</h3> <p>To aid in debugging frontends fast-import ignores any line that begins with <code>#</code> (ASCII pound/hash) up to and including the line ending <code>LF</code>. A comment line may contain any sequence of bytes that does not contain an LF and therefore may be used to include any detailed debugging information that might be specific to the frontend and useful when inspecting a fast-import data stream.</p> </div> <div class="sect2"> <h3 id="_date_formats"> +Date Formats</h3> <p>The following date formats are supported. A frontend should select the format it will use for this import by passing the format name in the --date-format=<fmt> command-line option.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fast-import.txt-coderawcode"> <code>raw</code> </dt> <dd> <p>This is the Git native format and is <code><time> SP <offutc></code>. It is also fast-import’s default format, if --date-format was not specified.</p> <p>The time of the event is specified by <code><time></code> as the number of seconds since the UNIX epoch (midnight, Jan 1, 1970, UTC) and is written as an ASCII decimal integer.</p> <p>The local offset is specified by <code><offutc></code> as a positive or negative offset from UTC. For example EST (which is 5 hours behind UTC) would be expressed in <code><tz></code> by “-0500” while UTC is “+0000”. The local offset does not affect <code><time></code>; it is used only as an advisement to help formatting routines display the timestamp.</p> <p>If the local offset is not available in the source material, use “+0000”, or the most common local offset. For example many organizations have a CVS repository which has only ever been accessed by users who are located in the same location and time zone. In this case a reasonable offset from UTC could be assumed.</p> <p>Unlike the <code>rfc2822</code> format, this format is very strict. Any variation in formatting will cause fast-import to reject the value, and some sanity checks on the numeric values may also be performed.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-coderaw-permissivecode"> <code>raw-permissive</code> </dt> <dd> <p>This is the same as <code>raw</code> except that no sanity checks on the numeric epoch and local offset are performed. This can be useful when trying to filter or import an existing history with e.g. bogus timezone values.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-coderfc2822code"> <code>rfc2822</code> </dt> <dd> <p>This is the standard email format as described by RFC 2822.</p> <p>An example value is “Tue Feb 6 11:22:18 2007 -0500”. The Git parser is accurate, but a little on the lenient side. It is the same parser used by <code>git am</code> when applying patches received from email.</p> <p>Some malformed strings may be accepted as valid dates. In some of these cases Git will still be able to obtain the correct date from the malformed string. There are also some types of malformed strings which Git will parse wrong, and yet consider valid. Seriously malformed strings will be rejected.</p> <p>Unlike the <code>raw</code> format above, the time zone/UTC offset information contained in an RFC 2822 date string is used to adjust the date value to UTC prior to storage. Therefore it is important that this information be as accurate as possible.</p> <p>If the source material uses RFC 2822 style dates, the frontend should let fast-import handle the parsing and conversion (rather than attempting to do it itself) as the Git parser has been well tested in the wild.</p> <p>Frontends should prefer the <code>raw</code> format if the source material already uses UNIX-epoch format, can be coaxed to give dates in that format, or its format is easily convertible to it, as there is no ambiguity in parsing.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-codenowcode"> <code>now</code> </dt> <dd> <p>Always use the current time and time zone. The literal <code>now</code> must always be supplied for <code><when></code>.</p> <p>This is a toy format. The current time and time zone of this system is always copied into the identity string at the time it is being created by fast-import. There is no way to specify a different time or time zone.</p> <p>This particular format is supplied as it’s short to implement and may be useful to a process that wants to create a new commit right now, without needing to use a working directory or <code>git update-index</code>.</p> <p>If separate <code>author</code> and <code>committer</code> commands are used in a <code>commit</code> the timestamps may not match, as the system clock will be polled twice (once for each command). The only way to ensure that both author and committer identity information has the same timestamp is to omit <code>author</code> (thus copying from <code>committer</code>) or to use a date format other than <code>now</code>.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_commands"> +Commands</h3> <p>fast-import accepts several commands to update the current repository and control the current import process. More detailed discussion (with examples) of each command follows later.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fast-import.txt-codecommitcode"> <code>commit</code> </dt> <dd> <p>Creates a new branch or updates an existing branch by creating a new commit and updating the branch to point at the newly created commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-codetagcode"> <code>tag</code> </dt> <dd> <p>Creates an annotated tag object from an existing commit or branch. Lightweight tags are not supported by this command, as they are not recommended for recording meaningful points in time.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-coderesetcode"> <code>reset</code> </dt> <dd> <p>Reset an existing branch (or a new branch) to a specific revision. This command must be used to change a branch to a specific revision without making a commit on it.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-codeblobcode"> <code>blob</code> </dt> <dd> <p>Convert raw file data into a blob, for future use in a <code>commit</code> command. This command is optional and is not needed to perform an import.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-codealiascode"> <code>alias</code> </dt> <dd> <p>Record that a mark refers to a given object without first creating any new object. Using --import-marks and referring to missing marks will cause fast-import to fail, so aliases can provide a way to set otherwise pruned commits to a valid value (e.g. the nearest non-pruned ancestor).</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-codecheckpointcode"> <code>checkpoint</code> </dt> <dd> <p>Forces fast-import to close the current packfile, generate its unique SHA-1 checksum and index, and start a new packfile. This command is optional and is not needed to perform an import.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-codeprogresscode"> <code>progress</code> </dt> <dd> <p>Causes fast-import to echo the entire line to its own standard output. This command is optional and is not needed to perform an import.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-codedonecode"> <code>done</code> </dt> <dd> <p>Marks the end of the stream. This command is optional unless the <code>done</code> feature was requested using the <code>--done</code> command-line option or <code>feature done</code> command.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-codeget-markcode"> <code>get-mark</code> </dt> <dd> <p>Causes fast-import to print the SHA-1 corresponding to a mark to the file descriptor set with <code>--cat-blob-fd</code>, or <code>stdout</code> if unspecified.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-codecat-blobcode"> <code>cat-blob</code> </dt> <dd> <p>Causes fast-import to print a blob in <code>cat-file --batch</code> format to the file descriptor set with <code>--cat-blob-fd</code> or <code>stdout</code> if unspecified.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-codelscode"> <code>ls</code> </dt> <dd> <p>Causes fast-import to print a line describing a directory entry in <code>ls-tree</code> format to the file descriptor set with <code>--cat-blob-fd</code> or <code>stdout</code> if unspecified.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-codefeaturecode"> <code>feature</code> </dt> <dd> <p>Enable the specified feature. This requires that fast-import supports the specified feature, and aborts if it does not.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-codeoptioncode"> <code>option</code> </dt> <dd> <p>Specify any of the options listed under OPTIONS that do not change stream semantic to suit the frontend’s needs. This command is optional and is not needed to perform an import.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_commit"> +<code>commit</code> +</h3> <p>Create or update a branch with a new commit, recording one logical change to the project.</p> <div class="literalblock"> <div class="content"> <pre> 'commit' SP <ref> LF + mark? + original-oid? + ('author' (SP <name>)? SP LT <email> GT SP <when> LF)? + 'committer' (SP <name>)? SP LT <email> GT SP <when> LF + ('encoding' SP <encoding>)? + data + ('from' SP <commit-ish> LF)? + ('merge' SP <commit-ish> LF)* + (filemodify | filedelete | filecopy | filerename | filedeleteall | notemodify)* + LF?</pre> </div> </div> <p>where <code><ref></code> is the name of the branch to make the commit on. Typically branch names are prefixed with <code>refs/heads/</code> in Git, so importing the CVS branch symbol <code>RELENG-1_0</code> would use <code>refs/heads/RELENG-1_0</code> for the value of <code><ref></code>. The value of <code><ref></code> must be a valid refname in Git. As <code>LF</code> is not valid in a Git refname, no quoting or escaping syntax is supported here.</p> <p>A <code>mark</code> command may optionally appear, requesting fast-import to save a reference to the newly created commit for future use by the frontend (see below for format). It is very common for frontends to mark every commit they create, thereby allowing future branch creation from any imported commit.</p> <p>The <code>data</code> command following <code>committer</code> must supply the commit message (see below for <code>data</code> command syntax). To import an empty commit message use a 0 length data. Commit messages are free-form and are not interpreted by Git. Currently they must be encoded in UTF-8, as fast-import does not permit other encodings to be specified.</p> <p>Zero or more <code>filemodify</code>, <code>filedelete</code>, <code>filecopy</code>, <code>filerename</code>, <code>filedeleteall</code> and <code>notemodify</code> commands may be included to update the contents of the branch prior to creating the commit. These commands may be supplied in any order. However it is recommended that a <code>filedeleteall</code> command precede all <code>filemodify</code>, <code>filecopy</code>, <code>filerename</code> and <code>notemodify</code> commands in the same commit, as <code>filedeleteall</code> wipes the branch clean (see below).</p> <p>The <code>LF</code> after the command is optional (it used to be required). Note that for reasons of backward compatibility, if the commit ends with a <code>data</code> command (i.e. it has no <code>from</code>, <code>merge</code>, <code>filemodify</code>, <code>filedelete</code>, <code>filecopy</code>, <code>filerename</code>, <code>filedeleteall</code> or <code>notemodify</code> commands) then two <code>LF</code> commands may appear at the end of the command instead of just one.</p> <div class="sect3"> <h4 id="_author"> +<code>author</code> +</h4> <p>An <code>author</code> command may optionally appear, if the author information might differ from the committer information. If <code>author</code> is omitted then fast-import will automatically use the committer’s information for the author portion of the commit. See below for a description of the fields in <code>author</code>, as they are identical to <code>committer</code>.</p> </div> <div class="sect3"> <h4 id="_committer"> +<code>committer</code> +</h4> <p>The <code>committer</code> command indicates who made this commit, and when they made it.</p> <p>Here <code><name></code> is the person’s display name (for example “Com M Itter”) and <code><email></code> is the person’s email address (“cm@example.com”). <code>LT</code> and <code>GT</code> are the literal less-than (\x3c) and greater-than (\x3e) symbols. These are required to delimit the email address from the other fields in the line. Note that <code><name></code> and <code><email></code> are free-form and may contain any sequence of bytes, except <code>LT</code>, <code>GT</code> and <code>LF</code>. <code><name></code> is typically UTF-8 encoded.</p> <p>The time of the change is specified by <code><when></code> using the date format that was selected by the --date-format=<fmt> command-line option. See “Date Formats” above for the set of supported formats, and their syntax.</p> </div> <div class="sect3"> <h4 id="_encoding"> +<code>encoding</code> +</h4> <p>The optional <code>encoding</code> command indicates the encoding of the commit message. Most commits are UTF-8 and the encoding is omitted, but this allows importing commit messages into git without first reencoding them.</p> </div> <div class="sect3"> <h4 id="_from"> +<code>from</code> +</h4> <p>The <code>from</code> command is used to specify the commit to initialize this branch from. This revision will be the first ancestor of the new commit. The state of the tree built at this commit will begin with the state at the <code>from</code> commit, and be altered by the content modifications in this commit.</p> <p>Omitting the <code>from</code> command in the first commit of a new branch will cause fast-import to create that commit with no ancestor. This tends to be desired only for the initial commit of a project. If the frontend creates all files from scratch when making a new branch, a <code>merge</code> command may be used instead of <code>from</code> to start the commit with an empty tree. Omitting the <code>from</code> command on existing branches is usually desired, as the current commit on that branch is automatically assumed to be the first ancestor of the new commit.</p> <p>As <code>LF</code> is not valid in a Git refname or SHA-1 expression, no quoting or escaping syntax is supported within <code><commit-ish></code>.</p> <p>Here <code><commit-ish></code> is any of the following:</p> <div class="ulist"> <ul> <li> <p>The name of an existing branch already in fast-import’s internal branch table. If fast-import doesn’t know the name, it’s treated as a SHA-1 expression.</p> </li> <li> <p>A mark reference, <code>:<idnum></code>, where <code><idnum></code> is the mark number.</p> <p>The reason fast-import uses <code>:</code> to denote a mark reference is this character is not legal in a Git branch name. The leading <code>:</code> makes it easy to distinguish between the mark 42 (<code>:42</code>) and the branch 42 (<code>42</code> or <code>refs/heads/42</code>), or an abbreviated SHA-1 which happened to consist only of base-10 digits.</p> <p>Marks must be declared (via <code>mark</code>) before they can be used.</p> </li> <li> <p>A complete 40 byte or abbreviated commit SHA-1 in hex.</p> </li> <li> <p>Any valid Git SHA-1 expression that resolves to a commit. See “SPECIFYING REVISIONS” in <a href="gitrevisions">gitrevisions[7]</a> for details.</p> </li> <li> <p>The special null SHA-1 (40 zeros) specifies that the branch is to be removed.</p> </li> </ul> </div> <p>The special case of restarting an incremental import from the current branch value should be written as:</p> <div class="listingblock"> <div class="content"> <pre> from refs/heads/branch^0</pre> </div> </div> <p>The <code>^0</code> suffix is necessary as fast-import does not permit a branch to start from itself, and the branch is created in memory before the <code>from</code> command is even read from the input. Adding <code>^0</code> will force fast-import to resolve the commit through Git’s revision parsing library, rather than its internal branch table, thereby loading in the existing value of the branch.</p> </div> <div class="sect3"> <h4 id="_merge"> +<code>merge</code> +</h4> <p>Includes one additional ancestor commit. The additional ancestry link does not change the way the tree state is built at this commit. If the <code>from</code> command is omitted when creating a new branch, the first <code>merge</code> commit will be the first ancestor of the current commit, and the branch will start out with no files. An unlimited number of <code>merge</code> commands per commit are permitted by fast-import, thereby establishing an n-way merge.</p> <p>Here <code><commit-ish></code> is any of the commit specification expressions also accepted by <code>from</code> (see above).</p> </div> <div class="sect3"> <h4 id="_filemodify"> +<code>filemodify</code> +</h4> <p>Included in a <code>commit</code> command to add a new file or change the content of an existing file. This command has two different means of specifying the content of the file.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fast-import.txt-Externaldataformat"> External data format </dt> <dd> <p>The data content for the file was already supplied by a prior <code>blob</code> command. The frontend just needs to connect it.</p> <div class="literalblock"> <div class="content"> <pre> 'M' SP <mode> SP <dataref> SP <path> LF</pre> </div> </div> <p>Here usually <code><dataref></code> must be either a mark reference (<code>:<idnum></code>) set by a prior <code>blob</code> command, or a full 40-byte SHA-1 of an existing Git blob object. If <code><mode></code> is <code>040000`</code> then <code><dataref></code> must be the full 40-byte SHA-1 of an existing Git tree object or a mark reference set with <code>--import-marks</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-Inlinedataformat"> Inline data format </dt> <dd> <p>The data content for the file has not been supplied yet. The frontend wants to supply it as part of this modify command.</p> <div class="literalblock"> <div class="content"> <pre> 'M' SP <mode> SP 'inline' SP <path> LF + data</pre> </div> </div> <p>See below for a detailed description of the <code>data</code> command.</p> </dd> </dl> </div> <p>In both formats <code><mode></code> is the type of file entry, specified in octal. Git only supports the following modes:</p> <div class="ulist"> <ul> <li> <p><code>100644</code> or <code>644</code>: A normal (not-executable) file. The majority of files in most projects use this mode. If in doubt, this is what you want.</p> </li> <li> <p><code>100755</code> or <code>755</code>: A normal, but executable, file.</p> </li> <li> <p><code>120000</code>: A symlink, the content of the file will be the link target.</p> </li> <li> <p><code>160000</code>: A gitlink, SHA-1 of the object refers to a commit in another repository. Git links can only be specified either by SHA or through a commit mark. They are used to implement submodules.</p> </li> <li> <p><code>040000</code>: A subdirectory. Subdirectories can only be specified by SHA or through a tree mark set with <code>--import-marks</code>.</p> </li> </ul> </div> <p>In both formats <code><path></code> is the complete path of the file to be added (if not already existing) or modified (if already existing).</p> <p>A <code><path></code> string must use UNIX-style directory separators (forward slash <code>/</code>), may contain any byte other than <code>LF</code>, and must not start with double quote (<code>"</code>).</p> <p>A path can use C-style string quoting; this is accepted in all cases and mandatory if the filename starts with double quote or contains <code>LF</code>. In C-style quoting, the complete name should be surrounded with double quotes, and any <code>LF</code>, backslash, or double quote characters must be escaped by preceding them with a backslash (e.g., <code>"path/with\n, \\ and \" in it"</code>).</p> <p>The value of <code><path></code> must be in canonical form. That is it must not:</p> <div class="ulist"> <ul> <li> <p>contain an empty directory component (e.g. <code>foo//bar</code> is invalid),</p> </li> <li> <p>end with a directory separator (e.g. <code>foo/</code> is invalid),</p> </li> <li> <p>start with a directory separator (e.g. <code>/foo</code> is invalid),</p> </li> <li> <p>contain the special component <code>.</code> or <code>..</code> (e.g. <code>foo/./bar</code> and <code>foo/../bar</code> are invalid).</p> </li> </ul> </div> <p>The root of the tree can be represented by an empty string as <code><path></code>.</p> <p>It is recommended that <code><path></code> always be encoded using UTF-8.</p> </div> <div class="sect3"> <h4 id="_filedelete"> +<code>filedelete</code> +</h4> <p>Included in a <code>commit</code> command to remove a file or recursively delete an entire directory from the branch. If the file or directory removal makes its parent directory empty, the parent directory will be automatically removed too. This cascades up the tree until the first non-empty directory or the root is reached.</p> <div class="literalblock"> <div class="content"> <pre> 'D' SP <path> LF</pre> </div> </div> <p>here <code><path></code> is the complete path of the file or subdirectory to be removed from the branch. See <code>filemodify</code> above for a detailed description of <code><path></code>.</p> </div> <div class="sect3"> <h4 id="_filecopy"> +<code>filecopy</code> +</h4> <p>Recursively copies an existing file or subdirectory to a different location within the branch. The existing file or directory must exist. If the destination exists it will be completely replaced by the content copied from the source.</p> <div class="literalblock"> <div class="content"> <pre> 'C' SP <path> SP <path> LF</pre> </div> </div> <p>here the first <code><path></code> is the source location and the second <code><path></code> is the destination. See <code>filemodify</code> above for a detailed description of what <code><path></code> may look like. To use a source path that contains SP the path must be quoted.</p> <p>A <code>filecopy</code> command takes effect immediately. Once the source location has been copied to the destination any future commands applied to the source location will not impact the destination of the copy.</p> </div> <div class="sect3"> <h4 id="_filerename"> +<code>filerename</code> +</h4> <p>Renames an existing file or subdirectory to a different location within the branch. The existing file or directory must exist. If the destination exists it will be replaced by the source directory.</p> <div class="literalblock"> <div class="content"> <pre> 'R' SP <path> SP <path> LF</pre> </div> </div> <p>here the first <code><path></code> is the source location and the second <code><path></code> is the destination. See <code>filemodify</code> above for a detailed description of what <code><path></code> may look like. To use a source path that contains SP the path must be quoted.</p> <p>A <code>filerename</code> command takes effect immediately. Once the source location has been renamed to the destination any future commands applied to the source location will create new files there and not impact the destination of the rename.</p> <p>Note that a <code>filerename</code> is the same as a <code>filecopy</code> followed by a <code>filedelete</code> of the source location. There is a slight performance advantage to using <code>filerename</code>, but the advantage is so small that it is never worth trying to convert a delete/add pair in source material into a rename for fast-import. This <code>filerename</code> command is provided just to simplify frontends that already have rename information and don’t want bother with decomposing it into a <code>filecopy</code> followed by a <code>filedelete</code>.</p> </div> <div class="sect3"> <h4 id="_filedeleteall"> +<code>filedeleteall</code> +</h4> <p>Included in a <code>commit</code> command to remove all files (and also all directories) from the branch. This command resets the internal branch structure to have no files in it, allowing the frontend to subsequently add all interesting files from scratch.</p> <div class="literalblock"> <div class="content"> <pre> 'deleteall' LF</pre> </div> </div> <p>This command is extremely useful if the frontend does not know (or does not care to know) what files are currently on the branch, and therefore cannot generate the proper <code>filedelete</code> commands to update the content.</p> <p>Issuing a <code>filedeleteall</code> followed by the needed <code>filemodify</code> commands to set the correct content will produce the same results as sending only the needed <code>filemodify</code> and <code>filedelete</code> commands. The <code>filedeleteall</code> approach may however require fast-import to use slightly more memory per active branch (less than 1 MiB for even most large projects); so frontends that can easily obtain only the affected paths for a commit are encouraged to do so.</p> </div> <div class="sect3"> <h4 id="_notemodify"> +<code>notemodify</code> +</h4> <p>Included in a <code>commit</code> <code><notes_ref></code> command to add a new note annotating a <code><commit-ish></code> or change this annotation contents. Internally it is similar to filemodify 100644 on <code><commit-ish></code> path (maybe split into subdirectories). It’s not advised to use any other commands to write to the <code><notes_ref></code> tree except <code>filedeleteall</code> to delete all existing notes in this tree. This command has two different means of specifying the content of the note.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fast-import.txt-Externaldataformat-1"> External data format </dt> <dd> <p>The data content for the note was already supplied by a prior <code>blob</code> command. The frontend just needs to connect it to the commit that is to be annotated.</p> <div class="literalblock"> <div class="content"> <pre> 'N' SP <dataref> SP <commit-ish> LF</pre> </div> </div> <p>Here <code><dataref></code> can be either a mark reference (<code>:<idnum></code>) set by a prior <code>blob</code> command, or a full 40-byte SHA-1 of an existing Git blob object.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-Inlinedataformat-1"> Inline data format </dt> <dd> <p>The data content for the note has not been supplied yet. The frontend wants to supply it as part of this modify command.</p> <div class="literalblock"> <div class="content"> <pre> 'N' SP 'inline' SP <commit-ish> LF + data</pre> </div> </div> <p>See below for a detailed description of the <code>data</code> command.</p> </dd> </dl> </div> <p>In both formats <code><commit-ish></code> is any of the commit specification expressions also accepted by <code>from</code> (see above).</p> </div> </div> <div class="sect2"> <h3 id="_mark"> +<code>mark</code> +</h3> <p>Arranges for fast-import to save a reference to the current object, allowing the frontend to recall this object at a future point in time, without knowing its SHA-1. Here the current object is the object creation command the <code>mark</code> command appears within. This can be <code>commit</code>, <code>tag</code>, and <code>blob</code>, but <code>commit</code> is the most common usage.</p> <div class="literalblock"> <div class="content"> <pre> 'mark' SP ':' <idnum> LF</pre> </div> </div> <p>where <code><idnum></code> is the number assigned by the frontend to this mark. The value of <code><idnum></code> is expressed as an ASCII decimal integer. The value 0 is reserved and cannot be used as a mark. Only values greater than or equal to 1 may be used as marks.</p> <p>New marks are created automatically. Existing marks can be moved to another object simply by reusing the same <code><idnum></code> in another <code>mark</code> command.</p> </div> <div class="sect2"> <h3 id="_original_oid"> +<code>original-oid</code> +</h3> <p>Provides the name of the object in the original source control system. fast-import will simply ignore this directive, but filter processes which operate on and modify the stream before feeding to fast-import may have uses for this information</p> <div class="literalblock"> <div class="content"> <pre> 'original-oid' SP <object-identifier> LF</pre> </div> </div> <p>where <code><object-identifier></code> is any string not containing LF.</p> </div> <div class="sect2"> <h3 id="_tag"> +<code>tag</code> +</h3> <p>Creates an annotated tag referring to a specific commit. To create lightweight (non-annotated) tags see the <code>reset</code> command below.</p> <div class="literalblock"> <div class="content"> <pre> 'tag' SP <name> LF + mark? + 'from' SP <commit-ish> LF + original-oid? + 'tagger' (SP <name>)? SP LT <email> GT SP <when> LF + data</pre> </div> </div> <p>where <code><name></code> is the name of the tag to create.</p> <p>Tag names are automatically prefixed with <code>refs/tags/</code> when stored in Git, so importing the CVS branch symbol <code>RELENG-1_0-FINAL</code> would use just <code>RELENG-1_0-FINAL</code> for <code><name></code>, and fast-import will write the corresponding ref as <code>refs/tags/RELENG-1_0-FINAL</code>.</p> <p>The value of <code><name></code> must be a valid refname in Git and therefore may contain forward slashes. As <code>LF</code> is not valid in a Git refname, no quoting or escaping syntax is supported here.</p> <p>The <code>from</code> command is the same as in the <code>commit</code> command; see above for details.</p> <p>The <code>tagger</code> command uses the same format as <code>committer</code> within <code>commit</code>; again see above for details.</p> <p>The <code>data</code> command following <code>tagger</code> must supply the annotated tag message (see below for <code>data</code> command syntax). To import an empty tag message use a 0 length data. Tag messages are free-form and are not interpreted by Git. Currently they must be encoded in UTF-8, as fast-import does not permit other encodings to be specified.</p> <p>Signing annotated tags during import from within fast-import is not supported. Trying to include your own PGP/GPG signature is not recommended, as the frontend does not (easily) have access to the complete set of bytes which normally goes into such a signature. If signing is required, create lightweight tags from within fast-import with <code>reset</code>, then create the annotated versions of those tags offline with the standard <code>git tag</code> process.</p> </div> <div class="sect2"> <h3 id="_reset"> +<code>reset</code> +</h3> <p>Creates (or recreates) the named branch, optionally starting from a specific revision. The reset command allows a frontend to issue a new <code>from</code> command for an existing branch, or to create a new branch from an existing commit without creating a new commit.</p> <div class="literalblock"> <div class="content"> <pre> 'reset' SP <ref> LF + ('from' SP <commit-ish> LF)? + LF?</pre> </div> </div> <p>For a detailed description of <code><ref></code> and <code><commit-ish></code> see above under <code>commit</code> and <code>from</code>.</p> <p>The <code>LF</code> after the command is optional (it used to be required).</p> <p>The <code>reset</code> command can also be used to create lightweight (non-annotated) tags. For example:</p> <div class="exampleblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre>reset refs/tags/938 +from :938</pre> </div> </div> </div> </div> <p>would create the lightweight tag <code>refs/tags/938</code> referring to whatever commit mark <code>:938</code> references.</p> </div> <div class="sect2"> <h3 id="_blob"> +<code>blob</code> +</h3> <p>Requests writing one file revision to the packfile. The revision is not connected to any commit; this connection must be formed in a subsequent <code>commit</code> command by referencing the blob through an assigned mark.</p> <div class="literalblock"> <div class="content"> <pre> 'blob' LF + mark? + original-oid? + data</pre> </div> </div> <p>The mark command is optional here as some frontends have chosen to generate the Git SHA-1 for the blob on their own, and feed that directly to <code>commit</code>. This is typically more work than it’s worth however, as marks are inexpensive to store and easy to use.</p> </div> <div class="sect2"> <h3 id="_data"> +<code>data</code> +</h3> <p>Supplies raw data (for use as blob/file content, commit messages, or annotated tag messages) to fast-import. Data can be supplied using an exact byte count or delimited with a terminating line. Real frontends intended for production-quality conversions should always use the exact byte count format, as it is more robust and performs better. The delimited format is intended primarily for testing fast-import.</p> <p>Comment lines appearing within the <code><raw></code> part of <code>data</code> commands are always taken to be part of the body of the data and are therefore never ignored by fast-import. This makes it safe to import any file/message content whose lines might start with <code>#</code>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fast-import.txt-Exactbytecountformat"> Exact byte count format </dt> <dd> <p>The frontend must specify the number of bytes of data.</p> <div class="literalblock"> <div class="content"> <pre> 'data' SP <count> LF + <raw> LF?</pre> </div> </div> <p>where <code><count></code> is the exact number of bytes appearing within <code><raw></code>. The value of <code><count></code> is expressed as an ASCII decimal integer. The <code>LF</code> on either side of <code><raw></code> is not included in <code><count></code> and will not be included in the imported data.</p> <p>The <code>LF</code> after <code><raw></code> is optional (it used to be required) but recommended. Always including it makes debugging a fast-import stream easier as the next command always starts in column 0 of the next line, even if <code><raw></code> did not end with an <code>LF</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-Delimitedformat"> Delimited format </dt> <dd> <p>A delimiter string is used to mark the end of the data. fast-import will compute the length by searching for the delimiter. This format is primarily useful for testing and is not recommended for real data.</p> <div class="literalblock"> <div class="content"> <pre> 'data' SP '<<' <delim> LF + <raw> LF + <delim> LF + LF?</pre> </div> </div> <p>where <code><delim></code> is the chosen delimiter string. The string <code><delim></code> must not appear on a line by itself within <code><raw></code>, as otherwise fast-import will think the data ends earlier than it really does. The <code>LF</code> immediately trailing <code><raw></code> is part of <code><raw></code>. This is one of the limitations of the delimited format, it is impossible to supply a data chunk which does not have an LF as its last byte.</p> <p>The <code>LF</code> after <code><delim> LF</code> is optional (it used to be required).</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_alias"> +<code>alias</code> +</h3> <p>Record that a mark refers to a given object without first creating any new object.</p> <div class="literalblock"> <div class="content"> <pre> 'alias' LF + mark + 'to' SP <commit-ish> LF + LF?</pre> </div> </div> <p>For a detailed description of <code><commit-ish></code> see above under <code>from</code>.</p> </div> <div class="sect2"> <h3 id="_checkpoint"> +<code>checkpoint</code> +</h3> <p>Forces fast-import to close the current packfile, start a new one, and to save out all current branch refs, tags and marks.</p> <div class="literalblock"> <div class="content"> <pre> 'checkpoint' LF + LF?</pre> </div> </div> <p>Note that fast-import automatically switches packfiles when the current packfile reaches --max-pack-size, or 4 GiB, whichever limit is smaller. During an automatic packfile switch fast-import does not update the branch refs, tags or marks.</p> <p>As a <code>checkpoint</code> can require a significant amount of CPU time and disk IO (to compute the overall pack SHA-1 checksum, generate the corresponding index file, and update the refs) it can easily take several minutes for a single <code>checkpoint</code> command to complete.</p> <p>Frontends may choose to issue checkpoints during extremely large and long running imports, or when they need to allow another Git process access to a branch. However given that a 30 GiB Subversion repository can be loaded into Git through fast-import in about 3 hours, explicit checkpointing may not be necessary.</p> <p>The <code>LF</code> after the command is optional (it used to be required).</p> </div> <div class="sect2"> <h3 id="_progress"> +<code>progress</code> +</h3> <p>Causes fast-import to print the entire <code>progress</code> line unmodified to its standard output channel (file descriptor 1) when the command is processed from the input stream. The command otherwise has no impact on the current import, or on any of fast-import’s internal state.</p> <div class="literalblock"> <div class="content"> <pre> 'progress' SP <any> LF + LF?</pre> </div> </div> <p>The <code><any></code> part of the command may contain any sequence of bytes that does not contain <code>LF</code>. The <code>LF</code> after the command is optional. Callers may wish to process the output through a tool such as sed to remove the leading part of the line, for example:</p> <div class="exampleblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre>frontend | git fast-import | sed 's/^progress //'</pre> </div> </div> </div> </div> <p>Placing a <code>progress</code> command immediately after a <code>checkpoint</code> will inform the reader when the <code>checkpoint</code> has been completed and it can safely access the refs that fast-import updated.</p> </div> <div class="sect2"> <h3 id="_get_mark"> +<code>get-mark</code> +</h3> <p>Causes fast-import to print the SHA-1 corresponding to a mark to stdout or to the file descriptor previously arranged with the <code>--cat-blob-fd</code> argument. The command otherwise has no impact on the current import; its purpose is to retrieve SHA-1s that later commits might want to refer to in their commit messages.</p> <div class="literalblock"> <div class="content"> <pre> 'get-mark' SP ':' <idnum> LF</pre> </div> </div> <p>See “Responses To Commands” below for details about how to read this output safely.</p> </div> <div class="sect2"> <h3 id="_cat_blob"> +<code>cat-blob</code> +</h3> <p>Causes fast-import to print a blob to a file descriptor previously arranged with the <code>--cat-blob-fd</code> argument. The command otherwise has no impact on the current import; its main purpose is to retrieve blobs that may be in fast-import’s memory but not accessible from the target repository.</p> <div class="literalblock"> <div class="content"> <pre> 'cat-blob' SP <dataref> LF</pre> </div> </div> <p>The <code><dataref></code> can be either a mark reference (<code>:<idnum></code>) set previously or a full 40-byte SHA-1 of a Git blob, preexisting or ready to be written.</p> <p>Output uses the same format as <code>git cat-file --batch</code>:</p> <div class="exampleblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre><sha1> SP 'blob' SP <size> LF +<contents> LF</pre> </div> </div> </div> </div> <p>This command can be used where a <code>filemodify</code> directive can appear, allowing it to be used in the middle of a commit. For a <code>filemodify</code> using an inline directive, it can also appear right before the <code>data</code> directive.</p> <p>See “Responses To Commands” below for details about how to read this output safely.</p> </div> <div class="sect2"> <h3 id="_ls"> +<code>ls</code> +</h3> <p>Prints information about the object at a path to a file descriptor previously arranged with the <code>--cat-blob-fd</code> argument. This allows printing a blob from the active commit (with <code>cat-blob</code>) or copying a blob or tree from a previous commit for use in the current one (with <code>filemodify</code>).</p> <p>The <code>ls</code> command can also be used where a <code>filemodify</code> directive can appear, allowing it to be used in the middle of a commit.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fast-import.txt-Readingfromtheactivecommit"> Reading from the active commit </dt> <dd> <p>This form can only be used in the middle of a <code>commit</code>. The path names a directory entry within fast-import’s active commit. The path must be quoted in this case.</p> <div class="literalblock"> <div class="content"> <pre> 'ls' SP <path> LF</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-Readingfromanamedtree"> Reading from a named tree </dt> <dd> <p>The <code><dataref></code> can be a mark reference (<code>:<idnum></code>) or the full 40-byte SHA-1 of a Git tag, commit, or tree object, preexisting or waiting to be written. The path is relative to the top level of the tree named by <code><dataref></code>.</p> <div class="literalblock"> <div class="content"> <pre> 'ls' SP <dataref> SP <path> LF</pre> </div> </div> </dd> </dl> </div> <p>See <code>filemodify</code> above for a detailed description of <code><path></code>.</p> <p>Output uses the same format as <code>git ls-tree <tree> -- <path></code>:</p> <div class="exampleblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre><mode> SP ('blob' | 'tree' | 'commit') SP <dataref> HT <path> LF</pre> </div> </div> </div> </div> <p>The <dataref> represents the blob, tree, or commit object at <path> and can be used in later <code>get-mark</code>, <code>cat-blob</code>, <code>filemodify</code>, or <code>ls</code> commands.</p> <p>If there is no file or subtree at that path, <code>git fast-import</code> will instead report</p> <div class="exampleblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre>missing SP <path> LF</pre> </div> </div> </div> </div> <p>See “Responses To Commands” below for details about how to read this output safely.</p> </div> <div class="sect2"> <h3 id="_feature"> +<code>feature</code> +</h3> <p>Require that fast-import supports the specified feature, or abort if it does not.</p> <div class="literalblock"> <div class="content"> <pre> 'feature' SP <feature> ('=' <argument>)? LF</pre> </div> </div> <p>The <feature> part of the command may be any one of the following:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fast-import.txt-date-format"> date-format </dt> <dt class="hdlist1" id="Documentation/git-fast-import.txt-export-marks"> export-marks </dt> <dt class="hdlist1" id="Documentation/git-fast-import.txt-relative-marks"> relative-marks </dt> <dt class="hdlist1" id="Documentation/git-fast-import.txt-no-relative-marks"> no-relative-marks </dt> <dt class="hdlist1" id="Documentation/git-fast-import.txt-force"> force </dt> <dd> <p>Act as though the corresponding command-line option with a leading <code>--</code> was passed on the command line (see OPTIONS, above).</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-import-marks"> import-marks </dt> <dt class="hdlist1" id="Documentation/git-fast-import.txt-import-marks-if-exists"> import-marks-if-exists </dt> <dd> <p>Like --import-marks except in two respects: first, only one "feature import-marks" or "feature import-marks-if-exists" command is allowed per stream; second, an --import-marks= or --import-marks-if-exists command-line option overrides any of these "feature" commands in the stream; third, "feature import-marks-if-exists" like a corresponding command-line option silently skips a nonexistent file.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-get-mark"> get-mark </dt> <dt class="hdlist1" id="Documentation/git-fast-import.txt-cat-blob"> cat-blob </dt> <dt class="hdlist1" id="Documentation/git-fast-import.txt-ls"> ls </dt> <dd> <p>Require that the backend support the <code>get-mark</code>, <code>cat-blob</code>, or <code>ls</code> command respectively. Versions of fast-import not supporting the specified command will exit with a message indicating so. This lets the import error out early with a clear message, rather than wasting time on the early part of an import before the unsupported command is detected.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-notes"> notes </dt> <dd> <p>Require that the backend support the <code>notemodify</code> (N) subcommand to the <code>commit</code> command. Versions of fast-import not supporting notes will exit with a message indicating so.</p> </dd> <dt class="hdlist1" id="Documentation/git-fast-import.txt-done"> done </dt> <dd> <p>Error out if the stream ends without a <code>done</code> command. Without this feature, errors causing the frontend to end abruptly at a convenient point in the stream can go undetected. This may occur, for example, if an import front end dies in mid-operation without emitting SIGTERM or SIGKILL at its subordinate git fast-import instance.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_option"> +<code>option</code> +</h3> <p>Processes the specified option so that git fast-import behaves in a way that suits the frontend’s needs. Note that options specified by the frontend are overridden by any options the user may specify to git fast-import itself.</p> <div class="literalblock"> <div class="content"> <pre> 'option' SP <option> LF</pre> </div> </div> <p>The <code><option></code> part of the command may contain any of the options listed in the OPTIONS section that do not change import semantics, without the leading <code>--</code> and is treated in the same way.</p> <p>Option commands must be the first commands on the input (not counting feature commands), to give an option command after any non-option command is an error.</p> <p>The following command-line options change import semantics and may therefore not be passed as option:</p> <div class="ulist"> <ul> <li> <p>date-format</p> </li> <li> <p>import-marks</p> </li> <li> <p>export-marks</p> </li> <li> <p>cat-blob-fd</p> </li> <li> <p>force</p> </li> </ul> </div> </div> <div class="sect2"> <h3 id="_done"> +<code>done</code> +</h3> <p>If the <code>done</code> feature is not in use, treated as if EOF was read. This can be used to tell fast-import to finish early.</p> <p>If the <code>--done</code> command-line option or <code>feature done</code> command is in use, the <code>done</code> command is mandatory and marks the end of the stream.</p> </div> </div> <h2 id="_responses_to_commands">Responses to commands</h2> <div class="sectionbody"> <p>New objects written by fast-import are not available immediately. Most fast-import commands have no visible effect until the next checkpoint (or completion). The frontend can send commands to fill fast-import’s input pipe without worrying about how quickly they will take effect, which improves performance by simplifying scheduling.</p> <p>For some frontends, though, it is useful to be able to read back data from the current repository as it is being updated (for example when the source material describes objects in terms of patches to be applied to previously imported objects). This can be accomplished by connecting the frontend and fast-import via bidirectional pipes:</p> <div class="exampleblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre>mkfifo fast-import-output +frontend <fast-import-output | +git fast-import >fast-import-output</pre> </div> </div> </div> </div> <p>A frontend set up this way can use <code>progress</code>, <code>get-mark</code>, <code>ls</code>, and <code>cat-blob</code> commands to read information from the import in progress.</p> <p>To avoid deadlock, such frontends must completely consume any pending output from <code>progress</code>, <code>ls</code>, <code>get-mark</code>, and <code>cat-blob</code> before performing writes to fast-import that might block.</p> </div> <h2 id="_crash_reports">Crash reports</h2> <div class="sectionbody"> <p>If fast-import is supplied invalid input it will terminate with a non-zero exit status and create a crash report in the top level of the Git repository it was importing into. Crash reports contain a snapshot of the internal fast-import state as well as the most recent commands that lead up to the crash.</p> <p>All recent commands (including stream comments, file changes and progress commands) are shown in the command history within the crash report, but raw file data and commit messages are excluded from the crash report. This exclusion saves space within the report file and reduces the amount of buffering that fast-import must perform during execution.</p> <p>After writing a crash report fast-import will close the current packfile and export the marks table. This allows the frontend developer to inspect the repository state and resume the import from the point where it crashed. The modified branches and tags are not updated during a crash, as the import did not complete successfully. Branch and tag information can be found in the crash report and must be applied manually if the update is needed.</p> <p>An example crash:</p> <div class="exampleblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$ cat >in <<END_OF_INPUT +# my very first test commit +commit refs/heads/master +committer Shawn O. Pearce <spearce> 19283 -0400 +# who is that guy anyway? +data <<EOF +this is my commit +EOF +M 644 inline .gitignore +data <<EOF +.gitignore +EOF +M 777 inline bob +END_OF_INPUT</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$ git fast-import <in +fatal: Corrupt mode: M 777 inline bob +fast-import: dumping crash report to .git/fast_import_crash_8434</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$ cat .git/fast_import_crash_8434 +fast-import crash report: + fast-import process: 8434 + parent process : 1391 + at Sat Sep 1 00:58:12 2007</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>fatal: Corrupt mode: M 777 inline bob</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Most Recent Commands Before Crash +--------------------------------- + # my very first test commit + commit refs/heads/master + committer Shawn O. Pearce <spearce> 19283 -0400 + # who is that guy anyway? + data <<EOF + M 644 inline .gitignore + data <<EOF +* M 777 inline bob</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Active Branch LRU +----------------- + active_branches = 1 cur, 5 max</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>pos clock name +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 1) 0 refs/heads/master</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Inactive Branches +----------------- +refs/heads/master: + status : active loaded dirty + tip commit : 0000000000000000000000000000000000000000 + old tree : 0000000000000000000000000000000000000000 + cur tree : 0000000000000000000000000000000000000000 + commit clock: 0 + last pack :</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>------------------- +END OF CRASH REPORT</pre> </div> </div> </div> </div> </div> <h2 id="_tips_and_tricks">Tips and tricks</h2> <div class="sectionbody"> <p>The following tips and tricks have been collected from various users of fast-import, and are offered here as suggestions.</p> <div class="sect2"> <h3 id="_use_one_mark_per_commit"> +Use One Mark Per Commit</h3> <p>When doing a repository conversion, use a unique mark per commit (<code>mark :<n></code>) and supply the --export-marks option on the command line. fast-import will dump a file which lists every mark and the Git object SHA-1 that corresponds to it. If the frontend can tie the marks back to the source repository, it is easy to verify the accuracy and completeness of the import by comparing each Git commit to the corresponding source revision.</p> <p>Coming from a system such as Perforce or Subversion, this should be quite simple, as the fast-import mark can also be the Perforce changeset number or the Subversion revision number.</p> </div> <div class="sect2"> <h3 id="_freely_skip_around_branches"> +Freely Skip Around Branches</h3> <p>Don’t bother trying to optimize the frontend to stick to one branch at a time during an import. Although doing so might be slightly faster for fast-import, it tends to increase the complexity of the frontend code considerably.</p> <p>The branch LRU builtin to fast-import tends to behave very well, and the cost of activating an inactive branch is so low that bouncing around between branches has virtually no impact on import performance.</p> </div> <div class="sect2"> <h3 id="_handling_renames"> +Handling Renames</h3> <p>When importing a renamed file or directory, simply delete the old name(s) and modify the new name(s) during the corresponding commit. Git performs rename detection after-the-fact, rather than explicitly during a commit.</p> </div> <div class="sect2"> <h3 id="_use_tag_fixup_branches"> +Use Tag Fixup Branches</h3> <p>Some other SCM systems let the user create a tag from multiple files which are not from the same commit/changeset. Or to create tags which are a subset of the files available in the repository.</p> <p>Importing these tags as-is in Git is impossible without making at least one commit which “fixes up” the files to match the content of the tag. Use fast-import’s <code>reset</code> command to reset a dummy branch outside of your normal branch space to the base commit for the tag, then commit one or more file fixup commits, and finally tag the dummy branch.</p> <p>For example since all normal branches are stored under <code>refs/heads/</code> name the tag fixup branch <code>TAG_FIXUP</code>. This way it is impossible for the fixup branch used by the importer to have namespace conflicts with real branches imported from the source (the name <code>TAG_FIXUP</code> is not <code>refs/heads/TAG_FIXUP</code>).</p> <p>When committing fixups, consider using <code>merge</code> to connect the commit(s) which are supplying file revisions to the fixup branch. Doing so will allow tools such as <code>git blame</code> to track through the real commit history and properly annotate the source files.</p> <p>After fast-import terminates the frontend will need to do <code>rm .git/TAG_FIXUP</code> to remove the dummy branch.</p> </div> <div class="sect2"> <h3 id="_import_now_repack_later"> +Import Now, Repack Later</h3> <p>As soon as fast-import completes the Git repository is completely valid and ready for use. Typically this takes only a very short time, even for considerably large projects (100,000+ commits).</p> <p>However repacking the repository is necessary to improve data locality and access performance. It can also take hours on extremely large projects (especially if -f and a large --window parameter is used). Since repacking is safe to run alongside readers and writers, run the repack in the background and let it finish when it finishes. There is no reason to wait to explore your new Git project!</p> <p>If you choose to wait for the repack, don’t try to run benchmarks or performance tests until repacking is completed. fast-import outputs suboptimal packfiles that are simply never seen in real use situations.</p> </div> <div class="sect2"> <h3 id="_repacking_historical_data"> +Repacking Historical Data</h3> <p>If you are repacking very old imported data (e.g. older than the last year), consider expending some extra CPU time and supplying --window=50 (or higher) when you run <code>git repack</code>. This will take longer, but will also produce a smaller packfile. You only need to expend the effort once, and everyone using your project will benefit from the smaller repository.</p> </div> <div class="sect2"> <h3 id="_include_some_progress_messages"> +Include Some Progress Messages</h3> <p>Every once in a while have your frontend emit a <code>progress</code> message to fast-import. The contents of the messages are entirely free-form, so one suggestion would be to output the current month and year each time the current commit date moves into the next month. Your users will feel better knowing how much of the data stream has been processed.</p> </div> </div> <h2 id="_packfile_optimization">Packfile optimization</h2> <div class="sectionbody"> <p>When packing a blob fast-import always attempts to deltify against the last blob written. Unless specifically arranged for by the frontend, this will probably not be a prior version of the same file, so the generated delta will not be the smallest possible. The resulting packfile will be compressed, but will not be optimal.</p> <p>Frontends which have efficient access to all revisions of a single file (for example reading an RCS/CVS ,v file) can choose to supply all revisions of that file as a sequence of consecutive <code>blob</code> commands. This allows fast-import to deltify the different file revisions against each other, saving space in the final packfile. Marks can be used to later identify individual file revisions during a sequence of <code>commit</code> commands.</p> <p>The packfile(s) created by fast-import do not encourage good disk access patterns. This is caused by fast-import writing the data in the order it is received on standard input, while Git typically organizes data within packfiles to make the most recent (current tip) data appear before historical data. Git also clusters commits together, speeding up revision traversal through better cache locality.</p> <p>For this reason it is strongly recommended that users repack the repository with <code>git repack -a -d</code> after fast-import completes, allowing Git to reorganize the packfiles for faster data access. If blob deltas are suboptimal (see above) then also adding the <code>-f</code> option to force recomputation of all deltas can significantly reduce the final packfile size (30-50% smaller can be quite typical).</p> <p>Instead of running <code>git repack</code> you can also run <code>git gc +--aggressive</code>, which will also optimize other things after an import (e.g. pack loose refs). As noted in the "AGGRESSIVE" section in <a href="git-gc">git-gc[1]</a> the <code>--aggressive</code> option will find new deltas with the <code>-f</code> option to <a href="git-repack">git-repack[1]</a>. For the reasons elaborated on above using <code>--aggressive</code> after a fast-import is one of the few cases where it’s known to be worthwhile.</p> </div> <h2 id="_memory_utilization">Memory utilization</h2> <div class="sectionbody"> <p>There are a number of factors which affect how much memory fast-import requires to perform an import. Like critical sections of core Git, fast-import uses its own memory allocators to amortize any overheads associated with malloc. In practice fast-import tends to amortize any malloc overheads to 0, due to its use of large block allocations.</p> <div class="sect2"> <h3 id="_per_object"> +per object</h3> <p>fast-import maintains an in-memory structure for every object written in this execution. On a 32 bit system the structure is 32 bytes, on a 64 bit system the structure is 40 bytes (due to the larger pointer sizes). Objects in the table are not deallocated until fast-import terminates. Importing 2 million objects on a 32 bit system will require approximately 64 MiB of memory.</p> <p>The object table is actually a hashtable keyed on the object name (the unique SHA-1). This storage configuration allows fast-import to reuse an existing or already written object and avoid writing duplicates to the output packfile. Duplicate blobs are surprisingly common in an import, typically due to branch merges in the source.</p> </div> <div class="sect2"> <h3 id="_per_mark"> +per mark</h3> <p>Marks are stored in a sparse array, using 1 pointer (4 bytes or 8 bytes, depending on pointer size) per mark. Although the array is sparse, frontends are still strongly encouraged to use marks between 1 and n, where n is the total number of marks required for this import.</p> </div> <div class="sect2"> <h3 id="_per_branch"> +per branch</h3> <p>Branches are classified as active and inactive. The memory usage of the two classes is significantly different.</p> <p>Inactive branches are stored in a structure which uses 96 or 120 bytes (32 bit or 64 bit systems, respectively), plus the length of the branch name (typically under 200 bytes), per branch. fast-import will easily handle as many as 10,000 inactive branches in under 2 MiB of memory.</p> <p>Active branches have the same overhead as inactive branches, but also contain copies of every tree that has been recently modified on that branch. If subtree <code>include</code> has not been modified since the branch became active, its contents will not be loaded into memory, but if subtree <code>src</code> has been modified by a commit since the branch became active, then its contents will be loaded in memory.</p> <p>As active branches store metadata about the files contained on that branch, their in-memory storage size can grow to a considerable size (see below).</p> <p>fast-import automatically moves active branches to inactive status based on a simple least-recently-used algorithm. The LRU chain is updated on each <code>commit</code> command. The maximum number of active branches can be increased or decreased on the command line with --active-branches=.</p> </div> <div class="sect2"> <h3 id="_per_active_tree"> +per active tree</h3> <p>Trees (aka directories) use just 12 bytes of memory on top of the memory required for their entries (see “per active file” below). The cost of a tree is virtually 0, as its overhead amortizes out over the individual file entries.</p> </div> <div class="sect2"> <h3 id="_per_active_file_entry"> +per active file entry</h3> <p>Files (and pointers to subtrees) within active trees require 52 or 64 bytes (32/64 bit platforms) per entry. To conserve space, file and tree names are pooled in a common string table, allowing the filename “Makefile” to use just 16 bytes (after including the string header overhead) no matter how many times it occurs within the project.</p> <p>The active branch LRU, when coupled with the filename string pool and lazy loading of subtrees, allows fast-import to efficiently import projects with 2,000+ branches and 45,114+ files in a very limited memory footprint (less than 2.7 MiB per active branch).</p> </div> </div> <h2 id="_signals">Signals</h2> <div class="sectionbody"> <p>Sending <strong>SIGUSR1</strong> to the <code>git fast-import</code> process ends the current packfile early, simulating a <code>checkpoint</code> command. The impatient operator can use this facility to peek at the objects and refs from an import in progress, at the cost of some added running time and worse compression.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fast-import.txt-fastimportunpackLimit-1"> fastimport.unpackLimit </dt> <dd> <p>If the number of objects imported by <a href="git-fast-import">git-fast-import[1]</a> is below this limit, then the objects will be unpacked into loose object files. However, if the number of imported objects equals or exceeds this limit, then the pack will be stored as a pack. Storing the pack from a fast-import can make the import operation complete faster, especially on slow filesystems. If not set, the value of <code>transfer.unpackLimit</code> is used instead.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-fast-export">git-fast-export[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-fast-import" class="_attribution-link">https://git-scm.com/docs/git-fast-import</a> + </p> +</div> diff --git a/devdocs/git/git-fetch-pack.html b/devdocs/git/git-fetch-pack.html new file mode 100644 index 00000000..fd505718 --- /dev/null +++ b/devdocs/git/git-fetch-pack.html @@ -0,0 +1,9 @@ +<h1>git-fetch-pack</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-fetch-pack - Receive missing objects from another repository</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--include-tag] + [--upload-pack=<git-upload-pack>] + [--depth=<n>] [--no-progress] + [-v] <repository> [<refs>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Usually you would want to use <code>git fetch</code>, which is a higher level wrapper of this command, instead.</p> <p>Invokes <code>git-upload-pack</code> on a possibly remote repository and asks it to send objects missing from this repository, to update the named heads. The list of commits available locally is found out by scanning the local refs/ hierarchy and sent to <code>git-upload-pack</code> running on the other end.</p> <p>This command degenerates to download everything to complete the asked refs from the remote side when the local side does not have a common ancestor commit.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt---all"> --all </dt> <dd> <p>Fetch all remote refs.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt---stdin"> --stdin </dt> <dd> <p>Take the list of refs from stdin, one per line. If there are refs specified on the command line in addition to this option, then the refs from stdin are processed after those on the command line.</p> <p>If <code>--stateless-rpc</code> is specified together with this option then the list of refs must be in packet format (pkt-line). Each ref must be in a separate packet, and the list must end with a flush packet.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt---quiet"> --quiet </dt> <dd> <p>Pass <code>-q</code> flag to <code>git unpack-objects</code>; this makes the cloning process less verbose.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt--k"> -k </dt> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt---keep"> --keep </dt> <dd> <p>Do not invoke <code>git unpack-objects</code> on received data, but create a single packfile out of it instead, and store it in the object database. If provided twice then the pack is locked against repacking.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt---thin"> --thin </dt> <dd> <p>Fetch a "thin" pack, which records objects in deltified form based on objects not included in the pack to reduce network traffic.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt---include-tag"> --include-tag </dt> <dd> <p>If the remote side supports it, annotated tags objects will be downloaded on the same connection as the other objects if the object the tag references is downloaded. The caller must otherwise determine the tags this option made available.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt---upload-packltgit-upload-packgt"> --upload-pack=<git-upload-pack> </dt> <dd> <p>Use this to specify the path to <code>git-upload-pack</code> on the remote side, if it is not found on your $PATH. Installations of sshd ignores the user’s environment setup scripts for login shells (e.g. .bash_profile) and your privately installed git may not be found on the system default $PATH. Another workaround suggested is to set up your $PATH in ".bashrc", but this flag is for people who do not want to pay the overhead for non-interactive shells by having a lean .bashrc file (they set most of the things up in .bash_profile).</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt---execltgit-upload-packgt"> --exec=<git-upload-pack> </dt> <dd> <p>Same as --upload-pack=<git-upload-pack>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt---depthltngt"> --depth=<n> </dt> <dd> <p>Limit fetching to ancestor-chains not longer than n. <code>git-upload-pack</code> treats the special depth 2147483647 as infinite even if there is an ancestor-chain that long.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt---shallow-sinceltdategt"> --shallow-since=<date> </dt> <dd> <p>Deepen or shorten the history of a shallow repository to include all reachable commits after <date>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt---shallow-excludeltrevisiongt"> --shallow-exclude=<revision> </dt> <dd> <p>Deepen or shorten the history of a shallow repository to exclude commits reachable from a specified remote branch or tag. This option can be specified multiple times.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt---deepen-relative"> --deepen-relative </dt> <dd> <p>Argument --depth specifies the number of commits from the current shallow boundary instead of from the tip of each remote branch history.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt---refetch"> --refetch </dt> <dd> <p>Skips negotiating commits with the server in order to fetch all matching objects. Use to reapply a new partial clone blob/tree filter.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt---no-progress"> --no-progress </dt> <dd> <p>Do not show the progress.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt---check-self-contained-and-connected"> --check-self-contained-and-connected </dt> <dd> <p>Output "connectivity-ok" if the received pack is self-contained and connected.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt--v"> -v </dt> <dd> <p>Run verbosely.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt-ltrepositorygt"> <repository> </dt> <dd> <p>The URL to the remote repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch-pack.txt-ltrefsgt82308203"> <refs>… </dt> <dd> <p>The remote heads to update from. This is relative to $GIT_DIR (e.g. "HEAD", "refs/heads/master"). When unspecified, update from all heads the remote side has.</p> <p>If the remote has enabled the options <code>uploadpack.allowTipSHA1InWant</code>, <code>uploadpack.allowReachableSHA1InWant</code>, or <code>uploadpack.allowAnySHA1InWant</code>, they may alternatively be 40-hex sha1s present on the remote.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-fetch">git-fetch[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-fetch-pack" class="_attribution-link">https://git-scm.com/docs/git-fetch-pack</a> + </p> +</div> diff --git a/devdocs/git/git-fetch.html b/devdocs/git/git-fetch.html new file mode 100644 index 00000000..0da8b780 --- /dev/null +++ b/devdocs/git/git-fetch.html @@ -0,0 +1,39 @@ +<h1>git-fetch</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-fetch - Download objects and refs from another repository</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git fetch [<options>] [<repository> [<refspec>…]] +git fetch [<options>] <group> +git fetch --multiple [<options>] [(<repository> | <group>)…] +git fetch --all [<options>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Fetch branches and/or tags (collectively, "refs") from one or more other repositories, along with the objects necessary to complete their histories. Remote-tracking branches are updated (see the description of <refspec> below for ways to control this behavior).</p> <p>By default, any tag that points into the histories being fetched is also fetched; the effect is to fetch tags that point at branches that you are interested in. This default behavior can be changed by using the --tags or --no-tags options or by configuring remote.<name>.tagOpt. By using a refspec that fetches tags explicitly, you can fetch tags that do not point into branches you are interested in as well.</p> <p><code>git fetch</code> can fetch from either a single named repository or URL, or from several repositories at once if <group> is given and there is a remotes.<group> entry in the configuration file. (See <a href="git-config">git-config[1]</a>).</p> <p>When no remote is specified, by default the <code>origin</code> remote will be used, unless there’s an upstream branch configured for the current branch.</p> <p>The names of refs that are fetched, together with the object names they point at, are written to <code>.git/FETCH_HEAD</code>. This information may be used by scripts or other git commands, such as <a href="git-pull">git-pull[1]</a>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fetch.txt---all"> --all </dt> <dd> <p>Fetch all remotes.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-fetch.txt---append"> --append </dt> <dd> <p>Append ref names and object names of fetched refs to the existing contents of <code>.git/FETCH_HEAD</code>. Without this option old data in <code>.git/FETCH_HEAD</code> will be overwritten.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---atomic"> --atomic </dt> <dd> <p>Use an atomic transaction to update local refs. Either all refs are updated, or on error, no refs are updated.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---depthltdepthgt"> --depth=<depth> </dt> <dd> <p>Limit fetching to the specified number of commits from the tip of each remote branch history. If fetching to a <code>shallow</code> repository created by <code>git clone</code> with <code>--depth=<depth></code> option (see <a href="git-clone">git-clone[1]</a>), deepen or shorten the history to the specified number of commits. Tags for the deepened commits are not fetched.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---deepenltdepthgt"> --deepen=<depth> </dt> <dd> <p>Similar to --depth, except it specifies the number of commits from the current shallow boundary instead of from the tip of each remote branch history.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---shallow-sinceltdategt"> --shallow-since=<date> </dt> <dd> <p>Deepen or shorten the history of a shallow repository to include all reachable commits after <date>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---shallow-excludeltrevisiongt"> --shallow-exclude=<revision> </dt> <dd> <p>Deepen or shorten the history of a shallow repository to exclude commits reachable from a specified remote branch or tag. This option can be specified multiple times.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---unshallow"> --unshallow </dt> <dd> <p>If the source repository is complete, convert a shallow repository to a complete one, removing all the limitations imposed by shallow repositories.</p> <p>If the source repository is shallow, fetch as much as possible so that the current repository has the same history as the source repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---update-shallow"> --update-shallow </dt> <dd> <p>By default when fetching from a shallow repository, <code>git fetch</code> refuses refs that require updating .git/shallow. This option updates .git/shallow and accepts such refs.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---negotiation-tipltcommitglobgt"> --negotiation-tip=<commit|glob> </dt> <dd> <p>By default, Git will report, to the server, commits reachable from all local refs to find common commits in an attempt to reduce the size of the to-be-received packfile. If specified, Git will only report commits reachable from the given tips. This is useful to speed up fetches when the user knows which local ref is likely to have commits in common with the upstream ref being fetched.</p> <p>This option may be specified more than once; if so, Git will report commits reachable from any of the given commits.</p> <p>The argument to this option may be a glob on ref names, a ref, or the (possibly abbreviated) SHA-1 of a commit. Specifying a glob is equivalent to specifying this option multiple times, one for each matching ref name.</p> <p>See also the <code>fetch.negotiationAlgorithm</code> and <code>push.negotiate</code> configuration variables documented in <a href="git-config">git-config[1]</a>, and the <code>--negotiate-only</code> option below.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---negotiate-only"> --negotiate-only </dt> <dd> <p>Do not fetch anything from the server, and instead print the ancestors of the provided <code>--negotiation-tip=*</code> arguments, which we have in common with the server.</p> <p>This is incompatible with <code>--recurse-submodules=[yes|on-demand]</code>. Internally this is used to implement the <code>push.negotiate</code> option, see <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---dry-run"> --dry-run </dt> <dd> <p>Show what would be done, without making any changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---porcelain"> --porcelain </dt> <dd> <p>Print the output to standard output in an easy-to-parse format for scripts. See section OUTPUT in <a href="git-fetch">git-fetch[1]</a> for details.</p> <p>This is incompatible with <code>--recurse-submodules=[yes|on-demand]</code> and takes precedence over the <code>fetch.output</code> config option.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---no-write-fetch-head"> --[no-]write-fetch-head </dt> <dd> <p>Write the list of remote refs fetched in the <code>FETCH_HEAD</code> file directly under <code>$GIT_DIR</code>. This is the default. Passing <code>--no-write-fetch-head</code> from the command line tells Git not to write the file. Under <code>--dry-run</code> option, the file is never written.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-fetch.txt---force"> --force </dt> <dd> <p>When <code>git fetch</code> is used with <code><src>:<dst></code> refspec, it may refuse to update the local branch as discussed in the <code><refspec></code> part below. This option overrides that check.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt--k"> -k </dt> <dt class="hdlist1" id="Documentation/git-fetch.txt---keep"> --keep </dt> <dd> <p>Keep downloaded pack.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---multiple"> --multiple </dt> <dd> <p>Allow several <repository> and <group> arguments to be specified. No <refspec>s may be specified.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---no-auto-maintenance"> --[no-]auto-maintenance </dt> <dt class="hdlist1" id="Documentation/git-fetch.txt---no-auto-gc"> --[no-]auto-gc </dt> <dd> <p>Run <code>git maintenance run --auto</code> at the end to perform automatic repository maintenance if needed. (<code>--[no-]auto-gc</code> is a synonym.) This is enabled by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---no-write-commit-graph"> --[no-]write-commit-graph </dt> <dd> <p>Write a commit-graph after fetching. This overrides the config setting <code>fetch.writeCommitGraph</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---prefetch"> --prefetch </dt> <dd> <p>Modify the configured refspec to place all refs into the <code>refs/prefetch/</code> namespace. See the <code>prefetch</code> task in <a href="git-maintenance">git-maintenance[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-fetch.txt---prune"> --prune </dt> <dd> <p>Before fetching, remove any remote-tracking references that no longer exist on the remote. Tags are not subject to pruning if they are fetched only because of the default tag auto-following or due to a --tags option. However, if tags are fetched due to an explicit refspec (either on the command line or in the remote configuration, for example if the remote was cloned with the --mirror option), then they are also subject to pruning. Supplying <code>--prune-tags</code> is a shorthand for providing the tag refspec.</p> <p>See the PRUNING section below for more details.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt--P"> -P </dt> <dt class="hdlist1" id="Documentation/git-fetch.txt---prune-tags"> --prune-tags </dt> <dd> <p>Before fetching, remove any local tags that no longer exist on the remote if <code>--prune</code> is enabled. This option should be used more carefully, unlike <code>--prune</code> it will remove any local references (local tags) that have been created. This option is a shorthand for providing the explicit tag refspec along with <code>--prune</code>, see the discussion about that in its documentation.</p> <p>See the PRUNING section below for more details.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-fetch.txt---no-tags"> --no-tags </dt> <dd> <p>By default, tags that point at objects that are downloaded from the remote repository are fetched and stored locally. This option disables this automatic tag following. The default behavior for a remote may be specified with the remote.<name>.tagOpt setting. See <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---refetch"> --refetch </dt> <dd> <p>Instead of negotiating with the server to avoid transferring commits and associated objects that are already present locally, this option fetches all objects as a fresh clone would. Use this to reapply a partial clone filter from configuration or using <code>--filter=</code> when the filter definition has changed. Automatic post-fetch maintenance will perform object database pack consolidation to remove any duplicate objects.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---refmapltrefspecgt"> --refmap=<refspec> </dt> <dd> <p>When fetching refs listed on the command line, use the specified refspec (can be given more than once) to map the refs to remote-tracking branches, instead of the values of <code>remote.*.fetch</code> configuration variables for the remote repository. Providing an empty <code><refspec></code> to the <code>--refmap</code> option causes Git to ignore the configured refspecs and rely entirely on the refspecs supplied as command-line arguments. See section on "Configured Remote-tracking Branches" for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt--t"> -t </dt> <dt class="hdlist1" id="Documentation/git-fetch.txt---tags"> --tags </dt> <dd> <p>Fetch all tags from the remote (i.e., fetch remote tags <code>refs/tags/*</code> into local tags with the same name), in addition to whatever else would otherwise be fetched. Using this option alone does not subject tags to pruning, even if --prune is used (though tags may be pruned anyway if they are also the destination of an explicit refspec; see <code>--prune</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---recurse-submodulesyeson-demandno"> --recurse-submodules[=yes|on-demand|no] </dt> <dd> <p>This option controls if and under what conditions new commits of submodules should be fetched too. When recursing through submodules, <code>git fetch</code> always attempts to fetch "changed" submodules, that is, a submodule that has commits that are referenced by a newly fetched superproject commit but are missing in the local submodule clone. A changed submodule can be fetched as long as it is present locally e.g. in <code>$GIT_DIR/modules/</code> (see <a href="gitsubmodules">gitsubmodules[7]</a>); if the upstream adds a new submodule, that submodule cannot be fetched until it is cloned e.g. by <code>git submodule update</code>.</p> <p>When set to <code>on-demand</code>, only changed submodules are fetched. When set to <code>yes</code>, all populated submodules are fetched and submodules that are both unpopulated and changed are fetched. When set to <code>no</code>, submodules are never fetched.</p> <p>When unspecified, this uses the value of <code>fetch.recurseSubmodules</code> if it is set (see <a href="git-config">git-config[1]</a>), defaulting to <code>on-demand</code> if unset. When this option is used without any value, it defaults to <code>yes</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt--j"> -j </dt> <dt class="hdlist1" id="Documentation/git-fetch.txt---jobsltngt"> --jobs=<n> </dt> <dd> <p>Number of parallel children to be used for all forms of fetching.</p> <p>If the <code>--multiple</code> option was specified, the different remotes will be fetched in parallel. If multiple submodules are fetched, they will be fetched in parallel. To control them independently, use the config settings <code>fetch.parallel</code> and <code>submodule.fetchJobs</code> (see <a href="git-config">git-config[1]</a>).</p> <p>Typically, parallel recursive and multi-remote fetches will be faster. By default fetches are performed sequentially, not in parallel.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---no-recurse-submodules"> --no-recurse-submodules </dt> <dd> <p>Disable recursive fetching of submodules (this has the same effect as using the <code>--recurse-submodules=no</code> option).</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---set-upstream"> --set-upstream </dt> <dd> <p>If the remote is fetched successfully, add upstream (tracking) reference, used by argument-less <a href="git-pull">git-pull[1]</a> and other commands. For more information, see <code>branch.<name>.merge</code> and <code>branch.<name>.remote</code> in <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---submodule-prefixltpathgt"> --submodule-prefix=<path> </dt> <dd> <p>Prepend <path> to paths printed in informative messages such as "Fetching submodule foo". This option is used internally when recursing over submodules.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---recurse-submodules-defaultyeson-demand"> --recurse-submodules-default=[yes|on-demand] </dt> <dd> <p>This option is used internally to temporarily provide a non-negative default value for the --recurse-submodules option. All other methods of configuring fetch’s submodule recursion (such as settings in <a href="gitmodules">gitmodules[5]</a> and <a href="git-config">git-config[1]</a>) override this option, as does specifying --[no-]recurse-submodules directly.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt--u"> -u </dt> <dt class="hdlist1" id="Documentation/git-fetch.txt---update-head-ok"> --update-head-ok </dt> <dd> <p>By default <code>git fetch</code> refuses to update the head which corresponds to the current branch. This flag disables the check. This is purely for the internal use for <code>git pull</code> to communicate with <code>git fetch</code>, and unless you are implementing your own Porcelain you are not supposed to use it.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---upload-packltupload-packgt"> --upload-pack <upload-pack> </dt> <dd> <p>When given, and the repository to fetch from is handled by <code>git fetch-pack</code>, <code>--exec=<upload-pack></code> is passed to the command to specify non-default path for the command run on the other end.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-fetch.txt---quiet"> --quiet </dt> <dd> <p>Pass --quiet to git-fetch-pack and silence any other internally used git commands. Progress is not reported to the standard error stream.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-fetch.txt---verbose"> --verbose </dt> <dd> <p>Be verbose.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---progress"> --progress </dt> <dd> <p>Progress status is reported on the standard error stream by default when it is attached to a terminal, unless -q is specified. This flag forces progress status even if the standard error stream is not directed to a terminal.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt--oltoptiongt"> -o <option> </dt> <dt class="hdlist1" id="Documentation/git-fetch.txt---server-optionltoptiongt"> --server-option=<option> </dt> <dd> <p>Transmit the given string to the server when communicating using protocol version 2. The given string must not contain a NUL or LF character. The server’s handling of server options, including unknown ones, is server-specific. When multiple <code>--server-option=<option></code> are given, they are all sent to the other side in the order listed on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---show-forced-updates"> --show-forced-updates </dt> <dd> <p>By default, git checks if a branch is force-updated during fetch. This can be disabled through fetch.showForcedUpdates, but the --show-forced-updates option guarantees this check occurs. See <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---no-show-forced-updates"> --no-show-forced-updates </dt> <dd> <p>By default, git checks if a branch is force-updated during fetch. Pass --no-show-forced-updates or set fetch.showForcedUpdates to false to skip this check for performance reasons. If used during <code>git-pull</code> the --ff-only option will still check for forced updates before attempting a fast-forward update. See <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt--4"> -4 </dt> <dt class="hdlist1" id="Documentation/git-fetch.txt---ipv4"> --ipv4 </dt> <dd> <p>Use IPv4 addresses only, ignoring IPv6 addresses.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt--6"> -6 </dt> <dt class="hdlist1" id="Documentation/git-fetch.txt---ipv6"> --ipv6 </dt> <dd> <p>Use IPv6 addresses only, ignoring IPv4 addresses.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-ltrepositorygt"> <repository> </dt> <dd> <p>The "remote" repository that is the source of a fetch or pull operation. This parameter can be either a URL (see the section <a href="#URLS">GIT URLS</a> below) or the name of a remote (see the section <a href="#REMOTES">REMOTES</a> below).</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-ltgroupgt"> <group> </dt> <dd> <p>A name referring to a list of repositories as the value of remotes.<group> in the configuration file. (See <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-ltrefspecgt"> <refspec> </dt> <dd> <p>Specifies which refs to fetch and which local refs to update. When no <refspec>s appear on the command line, the refs to fetch are read from <code>remote.<repository>.fetch</code> variables instead (see <a href="#CRTB">CONFIGURED REMOTE-TRACKING BRANCHES</a> below).</p> <p>The format of a <refspec> parameter is an optional plus <code>+</code>, followed by the source <src>, followed by a colon <code>:</code>, followed by the destination ref <dst>. The colon can be omitted when <dst> is empty. <src> is typically a ref, but it can also be a fully spelled hex object name.</p> <p>A <refspec> may contain a <code>*</code> in its <src> to indicate a simple pattern match. Such a refspec functions like a glob that matches any ref with the same prefix. A pattern <refspec> must have a <code>*</code> in both the <src> and <dst>. It will map refs to the destination by replacing the <code>*</code> with the contents matched from the source.</p> <p>If a refspec is prefixed by <code>^</code>, it will be interpreted as a negative refspec. Rather than specifying which refs to fetch or which local refs to update, such a refspec will instead specify refs to exclude. A ref will be considered to match if it matches at least one positive refspec, and does not match any negative refspec. Negative refspecs can be useful to restrict the scope of a pattern refspec so that it will not include specific refs. Negative refspecs can themselves be pattern refspecs. However, they may only contain a <src> and do not specify a <dst>. Fully spelled out hex object names are also not supported.</p> <p><code>tag <tag></code> means the same as <code>refs/tags/<tag>:refs/tags/<tag></code>; it requests fetching everything up to the given tag.</p> <p>The remote ref that matches <src> is fetched, and if <dst> is not an empty string, an attempt is made to update the local ref that matches it.</p> <p>Whether that update is allowed without <code>--force</code> depends on the ref namespace it’s being fetched to, the type of object being fetched, and whether the update is considered to be a fast-forward. Generally, the same rules apply for fetching as when pushing, see the <code><refspec>...</code> section of <a href="git-push">git-push[1]</a> for what those are. Exceptions to those rules particular to <code>git fetch</code> are noted below.</p> <p>Until Git version 2.20, and unlike when pushing with <a href="git-push">git-push[1]</a>, any updates to <code>refs/tags/*</code> would be accepted without <code>+</code> in the refspec (or <code>--force</code>). When fetching, we promiscuously considered all tag updates from a remote to be forced fetches. Since Git version 2.20, fetching to update <code>refs/tags/*</code> works the same way as when pushing. I.e. any updates will be rejected without <code>+</code> in the refspec (or <code>--force</code>).</p> <p>Unlike when pushing with <a href="git-push">git-push[1]</a>, any updates outside of <code>refs/{tags,heads}/*</code> will be accepted without <code>+</code> in the refspec (or <code>--force</code>), whether that’s swapping e.g. a tree object for a blob, or a commit for another commit that doesn’t have the previous commit as an ancestor etc.</p> <p>Unlike when pushing with <a href="git-push">git-push[1]</a>, there is no configuration which’ll amend these rules, and nothing like a <code>pre-fetch</code> hook analogous to the <code>pre-receive</code> hook.</p> <p>As with pushing with <a href="git-push">git-push[1]</a>, all of the rules described above about what’s not allowed as an update can be overridden by adding an optional leading <code>+</code> to a refspec (or using the <code>--force</code> command line option). The only exception to this is that no amount of forcing will make the <code>refs/heads/*</code> namespace accept a non-commit object.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> When the remote branch you want to fetch is known to be rewound and rebased regularly, it is expected that its new tip will not be a descendant of its previous tip (as stored in your remote-tracking branch the last time you fetched). You would want to use the <code>+</code> sign to indicate non-fast-forward updates will be needed for such branches. There is no way to determine or declare that a branch will be made available in a repository with this behavior; the pulling user simply must know this is the expected usage pattern for a branch. </td> </tr> </table> </div> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt---stdin"> --stdin </dt> <dd> <p>Read refspecs, one per line, from stdin in addition to those provided as arguments. The "tag <name>" format is not supported.</p> </dd> </dl> </div> </div> <h2 id="_git_urls">Git urls</h2> <div class="sectionbody"> <p>In general, URLs contain information about the transport protocol, the address of the remote server, and the path to the repository. Depending on the transport protocol, some of this information may be absent.</p> <p>Git supports ssh, git, http, and https protocols (in addition, ftp and ftps can be used for fetching, but this is inefficient and deprecated; do not use them).</p> <p>The native transport (i.e. git:// URL) does no authentication and should be used with caution on unsecured networks.</p> <p>The following syntaxes may be used with them:</p> <div class="ulist"> <ul> <li> <p>ssh://[user@]host.xz[:port]/path/to/repo.git/</p> </li> <li> <p>git://host.xz[:port]/path/to/repo.git/</p> </li> <li> <p>http[s]://host.xz[:port]/path/to/repo.git/</p> </li> <li> <p>ftp[s]://host.xz[:port]/path/to/repo.git/</p> </li> </ul> </div> <p>An alternative scp-like syntax may also be used with the ssh protocol:</p> <div class="ulist"> <ul> <li> <p>[user@]host.xz:path/to/repo.git/</p> </li> </ul> </div> <p>This syntax is only recognized if there are no slashes before the first colon. This helps differentiate a local path that contains a colon. For example the local path <code>foo:bar</code> could be specified as an absolute path or <code>./foo:bar</code> to avoid being misinterpreted as an ssh url.</p> <p>The ssh and git protocols additionally support ~username expansion:</p> <div class="ulist"> <ul> <li> <p>ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/</p> </li> <li> <p>git://host.xz[:port]/~[user]/path/to/repo.git/</p> </li> <li> <p>[user@]host.xz:/~[user]/path/to/repo.git/</p> </li> </ul> </div> <p>For local repositories, also supported by Git natively, the following syntaxes may be used:</p> <div class="ulist"> <ul> <li> <p>/path/to/repo.git/</p> </li> <li> <p>file:///path/to/repo.git/</p> </li> </ul> </div> <p>These two syntaxes are mostly equivalent, except when cloning, when the former implies --local option. See <a href="git-clone">git-clone[1]</a> for details.</p> <p><code>git clone</code>, <code>git fetch</code> and <code>git pull</code>, but not <code>git push</code>, will also accept a suitable bundle file. See <a href="git-bundle">git-bundle[1]</a>.</p> <p>When Git doesn’t know how to handle a certain transport protocol, it attempts to use the <code>remote-<transport></code> remote helper, if one exists. To explicitly request a remote helper, the following syntax may be used:</p> <div class="ulist"> <ul> <li> <p><transport>::<address></p> </li> </ul> </div> <p>where <address> may be a path, a server and path, or an arbitrary URL-like string recognized by the specific remote helper being invoked. See <a href="gitremote-helpers">gitremote-helpers[7]</a> for details.</p> <p>If there are a large number of similarly-named remote repositories and you want to use a different format for them (such that the URLs you use will be rewritten into URLs that work), you can create a configuration section of the form:</p> <div class="listingblock"> <div class="content"> <pre> [url "<actual url base>"] + insteadOf = <other url base></pre> </div> </div> <p>For example, with this:</p> <div class="listingblock"> <div class="content"> <pre> [url "git://git.host.xz/"] + insteadOf = host.xz:/path/to/ + insteadOf = work:</pre> </div> </div> <p>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</p> <p>If you want to rewrite URLs for push only, you can create a configuration section of the form:</p> <div class="listingblock"> <div class="content"> <pre> [url "<actual url base>"] + pushInsteadOf = <other url base></pre> </div> </div> <p>For example, with this:</p> <div class="listingblock"> <div class="content"> <pre> [url "ssh://example.org/"] + pushInsteadOf = git://example.org/</pre> </div> </div> <p>a URL like "git://example.org/path/to/repo.git" will be rewritten to "ssh://example.org/path/to/repo.git" for pushes, but pulls will still use the original URL.</p> </div> <h2 id="_remotes">Remotes</h2> <div class="sectionbody"> <p>The name of one of the following can be used instead of a URL as <code><repository></code> argument:</p> <div class="ulist"> <ul> <li> <p>a remote in the Git configuration file: <code>$GIT_DIR/config</code>,</p> </li> <li> <p>a file in the <code>$GIT_DIR/remotes</code> directory, or</p> </li> <li> <p>a file in the <code>$GIT_DIR/branches</code> directory.</p> </li> </ul> </div> <p>All of these also allow you to omit the refspec from the command line because they each contain a refspec which git will use by default.</p> <div class="sect2"> <h3 id="_named_remote_in_configuration_file"> +Named remote in configuration file</h3> <p>You can choose to provide the name of a remote which you had previously configured using <a href="git-remote">git-remote[1]</a>, <a href="git-config">git-config[1]</a> or even by a manual edit to the <code>$GIT_DIR/config</code> file. The URL of this remote will be used to access the repository. The refspec of this remote will be used by default when you do not provide a refspec on the command line. The entry in the config file would appear like this:</p> <div class="listingblock"> <div class="content"> <pre> [remote "<name>"] + url = <URL> + pushurl = <pushurl> + push = <refspec> + fetch = <refspec></pre> </div> </div> <p>The <code><pushurl></code> is used for pushes only. It is optional and defaults to <code><URL></code>. Pushing to a remote affects all defined pushurls or all defined urls if no pushurls are defined. Fetch, however, will only fetch from the first defined url if multiple urls are defined.</p> </div> <div class="sect2"> <h3 id="_named_file_in_git_dirremotes"> +Named file in <code>$GIT_DIR/remotes</code> +</h3> <p>You can choose to provide the name of a file in <code>$GIT_DIR/remotes</code>. The URL in this file will be used to access the repository. The refspec in this file will be used as default when you do not provide a refspec on the command line. This file should have the following format:</p> <div class="listingblock"> <div class="content"> <pre> URL: one of the above URL formats + Push: <refspec> + Pull: <refspec></pre> </div> </div> <p><code>Push:</code> lines are used by <code>git push</code> and <code>Pull:</code> lines are used by <code>git pull</code> and <code>git fetch</code>. Multiple <code>Push:</code> and <code>Pull:</code> lines may be specified for additional branch mappings.</p> </div> <div class="sect2"> <h3 id="_named_file_in_git_dirbranches"> +Named file in <code>$GIT_DIR/branches</code> +</h3> <p>You can choose to provide the name of a file in <code>$GIT_DIR/branches</code>. The URL in this file will be used to access the repository. This file should have the following format:</p> <div class="listingblock"> <div class="content"> <pre> <URL>#<head></pre> </div> </div> <p><code><URL></code> is required; <code>#<head></code> is optional.</p> <p>Depending on the operation, git will use one of the following refspecs, if you don’t provide one on the command line. <code><branch></code> is the name of this file in <code>$GIT_DIR/branches</code> and <code><head></code> defaults to <code>master</code>.</p> <p>git fetch uses:</p> <div class="listingblock"> <div class="content"> <pre> refs/heads/<head>:refs/heads/<branch></pre> </div> </div> <p>git push uses:</p> <div class="listingblock"> <div class="content"> <pre> HEAD:refs/heads/<head></pre> </div> </div> </div> </div> <h2 id="_configured_remote_tracking_branches">Configured remote-tracking branches</h2> <div class="sectionbody"> <p>You often interact with the same remote repository by regularly and repeatedly fetching from it. In order to keep track of the progress of such a remote repository, <code>git fetch</code> allows you to configure <code>remote.<repository>.fetch</code> configuration variables.</p> <p>Typically such a variable may look like this:</p> <div class="listingblock"> <div class="content"> <pre>[remote "origin"] + fetch = +refs/heads/*:refs/remotes/origin/*</pre> </div> </div> <p>This configuration is used in two ways:</p> <div class="ulist"> <ul> <li> <p>When <code>git fetch</code> is run without specifying what branches and/or tags to fetch on the command line, e.g. <code>git fetch origin</code> or <code>git fetch</code>, <code>remote.<repository>.fetch</code> values are used as the refspecs—they specify which refs to fetch and which local refs to update. The example above will fetch all branches that exist in the <code>origin</code> (i.e. any ref that matches the left-hand side of the value, <code>refs/heads/*</code>) and update the corresponding remote-tracking branches in the <code>refs/remotes/origin/*</code> hierarchy.</p> </li> <li> <p>When <code>git fetch</code> is run with explicit branches and/or tags to fetch on the command line, e.g. <code>git fetch origin master</code>, the <refspec>s given on the command line determine what are to be fetched (e.g. <code>master</code> in the example, which is a short-hand for <code>master:</code>, which in turn means "fetch the <code>master</code> branch but I do not explicitly say what remote-tracking branch to update with it from the command line"), and the example command will fetch <code>only</code> the <code>master</code> branch. The <code>remote.<repository>.fetch</code> values determine which remote-tracking branch, if any, is updated. When used in this way, the <code>remote.<repository>.fetch</code> values do not have any effect in deciding <code>what</code> gets fetched (i.e. the values are not used as refspecs when the command-line lists refspecs); they are only used to decide <code>where</code> the refs that are fetched are stored by acting as a mapping.</p> </li> </ul> </div> <p>The latter use of the <code>remote.<repository>.fetch</code> values can be overridden by giving the <code>--refmap=<refspec></code> parameter(s) on the command line.</p> </div> <h2 id="_pruning">Pruning</h2> <div class="sectionbody"> <p>Git has a default disposition of keeping data unless it’s explicitly thrown away; this extends to holding onto local references to branches on remotes that have themselves deleted those branches.</p> <p>If left to accumulate, these stale references might make performance worse on big and busy repos that have a lot of branch churn, and e.g. make the output of commands like <code>git branch -a --contains +<commit></code> needlessly verbose, as well as impacting anything else that’ll work with the complete set of known references.</p> <p>These remote-tracking references can be deleted as a one-off with either of:</p> <div class="listingblock"> <div class="content"> <pre># While fetching +$ git fetch --prune <name> + +# Only prune, don't fetch +$ git remote prune <name></pre> </div> </div> <p>To prune references as part of your normal workflow without needing to remember to run that, set <code>fetch.prune</code> globally, or <code>remote.<name>.prune</code> per-remote in the config. See <a href="git-config">git-config[1]</a>.</p> <p>Here’s where things get tricky and more specific. The pruning feature doesn’t actually care about branches, instead it’ll prune local ←→ remote-references as a function of the refspec of the remote (see <code><refspec></code> and <a href="#CRTB">CONFIGURED REMOTE-TRACKING BRANCHES</a> above).</p> <p>Therefore if the refspec for the remote includes e.g. <code>refs/tags/*:refs/tags/*</code>, or you manually run e.g. <code>git fetch +--prune <name> "refs/tags/*:refs/tags/*"</code> it won’t be stale remote tracking branches that are deleted, but any local tag that doesn’t exist on the remote.</p> <p>This might not be what you expect, i.e. you want to prune remote <code><name></code>, but also explicitly fetch tags from it, so when you fetch from it you delete all your local tags, most of which may not have come from the <code><name></code> remote in the first place.</p> <p>So be careful when using this with a refspec like <code>refs/tags/*:refs/tags/*</code>, or any other refspec which might map references from multiple remotes to the same local namespace.</p> <p>Since keeping up-to-date with both branches and tags on the remote is a common use-case the <code>--prune-tags</code> option can be supplied along with <code>--prune</code> to prune local tags that don’t exist on the remote, and force-update those tags that differ. Tag pruning can also be enabled with <code>fetch.pruneTags</code> or <code>remote.<name>.pruneTags</code> in the config. See <a href="git-config">git-config[1]</a>.</p> <p>The <code>--prune-tags</code> option is equivalent to having <code>refs/tags/*:refs/tags/*</code> declared in the refspecs of the remote. This can lead to some seemingly strange interactions:</p> <div class="listingblock"> <div class="content"> <pre># These both fetch tags +$ git fetch --no-tags origin 'refs/tags/*:refs/tags/*' +$ git fetch --no-tags --prune-tags origin</pre> </div> </div> <p>The reason it doesn’t error out when provided without <code>--prune</code> or its config versions is for flexibility of the configured versions, and to maintain a 1=1 mapping between what the command line flags do, and what the configuration versions do.</p> <p>It’s reasonable to e.g. configure <code>fetch.pruneTags=true</code> in <code>~/.gitconfig</code> to have tags pruned whenever <code>git fetch --prune</code> is run, without making every invocation of <code>git fetch</code> without <code>--prune</code> an error.</p> <p>Pruning tags with <code>--prune-tags</code> also works when fetching a URL instead of a named remote. These will all prune tags not found on origin:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch origin --prune --prune-tags +$ git fetch origin --prune 'refs/tags/*:refs/tags/*' +$ git fetch <url of origin> --prune --prune-tags +$ git fetch <url of origin> --prune 'refs/tags/*:refs/tags/*'</pre> </div> </div> </div> <h2 id="_output">Output</h2> <div class="sectionbody"> <p>The output of "git fetch" depends on the transport method used; this section describes the output when fetching over the Git protocol (either locally or via ssh) and Smart HTTP protocol.</p> <p>The status of the fetch is output in tabular form, with each line representing the status of a single ref. Each line is of the form:</p> <div class="listingblock"> <div class="content"> <pre> <flag> <summary> <from> -> <to> [<reason>]</pre> </div> </div> <p>When using <code>--porcelain</code>, the output format is intended to be machine-parseable. In contrast to the human-readable output formats it thus prints to standard output instead of standard error. Each line is of the form:</p> <div class="listingblock"> <div class="content"> <pre><flag> <old-object-id> <new-object-id> <local-reference></pre> </div> </div> <p>The status of up-to-date refs is shown only if the --verbose option is used.</p> <p>In compact output mode, specified with configuration variable fetch.output, if either entire <code><from></code> or <code><to></code> is found in the other string, it will be substituted with <code>*</code> in the other string. For example, <code>master -> origin/master</code> becomes <code>master -> origin/*</code>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fetch.txt-flag"> flag </dt> <dd> <p>A single character indicating the status of the ref:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fetch.txt-space"> (space) </dt> <dd> <p>for a successfully fetched fast-forward;</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-codecode"> <code>+</code> </dt> <dd> <p>for a successful forced update;</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-code-code"> <code>-</code> </dt> <dd> <p>for a successfully pruned ref;</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-codetcode"> <code>t</code> </dt> <dd> <p>for a successful tag update;</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-codecode-1"> <code>*</code> </dt> <dd> <p>for a successfully fetched new ref;</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-codecode-1-1"> <code>!</code> </dt> <dd> <p>for a ref that was rejected or failed to update; and</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-codecode-1-1-1"> <code>=</code> </dt> <dd> <p>for a ref that was up to date and did not need fetching.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-summary"> summary </dt> <dd> <p>For a successfully fetched ref, the summary shows the old and new values of the ref in a form suitable for using as an argument to <code>git log</code> (this is <code><old>..<new></code> in most cases, and <code><old>...<new></code> for forced non-fast-forward updates).</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-from"> from </dt> <dd> <p>The name of the remote ref being fetched from, minus its <code>refs/<type>/</code> prefix. In the case of deletion, the name of the remote ref is "(none)".</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-to"> to </dt> <dd> <p>The name of the local ref being updated, minus its <code>refs/<type>/</code> prefix.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-reason"> reason </dt> <dd> <p>A human-readable explanation. In the case of successfully fetched refs, no explanation is needed. For a failed ref, the reason for failure is described.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Update the remote-tracking branches:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch origin</pre> </div> </div> <p>The above command copies all branches from the remote <code>refs/heads/</code> namespace and stores them to the local <code>refs/remotes/origin/</code> namespace, unless the <code>remote.<repository>.fetch</code> option is used to specify a non-default refspec.</p> </li> <li> <p>Using refspecs explicitly:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch origin +seen:seen maint:tmp</pre> </div> </div> <p>This updates (or creates, as necessary) branches <code>seen</code> and <code>tmp</code> in the local repository by fetching from the branches (respectively) <code>seen</code> and <code>maint</code> from the remote repository.</p> <p>The <code>seen</code> branch will be updated even if it does not fast-forward, because it is prefixed with a plus sign; <code>tmp</code> will not be.</p> </li> <li> <p>Peek at a remote’s branch, without configuring the remote in your local repository:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch git://git.kernel.org/pub/scm/git/git.git maint +$ git log FETCH_HEAD</pre> </div> </div> <p>The first command fetches the <code>maint</code> branch from the repository at <code>git://git.kernel.org/pub/scm/git/git.git</code> and the second command uses <code>FETCH_HEAD</code> to examine the branch with <a href="git-log">git-log[1]</a>. The fetched objects will eventually be removed by git’s built-in housekeeping (see <a href="git-gc">git-gc[1]</a>).</p> </li> </ul> </div> </div> <h2 id="_security">Security</h2> <div class="sectionbody"> <p>The fetch and push protocols are not designed to prevent one side from stealing data from the other repository that was not intended to be shared. If you have private data that you need to protect from a malicious peer, your best option is to store it in another repository. This applies to both clients and servers. In particular, namespaces on a server are not effective for read access control; you should only grant read access to a namespace to clients that you would trust with read access to the entire repository.</p> <p>The known attack vectors are as follows:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>The victim sends "have" lines advertising the IDs of objects it has that are not explicitly intended to be shared but can be used to optimize the transfer if the peer also has them. The attacker chooses an object ID X to steal and sends a ref to X, but isn’t required to send the content of X because the victim already has it. Now the victim believes that the attacker has X, and it sends the content of X back to the attacker later. (This attack is most straightforward for a client to perform on a server, by creating a ref to X in the namespace the client has access to and then fetching it. The most likely way for a server to perform it on a client is to "merge" X into a public branch and hope that the user does additional work on this branch and pushes it back to the server without noticing the merge.)</p> </li> <li> <p>As in #1, the attacker chooses an object ID X to steal. The victim sends an object Y that the attacker already has, and the attacker falsely claims to have X and not Y, so the victim sends Y as a delta against X. The delta reveals regions of X that are similar to Y to the attacker.</p> </li> </ol> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fetch.txt-fetchrecurseSubmodules"> fetch.recurseSubmodules </dt> <dd> <p>This option controls whether <code>git fetch</code> (and the underlying fetch in <code>git pull</code>) will recursively fetch into populated submodules. This option can be set either to a boolean value or to <code>on-demand</code>. Setting it to a boolean changes the behavior of fetch and pull to recurse unconditionally into submodules when set to true or to not recurse at all when set to false. When set to <code>on-demand</code>, fetch and pull will only recurse into a populated submodule when its superproject retrieves a commit that updates the submodule’s reference. Defaults to <code>on-demand</code>, or to the value of <code>submodule.recurse</code> if set.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-fetchfsckObjects"> fetch.fsckObjects </dt> <dd> <p>If it is set to true, git-fetch-pack will check all fetched objects. See <code>transfer.fsckObjects</code> for what’s checked. Defaults to false. If not set, the value of <code>transfer.fsckObjects</code> is used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-fetchfsckltmsg-idgt"> fetch.fsck.<msg-id> </dt> <dd> <p>Acts like <code>fsck.<msg-id></code>, but is used by <a href="git-fetch-pack">git-fetch-pack[1]</a> instead of <a href="git-fsck">git-fsck[1]</a>. See the <code>fsck.<msg-id></code> documentation for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-fetchfsckskipList"> fetch.fsck.skipList </dt> <dd> <p>Acts like <code>fsck.skipList</code>, but is used by <a href="git-fetch-pack">git-fetch-pack[1]</a> instead of <a href="git-fsck">git-fsck[1]</a>. See the <code>fsck.skipList</code> documentation for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-fetchunpackLimit"> fetch.unpackLimit </dt> <dd> <p>If the number of objects fetched over the Git native transfer is below this limit, then the objects will be unpacked into loose object files. However if the number of received objects equals or exceeds this limit then the received pack will be stored as a pack, after adding any missing delta bases. Storing the pack from a push can make the push operation complete faster, especially on slow filesystems. If not set, the value of <code>transfer.unpackLimit</code> is used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-fetchprune"> fetch.prune </dt> <dd> <p>If true, fetch will automatically behave as if the <code>--prune</code> option was given on the command line. See also <code>remote.<name>.prune</code> and the PRUNING section of <a href="git-fetch">git-fetch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-fetchpruneTags"> fetch.pruneTags </dt> <dd> <p>If true, fetch will automatically behave as if the <code>refs/tags/*:refs/tags/*</code> refspec was provided when pruning, if not set already. This allows for setting both this option and <code>fetch.prune</code> to maintain a 1=1 mapping to upstream refs. See also <code>remote.<name>.pruneTags</code> and the PRUNING section of <a href="git-fetch">git-fetch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-fetchoutput"> fetch.output </dt> <dd> <p>Control how ref update status is printed. Valid values are <code>full</code> and <code>compact</code>. Default value is <code>full</code>. See the OUTPUT section in <a href="git-fetch">git-fetch[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-fetchnegotiationAlgorithm"> fetch.negotiationAlgorithm </dt> <dd> <p>Control how information about the commits in the local repository is sent when negotiating the contents of the packfile to be sent by the server. Set to "consecutive" to use an algorithm that walks over consecutive commits checking each one. Set to "skipping" to use an algorithm that skips commits in an effort to converge faster, but may result in a larger-than-necessary packfile; or set to "noop" to not send any information at all, which will almost certainly result in a larger-than-necessary packfile, but will skip the negotiation step. Set to "default" to override settings made previously and use the default behaviour. The default is normally "consecutive", but if <code>feature.experimental</code> is true, then the default is "skipping". Unknown values will cause <code>git fetch</code> to error out.</p> <p>See also the <code>--negotiate-only</code> and <code>--negotiation-tip</code> options to <a href="git-fetch">git-fetch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-fetchshowForcedUpdates"> fetch.showForcedUpdates </dt> <dd> <p>Set to false to enable <code>--no-show-forced-updates</code> in <a href="git-fetch">git-fetch[1]</a> and <a href="git-pull">git-pull[1]</a> commands. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-fetchparallel"> fetch.parallel </dt> <dd> <p>Specifies the maximal number of fetch operations to be run in parallel at a time (submodules, or remotes when the <code>--multiple</code> option of <a href="git-fetch">git-fetch[1]</a> is in effect).</p> <p>A value of 0 will give some reasonable default. If unset, it defaults to 1.</p> <p>For submodules, this setting can be overridden using the <code>submodule.fetchJobs</code> config setting.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-fetchwriteCommitGraph"> fetch.writeCommitGraph </dt> <dd> <p>Set to true to write a commit-graph after every <code>git fetch</code> command that downloads a pack-file from a remote. Using the <code>--split</code> option, most executions will create a very small commit-graph file on top of the existing commit-graph file(s). Occasionally, these files will merge and the write may take longer. Having an updated commit-graph file helps performance of many Git commands, including <code>git merge-base</code>, <code>git push -f</code>, and <code>git log --graph</code>. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-fetchbundleURI"> fetch.bundleURI </dt> <dd> <p>This value stores a URI for downloading Git object data from a bundle URI before performing an incremental fetch from the origin Git server. This is similar to how the <code>--bundle-uri</code> option behaves in <a href="git-clone">git-clone[1]</a>. <code>git clone --bundle-uri</code> will set the <code>fetch.bundleURI</code> value if the supplied bundle URI contains a bundle list that is organized for incremental fetches.</p> <p>If you modify this value and your repository has a <code>fetch.bundleCreationToken</code> value, then remove that <code>fetch.bundleCreationToken</code> value before fetching from the new bundle URI.</p> </dd> <dt class="hdlist1" id="Documentation/git-fetch.txt-fetchbundleCreationToken"> fetch.bundleCreationToken </dt> <dd> <p>When using <code>fetch.bundleURI</code> to fetch incrementally from a bundle list that uses the "creationToken" heuristic, this config value stores the maximum <code>creationToken</code> value of the downloaded bundles. This value is used to prevent downloading bundles in the future if the advertised <code>creationToken</code> is not strictly larger than this value.</p> <p>The creation token values are chosen by the provider serving the specific bundle URI. If you modify the URI at <code>fetch.bundleURI</code>, then be sure to remove the value for the <code>fetch.bundleCreationToken</code> value before fetching.</p> </dd> </dl> </div> </div> <h2 id="_bugs">Bugs</h2> <div class="sectionbody"> <p>Using --recurse-submodules can only fetch new commits in submodules that are present locally e.g. in <code>$GIT_DIR/modules/</code>. If the upstream adds a new submodule, that submodule cannot be fetched until it is cloned e.g. by <code>git +submodule update</code>. This is expected to be fixed in a future Git version.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-pull">git-pull[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-fetch" class="_attribution-link">https://git-scm.com/docs/git-fetch</a> + </p> +</div> diff --git a/devdocs/git/git-filter-branch.html b/devdocs/git/git-filter-branch.html new file mode 100644 index 00000000..cb6fcaa4 --- /dev/null +++ b/devdocs/git/git-filter-branch.html @@ -0,0 +1,55 @@ +<h1>git-filter-branch</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-filter-branch - Rewrite branches</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git filter-branch [--setup <command>] [--subdirectory-filter <directory>] + [--env-filter <command>] [--tree-filter <command>] + [--index-filter <command>] [--parent-filter <command>] + [--msg-filter <command>] [--commit-filter <command>] + [--tag-name-filter <command>] [--prune-empty] + [--original <namespace>] [-d <directory>] [-f | --force] + [--state-branch <branch>] [--] [<rev-list options>…]</pre> </div> </div> <h2 id="_warning">Warning</h2> <div class="sectionbody"> <p><code>git filter-branch</code> has a plethora of pitfalls that can produce non-obvious manglings of the intended history rewrite (and can leave you with little time to investigate such problems since it has such abysmal performance). These safety and performance issues cannot be backward compatibly fixed and as such, its use is not recommended. Please use an alternative history filtering tool such as <a href="https://github.com/newren/git-filter-repo/">git filter-repo</a>. If you still need to use <code>git filter-branch</code>, please carefully read <a href="#SAFETY">SAFETY</a> (and <a href="#PERFORMANCE">PERFORMANCE</a>) to learn about the land mines of filter-branch, and then vigilantly avoid as many of the hazards listed there as reasonably possible.</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Lets you rewrite Git revision history by rewriting the branches mentioned in the <rev-list options>, applying custom filters on each revision. Those filters can modify each tree (e.g. removing a file or running a perl rewrite on all files) or information about each commit. Otherwise, all information (including original commit times or merge information) will be preserved.</p> <p>The command will only rewrite the <code>positive</code> refs mentioned in the command line (e.g. if you pass <code>a..b</code>, only <code>b</code> will be rewritten). If you specify no filters, the commits will be recommitted without any changes, which would normally have no effect. Nevertheless, this may be useful in the future for compensating for some Git bugs or such, therefore such a usage is permitted.</p> <p><strong>NOTE</strong>: This command honors <code>.git/info/grafts</code> file and refs in the <code>refs/replace/</code> namespace. If you have any grafts or replacement refs defined, running this command will make them permanent.</p> <p><strong>WARNING</strong>! The rewritten history will have different object names for all the objects and will not converge with the original branch. You will not be able to easily push and distribute the rewritten branch on top of the original branch. Please do not use this command if you do not know the full implications, and avoid using it anyway, if a simple single commit would suffice to fix your problem. (See the "RECOVERING FROM UPSTREAM REBASE" section in <a href="git-rebase">git-rebase[1]</a> for further information about rewriting published history.)</p> <p>Always verify that the rewritten version is correct: The original refs, if different from the rewritten ones, will be stored in the namespace <code>refs/original/</code>.</p> <p>Note that since this operation is very I/O expensive, it might be a good idea to redirect the temporary directory off-disk with the <code>-d</code> option, e.g. on tmpfs. Reportedly the speedup is very noticeable.</p> <div class="sect2"> <h3 id="_filters"> +Filters</h3> <p>The filters are applied in the order as listed below. The <command> argument is always evaluated in the shell context using the <code>eval</code> command (with the notable exception of the commit filter, for technical reasons). Prior to that, the <code>$GIT_COMMIT</code> environment variable will be set to contain the id of the commit being rewritten. Also, GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, GIT_AUTHOR_DATE, GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL, and GIT_COMMITTER_DATE are taken from the current commit and exported to the environment, in order to affect the author and committer identities of the replacement commit created by <a href="git-commit-tree">git-commit-tree[1]</a> after the filters have run.</p> <p>If any evaluation of <command> returns a non-zero exit status, the whole operation will be aborted.</p> <p>A <code>map</code> function is available that takes an "original sha1 id" argument and outputs a "rewritten sha1 id" if the commit has been already rewritten, and "original sha1 id" otherwise; the <code>map</code> function can return several ids on separate lines if your commit filter emitted multiple commits.</p> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-filter-branch.txt---setupltcommandgt"> --setup <command> </dt> <dd> <p>This is not a real filter executed for each commit but a one time setup just before the loop. Therefore no commit-specific variables are defined yet. Functions or variables defined here can be used or modified in the following filter steps except the commit filter, for technical reasons.</p> </dd> <dt class="hdlist1" id="Documentation/git-filter-branch.txt---subdirectory-filterltdirectorygt"> --subdirectory-filter <directory> </dt> <dd> <p>Only look at the history which touches the given subdirectory. The result will contain that directory (and only that) as its project root. Implies <a href="#Remap_to_ancestor">Remap to ancestor</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-filter-branch.txt---env-filterltcommandgt"> --env-filter <command> </dt> <dd> <p>This filter may be used if you only need to modify the environment in which the commit will be performed. Specifically, you might want to rewrite the author/committer name/email/time environment variables (see <a href="git-commit-tree">git-commit-tree[1]</a> for details).</p> </dd> <dt class="hdlist1" id="Documentation/git-filter-branch.txt---tree-filterltcommandgt"> --tree-filter <command> </dt> <dd> <p>This is the filter for rewriting the tree and its contents. The argument is evaluated in shell with the working directory set to the root of the checked out tree. The new tree is then used as-is (new files are auto-added, disappeared files are auto-removed - neither .gitignore files nor any other ignore rules <strong>HAVE ANY EFFECT</strong>!).</p> </dd> <dt class="hdlist1" id="Documentation/git-filter-branch.txt---index-filterltcommandgt"> --index-filter <command> </dt> <dd> <p>This is the filter for rewriting the index. It is similar to the tree filter but does not check out the tree, which makes it much faster. Frequently used with <code>git rm --cached +--ignore-unmatch ...</code>, see EXAMPLES below. For hairy cases, see <a href="git-update-index">git-update-index[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-filter-branch.txt---parent-filterltcommandgt"> --parent-filter <command> </dt> <dd> <p>This is the filter for rewriting the commit’s parent list. It will receive the parent string on stdin and shall output the new parent string on stdout. The parent string is in the format described in <a href="git-commit-tree">git-commit-tree[1]</a>: empty for the initial commit, "-p parent" for a normal commit and "-p parent1 -p parent2 -p parent3 …" for a merge commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-filter-branch.txt---msg-filterltcommandgt"> --msg-filter <command> </dt> <dd> <p>This is the filter for rewriting the commit messages. The argument is evaluated in the shell with the original commit message on standard input; its standard output is used as the new commit message.</p> </dd> <dt class="hdlist1" id="Documentation/git-filter-branch.txt---commit-filterltcommandgt"> --commit-filter <command> </dt> <dd> <p>This is the filter for performing the commit. If this filter is specified, it will be called instead of the <code>git commit-tree</code> command, with arguments of the form "<TREE_ID> [(-p <PARENT_COMMIT_ID>)…]" and the log message on stdin. The commit id is expected on stdout.</p> <p>As a special extension, the commit filter may emit multiple commit ids; in that case, the rewritten children of the original commit will have all of them as parents.</p> <p>You can use the <code>map</code> convenience function in this filter, and other convenience functions, too. For example, calling <code>skip_commit "$@"</code> will leave out the current commit (but not its changes! If you want that, use <code>git rebase</code> instead).</p> <p>You can also use the <code>git_commit_non_empty_tree "$@"</code> instead of <code>git commit-tree "$@"</code> if you don’t wish to keep commits with a single parent and that makes no change to the tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-filter-branch.txt---tag-name-filterltcommandgt"> --tag-name-filter <command> </dt> <dd> <p>This is the filter for rewriting tag names. When passed, it will be called for every tag ref that points to a rewritten object (or to a tag object which points to a rewritten object). The original tag name is passed via standard input, and the new tag name is expected on standard output.</p> <p>The original tags are not deleted, but can be overwritten; use "--tag-name-filter cat" to simply update the tags. In this case, be very careful and make sure you have the old tags backed up in case the conversion has run afoul.</p> <p>Nearly proper rewriting of tag objects is supported. If the tag has a message attached, a new tag object will be created with the same message, author, and timestamp. If the tag has a signature attached, the signature will be stripped. It is by definition impossible to preserve signatures. The reason this is "nearly" proper, is because ideally if the tag did not change (points to the same object, has the same name, etc.) it should retain any signature. That is not the case, signatures will always be removed, buyer beware. There is also no support for changing the author or timestamp (or the tag message for that matter). Tags which point to other tags will be rewritten to point to the underlying commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-filter-branch.txt---prune-empty"> --prune-empty </dt> <dd> <p>Some filters will generate empty commits that leave the tree untouched. This option instructs git-filter-branch to remove such commits if they have exactly one or zero non-pruned parents; merge commits will therefore remain intact. This option cannot be used together with <code>--commit-filter</code>, though the same effect can be achieved by using the provided <code>git_commit_non_empty_tree</code> function in a commit filter.</p> </dd> <dt class="hdlist1" id="Documentation/git-filter-branch.txt---originalltnamespacegt"> --original <namespace> </dt> <dd> <p>Use this option to set the namespace where the original commits will be stored. The default value is <code>refs/original</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-filter-branch.txt--dltdirectorygt"> -d <directory> </dt> <dd> <p>Use this option to set the path to the temporary directory used for rewriting. When applying a tree filter, the command needs to temporarily check out the tree to some directory, which may consume considerable space in case of large projects. By default it does this in the <code>.git-rewrite/</code> directory but you can override that choice by this parameter.</p> </dd> <dt class="hdlist1" id="Documentation/git-filter-branch.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-filter-branch.txt---force"> --force </dt> <dd> <p><code>git filter-branch</code> refuses to start with an existing temporary directory or when there are already refs starting with <code>refs/original/</code>, unless forced.</p> </dd> <dt class="hdlist1" id="Documentation/git-filter-branch.txt---state-branchltbranchgt"> --state-branch <branch> </dt> <dd> <p>This option will cause the mapping from old to new objects to be loaded from named branch upon startup and saved as a new commit to that branch upon exit, enabling incremental of large trees. If <code><branch></code> does not exist it will be created.</p> </dd> <dt class="hdlist1" id="Documentation/git-filter-branch.txt-ltrev-listoptionsgt82308203"> <rev-list options>… </dt> <dd> <p>Arguments for <code>git rev-list</code>. All positive refs included by these options are rewritten. You may also specify options such as <code>--all</code>, but you must use <code>--</code> to separate them from the <code>git filter-branch</code> options. Implies <a href="#Remap_to_ancestor">Remap to ancestor</a>.</p> </dd> </dl> </div> <div class="sect2"> <h3 id="Remap_to_ancestor"> +Remap to ancestor</h3> <p>By using <a href="git-rev-list">git-rev-list[1]</a> arguments, e.g., path limiters, you can limit the set of revisions which get rewritten. However, positive refs on the command line are distinguished: we don’t let them be excluded by such limiters. For this purpose, they are instead rewritten to point at the nearest ancestor that was not excluded.</p> </div> </div> <h2 id="_exit_status">Exit status</h2> <div class="sectionbody"> <p>On success, the exit status is <code>0</code>. If the filter can’t find any commits to rewrite, the exit status is <code>2</code>. On any other error, the exit status may be any other non-zero value.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>Suppose you want to remove a file (containing confidential information or copyright violation) from all commits:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git filter-branch --tree-filter 'rm filename' HEAD</pre> </div> </div> <p>However, if the file is absent from the tree of some commit, a simple <code>rm filename</code> will fail for that tree and commit. Thus you may instead want to use <code>rm -f filename</code> as the script.</p> <p>Using <code>--index-filter</code> with <code>git rm</code> yields a significantly faster version. Like with using <code>rm filename</code>, <code>git rm --cached filename</code> will fail if the file is absent from the tree of a commit. If you want to "completely forget" a file, it does not matter when it entered history, so we also add <code>--ignore-unmatch</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git filter-branch --index-filter 'git rm --cached --ignore-unmatch filename' HEAD</pre> </div> </div> <p>Now, you will get the rewritten history saved in HEAD.</p> <p>To rewrite the repository to look as if <code>foodir/</code> had been its project root, and discard all other history:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git filter-branch --subdirectory-filter foodir -- --all</pre> </div> </div> <p>Thus you can, e.g., turn a library subdirectory into a repository of its own. Note the <code>--</code> that separates <code>filter-branch</code> options from revision options, and the <code>--all</code> to rewrite all branches and tags.</p> <p>To set a commit (which typically is at the tip of another history) to be the parent of the current initial commit, in order to paste the other history behind the current history:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git filter-branch --parent-filter 'sed "s/^\$/-p <graft-id>/"' HEAD</pre> </div> </div> <p>(if the parent string is empty - which happens when we are dealing with the initial commit - add graftcommit as a parent). Note that this assumes history with a single root (that is, no merge without common ancestors happened). If this is not the case, use:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git filter-branch --parent-filter \ + 'test $GIT_COMMIT = <commit-id> && echo "-p <graft-id>" || cat' HEAD</pre> </div> </div> <p>or even simpler:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git replace --graft $commit-id $graft-id +git filter-branch $graft-id..HEAD</pre> </div> </div> <p>To remove commits authored by "Darl McBribe" from the history:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git filter-branch --commit-filter ' + if [ "$GIT_AUTHOR_NAME" = "Darl McBribe" ]; + then + skip_commit "$@"; + else + git commit-tree "$@"; + fi' HEAD</pre> </div> </div> <p>The function <code>skip_commit</code> is defined as follows:</p> <div class="listingblock"> <div class="content"> <pre>skip_commit() +{ + shift; + while [ -n "$1" ]; + do + shift; + map "$1"; + shift; + done; +}</pre> </div> </div> <p>The shift magic first throws away the tree id and then the -p parameters. Note that this handles merges properly! In case Darl committed a merge between P1 and P2, it will be propagated properly and all children of the merge will become merge commits with P1,P2 as their parents instead of the merge commit.</p> <p><strong>NOTE</strong> the changes introduced by the commits, and which are not reverted by subsequent commits, will still be in the rewritten branch. If you want to throw out <code>changes</code> together with the commits, you should use the interactive mode of <code>git rebase</code>.</p> <p>You can rewrite the commit log messages using <code>--msg-filter</code>. For example, <code>git svn-id</code> strings in a repository created by <code>git svn</code> can be removed this way:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git filter-branch --msg-filter ' + sed -e "/^git-svn-id:/d" +'</pre> </div> </div> <p>If you need to add <code>Acked-by</code> lines to, say, the last 10 commits (none of which is a merge), use this command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git filter-branch --msg-filter ' + cat && + echo "Acked-by: Bugs Bunny <bunny@bugzilla.org>" +' HEAD~10..HEAD</pre> </div> </div> <p>The <code>--env-filter</code> option can be used to modify committer and/or author identity. For example, if you found out that your commits have the wrong identity due to a misconfigured user.email, you can make a correction, before publishing the project, like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git filter-branch --env-filter ' + if test "$GIT_AUTHOR_EMAIL" = "root@localhost" + then + GIT_AUTHOR_EMAIL=john@example.com + fi + if test "$GIT_COMMITTER_EMAIL" = "root@localhost" + then + GIT_COMMITTER_EMAIL=john@example.com + fi +' -- --all</pre> </div> </div> <p>To restrict rewriting to only part of the history, specify a revision range in addition to the new branch name. The new branch name will point to the top-most revision that a <code>git rev-list</code> of this range will print.</p> <p>Consider this history:</p> <div class="listingblock"> <div class="content"> <pre> D--E--F--G--H + / / +A--B-----C</pre> </div> </div> <p>To rewrite only commits D,E,F,G,H, but leave A, B and C alone, use:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git filter-branch ... C..H</pre> </div> </div> <p>To rewrite commits E,F,G,H, use one of these:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git filter-branch ... C..H --not D +git filter-branch ... D..H --not C</pre> </div> </div> <p>To move the whole tree into a subdirectory, or remove it from there:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git filter-branch --index-filter \ + 'git ls-files -s | sed "s-\t\"*-&newsubdir/-" | + GIT_INDEX_FILE=$GIT_INDEX_FILE.new \ + git update-index --index-info && + mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD</pre> </div> </div> </div> <h2 id="_checklist_for_shrinking_a_repository">Checklist for shrinking a repository</h2> <div class="sectionbody"> <p>git-filter-branch can be used to get rid of a subset of files, usually with some combination of <code>--index-filter</code> and <code>--subdirectory-filter</code>. People expect the resulting repository to be smaller than the original, but you need a few more steps to actually make it smaller, because Git tries hard not to lose your objects until you tell it to. First make sure that:</p> <div class="ulist"> <ul> <li> <p>You really removed all variants of a filename, if a blob was moved over its lifetime. <code>git log --name-only --follow --all -- filename</code> can help you find renames.</p> </li> <li> <p>You really filtered all refs: use <code>--tag-name-filter cat -- --all</code> when calling git-filter-branch.</p> </li> </ul> </div> <p>Then there are two ways to get a smaller repository. A safer way is to clone, that keeps your original intact.</p> <div class="ulist"> <ul> <li> <p>Clone it with <code>git clone file:///path/to/repo</code>. The clone will not have the removed objects. See <a href="git-clone">git-clone[1]</a>. (Note that cloning with a plain path just hardlinks everything!)</p> </li> </ul> </div> <p>If you really don’t want to clone it, for whatever reasons, check the following points instead (in this order). This is a very destructive approach, so <strong>make a backup</strong> or go back to cloning it. You have been warned.</p> <div class="ulist"> <ul> <li> <p>Remove the original refs backed up by git-filter-branch: say <code>git +for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git +update-ref -d</code>.</p> </li> <li> <p>Expire all reflogs with <code>git reflog expire --expire=now --all</code>.</p> </li> <li> <p>Garbage collect all unreferenced objects with <code>git gc --prune=now</code> (or if your git-gc is not new enough to support arguments to <code>--prune</code>, use <code>git repack -ad; git prune</code> instead).</p> </li> </ul> </div> </div> <h2 id="PERFORMANCE">Performance</h2> <div class="sectionbody"> <p>The performance of git-filter-branch is glacially slow; its design makes it impossible for a backward-compatible implementation to ever be fast:</p> <div class="ulist"> <ul> <li> <p>In editing files, git-filter-branch by design checks out each and every commit as it existed in the original repo. If your repo has <code>10^5</code> files and <code>10^5</code> commits, but each commit only modifies five files, then git-filter-branch will make you do <code>10^10</code> modifications, despite only having (at most) <code>5*10^5</code> unique blobs.</p> </li> <li> <p>If you try and cheat and try to make git-filter-branch only work on files modified in a commit, then two things happen</p> <div class="ulist"> <ul> <li> <p>you run into problems with deletions whenever the user is simply trying to rename files (because attempting to delete files that don’t exist looks like a no-op; it takes some chicanery to remap deletes across file renames when the renames happen via arbitrary user-provided shell)</p> </li> <li> <p>even if you succeed at the map-deletes-for-renames chicanery, you still technically violate backward compatibility because users are allowed to filter files in ways that depend upon topology of commits instead of filtering solely based on file contents or names (though this has not been observed in the wild).</p> </li> </ul> </div> </li> <li> <p>Even if you don’t need to edit files but only want to e.g. rename or remove some and thus can avoid checking out each file (i.e. you can use --index-filter), you still are passing shell snippets for your filters. This means that for every commit, you have to have a prepared git repo where those filters can be run. That’s a significant setup.</p> </li> <li> <p>Further, several additional files are created or updated per commit by git-filter-branch. Some of these are for supporting the convenience functions provided by git-filter-branch (such as map()), while others are for keeping track of internal state (but could have also been accessed by user filters; one of git-filter-branch’s regression tests does so). This essentially amounts to using the filesystem as an IPC mechanism between git-filter-branch and the user-provided filters. Disks tend to be a slow IPC mechanism, and writing these files also effectively represents a forced synchronization point between separate processes that we hit with every commit.</p> </li> <li> <p>The user-provided shell commands will likely involve a pipeline of commands, resulting in the creation of many processes per commit. Creating and running another process takes a widely varying amount of time between operating systems, but on any platform it is very slow relative to invoking a function.</p> </li> <li> <p>git-filter-branch itself is written in shell, which is kind of slow. This is the one performance issue that could be backward-compatibly fixed, but compared to the above problems that are intrinsic to the design of git-filter-branch, the language of the tool itself is a relatively minor issue.</p> <div class="ulist"> <ul> <li> <p>Side note: Unfortunately, people tend to fixate on the written-in-shell aspect and periodically ask if git-filter-branch could be rewritten in another language to fix the performance issues. Not only does that ignore the bigger intrinsic problems with the design, it’d help less than you’d expect: if git-filter-branch itself were not shell, then the convenience functions (map(), skip_commit(), etc) and the <code>--setup</code> argument could no longer be executed once at the beginning of the program but would instead need to be prepended to every user filter (and thus re-executed with every commit).</p> </li> </ul> </div> </li> </ul> </div> <p>The <a href="https://github.com/newren/git-filter-repo/">git filter-repo</a> tool is an alternative to git-filter-branch which does not suffer from these performance problems or the safety problems (mentioned below). For those with existing tooling which relies upon git-filter-branch, <code>git filter-repo</code> also provides <a href="https://github.com/newren/git-filter-repo/blob/master/contrib/filter-repo-demos/filter-lamely">filter-lamely</a>, a drop-in git-filter-branch replacement (with a few caveats). While filter-lamely suffers from all the same safety issues as git-filter-branch, it at least ameliorates the performance issues a little.</p> </div> <h2 id="SAFETY">Safety</h2> <div class="sectionbody"> <p>git-filter-branch is riddled with gotchas resulting in various ways to easily corrupt repos or end up with a mess worse than what you started with:</p> <div class="ulist"> <ul> <li> <p>Someone can have a set of "working and tested filters" which they document or provide to a coworker, who then runs them on a different OS where the same commands are not working/tested (some examples in the git-filter-branch manpage are also affected by this). BSD vs. GNU userland differences can really bite. If lucky, error messages are spewed. But just as likely, the commands either don’t do the filtering requested, or silently corrupt by making some unwanted change. The unwanted change may only affect a few commits, so it’s not necessarily obvious either. (The fact that problems won’t necessarily be obvious means they are likely to go unnoticed until the rewritten history is in use for quite a while, at which point it’s really hard to justify another flag-day for another rewrite.)</p> </li> <li> <p>Filenames with spaces are often mishandled by shell snippets since they cause problems for shell pipelines. Not everyone is familiar with find -print0, xargs -0, git-ls-files -z, etc. Even people who are familiar with these may assume such flags are not relevant because someone else renamed any such files in their repo back before the person doing the filtering joined the project. And often, even those familiar with handling arguments with spaces may not do so just because they aren’t in the mindset of thinking about everything that could possibly go wrong.</p> </li> <li> <p>Non-ascii filenames can be silently removed despite being in a desired directory. Keeping only wanted paths is often done using pipelines like <code>git ls-files | grep -v ^WANTED_DIR/ | xargs git rm</code>. ls-files will only quote filenames if needed, so folks may not notice that one of the files didn’t match the regex (at least not until it’s much too late). Yes, someone who knows about core.quotePath can avoid this (unless they have other special characters like \t, \n, or "), and people who use ls-files -z with something other than grep can avoid this, but that doesn’t mean they will.</p> </li> <li> <p>Similarly, when moving files around, one can find that filenames with non-ascii or special characters end up in a different directory, one that includes a double quote character. (This is technically the same issue as above with quoting, but perhaps an interesting different way that it can and has manifested as a problem.)</p> </li> <li> <p>It’s far too easy to accidentally mix up old and new history. It’s still possible with any tool, but git-filter-branch almost invites it. If lucky, the only downside is users getting frustrated that they don’t know how to shrink their repo and remove the old stuff. If unlucky, they merge old and new history and end up with multiple "copies" of each commit, some of which have unwanted or sensitive files and others which don’t. This comes about in multiple different ways:</p> <div class="ulist"> <ul> <li> <p>the default to only doing a partial history rewrite (<code>--all</code> is not the default and few examples show it)</p> </li> <li> <p>the fact that there’s no automatic post-run cleanup</p> </li> <li> <p>the fact that --tag-name-filter (when used to rename tags) doesn’t remove the old tags but just adds new ones with the new name</p> </li> <li> <p>the fact that little educational information is provided to inform users of the ramifications of a rewrite and how to avoid mixing old and new history. For example, this man page discusses how users need to understand that they need to rebase their changes for all their branches on top of new history (or delete and reclone), but that’s only one of multiple concerns to consider. See the "DISCUSSION" section of the git filter-repo manual page for more details.</p> </li> </ul> </div> </li> <li> <p>Annotated tags can be accidentally converted to lightweight tags, due to either of two issues:</p> <div class="ulist"> <ul> <li> <p>Someone can do a history rewrite, realize they messed up, restore from the backups in refs/original/, and then redo their git-filter-branch command. (The backup in refs/original/ is not a real backup; it dereferences tags first.)</p> </li> <li> <p>Running git-filter-branch with either --tags or --all in your <rev-list options>. In order to retain annotated tags as annotated, you must use --tag-name-filter (and must not have restored from refs/original/ in a previously botched rewrite).</p> </li> </ul> </div> </li> <li> <p>Any commit messages that specify an encoding will become corrupted by the rewrite; git-filter-branch ignores the encoding, takes the original bytes, and feeds it to commit-tree without telling it the proper encoding. (This happens whether or not --msg-filter is used.)</p> </li> <li> <p>Commit messages (even if they are all UTF-8) by default become corrupted due to not being updated — any references to other commit hashes in commit messages will now refer to no-longer-extant commits.</p> </li> <li> <p>There are no facilities for helping users find what unwanted crud they should delete, which means they are much more likely to have incomplete or partial cleanups that sometimes result in confusion and people wasting time trying to understand. (For example, folks tend to just look for big files to delete instead of big directories or extensions, and once they do so, then sometime later folks using the new repository who are going through history will notice a build artifact directory that has some files but not others, or a cache of dependencies (node_modules or similar) which couldn’t have ever been functional since it’s missing some files.)</p> </li> <li> <p>If --prune-empty isn’t specified, then the filtering process can create hoards of confusing empty commits</p> </li> <li> <p>If --prune-empty is specified, then intentionally placed empty commits from before the filtering operation are also pruned instead of just pruning commits that became empty due to filtering rules.</p> </li> <li> <p>If --prune-empty is specified, sometimes empty commits are missed and left around anyway (a somewhat rare bug, but it happens…)</p> </li> <li> <p>A minor issue, but users who have a goal to update all names and emails in a repository may be led to --env-filter which will only update authors and committers, missing taggers.</p> </li> <li> <p>If the user provides a --tag-name-filter that maps multiple tags to the same name, no warning or error is provided; git-filter-branch simply overwrites each tag in some undocumented pre-defined order resulting in only one tag at the end. (A git-filter-branch regression test requires this surprising behavior.)</p> </li> </ul> </div> <p>Also, the poor performance of git-filter-branch often leads to safety issues:</p> <div class="ulist"> <ul> <li> <p>Coming up with the correct shell snippet to do the filtering you want is sometimes difficult unless you’re just doing a trivial modification such as deleting a couple files. Unfortunately, people often learn if the snippet is right or wrong by trying it out, but the rightness or wrongness can vary depending on special circumstances (spaces in filenames, non-ascii filenames, funny author names or emails, invalid timezones, presence of grafts or replace objects, etc.), meaning they may have to wait a long time, hit an error, then restart. The performance of git-filter-branch is so bad that this cycle is painful, reducing the time available to carefully re-check (to say nothing about what it does to the patience of the person doing the rewrite even if they do technically have more time available). This problem is extra compounded because errors from broken filters may not be shown for a long time and/or get lost in a sea of output. Even worse, broken filters often just result in silent incorrect rewrites.</p> </li> <li> <p>To top it all off, even when users finally find working commands, they naturally want to share them. But they may be unaware that their repo didn’t have some special cases that someone else’s does. So, when someone else with a different repository runs the same commands, they get hit by the problems above. Or, the user just runs commands that really were vetted for special cases, but they run it on a different OS where it doesn’t work, as noted above.</p> </li> </ul> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-filter-branch" class="_attribution-link">https://git-scm.com/docs/git-filter-branch</a> + </p> +</div> diff --git a/devdocs/git/git-fmt-merge-msg.html b/devdocs/git/git-fmt-merge-msg.html new file mode 100644 index 00000000..1b478fb5 --- /dev/null +++ b/devdocs/git/git-fmt-merge-msg.html @@ -0,0 +1,8 @@ +<h1>git-fmt-merge-msg</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-fmt-merge-msg - Produce a merge commit message</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git fmt-merge-msg [-m <message>] [--into-name <branch>] [--log[=<n>] | --no-log] +git fmt-merge-msg [-m <message>] [--log[=<n>] | --no-log] -F <file></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Takes the list of merged objects on stdin and produces a suitable commit message to be used for the merge commit, usually to be passed as the <code><merge-message></code> argument of <code>git merge</code>.</p> <p>This command is intended mostly for internal use by scripts automatically invoking <code>git merge</code>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fmt-merge-msg.txt---logltngt"> --log[=<n>] </dt> <dd> <p>In addition to branch names, populate the log message with one-line descriptions from the actual commits that are being merged. At most <n> commits from each merge parent will be used (20 if <n> is omitted). This overrides the <code>merge.log</code> configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-fmt-merge-msg.txt---no-log"> --no-log </dt> <dd> <p>Do not list one-line descriptions from the actual commits being merged.</p> </dd> <dt class="hdlist1" id="Documentation/git-fmt-merge-msg.txt---no-summary"> --[no-]summary </dt> <dd> <p>Synonyms to --log and --no-log; these are deprecated and will be removed in the future.</p> </dd> <dt class="hdlist1" id="Documentation/git-fmt-merge-msg.txt--mltmessagegt"> -m <message> </dt> <dt class="hdlist1" id="Documentation/git-fmt-merge-msg.txt---messageltmessagegt"> --message <message> </dt> <dd> <p>Use <message> instead of the branch names for the first line of the log message. For use with <code>--log</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fmt-merge-msg.txt---into-nameltbranchgt"> --into-name <branch> </dt> <dd> <p>Prepare the merge message as if merging to the branch <code><branch></code>, instead of the name of the real branch to which the merge is made.</p> </dd> <dt class="hdlist1" id="Documentation/git-fmt-merge-msg.txt--Fltfilegt"> -F <file> </dt> <dt class="hdlist1" id="Documentation/git-fmt-merge-msg.txt---fileltfilegt"> --file <file> </dt> <dd> <p>Take the list of merged objects from <file> instead of stdin.</p> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fmt-merge-msg.txt-mergebranchdesc"> merge.branchdesc </dt> <dd> <p>In addition to branch names, populate the log message with the branch description text associated with them. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-fmt-merge-msg.txt-mergelog"> merge.log </dt> <dd> <p>In addition to branch names, populate the log message with at most the specified number of one-line descriptions from the actual commits that are being merged. Defaults to false, and true is a synonym for 20.</p> </dd> <dt class="hdlist1" id="Documentation/git-fmt-merge-msg.txt-mergesuppressDest"> merge.suppressDest </dt> <dd> <p>By adding a glob that matches the names of integration branches to this multi-valued configuration variable, the default merge message computed for merges into these integration branches will omit "into <branch name>" from its title.</p> <p>An element with an empty value can be used to clear the list of globs accumulated from previous configuration entries. When there is no <code>merge.suppressDest</code> variable defined, the default value of <code>master</code> is used for backward compatibility.</p> </dd> <dt class="hdlist1" id="Documentation/git-fmt-merge-msg.txt-mergesummary"> merge.summary </dt> <dd> <p>Synonym to <code>merge.log</code>; this is deprecated and will be removed in the future.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch origin master +$ git fmt-merge-msg --log <$GIT_DIR/FETCH_HEAD</pre> </div> </div> <p>Print a log message describing a merge of the "master" branch from the "origin" remote.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-merge">git-merge[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-fmt-merge-msg" class="_attribution-link">https://git-scm.com/docs/git-fmt-merge-msg</a> + </p> +</div> diff --git a/devdocs/git/git-for-each-ref.html b/devdocs/git/git-for-each-ref.html new file mode 100644 index 00000000..0396f76f --- /dev/null +++ b/devdocs/git/git-for-each-ref.html @@ -0,0 +1,74 @@ +<h1>git-for-each-ref</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-for-each-ref - Output information on each ref</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git for-each-ref [--count=<count>] [--shell|--perl|--python|--tcl] + [(--sort=<key>)…] [--format=<format>] + [ --stdin | <pattern>… ] + [--points-at=<object>] + [--merged[=<object>]] [--no-merged[=<object>]] + [--contains[=<object>]] [--no-contains[=<object>]] + [--exclude=<pattern> …]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Iterate over all refs that match <code><pattern></code> and show them according to the given <code><format></code>, after sorting them according to the given set of <code><key></code>. If <code><count></code> is given, stop after showing that many refs. The interpolated values in <code><format></code> can optionally be quoted as string literals in the specified host language allowing their direct evaluation in that language.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-ltpatterngt82308203"> <pattern>… </dt> <dd> <p>If one or more patterns are given, only refs are shown that match against at least one pattern, either using fnmatch(3) or literally, in the latter case matching completely or from the beginning up to a slash.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---stdin"> --stdin </dt> <dd> <p>If <code>--stdin</code> is supplied, then the list of patterns is read from standard input instead of from the argument list.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---countltcountgt"> --count=<count> </dt> <dd> <p>By default the command shows all refs that match <code><pattern></code>. This option makes it stop after showing that many refs.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---sortltkeygt"> --sort=<key> </dt> <dd> <p>A field name to sort on. Prefix <code>-</code> to sort in descending order of the value. When unspecified, <code>refname</code> is used. You may use the --sort=<key> option multiple times, in which case the last key becomes the primary key.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---formatltformatgt"> --format=<format> </dt> <dd> <p>A string that interpolates <code>%(fieldname)</code> from a ref being shown and the object it points at. If <code>fieldname</code> is prefixed with an asterisk (<code>*</code>) and the ref points at a tag object, use the value for the field in the object which the tag object refers to (instead of the field in the tag object). When unspecified, <code><format></code> defaults to <code>%(objectname) SPC %(objecttype) TAB %(refname)</code>. It also interpolates <code>%%</code> to <code>%</code>, and <code>%xx</code> where <code>xx</code> are hex digits interpolates to character with hex code <code>xx</code>; for example <code>%00</code> interpolates to <code>\0</code> (NUL), <code>%09</code> to <code>\t</code> (TAB) and <code>%0a</code> to <code>\n</code> (LF).</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---colorltwhengt"> --color[=<when>] </dt> <dd> <p>Respect any colors specified in the <code>--format</code> option. The <code><when></code> field must be one of <code>always</code>, <code>never</code>, or <code>auto</code> (if <code><when></code> is absent, behave as if <code>always</code> was given).</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---shell"> --shell </dt> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---perl"> --perl </dt> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---python"> --python </dt> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---tcl"> --tcl </dt> <dd> <p>If given, strings that substitute <code>%(fieldname)</code> placeholders are quoted as string literals suitable for the specified host language. This is meant to produce a scriptlet that can directly be `eval`ed.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---points-atltobjectgt"> --points-at=<object> </dt> <dd> <p>Only list refs which points at the given object.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---mergedltobjectgt"> --merged[=<object>] </dt> <dd> <p>Only list refs whose tips are reachable from the specified commit (HEAD if not specified).</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---no-mergedltobjectgt"> --no-merged[=<object>] </dt> <dd> <p>Only list refs whose tips are not reachable from the specified commit (HEAD if not specified).</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---containsltobjectgt"> --contains[=<object>] </dt> <dd> <p>Only list refs which contain the specified commit (HEAD if not specified).</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---no-containsltobjectgt"> --no-contains[=<object>] </dt> <dd> <p>Only list refs which don’t contain the specified commit (HEAD if not specified).</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---ignore-case"> --ignore-case </dt> <dd> <p>Sorting and filtering refs are case insensitive.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---omit-empty"> --omit-empty </dt> <dd> <p>Do not print a newline after formatted refs where the format expands to the empty string.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt---excludeltpatterngt"> --exclude=<pattern> </dt> <dd> <p>If one or more patterns are given, only refs which do not match any excluded pattern(s) are shown. Matching is done using the same rules as <code><pattern></code> above.</p> </dd> </dl> </div> </div> <h2 id="_field_names">Field names</h2> <div class="sectionbody"> <p>Various values from structured fields in referenced objects can be used to interpolate into the resulting output, or as sort keys.</p> <p>For all objects, the following names can be used:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-refname"> refname </dt> <dd> <p>The name of the ref (the part after $GIT_DIR/). For a non-ambiguous short name of the ref append <code>:short</code>. The option core.warnAmbiguousRefs is used to select the strict abbreviation mode. If <code>lstrip=<N></code> (<code>rstrip=<N></code>) is appended, strips <code><N></code> slash-separated path components from the front (back) of the refname (e.g. <code>%(refname:lstrip=2)</code> turns <code>refs/tags/foo</code> into <code>foo</code> and <code>%(refname:rstrip=2)</code> turns <code>refs/tags/foo</code> into <code>refs</code>). If <code><N></code> is a negative number, strip as many path components as necessary from the specified end to leave <code>-<N></code> path components (e.g. <code>%(refname:lstrip=-2)</code> turns <code>refs/tags/foo</code> into <code>tags/foo</code> and <code>%(refname:rstrip=-1)</code> turns <code>refs/tags/foo</code> into <code>refs</code>). When the ref does not have enough components, the result becomes an empty string if stripping with positive <N>, or it becomes the full refname if stripping with negative <N>. Neither is an error.</p> <p><code>strip</code> can be used as a synonym to <code>lstrip</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-objecttype"> objecttype </dt> <dd> <p>The type of the object (<code>blob</code>, <code>tree</code>, <code>commit</code>, <code>tag</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-objectsize"> objectsize </dt> <dd> <p>The size of the object (the same as <code>git cat-file -s</code> reports). Append <code>:disk</code> to get the size, in bytes, that the object takes up on disk. See the note about on-disk sizes in the <code>CAVEATS</code> section below.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-objectname"> objectname </dt> <dd> <p>The object name (aka SHA-1). For a non-ambiguous abbreviation of the object name append <code>:short</code>. For an abbreviation of the object name with desired length append <code>:short=<length></code>, where the minimum length is MINIMUM_ABBREV. The length may be exceeded to ensure unique object names.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-deltabase"> deltabase </dt> <dd> <p>This expands to the object name of the delta base for the given object, if it is stored as a delta. Otherwise it expands to the null object name (all zeroes).</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-upstream"> upstream </dt> <dd> <p>The name of a local ref which can be considered “upstream” from the displayed ref. Respects <code>:short</code>, <code>:lstrip</code> and <code>:rstrip</code> in the same way as <code>refname</code> above. Additionally respects <code>:track</code> to show "[ahead N, behind M]" and <code>:trackshort</code> to show the terse version: ">" (ahead), "<" (behind), "<>" (ahead and behind), or "=" (in sync). <code>:track</code> also prints "[gone]" whenever unknown upstream ref is encountered. Append <code>:track,nobracket</code> to show tracking information without brackets (i.e "ahead N, behind M").</p> <p>For any remote-tracking branch <code>%(upstream)</code>, <code>%(upstream:remotename)</code> and <code>%(upstream:remoteref)</code> refer to the name of the remote and the name of the tracked remote ref, respectively. In other words, the remote-tracking branch can be updated explicitly and individually by using the refspec <code>%(upstream:remoteref):%(upstream)</code> to fetch from <code>%(upstream:remotename)</code>.</p> <p>Has no effect if the ref does not have tracking information associated with it. All the options apart from <code>nobracket</code> are mutually exclusive, but if used together the last option is selected.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-push"> push </dt> <dd> <p>The name of a local ref which represents the <code>@{push}</code> location for the displayed ref. Respects <code>:short</code>, <code>:lstrip</code>, <code>:rstrip</code>, <code>:track</code>, <code>:trackshort</code>, <code>:remotename</code>, and <code>:remoteref</code> options as <code>upstream</code> does. Produces an empty string if no <code>@{push}</code> ref is configured.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-HEAD"> HEAD </dt> <dd> <p><code>*</code> if HEAD matches current ref (the checked out branch), ' ' otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-color"> color </dt> <dd> <p>Change output color. Followed by <code>:<colorname></code>, where color names are described under Values in the "CONFIGURATION FILE" section of <a href="git-config">git-config[1]</a>. For example, <code>%(color:bold red)</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-align"> align </dt> <dd> <p>Left-, middle-, or right-align the content between %(align:…) and %(end). The "align:" is followed by <code>width=<width></code> and <code>position=<position></code> in any order separated by a comma, where the <code><position></code> is either left, right or middle, default being left and <code><width></code> is the total length of the content with alignment. For brevity, the "width=" and/or "position=" prefixes may be omitted, and bare <width> and <position> used instead. For instance, <code>%(align:<width>,<position>)</code>. If the contents length is more than the width then no alignment is performed. If used with <code>--quote</code> everything in between %(align:…) and %(end) is quoted, but if nested then only the topmost level performs quoting.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-if"> if </dt> <dd> <p>Used as %(if)…%(then)…%(end) or %(if)…%(then)…%(else)…%(end). If there is an atom with value or string literal after the %(if) then everything after the %(then) is printed, else if the %(else) atom is used, then everything after %(else) is printed. We ignore space when evaluating the string before %(then), this is useful when we use the %(HEAD) atom which prints either "*" or " " and we want to apply the <code>if</code> condition only on the <code>HEAD</code> ref. Append ":equals=<string>" or ":notequals=<string>" to compare the value between the %(if:…) and %(then) atoms with the given string.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-symref"> symref </dt> <dd> <p>The ref which the given symbolic ref refers to. If not a symbolic ref, nothing is printed. Respects the <code>:short</code>, <code>:lstrip</code> and <code>:rstrip</code> options in the same way as <code>refname</code> above.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-signature"> signature </dt> <dd> <p>The GPG signature of a commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-signaturegrade"> signature:grade </dt> <dd> <p>Show "G" for a good (valid) signature, "B" for a bad signature, "U" for a good signature with unknown validity, "X" for a good signature that has expired, "Y" for a good signature made by an expired key, "R" for a good signature made by a revoked key, "E" if the signature cannot be checked (e.g. missing key) and "N" for no signature.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-signaturesigner"> signature:signer </dt> <dd> <p>The signer of the GPG signature of a commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-signaturekey"> signature:key </dt> <dd> <p>The key of the GPG signature of a commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-signaturefingerprint"> signature:fingerprint </dt> <dd> <p>The fingerprint of the GPG signature of a commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-signatureprimarykeyfingerprint"> signature:primarykeyfingerprint </dt> <dd> <p>The primary key fingerprint of the GPG signature of a commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-signaturetrustlevel"> signature:trustlevel </dt> <dd> <p>The trust level of the GPG signature of a commit. Possible outputs are <code>ultimate</code>, <code>fully</code>, <code>marginal</code>, <code>never</code> and <code>undefined</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-worktreepath"> worktreepath </dt> <dd> <p>The absolute path to the worktree in which the ref is checked out, if it is checked out in any linked worktree. Empty string otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-ahead-behindltcommittishgt"> ahead-behind:<committish> </dt> <dd> <p>Two integers, separated by a space, demonstrating the number of commits ahead and behind, respectively, when comparing the output ref to the <code><committish></code> specified in the format.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-describeoptions"> describe[:options] </dt> <dd> <p>A human-readable name, like <a href="git-describe">git-describe[1]</a>; empty string for undescribable commits. The <code>describe</code> string may be followed by a colon and one or more comma-separated options.</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-tagsltbool-valuegt"> tags=<bool-value> </dt> <dd> <p>Instead of only considering annotated tags, consider lightweight tags as well; see the corresponding option in <a href="git-describe">git-describe[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-abbrevltnumbergt"> abbrev=<number> </dt> <dd> <p>Use at least <number> hexadecimal digits; see the corresponding option in <a href="git-describe">git-describe[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-matchltpatterngt"> match=<pattern> </dt> <dd> <p>Only consider tags matching the given <code>glob(7)</code> pattern, excluding the "refs/tags/" prefix; see the corresponding option in <a href="git-describe">git-describe[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-excludeltpatterngt"> exclude=<pattern> </dt> <dd> <p>Do not consider tags matching the given <code>glob(7)</code> pattern, excluding the "refs/tags/" prefix; see the corresponding option in <a href="git-describe">git-describe[1]</a> for details.</p> </dd> </dl> </div> </div> </div> </dd> </dl> </div> <p>In addition to the above, for commit and tag objects, the header field names (<code>tree</code>, <code>parent</code>, <code>object</code>, <code>type</code>, and <code>tag</code>) can be used to specify the value in the header field. Fields <code>tree</code> and <code>parent</code> can also be used with modifier <code>:short</code> and <code>:short=<length></code> just like <code>objectname</code>.</p> <p>For commit and tag objects, the special <code>creatordate</code> and <code>creator</code> fields will correspond to the appropriate date or name-email-date tuple from the <code>committer</code> or <code>tagger</code> fields depending on the object type. These are intended for working on a mix of annotated and lightweight tags.</p> <p>Fields that have name-email-date tuple as its value (<code>author</code>, <code>committer</code>, and <code>tagger</code>) can be suffixed with <code>name</code>, <code>email</code>, and <code>date</code> to extract the named component. For email fields (<code>authoremail</code>, <code>committeremail</code> and <code>taggeremail</code>), <code>:trim</code> can be appended to get the email without angle brackets, and <code>:localpart</code> to get the part before the <code>@</code> symbol out of the trimmed email. In addition to these, the <code>:mailmap</code> option and the corresponding <code>:mailmap,trim</code> and <code>:mailmap,localpart</code> can be used (order does not matter) to get values of the name and email according to the .mailmap file or according to the file set in the mailmap.file or mailmap.blob configuration variable (see <a href="gitmailmap">gitmailmap[5]</a>).</p> <p>The raw data in an object is <code>raw</code>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-rawsize"> raw:size </dt> <dd> <p>The raw data size of the object.</p> </dd> </dl> </div> <p>Note that <code>--format=%(raw)</code> can not be used with <code>--python</code>, <code>--shell</code>, <code>--tcl</code>, because such language may not support arbitrary binary data in their string variable type.</p> <p>The message in a commit or a tag object is <code>contents</code>, from which <code>contents:<part></code> can be used to extract various parts out of:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-contentssize"> contents:size </dt> <dd> <p>The size in bytes of the commit or tag message.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-contentssubject"> contents:subject </dt> <dd> <p>The first paragraph of the message, which typically is a single line, is taken as the "subject" of the commit or the tag message. Instead of <code>contents:subject</code>, field <code>subject</code> can also be used to obtain same results. <code>:sanitize</code> can be appended to <code>subject</code> for subject line suitable for filename.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-contentsbody"> contents:body </dt> <dd> <p>The remainder of the commit or the tag message that follows the "subject".</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-contentssignature"> contents:signature </dt> <dd> <p>The optional GPG signature of the tag.</p> </dd> <dt class="hdlist1" id="Documentation/git-for-each-ref.txt-contentslinesN"> contents:lines=N </dt> <dd> <p>The first <code>N</code> lines of the message.</p> </dd> </dl> </div> <p>Additionally, the trailers as interpreted by <a href="git-interpret-trailers">git-interpret-trailers[1]</a> are obtained as <code>trailers[:options]</code> (or by using the historical alias <code>contents:trailers[:options]</code>). For valid [:option] values see <code>trailers</code> section of <a href="git-log">git-log[1]</a>.</p> <p>For sorting purposes, fields with numeric values sort in numeric order (<code>objectsize</code>, <code>authordate</code>, <code>committerdate</code>, <code>creatordate</code>, <code>taggerdate</code>). All other fields are used to sort in their byte-value order.</p> <p>There is also an option to sort by versions, this can be done by using the fieldname <code>version:refname</code> or its alias <code>v:refname</code>.</p> <p>In any case, a field name that refers to a field inapplicable to the object referred by the ref does not cause an error. It returns an empty string instead.</p> <p>As a special case for the date-type fields, you may specify a format for the date by adding <code>:</code> followed by date format name (see the values the <code>--date</code> option to <a href="git-rev-list">git-rev-list[1]</a> takes).</p> <p>Some atoms like %(align) and %(if) always require a matching %(end). We call them "opening atoms" and sometimes denote them as %($open).</p> <p>When a scripting language specific quoting is in effect, everything between a top-level opening atom and its matching %(end) is evaluated according to the semantics of the opening atom and only its result from the top-level is quoted.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>An example directly producing formatted text. Show the most recent 3 tagged commits:</p> <div class="listingblock"> <div class="content"> <pre>#!/bin/sh + +git for-each-ref --count=3 --sort='-*authordate' \ +--format='From: %(*authorname) %(*authoremail) +Subject: %(*subject) +Date: %(*authordate) +Ref: %(*refname) + +%(*body) +' 'refs/tags'</pre> </div> </div> <p>A simple example showing the use of shell eval on the output, demonstrating the use of --shell. List the prefixes of all heads:</p> <div class="listingblock"> <div class="content"> <pre>#!/bin/sh + +git for-each-ref --shell --format="ref=%(refname)" refs/heads | \ +while read entry +do + eval "$entry" + echo `dirname $ref` +done</pre> </div> </div> <p>A bit more elaborate report on tags, demonstrating that the format may be an entire script:</p> <div class="listingblock"> <div class="content"> <pre>#!/bin/sh + +fmt=' + r=%(refname) + t=%(*objecttype) + T=${r#refs/tags/} + + o=%(*objectname) + n=%(*authorname) + e=%(*authoremail) + s=%(*subject) + d=%(*authordate) + b=%(*body) + + kind=Tag + if test "z$t" = z + then + # could be a lightweight tag + t=%(objecttype) + kind="Lightweight tag" + o=%(objectname) + n=%(authorname) + e=%(authoremail) + s=%(subject) + d=%(authordate) + b=%(body) + fi + echo "$kind $T points at a $t object $o" + if test "z$t" = zcommit + then + echo "The commit was authored by $n $e +at $d, and titled + + $s + +Its message reads as: +" + echo "$b" | sed -e "s/^/ /" + echo + fi +' + +eval=`git for-each-ref --shell --format="$fmt" \ + --sort='*objecttype' \ + --sort=-taggerdate \ + refs/tags` +eval "$eval"</pre> </div> </div> <p>An example to show the usage of %(if)…%(then)…%(else)…%(end). This prefixes the current branch with a star.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git for-each-ref --format="%(if)%(HEAD)%(then)* %(else) %(end)%(refname:short)" refs/heads/</pre> </div> </div> <p>An example to show the usage of %(if)…%(then)…%(end). This prints the authorname, if present.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git for-each-ref --format="%(refname)%(if)%(authorname)%(then) Authored by: %(authorname)%(end)"</pre> </div> </div> </div> <h2 id="_caveats">Caveats</h2> <div class="sectionbody"> <p>Note that the sizes of objects on disk are reported accurately, but care should be taken in drawing conclusions about which refs or objects are responsible for disk usage. The size of a packed non-delta object may be much larger than the size of objects which delta against it, but the choice of which object is the base and which is the delta is arbitrary and is subject to change during a repack.</p> <p>Note also that multiple copies of an object may be present in the object database; in this case, it is undefined which copy’s size or delta base will be reported.</p> </div> <h2 id="_notes">Notes</h2> <div class="sectionbody"> <p>When combining multiple <code>--contains</code> and <code>--no-contains</code> filters, only references that contain at least one of the <code>--contains</code> commits and contain none of the <code>--no-contains</code> commits are shown.</p> <p>When combining multiple <code>--merged</code> and <code>--no-merged</code> filters, only references that are reachable from at least one of the <code>--merged</code> commits and from none of the <code>--no-merged</code> commits are shown.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-show-ref">git-show-ref[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-for-each-ref" class="_attribution-link">https://git-scm.com/docs/git-for-each-ref</a> + </p> +</div> diff --git a/devdocs/git/git-for-each-repo.html b/devdocs/git/git-for-each-repo.html new file mode 100644 index 00000000..f904a74f --- /dev/null +++ b/devdocs/git/git-for-each-repo.html @@ -0,0 +1,6 @@ +<h1>git-for-each-repo</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-for-each-repo - Run a Git command on a list of repositories</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git for-each-repo --config=<config> [--] <arguments></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Run a Git command on a list of repositories. The arguments after the known options or <code>--</code> indicator are used as the arguments for the Git subprocess.</p> <p>THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.</p> <p>For example, we could run maintenance on each of a list of repositories stored in a <code>maintenance.repo</code> config variable using</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git for-each-repo --config=maintenance.repo maintenance run</pre> </div> </div> <p>This will run <code>git -C <repo> maintenance run</code> for each value <code><repo></code> in the multi-valued config variable <code>maintenance.repo</code>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-for-each-repo.txt---configltconfiggt"> --config=<config> </dt> <dd> <p>Use the given config variable as a multi-valued list storing absolute path names. Iterate on that list of paths to run the given arguments.</p> <p>These config values are loaded from system, global, and local Git config, as available. If <code>git for-each-repo</code> is run in a directory that is not a Git repository, then only the system and global config is used.</p> </dd> </dl> </div> </div> <h2 id="_subprocess_behavior">Subprocess behavior</h2> <div class="sectionbody"> <p>If any <code>git -C <repo> <arguments></code> subprocess returns a non-zero exit code, then the <code>git for-each-repo</code> process returns that exit code without running more subprocesses.</p> <p>Each <code>git -C <repo> <arguments></code> subprocess inherits the standard file descriptors <code>stdin</code>, <code>stdout</code>, and <code>stderr</code>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-for-each-repo" class="_attribution-link">https://git-scm.com/docs/git-for-each-repo</a> + </p> +</div> diff --git a/devdocs/git/git-format-patch.html b/devdocs/git/git-format-patch.html new file mode 100644 index 00000000..b69e44f1 --- /dev/null +++ b/devdocs/git/git-format-patch.html @@ -0,0 +1,84 @@ +<h1>git-format-patch</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-format-patch - Prepare patches for e-mail submission</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git format-patch [-k] [(-o|--output-directory) <dir> | --stdout] + [--no-thread | --thread[=<style>]] + [(--attach|--inline)[=<boundary>] | --no-attach] + [-s | --signoff] + [--signature=<signature> | --no-signature] + [--signature-file=<file>] + [-n | --numbered | -N | --no-numbered] + [--start-number <n>] [--numbered-files] + [--in-reply-to=<message id>] [--suffix=.<sfx>] + [--ignore-if-in-upstream] [--always] + [--cover-from-description=<mode>] + [--rfc] [--subject-prefix=<subject prefix>] + [(--reroll-count|-v) <n>] + [--to=<email>] [--cc=<email>] + [--[no-]cover-letter] [--quiet] + [--[no-]encode-email-headers] + [--no-notes | --notes[=<ref>]] + [--interdiff=<previous>] + [--range-diff=<previous> [--creation-factor=<percent>]] + [--filename-max-length=<n>] + [--progress] + [<common diff options>] + [ <since> | <revision range> ]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Prepare each non-merge commit with its "patch" in one "message" per commit, formatted to resemble a UNIX mailbox. The output of this command is convenient for e-mail submission or for use with <code>git am</code>.</p> <p>A "message" generated by the command consists of three parts:</p> <div class="ulist"> <ul> <li> <p>A brief metadata header that begins with <code>From <commit></code> with a fixed <code>Mon Sep 17 00:00:00 2001</code> datestamp to help programs like "file(1)" to recognize that the file is an output from this command, fields that record the author identity, the author date, and the title of the change (taken from the first paragraph of the commit log message).</p> </li> <li> <p>The second and subsequent paragraphs of the commit log message.</p> </li> <li> <p>The "patch", which is the "diff -p --stat" output (see <a href="git-diff">git-diff[1]</a>) between the commit and its parent.</p> </li> </ul> </div> <p>The log message and the patch are separated by a line with a three-dash line.</p> <p>There are two ways to specify which commits to operate on.</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>A single commit, <since>, specifies that the commits leading to the tip of the current branch that are not in the history that leads to the <since> to be output.</p> </li> <li> <p>Generic <revision range> expression (see "SPECIFYING REVISIONS" section in <a href="gitrevisions">gitrevisions[7]</a>) means the commits in the specified range.</p> </li> </ol> </div> <p>The first rule takes precedence in the case of a single <commit>. To apply the second rule, i.e., format everything since the beginning of history up until <commit>, use the <code>--root</code> option: <code>git format-patch +--root <commit></code>. If you want to format only <commit> itself, you can do this with <code>git format-patch -1 <commit></code>.</p> <p>By default, each output file is numbered sequentially from 1, and uses the first line of the commit message (massaged for pathname safety) as the filename. With the <code>--numbered-files</code> option, the output file names will only be numbers, without the first line of the commit appended. The names of the output files are printed to standard output, unless the <code>--stdout</code> option is specified.</p> <p>If <code>-o</code> is specified, output files are created in <dir>. Otherwise they are created in the current working directory. The default path can be set with the <code>format.outputDirectory</code> configuration option. The <code>-o</code> option takes precedence over <code>format.outputDirectory</code>. To store patches in the current working directory even when <code>format.outputDirectory</code> points elsewhere, use <code>-o .</code>. All directory components will be created.</p> <p>By default, the subject of a single patch is "[PATCH] " followed by the concatenation of lines from the commit message up to the first blank line (see the DISCUSSION section of <a href="git-commit">git-commit[1]</a>).</p> <p>When multiple patches are output, the subject prefix will instead be "[PATCH n/m] ". To force 1/1 to be added for a single patch, use <code>-n</code>. To omit patch numbers from the subject, use <code>-N</code>.</p> <p>If given <code>--thread</code>, <code>git-format-patch</code> will generate <code>In-Reply-To</code> and <code>References</code> headers to make the second and subsequent patch mails appear as replies to the first mail; this also generates a <code>Message-ID</code> header to reference.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-format-patch.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-stat"> --no-stat </dt> <dd> <p>Generate plain patches without any diffstats.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--Ultngt"> -U<n> </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---unifiedltngt"> --unified=<n> </dt> <dd> <p>Generate diffs with <n> lines of context instead of the usual three.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---outputltfilegt"> --output=<file> </dt> <dd> <p>Output to a specific file instead of stdout.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---output-indicator-newltchargt"> --output-indicator-new=<char> </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---output-indicator-oldltchargt"> --output-indicator-old=<char> </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---output-indicator-contextltchargt"> --output-indicator-context=<char> </dt> <dd> <p>Specify the character used to indicate new, old or context lines in the generated patch. Normally they are <code>+</code>, <code>-</code> and ' ' respectively.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---indent-heuristic"> --indent-heuristic </dt> <dd> <p>Enable the heuristic that shifts diff hunk boundaries to make patches easier to read. This is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-indent-heuristic"> --no-indent-heuristic </dt> <dd> <p>Disable the indent heuristic.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---minimal"> --minimal </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---patience"> --patience </dt> <dd> <p>Generate a diff using the "patience diff" algorithm.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---histogram"> --histogram </dt> <dd> <p>Generate a diff using the "histogram diff" algorithm.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---anchoredlttextgt"> --anchored=<text> </dt> <dd> <p>Generate a diff using the "anchored diff" algorithm.</p> <p>This option may be specified more than once.</p> <p>If a line exists in both the source and destination, exists only once, and starts with this text, this algorithm attempts to prevent it from appearing as a deletion or addition in the output. It uses the "patience diff" algorithm internally.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---diff-algorithmpatienceminimalhistogrammyers"> --diff-algorithm={patience|minimal|histogram|myers} </dt> <dd> <p>Choose a diff algorithm. The variants are as follows:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-format-patch.txt-codedefaultcodecodemyerscode"> <code>default</code>, <code>myers</code> </dt> <dd> <p>The basic greedy diff algorithm. Currently, this is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt-codeminimalcode"> <code>minimal</code> </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt-codepatiencecode"> <code>patience</code> </dt> <dd> <p>Use "patience diff" algorithm when generating patches.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt-codehistogramcode"> <code>histogram</code> </dt> <dd> <p>This algorithm extends the patience algorithm to "support low-occurrence common elements".</p> </dd> </dl> </div> </div> </div> <p>For instance, if you configured the <code>diff.algorithm</code> variable to a non-default value and want to use the default one, then you have to use <code>--diff-algorithm=default</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---statltwidthgtltname-widthgtltcountgt"> --stat[=<width>[,<name-width>[,<count>]]] </dt> <dd> <p>Generate a diffstat. By default, as much space as necessary will be used for the filename part, and the rest for the graph part. Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden by <code><width></code>. The width of the filename part can be limited by giving another width <code><name-width></code> after a comma or by setting <code>diff.statNameWidth=<width></code>. The width of the graph part can be limited by using <code>--stat-graph-width=<width></code> or by setting <code>diff.statGraphWidth=<width></code>. Using <code>--stat</code> or <code>--stat-graph-width</code> affects all commands generating a stat graph, while setting <code>diff.statNameWidth</code> or <code>diff.statGraphWidth</code> does not affect <code>git format-patch</code>. By giving a third parameter <code><count></code>, you can limit the output to the first <code><count></code> lines, followed by <code>...</code> if there are more.</p> <p>These parameters can also be set individually with <code>--stat-width=<width></code>, <code>--stat-name-width=<name-width></code> and <code>--stat-count=<count></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---compact-summary"> --compact-summary </dt> <dd> <p>Output a condensed summary of extended header information such as file creations or deletions ("new" or "gone", optionally "+l" if it’s a symlink) and mode changes ("+x" or "-x" for adding or removing executable bit respectively) in diffstat. The information is put between the filename part and the graph part. Implies <code>--stat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---numstat"> --numstat </dt> <dd> <p>Similar to <code>--stat</code>, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly. For binary files, outputs two <code>-</code> instead of saying <code>0 0</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---shortstat"> --shortstat </dt> <dd> <p>Output only the last line of the <code>--stat</code> format containing total number of modified files, as well as number of added and deleted lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--Xltparam1param282308203gt"> -X[<param1,param2,…>] </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---dirstatltparam1param282308203gt"> --dirstat[=<param1,param2,…>] </dt> <dd> <p>Output the distribution of relative amount of changes for each sub-directory. The behavior of <code>--dirstat</code> can be customized by passing it a comma separated list of parameters. The defaults are controlled by the <code>diff.dirstat</code> configuration variable (see <a href="git-config">git-config[1]</a>). The following parameters are available:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-format-patch.txt-codechangescode"> <code>changes</code> </dt> <dd> <p>Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination. This ignores the amount of pure code movements within a file. In other words, rearranging lines in a file is not counted as much as other changes. This is the default behavior when no parameter is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt-codelinescode"> <code>lines</code> </dt> <dd> <p>Compute the dirstat numbers by doing the regular line-based diff analysis, and summing the removed/added line counts. (For binary files, count 64-byte chunks instead, since binary files have no natural concept of lines). This is a more expensive <code>--dirstat</code> behavior than the <code>changes</code> behavior, but it does count rearranged lines within a file as much as other changes. The resulting output is consistent with what you get from the other <code>--*stat</code> options.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt-codefilescode"> <code>files</code> </dt> <dd> <p>Compute the dirstat numbers by counting the number of files changed. Each changed file counts equally in the dirstat analysis. This is the computationally cheapest <code>--dirstat</code> behavior, since it does not have to look at the file contents at all.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt-codecumulativecode"> <code>cumulative</code> </dt> <dd> <p>Count changes in a child directory for the parent directory as well. Note that when using <code>cumulative</code>, the sum of the percentages reported may exceed 100%. The default (non-cumulative) behavior can be specified with the <code>noncumulative</code> parameter.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt-ltlimitgt"> <limit> </dt> <dd> <p>An integer parameter specifies a cut-off percent (3% by default). Directories contributing less than this percentage of the changes are not shown in the output.</p> </dd> </dl> </div> </div> </div> <p>Example: The following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories: <code>--dirstat=files,10,cumulative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---cumulative"> --cumulative </dt> <dd> <p>Synonym for --dirstat=cumulative</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---dirstat-by-fileltparam1param2gt82308203"> --dirstat-by-file[=<param1,param2>…] </dt> <dd> <p>Synonym for --dirstat=files,param1,param2…</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---summary"> --summary </dt> <dd> <p>Output a condensed summary of extended header information such as creations, renames and mode changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-renames"> --no-renames </dt> <dd> <p>Turn off rename detection, even when the configuration file gives the default to do so.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-rename-empty"> --[no-]rename-empty </dt> <dd> <p>Whether to use empty blobs as rename source.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---full-index"> --full-index </dt> <dd> <p>Instead of the first handful of characters, show the full pre- and post-image blob object names on the "index" line when generating patch format output.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---binary"> --binary </dt> <dd> <p>In addition to <code>--full-index</code>, output a binary diff that can be applied with <code>git-apply</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---abbrevltngt"> --abbrev[=<n>] </dt> <dd> <p>Instead of showing the full 40-byte hexadecimal object name in diff-raw format output and diff-tree header lines, show the shortest prefix that is at least <code><n></code> hexdigits long that uniquely refers the object. In diff-patch output format, <code>--full-index</code> takes higher precedence, i.e. if <code>--full-index</code> is specified, full blob names will be shown regardless of <code>--abbrev</code>. Non default number of digits can be specified with <code>--abbrev=<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--Bltngtltmgt"> -B[<n>][/<m>] </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---break-rewritesltngtltmgt"> --break-rewrites[=[<n>][/<m>]] </dt> <dd> <p>Break complete rewrite changes into pairs of delete and create. This serves two purposes:</p> <p>It affects the way a change that amounts to a total rewrite of a file not as a series of deletion and insertion mixed together with a very few lines that happen to match textually as the context, but as a single deletion of everything old followed by a single insertion of everything new, and the number <code>m</code> controls this aspect of the -B option (defaults to 60%). <code>-B/70%</code> specifies that less than 30% of the original should remain in the result for Git to consider it a total rewrite (i.e. otherwise the resulting patch will be a series of deletion and insertion mixed together with context lines).</p> <p>When used with -M, a totally-rewritten file is also considered as the source of a rename (usually -M only considers a file that disappeared as the source of a rename), and the number <code>n</code> controls this aspect of the -B option (defaults to 50%). <code>-B20%</code> specifies that a change with addition and deletion compared to 20% or more of the file’s size are eligible for being picked up as a possible source of a rename to another file.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--Mltngt"> -M[<n>] </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---find-renamesltngt"> --find-renames[=<n>] </dt> <dd> <p>Detect renames. If <code>n</code> is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file’s size). For example, <code>-M90%</code> means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn’t changed. Without a <code>%</code> sign, the number is to be read as a fraction, with a decimal point before it. I.e., <code>-M5</code> becomes 0.5, and is thus the same as <code>-M50%</code>. Similarly, <code>-M05</code> is the same as <code>-M5%</code>. To limit detection to exact renames, use <code>-M100%</code>. The default similarity index is 50%.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--Cltngt"> -C[<n>] </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---find-copiesltngt"> --find-copies[=<n>] </dt> <dd> <p>Detect copies as well as renames. See also <code>--find-copies-harder</code>. If <code>n</code> is specified, it has the same meaning as for <code>-M<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---find-copies-harder"> --find-copies-harder </dt> <dd> <p>For performance reasons, by default, <code>-C</code> option finds copies only if the original file of the copy was modified in the same changeset. This flag makes the command inspect unmodified files as candidates for the source of copy. This is a very expensive operation for large projects, so use it with caution. Giving more than one <code>-C</code> option has the same effect.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--D"> -D </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---irreversible-delete"> --irreversible-delete </dt> <dd> <p>Omit the preimage for deletes, i.e. print only the header but not the diff between the preimage and <code>/dev/null</code>. The resulting patch is not meant to be applied with <code>patch</code> or <code>git apply</code>; this is solely for people who want to just concentrate on reviewing the text after the change. In addition, the output obviously lacks enough information to apply such a patch in reverse, even manually, hence the name of the option.</p> <p>When used together with <code>-B</code>, omit also the preimage in the deletion part of a delete/create pair.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--lltnumgt"> -l<num> </dt> <dd> <p>The <code>-M</code> and <code>-C</code> options involve some preliminary steps that can detect subsets of renames/copies cheaply, followed by an exhaustive fallback portion that compares all remaining unpaired destinations to all relevant sources. (For renames, only remaining unpaired sources are relevant; for copies, all original sources are relevant.) For N sources and destinations, this exhaustive check is O(N^2). This option prevents the exhaustive portion of rename/copy detection from running if the number of source/destination files involved exceeds the specified number. Defaults to diff.renameLimit. Note that a value of 0 is treated as unlimited.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--Oltorderfilegt"> -O<orderfile> </dt> <dd> <p>Control the order in which files appear in the output. This overrides the <code>diff.orderFile</code> configuration variable (see <a href="git-config">git-config[1]</a>). To cancel <code>diff.orderFile</code>, use <code>-O/dev/null</code>.</p> <p>The output order is determined by the order of glob patterns in <orderfile>. All files with pathnames that match the first pattern are output first, all files with pathnames that match the second pattern (but not the first) are output next, and so on. All files with pathnames that do not match any pattern are output last, as if there was an implicit match-all pattern at the end of the file. If multiple pathnames have the same rank (they match the same pattern but no earlier patterns), their output order relative to each other is the normal order.</p> <p><orderfile> is parsed as follows:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>Blank lines are ignored, so they can be used as separators for readability.</p> </li> <li> <p>Lines starting with a hash ("<code>#</code>") are ignored, so they can be used for comments. Add a backslash ("<code>\</code>") to the beginning of the pattern if it starts with a hash.</p> </li> <li> <p>Each other line contains a single pattern.</p> </li> </ul> </div> </div> </div> <p>Patterns have the same syntax and semantics as patterns used for fnmatch(3) without the FNM_PATHNAME flag, except a pathname also matches a pattern if removing any number of the final pathname components matches the pattern. For example, the pattern "<code>foo*bar</code>" matches "<code>fooasdfbar</code>" and "<code>foo/bar/baz/asdf</code>" but not "<code>foobarx</code>".</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---skip-toltfilegt"> --skip-to=<file> </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---rotate-toltfilegt"> --rotate-to=<file> </dt> <dd> <p>Discard the files before the named <file> from the output (i.e. <code>skip to</code>), or move them to the end of the output (i.e. <code>rotate to</code>). These options were invented primarily for the use of the <code>git difftool</code> command, and may not be very useful otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---relativeltpathgt"> --relative[=<path>] </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-relative"> --no-relative </dt> <dd> <p>When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option. When you are not in a subdirectory (e.g. in a bare repository), you can name which subdirectory to make the output relative to by giving a <path> as an argument. <code>--no-relative</code> can be used to countermand both <code>diff.relative</code> config option and previous <code>--relative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---text"> --text </dt> <dd> <p>Treat all files as text.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---ignore-cr-at-eol"> --ignore-cr-at-eol </dt> <dd> <p>Ignore carriage-return at the end of line when doing a comparison.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---ignore-space-at-eol"> --ignore-space-at-eol </dt> <dd> <p>Ignore changes in whitespace at EOL.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--b"> -b </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---ignore-space-change"> --ignore-space-change </dt> <dd> <p>Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--w"> -w </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---ignore-all-space"> --ignore-all-space </dt> <dd> <p>Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---ignore-blank-lines"> --ignore-blank-lines </dt> <dd> <p>Ignore changes whose lines are all blank.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--Iltregexgt"> -I<regex> </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---ignore-matching-linesltregexgt"> --ignore-matching-lines=<regex> </dt> <dd> <p>Ignore changes whose all lines match <regex>. This option may be specified more than once.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---inter-hunk-contextltlinesgt"> --inter-hunk-context=<lines> </dt> <dd> <p>Show the context between diff hunks, up to the specified number of lines, thereby fusing hunks that are close to each other. Defaults to <code>diff.interHunkContext</code> or 0 if the config option is unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--W"> -W </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---function-context"> --function-context </dt> <dd> <p>Show whole function as context lines for each change. The function names are determined in the same way as <code>git diff</code> works out patch hunk headers (see <code>Defining a custom hunk-header</code> in <a href="gitattributes">gitattributes[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---ext-diff"> --ext-diff </dt> <dd> <p>Allow an external diff helper to be executed. If you set an external diff driver with <a href="gitattributes">gitattributes[5]</a>, you need to use this option with <a href="git-log">git-log[1]</a> and friends.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-ext-diff"> --no-ext-diff </dt> <dd> <p>Disallow external diff drivers.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---textconv"> --textconv </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-textconv"> --no-textconv </dt> <dd> <p>Allow (or disallow) external text conversion filters to be run when comparing binary files. See <a href="gitattributes">gitattributes[5]</a> for details. Because textconv filters are typically a one-way conversion, the resulting diff is suitable for human consumption, but cannot be applied. For this reason, textconv filters are enabled by default only for <a href="git-diff">git-diff[1]</a> and <a href="git-log">git-log[1]</a>, but not for <a href="git-format-patch">git-format-patch[1]</a> or diff plumbing commands.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---ignore-submodulesltwhengt"> --ignore-submodules[=<when>] </dt> <dd> <p>Ignore changes to submodules in the diff generation. <when> can be either "none", "untracked", "dirty" or "all", which is the default. Using "none" will consider the submodule modified when it either contains untracked or modified files or its HEAD differs from the commit recorded in the superproject and can be used to override any settings of the <code>ignore</code> option in <a href="git-config">git-config[1]</a> or <a href="gitmodules">gitmodules[5]</a>. When "untracked" is used submodules are not considered dirty when they only contain untracked content (but they are still scanned for modified content). Using "dirty" ignores all changes to the work tree of submodules, only changes to the commits stored in the superproject are shown (this was the behavior until 1.7.0). Using "all" hides all changes to submodules.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---src-prefixltprefixgt"> --src-prefix=<prefix> </dt> <dd> <p>Show the given source prefix instead of "a/".</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---dst-prefixltprefixgt"> --dst-prefix=<prefix> </dt> <dd> <p>Show the given destination prefix instead of "b/".</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-prefix"> --no-prefix </dt> <dd> <p>Do not show any source or destination prefix.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---default-prefix"> --default-prefix </dt> <dd> <p>Use the default source and destination prefixes ("a/" and "b/"). This is usually the default already, but may be used to override config such as <code>diff.noprefix</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---line-prefixltprefixgt"> --line-prefix=<prefix> </dt> <dd> <p>Prepend an additional prefix to every line of output.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---ita-invisible-in-index"> --ita-invisible-in-index </dt> <dd> <p>By default entries added by "git add -N" appear as an existing empty file in "git diff" and a new file in "git diff --cached". This option makes the entry appear as a new file in "git diff" and non-existent in "git diff --cached". This option could be reverted with <code>--ita-visible-in-index</code>. Both options are experimental and could be removed in future.</p> </dd> </dl> </div> <p>For more detailed explanation on these common options, see also <a href="gitdiffcore">gitdiffcore[7]</a>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-format-patch.txt--ltngt"> -<n> </dt> <dd> <p>Prepare patches from the topmost <n> commits.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--oltdirgt"> -o <dir> </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---output-directoryltdirgt"> --output-directory <dir> </dt> <dd> <p>Use <dir> to store the resulting files, instead of the current working directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---numbered"> --numbered </dt> <dd> <p>Name output in <code>[PATCH n/m]</code> format, even with a single patch.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--N"> -N </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-numbered"> --no-numbered </dt> <dd> <p>Name output in <code>[PATCH]</code> format.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---start-numberltngt"> --start-number <n> </dt> <dd> <p>Start numbering the patches at <n> instead of 1.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---numbered-files"> --numbered-files </dt> <dd> <p>Output file names will be a simple number sequence without the default first line of the commit appended.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--k"> -k </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---keep-subject"> --keep-subject </dt> <dd> <p>Do not strip/add <code>[PATCH]</code> from the first line of the commit log message.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---signoff"> --signoff </dt> <dd> <p>Add a <code>Signed-off-by</code> trailer to the commit message, using the committer identity of yourself. See the signoff option in <a href="git-commit">git-commit[1]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---stdout"> --stdout </dt> <dd> <p>Print all commits to the standard output in mbox format, instead of creating a file for each one.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---attachltboundarygt"> --attach[=<boundary>] </dt> <dd> <p>Create multipart/mixed attachment, the first part of which is the commit message and the patch itself in the second part, with <code>Content-Disposition: attachment</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-attach"> --no-attach </dt> <dd> <p>Disable the creation of an attachment, overriding the configuration setting.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---inlineltboundarygt"> --inline[=<boundary>] </dt> <dd> <p>Create multipart/mixed attachment, the first part of which is the commit message and the patch itself in the second part, with <code>Content-Disposition: inline</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---threadltstylegt"> --thread[=<style>] </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-thread"> --no-thread </dt> <dd> <p>Controls addition of <code>In-Reply-To</code> and <code>References</code> headers to make the second and subsequent mails appear as replies to the first. Also controls generation of the <code>Message-ID</code> header to reference.</p> <p>The optional <style> argument can be either <code>shallow</code> or <code>deep</code>. <code>shallow</code> threading makes every mail a reply to the head of the series, where the head is chosen from the cover letter, the <code>--in-reply-to</code>, and the first patch mail, in this order. <code>deep</code> threading makes every mail a reply to the previous one.</p> <p>The default is <code>--no-thread</code>, unless the <code>format.thread</code> configuration is set. <code>--thread</code> without an argument is equivalent to <code>--thread=shallow</code>.</p> <p>Beware that the default for <code>git send-email</code> is to thread emails itself. If you want <code>git format-patch</code> to take care of threading, you will want to ensure that threading is disabled for <code>git send-email</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---in-reply-toltmessageidgt"> --in-reply-to=<message id> </dt> <dd> <p>Make the first mail (or all the mails with <code>--no-thread</code>) appear as a reply to the given <message id>, which avoids breaking threads to provide a new patch series.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---ignore-if-in-upstream"> --ignore-if-in-upstream </dt> <dd> <p>Do not include a patch that matches a commit in <until>..<since>. This will examine all patches reachable from <since> but not from <until> and compare them with the patches being generated, and any patch that matches is ignored.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---always"> --always </dt> <dd> <p>Include patches for commits that do not introduce any change, which are omitted by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---cover-from-descriptionltmodegt"> --cover-from-description=<mode> </dt> <dd> <p>Controls which parts of the cover letter will be automatically populated using the branch’s description.</p> <p>If <code><mode></code> is <code>message</code> or <code>default</code>, the cover letter subject will be populated with placeholder text. The body of the cover letter will be populated with the branch’s description. This is the default mode when no configuration nor command line option is specified.</p> <p>If <code><mode></code> is <code>subject</code>, the first paragraph of the branch description will populate the cover letter subject. The remainder of the description will populate the body of the cover letter.</p> <p>If <code><mode></code> is <code>auto</code>, if the first paragraph of the branch description is greater than 100 bytes, then the mode will be <code>message</code>, otherwise <code>subject</code> will be used.</p> <p>If <code><mode></code> is <code>none</code>, both the cover letter subject and body will be populated with placeholder text.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---description-fileltfilegt"> --description-file=<file> </dt> <dd> <p>Use the contents of <file> instead of the branch’s description for generating the cover letter.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---subject-prefixltsubjectprefixgt"> --subject-prefix=<subject prefix> </dt> <dd> <p>Instead of the standard <code>[PATCH]</code> prefix in the subject line, instead use <code>[<subject prefix>]</code>. This can be used to name a patch series, and can be combined with the <code>--numbered</code> option.</p> <p>The configuration variable <code>format.subjectPrefix</code> may also be used to configure a subject prefix to apply to a given repository for all patches. This is often useful on mailing lists which receive patches for several repositories and can be used to disambiguate the patches (with a value of e.g. "PATCH my-project").</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---filename-max-lengthltngt"> --filename-max-length=<n> </dt> <dd> <p>Instead of the standard 64 bytes, chomp the generated output filenames at around <code><n></code> bytes (too short a value will be silently raised to a reasonable length). Defaults to the value of the <code>format.filenameMaxLength</code> configuration variable, or 64 if unconfigured.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---rfc"> --rfc </dt> <dd> <p>Prepends "RFC" to the subject prefix (producing "RFC PATCH" by default). RFC means "Request For Comments"; use this when sending an experimental patch for discussion rather than application.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--vltngt"> -v <n> </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---reroll-countltngt"> --reroll-count=<n> </dt> <dd> <p>Mark the series as the <n>-th iteration of the topic. The output filenames have <code>v<n></code> prepended to them, and the subject prefix ("PATCH" by default, but configurable via the <code>--subject-prefix</code> option) has ` v<n>` appended to it. E.g. <code>--reroll-count=4</code> may produce <code>v4-0001-add-makefile.patch</code> file that has "Subject: [PATCH v4 1/20] Add makefile" in it. <code><n></code> does not have to be an integer (e.g. "--reroll-count=4.4", or "--reroll-count=4rev2" are allowed), but the downside of using such a reroll-count is that the range-diff/interdiff with the previous version does not state exactly which version the new iteration is compared against.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---toltemailgt"> --to=<email> </dt> <dd> <p>Add a <code>To:</code> header to the email headers. This is in addition to any configured headers, and may be used multiple times. The negated form <code>--no-to</code> discards all <code>To:</code> headers added so far (from config or command line).</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---ccltemailgt"> --cc=<email> </dt> <dd> <p>Add a <code>Cc:</code> header to the email headers. This is in addition to any configured headers, and may be used multiple times. The negated form <code>--no-cc</code> discards all <code>Cc:</code> headers added so far (from config or command line).</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---from"> --from </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---fromltidentgt"> --from=<ident> </dt> <dd> <p>Use <code>ident</code> in the <code>From:</code> header of each commit email. If the author ident of the commit is not textually identical to the provided <code>ident</code>, place a <code>From:</code> header in the body of the message with the original author. If no <code>ident</code> is given, use the committer ident.</p> <p>Note that this option is only useful if you are actually sending the emails and want to identify yourself as the sender, but retain the original author (and <code>git am</code> will correctly pick up the in-body header). Note also that <code>git send-email</code> already handles this transformation for you, and this option should not be used if you are feeding the result to <code>git send-email</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-force-in-body-from"> --[no-]force-in-body-from </dt> <dd> <p>With the e-mail sender specified via the <code>--from</code> option, by default, an in-body "From:" to identify the real author of the commit is added at the top of the commit log message if the sender is different from the author. With this option, the in-body "From:" is added even when the sender and the author have the same name and address, which may help if the mailing list software mangles the sender’s identity. Defaults to the value of the <code>format.forceInBodyFrom</code> configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---add-headerltheadergt"> --add-header=<header> </dt> <dd> <p>Add an arbitrary header to the email headers. This is in addition to any configured headers, and may be used multiple times. For example, <code>--add-header="Organization: git-foo"</code>. The negated form <code>--no-add-header</code> discards <strong>all</strong> (<code>To:</code>, <code>Cc:</code>, and custom) headers added so far from config or command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-cover-letter"> --[no-]cover-letter </dt> <dd> <p>In addition to the patches, generate a cover letter file containing the branch description, shortlog and the overall diffstat. You can fill in a description in the file before sending it out.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---encode-email-headers"> --encode-email-headers </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-encode-email-headers"> --no-encode-email-headers </dt> <dd> <p>Encode email headers that have non-ASCII characters with "Q-encoding" (described in RFC 2047), instead of outputting the headers verbatim. Defaults to the value of the <code>format.encodeEmailHeaders</code> configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---interdiffltpreviousgt"> --interdiff=<previous> </dt> <dd> <p>As a reviewer aid, insert an interdiff into the cover letter, or as commentary of the lone patch of a 1-patch series, showing the differences between the previous version of the patch series and the series currently being formatted. <code>previous</code> is a single revision naming the tip of the previous series which shares a common base with the series being formatted (for example <code>git format-patch +--cover-letter --interdiff=feature/v1 -3 feature/v2</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---range-diffltpreviousgt"> --range-diff=<previous> </dt> <dd> <p>As a reviewer aid, insert a range-diff (see <a href="git-range-diff">git-range-diff[1]</a>) into the cover letter, or as commentary of the lone patch of a 1-patch series, showing the differences between the previous version of the patch series and the series currently being formatted. <code>previous</code> can be a single revision naming the tip of the previous series if it shares a common base with the series being formatted (for example <code>git format-patch --cover-letter --range-diff=feature/v1 -3 +feature/v2</code>), or a revision range if the two versions of the series are disjoint (for example <code>git format-patch --cover-letter +--range-diff=feature/v1~3..feature/v1 -3 feature/v2</code>).</p> <p>Note that diff options passed to the command affect how the primary product of <code>format-patch</code> is generated, and they are not passed to the underlying <code>range-diff</code> machinery used to generate the cover-letter material (this may change in the future).</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---creation-factorltpercentgt"> --creation-factor=<percent> </dt> <dd> <p>Used with <code>--range-diff</code>, tweak the heuristic which matches up commits between the previous and current series of patches by adjusting the creation/deletion cost fudge factor. See <a href="git-range-diff">git-range-diff[1]</a>) for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---notesltrefgt"> --notes[=<ref>] </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-notes"> --no-notes </dt> <dd> <p>Append the notes (see <a href="git-notes">git-notes[1]</a>) for the commit after the three-dash line.</p> <p>The expected use case of this is to write supporting explanation for the commit that does not belong to the commit log message proper, and include it with the patch submission. While one can simply write these explanations after <code>format-patch</code> has run but before sending, keeping them as Git notes allows them to be maintained between versions of the patch series (but see the discussion of the <code>notes.rewrite</code> configuration options in <a href="git-notes">git-notes[1]</a> to use this workflow).</p> <p>The default is <code>--no-notes</code>, unless the <code>format.notes</code> configuration is set.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-signatureltsignaturegt"> --[no-]signature=<signature> </dt> <dd> <p>Add a signature to each message produced. Per RFC 3676 the signature is separated from the body by a line with '-- ' on it. If the signature option is omitted the signature defaults to the Git version number.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---signature-fileltfilegt"> --signature-file=<file> </dt> <dd> <p>Works just like --signature except the signature is read from a file.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---suffixltsfxgt"> --suffix=.<sfx> </dt> <dd> <p>Instead of using <code>.patch</code> as the suffix for generated filenames, use specified suffix. A common alternative is <code>--suffix=.txt</code>. Leaving this empty will remove the <code>.patch</code> suffix.</p> <p>Note that the leading character does not have to be a dot; for example, you can use <code>--suffix=-patch</code> to get <code>0001-description-of-my-change-patch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-format-patch.txt---quiet"> --quiet </dt> <dd> <p>Do not print the names of the generated files to standard output.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-binary"> --no-binary </dt> <dd> <p>Do not output contents of changes in binary files, instead display a notice that those files changed. Patches generated using this option cannot be applied properly, but they are still useful for code review.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---zero-commit"> --zero-commit </dt> <dd> <p>Output an all-zero hash in each patch’s From header instead of the hash of the commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---no-baseltcommitgt"> --[no-]base[=<commit>] </dt> <dd> <p>Record the base tree information to identify the state the patch series applies to. See the BASE TREE INFORMATION section below for details. If <commit> is "auto", a base commit is automatically chosen. The <code>--no-base</code> option overrides a <code>format.useAutoBase</code> configuration.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---root"> --root </dt> <dd> <p>Treat the revision argument as a <revision range>, even if it is just a single commit (that would normally be treated as a <since>). Note that root commits included in the specified range are always formatted as creation patches, independently of this flag.</p> </dd> <dt class="hdlist1" id="Documentation/git-format-patch.txt---progress"> --progress </dt> <dd> <p>Show progress reports on stderr as patches are generated.</p> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>You can specify extra mail header lines to be added to each message, defaults for the subject prefix and file suffix, number patches when outputting more than one patch, add "To:" or "Cc:" headers, configure attachments, change the patch output directory, and sign off patches with configuration variables.</p> <div class="listingblock"> <div class="content"> <pre>[format] + headers = "Organization: git-foo\n" + subjectPrefix = CHANGE + suffix = .txt + numbered = auto + to = <email> + cc = <email> + attach [ = mime-boundary-string ] + signOff = true + outputDirectory = <directory> + coverLetter = auto + coverFromDescription = auto</pre> </div> </div> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>The patch produced by <code>git format-patch</code> is in UNIX mailbox format, with a fixed "magic" time stamp to indicate that the file is output from format-patch rather than a real mailbox, like so:</p> <div class="listingblock"> <div class="content"> <pre>From 8f72bad1baf19a53459661343e21d6491c3908d3 Mon Sep 17 00:00:00 2001 +From: Tony Luck <tony.luck@intel.com> +Date: Tue, 13 Jul 2010 11:42:54 -0700 +Subject: [PATCH] =?UTF-8?q?[IA64]=20Put=20ia64=20config=20files=20on=20the=20?= + =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig=20diet?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +arch/arm config files were slimmed down using a python script +(See commit c2330e286f68f1c408b4aa6515ba49d57f05beae comment) + +Do the same for ia64 so we can have sleek & trim looking +...</pre> </div> </div> <p>Typically it will be placed in a MUA’s drafts folder, edited to add timely commentary that should not go in the changelog after the three dashes, and then sent as a message whose body, in our example, starts with "arch/arm config files were…". On the receiving end, readers can save interesting patches in a UNIX mailbox and apply them with <a href="git-am">git-am[1]</a>.</p> <p>When a patch is part of an ongoing discussion, the patch generated by <code>git format-patch</code> can be tweaked to take advantage of the <code>git am --scissors</code> feature. After your response to the discussion comes a line that consists solely of "<code>-- >8 --</code>" (scissors and perforation), followed by the patch with unnecessary header fields removed:</p> <div class="listingblock"> <div class="content"> <pre>... +> So we should do such-and-such. + +Makes sense to me. How about this patch? + +-- >8 -- +Subject: [IA64] Put ia64 config files on the Uwe Kleine-König diet + +arch/arm config files were slimmed down using a python script +...</pre> </div> </div> <p>When sending a patch this way, most often you are sending your own patch, so in addition to the "<code>From $SHA1 $magic_timestamp</code>" marker you should omit <code>From:</code> and <code>Date:</code> lines from the patch file. The patch title is likely to be different from the subject of the discussion the patch is in response to, so it is likely that you would want to keep the Subject: line, like the example above.</p> <div class="sect2"> <h3 id="_checking_for_patch_corruption"> +Checking for patch corruption</h3> <p>Many mailers if not set up properly will corrupt whitespace. Here are two common types of corruption:</p> <div class="ulist"> <ul> <li> <p>Empty context lines that do not have <code>any</code> whitespace.</p> </li> <li> <p>Non-empty context lines that have one extra whitespace at the beginning.</p> </li> </ul> </div> <p>One way to test if your MUA is set up correctly is:</p> <div class="ulist"> <ul> <li> <p>Send the patch to yourself, exactly the way you would, except with To: and Cc: lines that do not contain the list and maintainer address.</p> </li> <li> <p>Save that patch to a file in UNIX mailbox format. Call it a.patch, say.</p> </li> <li> <p>Apply it:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$ git fetch <project> master:test-apply +$ git switch test-apply +$ git restore --source=HEAD --staged --worktree :/ +$ git am a.patch</pre> </div> </div> </li> </ul> </div> <p>If it does not apply correctly, there can be various reasons.</p> <div class="ulist"> <ul> <li> <p>The patch itself does not apply cleanly. That is <code>bad</code> but does not have much to do with your MUA. You might want to rebase the patch with <a href="git-rebase">git-rebase[1]</a> before regenerating it in this case.</p> </li> <li> <p>The MUA corrupted your patch; "am" would complain that the patch does not apply. Look in the .git/rebase-apply/ subdirectory and see what <code>patch</code> file contains and check for the common corruption patterns mentioned above.</p> </li> <li> <p>While at it, check the <code>info</code> and <code>final-commit</code> files as well. If what is in <code>final-commit</code> is not exactly what you would want to see in the commit log message, it is very likely that the receiver would end up hand editing the log message when applying your patch. Things like "Hi, this is my first patch.\n" in the patch e-mail should come after the three-dash line that signals the end of the commit message.</p> </li> </ul> </div> </div> </div> <h2 id="_mua_specific_hints">Mua-specific hints</h2> <div class="sectionbody"> <p>Here are some hints on how to successfully submit patches inline using various mailers.</p> <div class="sect2"> <h3 id="_gmail"> +GMail</h3> <p>GMail does not have any way to turn off line wrapping in the web interface, so it will mangle any emails that you send. You can however use "git send-email" and send your patches through the GMail SMTP server, or use any IMAP email client to connect to the google IMAP server and forward the emails through that.</p> <p>For hints on using <code>git send-email</code> to send your patches through the GMail SMTP server, see the EXAMPLE section of <a href="git-send-email">git-send-email[1]</a>.</p> <p>For hints on submission using the IMAP interface, see the EXAMPLE section of <a href="git-imap-send">git-imap-send[1]</a>.</p> </div> <div class="sect2"> <h3 id="_thunderbird"> +Thunderbird</h3> <p>By default, Thunderbird will both wrap emails as well as flag them as being <code>format=flowed</code>, both of which will make the resulting email unusable by Git.</p> <p>There are three different approaches: use an add-on to turn off line wraps, configure Thunderbird to not mangle patches, or use an external editor to keep Thunderbird from mangling the patches.</p> <div class="sect3"> <h4 id="_approach_1_add_on"> +Approach #1 (add-on)</h4> <p>Install the Toggle Word Wrap add-on that is available from <a href="https://addons.mozilla.org/thunderbird/addon/toggle-word-wrap/" class="bare">https://addons.mozilla.org/thunderbird/addon/toggle-word-wrap/</a> It adds a menu entry "Enable Word Wrap" in the composer’s "Options" menu that you can tick off. Now you can compose the message as you otherwise do (cut + paste, <code>git format-patch</code> | <code>git imap-send</code>, etc), but you have to insert line breaks manually in any text that you type.</p> </div> <div class="sect3"> <h4 id="_approach_2_configuration"> +Approach #2 (configuration)</h4> <p>Three steps:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Configure your mail server composition as plain text: Edit…Account Settings…Composition & Addressing, uncheck "Compose Messages in HTML".</p> </li> <li> <p>Configure your general composition window to not wrap.</p> <p>In Thunderbird 2: Edit..Preferences..Composition, wrap plain text messages at 0</p> <p>In Thunderbird 3: Edit..Preferences..Advanced..Config Editor. Search for "mail.wrap_long_lines". Toggle it to make sure it is set to <code>false</code>. Also, search for "mailnews.wraplength" and set the value to 0.</p> </li> <li> <p>Disable the use of format=flowed: Edit..Preferences..Advanced..Config Editor. Search for "mailnews.send_plaintext_flowed". Toggle it to make sure it is set to <code>false</code>.</p> </li> </ol> </div> <p>After that is done, you should be able to compose email as you otherwise would (cut + paste, <code>git format-patch</code> | <code>git imap-send</code>, etc), and the patches will not be mangled.</p> </div> <div class="sect3"> <h4 id="_approach_3_external_editor"> +Approach #3 (external editor)</h4> <p>The following Thunderbird extensions are needed: AboutConfig from <a href="https://mjg.github.io/AboutConfig/" class="bare">https://mjg.github.io/AboutConfig/</a> and External Editor from <a href="https://globs.org/articles.php?lng=en&pg=8" class="bare">https://globs.org/articles.php?lng=en&pg=8</a></p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Prepare the patch as a text file using your method of choice.</p> </li> <li> <p>Before opening a compose window, use Edit→Account Settings to uncheck the "Compose messages in HTML format" setting in the "Composition & Addressing" panel of the account to be used to send the patch.</p> </li> <li> <p>In the main Thunderbird window, <code>before</code> you open the compose window for the patch, use Tools→about:config to set the following to the indicated values:</p> <div class="listingblock"> <div class="content"> <pre> mailnews.send_plaintext_flowed => false + mailnews.wraplength => 0</pre> </div> </div> </li> <li> <p>Open a compose window and click the external editor icon.</p> </li> <li> <p>In the external editor window, read in the patch file and exit the editor normally.</p> </li> </ol> </div> <p>Side note: it may be possible to do step 2 with about:config and the following settings but no one’s tried yet.</p> <div class="listingblock"> <div class="content"> <pre> mail.html_compose => false + mail.identity.default.compose_html => false + mail.identity.id?.compose_html => false</pre> </div> </div> <p>There is a script in contrib/thunderbird-patch-inline which can help you include patches with Thunderbird in an easy way. To use it, do the steps above and then use the script as the external editor.</p> </div> </div> <div class="sect2"> <h3 id="_kmail"> +KMail</h3> <p>This should help you to submit patches inline using KMail.</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Prepare the patch as a text file.</p> </li> <li> <p>Click on New Mail.</p> </li> <li> <p>Go under "Options" in the Composer window and be sure that "Word wrap" is not set.</p> </li> <li> <p>Use Message → Insert file… and insert the patch.</p> </li> <li> <p>Back in the compose window: add whatever other text you wish to the message, complete the addressing and subject fields, and press send.</p> </li> </ol> </div> </div> </div> <h2 id="_base_tree_information">Base tree information</h2> <div class="sectionbody"> <p>The base tree information block is used for maintainers or third party testers to know the exact state the patch series applies to. It consists of the <code>base commit</code>, which is a well-known commit that is part of the stable part of the project history everybody else works off of, and zero or more <code>prerequisite patches</code>, which are well-known patches in flight that is not yet part of the <code>base commit</code> that need to be applied on top of <code>base commit</code> in topological order before the patches can be applied.</p> <p>The <code>base commit</code> is shown as "base-commit: " followed by the 40-hex of the commit object name. A <code>prerequisite patch</code> is shown as "prerequisite-patch-id: " followed by the 40-hex <code>patch id</code>, which can be obtained by passing the patch through the <code>git patch-id --stable</code> command.</p> <p>Imagine that on top of the public commit P, you applied well-known patches X, Y and Z from somebody else, and then built your three-patch series A, B, C, the history would be like:</p> <div class="literalblock"> <div class="content"> <pre>---P---X---Y---Z---A---B---C</pre> </div> </div> <p>With <code>git format-patch --base=P -3 C</code> (or variants thereof, e.g. with <code>--cover-letter</code> or using <code>Z..C</code> instead of <code>-3 C</code> to specify the range), the base tree information block is shown at the end of the first message the command outputs (either the first patch, or the cover letter), like this:</p> <div class="listingblock"> <div class="content"> <pre>base-commit: P +prerequisite-patch-id: X +prerequisite-patch-id: Y +prerequisite-patch-id: Z</pre> </div> </div> <p>For non-linear topology, such as</p> <div class="literalblock"> <div class="content"> <pre>---P---X---A---M---C + \ / + Y---Z---B</pre> </div> </div> <p>You can also use <code>git format-patch --base=P -3 C</code> to generate patches for A, B and C, and the identifiers for P, X, Y, Z are appended at the end of the first message.</p> <p>If set <code>--base=auto</code> in cmdline, it will automatically compute the base commit as the merge base of tip commit of the remote-tracking branch and revision-range specified in cmdline. For a local branch, you need to make it to track a remote branch by <code>git branch +--set-upstream-to</code> before using this option.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Extract commits between revisions R1 and R2, and apply them on top of the current branch using <code>git am</code> to cherry-pick them:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git format-patch -k --stdout R1..R2 | git am -3 -k</pre> </div> </div> </li> <li> <p>Extract all commits which are in the current branch but not in the origin branch:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git format-patch origin</pre> </div> </div> <p>For each commit a separate file is created in the current directory.</p> </li> <li> <p>Extract all commits that lead to <code>origin</code> since the inception of the project:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git format-patch --root origin</pre> </div> </div> </li> <li> <p>The same as the previous one:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git format-patch -M -B origin</pre> </div> </div> <p>Additionally, it detects and handles renames and complete rewrites intelligently to produce a renaming patch. A renaming patch reduces the amount of text output, and generally makes it easier to review. Note that non-Git "patch" programs won’t understand renaming patches, so use it only when you know the recipient uses Git to apply your patch.</p> </li> <li> <p>Extract three topmost commits from the current branch and format them as e-mailable patches:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git format-patch -3</pre> </div> </div> </li> </ul> </div> </div> <h2 id="_caveats">Caveats</h2> <div class="sectionbody"> <p>Note that <code>format-patch</code> will omit merge commits from the output, even if they are part of the requested range. A simple "patch" does not include enough information for the receiving end to reproduce the same merge commit.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-am">git-am[1]</a>, <a href="git-send-email">git-send-email[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-format-patch" class="_attribution-link">https://git-scm.com/docs/git-format-patch</a> + </p> +</div> diff --git a/devdocs/git/git-fsck.html b/devdocs/git/git-fsck.html new file mode 100644 index 00000000..f96ccc83 --- /dev/null +++ b/devdocs/git/git-fsck.html @@ -0,0 +1,9 @@ +<h1>git-fsck</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-fsck - Verifies the connectivity and validity of the objects in the database</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git fsck [--tags] [--root] [--unreachable] [--cache] [--no-reflogs] + [--[no-]full] [--strict] [--verbose] [--lost-found] + [--[no-]dangling] [--[no-]progress] [--connectivity-only] + [--[no-]name-objects] [<object>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Verifies the connectivity and validity of the objects in the database.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fsck.txt-ltobjectgt"> <object> </dt> <dd> <p>An object to treat as the head of an unreachability trace.</p> <p>If no objects are given, <code>git fsck</code> defaults to using the index file, all SHA-1 references in the <code>refs</code> namespace, and all reflogs (unless --no-reflogs is given) as heads.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt---unreachable"> --unreachable </dt> <dd> <p>Print out objects that exist but that aren’t reachable from any of the reference nodes.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt---no-dangling"> --[no-]dangling </dt> <dd> <p>Print objects that exist but that are never <code>directly</code> used (default). <code>--no-dangling</code> can be used to omit this information from the output.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt---root"> --root </dt> <dd> <p>Report root nodes.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt---tags"> --tags </dt> <dd> <p>Report tags.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt---cache"> --cache </dt> <dd> <p>Consider any object recorded in the index also as a head node for an unreachability trace.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt---no-reflogs"> --no-reflogs </dt> <dd> <p>Do not consider commits that are referenced only by an entry in a reflog to be reachable. This option is meant only to search for commits that used to be in a ref, but now aren’t, but are still in that corresponding reflog.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt---full"> --full </dt> <dd> <p>Check not just objects in GIT_OBJECT_DIRECTORY ($GIT_DIR/objects), but also the ones found in alternate object pools listed in GIT_ALTERNATE_OBJECT_DIRECTORIES or $GIT_DIR/objects/info/alternates, and in packed Git archives found in $GIT_DIR/objects/pack and corresponding pack subdirectories in alternate object pools. This is now default; you can turn it off with --no-full.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt---connectivity-only"> --connectivity-only </dt> <dd> <p>Check only the connectivity of reachable objects, making sure that any objects referenced by a reachable tag, commit, or tree are present. This speeds up the operation by avoiding reading blobs entirely (though it does still check that referenced blobs exist). This will detect corruption in commits and trees, but not do any semantic checks (e.g., for format errors). Corruption in blob objects will not be detected at all.</p> <p>Unreachable tags, commits, and trees will also be accessed to find the tips of dangling segments of history. Use <code>--no-dangling</code> if you don’t care about this output and want to speed it up further.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt---strict"> --strict </dt> <dd> <p>Enable more strict checking, namely to catch a file mode recorded with g+w bit set, which was created by older versions of Git. Existing repositories, including the Linux kernel, Git itself, and sparse repository have old objects that trigger this check, but it is recommended to check new projects with this flag.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt---verbose"> --verbose </dt> <dd> <p>Be chatty.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt---lost-found"> --lost-found </dt> <dd> <p>Write dangling objects into .git/lost-found/commit/ or .git/lost-found/other/, depending on type. If the object is a blob, the contents are written into the file, rather than its object name.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt---name-objects"> --name-objects </dt> <dd> <p>When displaying names of reachable objects, in addition to the SHA-1 also display a name that describes <strong>how</strong> they are reachable, compatible with <a href="git-rev-parse">git-rev-parse[1]</a>, e.g. <code>HEAD@{1234567890}~25^2:src/</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt---no-progress"> --[no-]progress </dt> <dd> <p>Progress status is reported on the standard error stream by default when it is attached to a terminal, unless --no-progress or --verbose is specified. --progress forces progress status even if the standard error stream is not directed to a terminal.</p> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fsck.txt-fsckltmsg-idgt"> fsck.<msg-id> </dt> <dd> <p>During fsck git may find issues with legacy data which wouldn’t be generated by current versions of git, and which wouldn’t be sent over the wire if <code>transfer.fsckObjects</code> was set. This feature is intended to support working with legacy repositories containing such data.</p> <p>Setting <code>fsck.<msg-id></code> will be picked up by <a href="git-fsck">git-fsck[1]</a>, but to accept pushes of such data set <code>receive.fsck.<msg-id></code> instead, or to clone or fetch it set <code>fetch.fsck.<msg-id></code>.</p> <p>The rest of the documentation discusses <code>fsck.*</code> for brevity, but the same applies for the corresponding <code>receive.fsck.*</code> and <code>fetch.fsck.*</code>. variables.</p> <p>Unlike variables like <code>color.ui</code> and <code>core.editor</code>, the <code>receive.fsck.<msg-id></code> and <code>fetch.fsck.<msg-id></code> variables will not fall back on the <code>fsck.<msg-id></code> configuration if they aren’t set. To uniformly configure the same fsck settings in different circumstances, all three of them must be set to the same values.</p> <p>When <code>fsck.<msg-id></code> is set, errors can be switched to warnings and vice versa by configuring the <code>fsck.<msg-id></code> setting where the <code><msg-id></code> is the fsck message ID and the value is one of <code>error</code>, <code>warn</code> or <code>ignore</code>. For convenience, fsck prefixes the error/warning with the message ID, e.g. "missingEmail: invalid author/committer line - missing email" means that setting <code>fsck.missingEmail = ignore</code> will hide that issue.</p> <p>In general, it is better to enumerate existing objects with problems with <code>fsck.skipList</code>, instead of listing the kind of breakages these problematic objects share to be ignored, as doing the latter will allow new instances of the same breakages go unnoticed.</p> <p>Setting an unknown <code>fsck.<msg-id></code> value will cause fsck to die, but doing the same for <code>receive.fsck.<msg-id></code> and <code>fetch.fsck.<msg-id></code> will only cause git to warn.</p> <p>See the <code>Fsck Messages</code> section of <a href="git-fsck">git-fsck[1]</a> for supported values of <code><msg-id></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-fsckskipList"> fsck.skipList </dt> <dd> <p>The path to a list of object names (i.e. one unabbreviated SHA-1 per line) that are known to be broken in a non-fatal way and should be ignored. On versions of Git 2.20 and later, comments (<code>#</code>), empty lines, and any leading and trailing whitespace are ignored. Everything but a SHA-1 per line will error out on older versions.</p> <p>This feature is useful when an established project should be accepted despite early commits containing errors that can be safely ignored, such as invalid committer email addresses. Note: corrupt objects cannot be skipped with this setting.</p> <p>Like <code>fsck.<msg-id></code> this variable has corresponding <code>receive.fsck.skipList</code> and <code>fetch.fsck.skipList</code> variants.</p> <p>Unlike variables like <code>color.ui</code> and <code>core.editor</code> the <code>receive.fsck.skipList</code> and <code>fetch.fsck.skipList</code> variables will not fall back on the <code>fsck.skipList</code> configuration if they aren’t set. To uniformly configure the same fsck settings in different circumstances, all three of them must be set to the same values.</p> <p>Older versions of Git (before 2.20) documented that the object names list should be sorted. This was never a requirement; the object names could appear in any order, but when reading the list we tracked whether the list was sorted for the purposes of an internal binary search implementation, which could save itself some work with an already sorted list. Unless you had a humongous list there was no reason to go out of your way to pre-sort the list. After Git version 2.20 a hash implementation is used instead, so there’s now no reason to pre-sort the list.</p> </dd> </dl> </div> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>git-fsck tests SHA-1 and general object sanity, and it does full tracking of the resulting reachability and everything else. It prints out any corruption it finds (missing or bad objects), and if you use the <code>--unreachable</code> flag it will also print out objects that exist but that aren’t reachable from any of the specified head nodes (or the default set, as mentioned above).</p> <p>Any corrupt objects you will have to find in backups or other archives (i.e., you can just remove them and do an <code>rsync</code> with some other site in the hopes that somebody else has the object you have corrupted).</p> <p>If core.commitGraph is true, the commit-graph file will also be inspected using <code>git commit-graph verify</code>. See <a href="git-commit-graph">git-commit-graph[1]</a>.</p> </div> <h2 id="_extracted_diagnostics">Extracted diagnostics</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fsck.txt-unreachablelttypegtltobjectgt"> unreachable <type> <object> </dt> <dd> <p>The <type> object <object>, isn’t actually referred to directly or indirectly in any of the trees or commits seen. This can mean that there’s another root node that you’re not specifying or that the tree is corrupt. If you haven’t missed a root node then you might as well delete unreachable nodes since they can’t be used.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-missinglttypegtltobjectgt"> missing <type> <object> </dt> <dd> <p>The <type> object <object>, is referred to but isn’t present in the database.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-danglinglttypegtltobjectgt"> dangling <type> <object> </dt> <dd> <p>The <type> object <object>, is present in the database but never <code>directly</code> used. A dangling commit could be a root node.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-hashmismatchltobjectgt"> hash mismatch <object> </dt> <dd> <p>The database has an object whose hash doesn’t match the object database value. This indicates a serious data integrity problem.</p> </dd> </dl> </div> </div> <h2 id="_fsck_messages">Fsck messages</h2> <div class="sectionbody"> <p>The following lists the types of errors <code>git fsck</code> detects and what each error means, with their default severity. The severity of the error, other than those that are marked as "(FATAL)", can be tweaked by setting the corresponding <code>fsck.<msg-id></code> configuration variable.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fsck.txt-codebadDatecode"> <code>badDate</code> </dt> <dd> <p>(ERROR) Invalid date format in an author/committer line.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codebadDateOverflowcode"> <code>badDateOverflow</code> </dt> <dd> <p>(ERROR) Invalid date value in an author/committer line.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codebadEmailcode"> <code>badEmail</code> </dt> <dd> <p>(ERROR) Invalid email format in an author/committer line.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codebadFilemodecode"> <code>badFilemode</code> </dt> <dd> <p>(INFO) A tree contains a bad filemode entry.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codebadNamecode"> <code>badName</code> </dt> <dd> <p>(ERROR) An author/committer name is empty.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codebadObjectSha1code"> <code>badObjectSha1</code> </dt> <dd> <p>(ERROR) An object has a bad sha1.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codebadParentSha1code"> <code>badParentSha1</code> </dt> <dd> <p>(ERROR) A commit object has a bad parent sha1.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codebadTagNamecode"> <code>badTagName</code> </dt> <dd> <p>(INFO) A tag has an invalid format.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codebadTimezonecode"> <code>badTimezone</code> </dt> <dd> <p>(ERROR) Found an invalid time zone in an author/committer line.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codebadTreecode"> <code>badTree</code> </dt> <dd> <p>(ERROR) A tree cannot be parsed.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codebadTreeSha1code"> <code>badTreeSha1</code> </dt> <dd> <p>(ERROR) A tree has an invalid format.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codebadTypecode"> <code>badType</code> </dt> <dd> <p>(ERROR) Found an invalid object type.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codeduplicateEntriescode"> <code>duplicateEntries</code> </dt> <dd> <p>(ERROR) A tree contains duplicate file entries.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codeemptyNamecode"> <code>emptyName</code> </dt> <dd> <p>(WARN) A path contains an empty name.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codeextraHeaderEntrycode"> <code>extraHeaderEntry</code> </dt> <dd> <p>(IGNORE) Extra headers found after <code>tagger</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codefullPathnamecode"> <code>fullPathname</code> </dt> <dd> <p>(WARN) A path contains the full path starting with "/".</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codegitattributesBlobcode"> <code>gitattributesBlob</code> </dt> <dd> <p>(ERROR) A non-blob found at <code>.gitattributes</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codegitattributesLargecode"> <code>gitattributesLarge</code> </dt> <dd> <p>(ERROR) The <code>.gitattributes</code> blob is too large.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codegitattributesLineLengthcode"> <code>gitattributesLineLength</code> </dt> <dd> <p>(ERROR) The <code>.gitattributes</code> blob contains too long lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codegitattributesMissingcode"> <code>gitattributesMissing</code> </dt> <dd> <p>(ERROR) Unable to read <code>.gitattributes</code> blob.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codegitattributesSymlinkcode"> <code>gitattributesSymlink</code> </dt> <dd> <p>(INFO) <code>.gitattributes</code> is a symlink.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codegitignoreSymlinkcode"> <code>gitignoreSymlink</code> </dt> <dd> <p>(INFO) <code>.gitignore</code> is a symlink.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codegitmodulesBlobcode"> <code>gitmodulesBlob</code> </dt> <dd> <p>(ERROR) A non-blob found at <code>.gitmodules</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codegitmodulesLargecode"> <code>gitmodulesLarge</code> </dt> <dd> <p>(ERROR) The <code>.gitmodules</code> file is too large to parse.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codegitmodulesMissingcode"> <code>gitmodulesMissing</code> </dt> <dd> <p>(ERROR) Unable to read <code>.gitmodules</code> blob.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codegitmodulesNamecode"> <code>gitmodulesName</code> </dt> <dd> <p>(ERROR) A submodule name is invalid.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codegitmodulesParsecode"> <code>gitmodulesParse</code> </dt> <dd> <p>(INFO) Could not parse <code>.gitmodules</code> blob.</p> </dd> </dl> </div> <p><code>gitmodulesLarge</code>; (ERROR) <code>.gitmodules</code> blob is too large to parse.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fsck.txt-codegitmodulesPathcode"> <code>gitmodulesPath</code> </dt> <dd> <p>(ERROR) <code>.gitmodules</code> path is invalid.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codegitmodulesSymlinkcode"> <code>gitmodulesSymlink</code> </dt> <dd> <p>(ERROR) <code>.gitmodules</code> is a symlink.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codegitmodulesUpdatecode"> <code>gitmodulesUpdate</code> </dt> <dd> <p>(ERROR) Found an invalid submodule update setting.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codegitmodulesUrlcode"> <code>gitmodulesUrl</code> </dt> <dd> <p>(ERROR) Found an invalid submodule url.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codehasDotcode"> <code>hasDot</code> </dt> <dd> <p>(WARN) A tree contains an entry named <code>.</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codehasDotdotcode"> <code>hasDotdot</code> </dt> <dd> <p>(WARN) A tree contains an entry named <code>..</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codehasDotgitcode"> <code>hasDotgit</code> </dt> <dd> <p>(WARN) A tree contains an entry named <code>.git</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codelargePathnamecode"> <code>largePathname</code> </dt> <dd> <p>(WARN) A tree contains an entry with a very long path name. If the value of <code>fsck.largePathname</code> contains a colon, that value is used as the maximum allowable length (e.g., "warn:10" would complain about any path component of 11 or more bytes). The default value is 4096.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codemailmapSymlinkcode"> <code>mailmapSymlink</code> </dt> <dd> <p>(INFO) <code>.mailmap</code> is a symlink.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codemissingAuthorcode"> <code>missingAuthor</code> </dt> <dd> <p>(ERROR) Author is missing.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codemissingCommittercode"> <code>missingCommitter</code> </dt> <dd> <p>(ERROR) Committer is missing.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codemissingEmailcode"> <code>missingEmail</code> </dt> <dd> <p>(ERROR) Email is missing in an author/committer line.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codemissingNameBeforeEmailcode"> <code>missingNameBeforeEmail</code> </dt> <dd> <p>(ERROR) Missing name before an email in an author/committer line.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codemissingObjectcode"> <code>missingObject</code> </dt> <dd> <p>(ERROR) Missing <code>object</code> line in tag object.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codemissingSpaceBeforeDatecode"> <code>missingSpaceBeforeDate</code> </dt> <dd> <p>(ERROR) Missing space before date in an author/committer line.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codemissingSpaceBeforeEmailcode"> <code>missingSpaceBeforeEmail</code> </dt> <dd> <p>(ERROR) Missing space before the email in an author/committer line.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codemissingTagcode"> <code>missingTag</code> </dt> <dd> <p>(ERROR) Unexpected end after <code>type</code> line in a tag object.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codemissingTagEntrycode"> <code>missingTagEntry</code> </dt> <dd> <p>(ERROR) Missing <code>tag</code> line in a tag object.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codemissingTaggerEntrycode"> <code>missingTaggerEntry</code> </dt> <dd> <p>(INFO) Missing <code>tagger</code> line in a tag object.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codemissingTreecode"> <code>missingTree</code> </dt> <dd> <p>(ERROR) Missing <code>tree</code> line in a commit object.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codemissingTypecode"> <code>missingType</code> </dt> <dd> <p>(ERROR) Invalid type value on the <code>type</code> line in a tag object.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codemissingTypeEntrycode"> <code>missingTypeEntry</code> </dt> <dd> <p>(ERROR) Missing <code>type</code> line in a tag object.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codemultipleAuthorscode"> <code>multipleAuthors</code> </dt> <dd> <p>(ERROR) Multiple author lines found in a commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codenulInCommitcode"> <code>nulInCommit</code> </dt> <dd> <p>(WARN) Found a NUL byte in the commit object body.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codenulInHeadercode"> <code>nulInHeader</code> </dt> <dd> <p>(FATAL) NUL byte exists in the object header.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codenullSha1code"> <code>nullSha1</code> </dt> <dd> <p>(WARN) Tree contains entries pointing to a null sha1.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codetreeNotSortedcode"> <code>treeNotSorted</code> </dt> <dd> <p>(ERROR) A tree is not properly sorted.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codeunknownTypecode"> <code>unknownType</code> </dt> <dd> <p>(ERROR) Found an unknown object type.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codeunterminatedHeadercode"> <code>unterminatedHeader</code> </dt> <dd> <p>(FATAL) Missing end-of-line in the object header.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codezeroPaddedDatecode"> <code>zeroPaddedDate</code> </dt> <dd> <p>(ERROR) Found a zero padded date in an author/committer line.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-codezeroPaddedFilemodecode"> <code>zeroPaddedFilemode</code> </dt> <dd> <p>(WARN) Found a zero padded filemode in a tree.</p> </dd> </dl> </div> </div> <h2 id="_environment_variables">Environment variables</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fsck.txt-GITOBJECTDIRECTORY"> GIT_OBJECT_DIRECTORY </dt> <dd> <p>used to specify the object database root (usually $GIT_DIR/objects)</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-GITINDEXFILE"> GIT_INDEX_FILE </dt> <dd> <p>used to specify the index file of the index</p> </dd> <dt class="hdlist1" id="Documentation/git-fsck.txt-GITALTERNATEOBJECTDIRECTORIES"> GIT_ALTERNATE_OBJECT_DIRECTORIES </dt> <dd> <p>used to specify additional object database roots (usually unset)</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-fsck" class="_attribution-link">https://git-scm.com/docs/git-fsck</a> + </p> +</div> diff --git a/devdocs/git/git-fsmonitor--daemon.html b/devdocs/git/git-fsmonitor--daemon.html new file mode 100644 index 00000000..186db586 --- /dev/null +++ b/devdocs/git/git-fsmonitor--daemon.html @@ -0,0 +1,9 @@ +<h1>git-fsmonitor--daemon</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-fsmonitor—daemon - A Built-in Filesystem Monitor</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git fsmonitor--daemon start +git fsmonitor--daemon run +git fsmonitor--daemon stop +git fsmonitor--daemon status</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>A daemon to watch the working directory for file and directory changes using platform-specific filesystem notification facilities.</p> <p>This daemon communicates directly with commands like <code>git status</code> using the <a href="api-simple-ipc">simple IPC</a> interface instead of the slower <a href="githooks">githooks[5]</a> interface.</p> <p>This daemon is built into Git so that no third-party tools are required.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fsmonitor--daemon.txt-start"> start </dt> <dd> <p>Starts a daemon in the background.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsmonitor--daemon.txt-run"> run </dt> <dd> <p>Runs a daemon in the foreground.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsmonitor--daemon.txt-stop"> stop </dt> <dd> <p>Stops the daemon running in the current working directory, if present.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsmonitor--daemon.txt-status"> status </dt> <dd> <p>Exits with zero status if a daemon is watching the current working directory.</p> </dd> </dl> </div> </div> <h2 id="_remarks">Remarks</h2> <div class="sectionbody"> <p>This daemon is a long running process used to watch a single working directory and maintain a list of the recently changed files and directories. Performance of commands such as <code>git status</code> can be increased if they just ask for a summary of changes to the working directory and can avoid scanning the disk.</p> <p>When <code>core.fsmonitor</code> is set to <code>true</code> (see <a href="git-config">git-config[1]</a>) commands, such as <code>git status</code>, will ask the daemon for changes and automatically start it (if necessary).</p> <p>For more information see the "File System Monitor" section in <a href="git-update-index">git-update-index[1]</a>.</p> </div> <h2 id="_caveats">Caveats</h2> <div class="sectionbody"> <p>The fsmonitor daemon does not currently know about submodules and does not know to filter out filesystem events that happen within a submodule. If fsmonitor daemon is watching a super repo and a file is modified within the working directory of a submodule, it will report the change (as happening against the super repo). However, the client will properly ignore these extra events, so performance may be affected but it will not cause an incorrect result.</p> <p>By default, the fsmonitor daemon refuses to work with network-mounted repositories; this may be overridden by setting <code>fsmonitor.allowRemote</code> to <code>true</code>. Note, however, that the fsmonitor daemon is not guaranteed to work correctly with all network-mounted repositories, so such use is considered experimental.</p> <p>On Mac OS, the inter-process communication (IPC) between various Git commands and the fsmonitor daemon is done via a Unix domain socket (UDS) — a special type of file — which is supported by native Mac OS filesystems, but not on network-mounted filesystems, NTFS, or FAT32. Other filesystems may or may not have the needed support; the fsmonitor daemon is not guaranteed to work with these filesystems and such use is considered experimental.</p> <p>By default, the socket is created in the <code>.git</code> directory. However, if the <code>.git</code> directory is on a network-mounted filesystem, it will instead be created at <code>$HOME/.git-fsmonitor-*</code> unless <code>$HOME</code> itself is on a network-mounted filesystem, in which case you must set the configuration variable <code>fsmonitor.socketDir</code> to the path of a directory on a Mac OS native filesystem in which to create the socket file.</p> <p>If none of the above directories (<code>.git</code>, <code>$HOME</code>, or <code>fsmonitor.socketDir</code>) is on a native Mac OS file filesystem the fsmonitor daemon will report an error that will cause the daemon and the currently running command to exit.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-fsmonitor--daemon.txt-fsmonitorallowRemote"> fsmonitor.allowRemote </dt> <dd> <p>By default, the fsmonitor daemon refuses to work with network-mounted repositories. Setting <code>fsmonitor.allowRemote</code> to <code>true</code> overrides this behavior. Only respected when <code>core.fsmonitor</code> is set to <code>true</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-fsmonitor--daemon.txt-fsmonitorsocketDir"> fsmonitor.socketDir </dt> <dd> <p>This Mac OS-specific option, if set, specifies the directory in which to create the Unix domain socket used for communication between the fsmonitor daemon and various Git commands. The directory must reside on a native Mac OS filesystem. Only respected when <code>core.fsmonitor</code> is set to <code>true</code>.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-fsmonitor--daemon" class="_attribution-link">https://git-scm.com/docs/git-fsmonitor--daemon</a> + </p> +</div> diff --git a/devdocs/git/git-gc.html b/devdocs/git/git-gc.html new file mode 100644 index 00000000..117bade1 --- /dev/null +++ b/devdocs/git/git-gc.html @@ -0,0 +1,8 @@ +<h1>git-gc</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-gc - Cleanup unnecessary files and optimize the local repository</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git gc [--aggressive] [--auto] [--quiet] [--prune=<date> | --no-prune] [--force] [--keep-largest-pack]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Runs a number of housekeeping tasks within the current repository, such as compressing file revisions (to reduce disk space and increase performance), removing unreachable objects which may have been created from prior invocations of <code>git add</code>, packing refs, pruning reflog, rerere metadata or stale working trees. May also update ancillary indexes such as the commit-graph.</p> <p>When common porcelain operations that create objects are run, they will check whether the repository has grown substantially since the last maintenance, and if so run <code>git gc</code> automatically. See <code>gc.auto</code> below for how to disable this behavior.</p> <p>Running <code>git gc</code> manually should only be needed when adding objects to a repository without regularly running such porcelain commands, to do a one-off repository optimization, or e.g. to clean up a suboptimal mass-import. See the "PACKFILE OPTIMIZATION" section in <a href="git-fast-import">git-fast-import[1]</a> for more details on the import case.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-gc.txt---aggressive"> --aggressive </dt> <dd> <p>Usually <code>git gc</code> runs very quickly while providing good disk space utilization and performance. This option will cause <code>git gc</code> to more aggressively optimize the repository at the expense of taking much more time. The effects of this optimization are mostly persistent. See the "AGGRESSIVE" section below for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---auto"> --auto </dt> <dd> <p>With this option, <code>git gc</code> checks whether any housekeeping is required; if not, it exits without performing any work.</p> <p>See the <code>gc.auto</code> option in the "CONFIGURATION" section below for how this heuristic works.</p> <p>Once housekeeping is triggered by exceeding the limits of configuration options such as <code>gc.auto</code> and <code>gc.autoPackLimit</code>, all other housekeeping tasks (e.g. rerere, working trees, reflog…) will be performed as well.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---no-cruft"> --[no-]cruft </dt> <dd> <p>When expiring unreachable objects, pack them separately into a cruft pack instead of storing them as loose objects. <code>--cruft</code> is on by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---max-cruft-sizeltngt"> --max-cruft-size=<n> </dt> <dd> <p>When packing unreachable objects into a cruft pack, limit the size of new cruft packs to be at most <code><n></code> bytes. Overrides any value specified via the <code>gc.maxCruftSize</code> configuration. See the <code>--max-cruft-size</code> option of <a href="git-repack">git-repack[1]</a> for more.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---pruneltdategt"> --prune=<date> </dt> <dd> <p>Prune loose objects older than date (default is 2 weeks ago, overridable by the config variable <code>gc.pruneExpire</code>). --prune=now prunes loose objects regardless of their age and increases the risk of corruption if another process is writing to the repository concurrently; see "NOTES" below. --prune is on by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---no-prune"> --no-prune </dt> <dd> <p>Do not prune any loose objects.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---quiet"> --quiet </dt> <dd> <p>Suppress all progress reports.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---force"> --force </dt> <dd> <p>Force <code>git gc</code> to run even if there may be another <code>git gc</code> instance running on this repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---keep-largest-pack"> --keep-largest-pack </dt> <dd> <p>All packs except the largest non-cruft pack, any packs marked with a <code>.keep</code> file, and any cruft pack(s) are consolidated into a single pack. When this option is used, <code>gc.bigPackThreshold</code> is ignored.</p> </dd> </dl> </div> </div> <h2 id="_aggressive">Aggressive</h2> <div class="sectionbody"> <p>When the <code>--aggressive</code> option is supplied, <a href="git-repack">git-repack[1]</a> will be invoked with the <code>-f</code> flag, which in turn will pass <code>--no-reuse-delta</code> to <a href="git-pack-objects">git-pack-objects[1]</a>. This will throw away any existing deltas and re-compute them, at the expense of spending much more time on the repacking.</p> <p>The effects of this are mostly persistent, e.g. when packs and loose objects are coalesced into one another pack the existing deltas in that pack might get re-used, but there are also various cases where we might pick a sub-optimal delta from a newer pack instead.</p> <p>Furthermore, supplying <code>--aggressive</code> will tweak the <code>--depth</code> and <code>--window</code> options passed to <a href="git-repack">git-repack[1]</a>. See the <code>gc.aggressiveDepth</code> and <code>gc.aggressiveWindow</code> settings below. By using a larger window size we’re more likely to find more optimal deltas.</p> <p>It’s probably not worth it to use this option on a given repository without running tailored performance benchmarks on it. It takes a lot more time, and the resulting space/delta optimization may or may not be worth it. Not using this at all is the right trade-off for most users and their repositories.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-gc.txt-gcaggressiveDepth"> gc.aggressiveDepth </dt> <dd> <p>The depth parameter used in the delta compression algorithm used by <code>git gc --aggressive</code>. This defaults to 50, which is the default for the <code>--depth</code> option when <code>--aggressive</code> isn’t in use.</p> <p>See the documentation for the <code>--depth</code> option in <a href="git-repack">git-repack[1]</a> for more details.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcaggressiveWindow"> gc.aggressiveWindow </dt> <dd> <p>The window size parameter used in the delta compression algorithm used by <code>git gc --aggressive</code>. This defaults to 250, which is a much more aggressive window size than the default <code>--window</code> of 10.</p> <p>See the documentation for the <code>--window</code> option in <a href="git-repack">git-repack[1]</a> for more details.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcauto"> gc.auto </dt> <dd> <p>When there are approximately more than this many loose objects in the repository, <code>git gc --auto</code> will pack them. Some Porcelain commands use this command to perform a light-weight garbage collection from time to time. The default value is 6700.</p> <p>Setting this to 0 disables not only automatic packing based on the number of loose objects, but also any other heuristic <code>git gc --auto</code> will otherwise use to determine if there’s work to do, such as <code>gc.autoPackLimit</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcautoPackLimit"> gc.autoPackLimit </dt> <dd> <p>When there are more than this many packs that are not marked with <code>*.keep</code> file in the repository, <code>git gc +--auto</code> consolidates them into one larger pack. The default value is 50. Setting this to 0 disables it. Setting <code>gc.auto</code> to 0 will also disable this.</p> <p>See the <code>gc.bigPackThreshold</code> configuration variable below. When in use, it’ll affect how the auto pack limit works.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcautoDetach"> gc.autoDetach </dt> <dd> <p>Make <code>git gc --auto</code> return immediately and run in the background if the system supports it. Default is true.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcbigPackThreshold"> gc.bigPackThreshold </dt> <dd> <p>If non-zero, all non-cruft packs larger than this limit are kept when <code>git gc</code> is run. This is very similar to <code>--keep-largest-pack</code> except that all non-cruft packs that meet the threshold are kept, not just the largest pack. Defaults to zero. Common unit suffixes of <code>k</code>, <code>m</code>, or <code>g</code> are supported.</p> <p>Note that if the number of kept packs is more than gc.autoPackLimit, this configuration variable is ignored, all packs except the base pack will be repacked. After this the number of packs should go below gc.autoPackLimit and gc.bigPackThreshold should be respected again.</p> <p>If the amount of memory estimated for <code>git repack</code> to run smoothly is not available and <code>gc.bigPackThreshold</code> is not set, the largest pack will also be excluded (this is the equivalent of running <code>git gc</code> with <code>--keep-largest-pack</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcwriteCommitGraph"> gc.writeCommitGraph </dt> <dd> <p>If true, then gc will rewrite the commit-graph file when <a href="git-gc">git-gc[1]</a> is run. When using <code>git gc --auto</code> the commit-graph will be updated if housekeeping is required. Default is true. See <a href="git-commit-graph">git-commit-graph[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gclogExpiry"> gc.logExpiry </dt> <dd> <p>If the file gc.log exists, then <code>git gc --auto</code> will print its content and exit with status zero instead of running unless that file is more than <code>gc.logExpiry</code> old. Default is "1.day". See <code>gc.pruneExpire</code> for more ways to specify its value.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcpackRefs"> gc.packRefs </dt> <dd> <p>Running <code>git pack-refs</code> in a repository renders it unclonable by Git versions prior to 1.5.1.2 over dumb transports such as HTTP. This variable determines whether <code>git gc</code> runs <code>git pack-refs</code>. This can be set to <code>notbare</code> to enable it within all non-bare repos or it can be set to a boolean value. The default is <code>true</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gccruftPacks"> gc.cruftPacks </dt> <dd> <p>Store unreachable objects in a cruft pack (see <a href="git-repack">git-repack[1]</a>) instead of as loose objects. The default is <code>true</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcmaxCruftSize"> gc.maxCruftSize </dt> <dd> <p>Limit the size of new cruft packs when repacking. When specified in addition to <code>--max-cruft-size</code>, the command line option takes priority. See the <code>--max-cruft-size</code> option of <a href="git-repack">git-repack[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcpruneExpire"> gc.pruneExpire </dt> <dd> <p>When <code>git gc</code> is run, it will call <code>prune --expire 2.weeks.ago</code> (and <code>repack --cruft --cruft-expiration 2.weeks.ago</code> if using cruft packs via <code>gc.cruftPacks</code> or <code>--cruft</code>). Override the grace period with this config variable. The value "now" may be used to disable this grace period and always prune unreachable objects immediately, or "never" may be used to suppress pruning. This feature helps prevent corruption when <code>git gc</code> runs concurrently with another process writing to the repository; see the "NOTES" section of <a href="git-gc">git-gc[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcworktreePruneExpire"> gc.worktreePruneExpire </dt> <dd> <p>When <code>git gc</code> is run, it calls <code>git worktree prune --expire 3.months.ago</code>. This config variable can be used to set a different grace period. The value "now" may be used to disable the grace period and prune <code>$GIT_DIR/worktrees</code> immediately, or "never" may be used to suppress pruning.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcreflogExpire"> gc.reflogExpire </dt> <dt class="hdlist1" id="Documentation/git-gc.txt-gcltpatterngtreflogExpire"> gc.<pattern>.reflogExpire </dt> <dd> <p><code>git reflog expire</code> removes reflog entries older than this time; defaults to 90 days. The value "now" expires all entries immediately, and "never" suppresses expiration altogether. With "<pattern>" (e.g. "refs/stash") in the middle the setting applies only to the refs that match the <pattern>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcreflogExpireUnreachable"> gc.reflogExpireUnreachable </dt> <dt class="hdlist1" id="Documentation/git-gc.txt-gcltpatterngtreflogExpireUnreachable"> gc.<pattern>.reflogExpireUnreachable </dt> <dd> <p><code>git reflog expire</code> removes reflog entries older than this time and are not reachable from the current tip; defaults to 30 days. The value "now" expires all entries immediately, and "never" suppresses expiration altogether. With "<pattern>" (e.g. "refs/stash") in the middle, the setting applies only to the refs that match the <pattern>.</p> <p>These types of entries are generally created as a result of using <code>git +commit --amend</code> or <code>git rebase</code> and are the commits prior to the amend or rebase occurring. Since these changes are not part of the current project most users will want to expire them sooner, which is why the default is more aggressive than <code>gc.reflogExpire</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcrecentObjectsHook"> gc.recentObjectsHook </dt> <dd> <p>When considering whether or not to remove an object (either when generating a cruft pack or storing unreachable objects as loose), use the shell to execute the specified command(s). Interpret their output as object IDs which Git will consider as "recent", regardless of their age. By treating their mtimes as "now", any objects (and their descendants) mentioned in the output will be kept regardless of their true age.</p> <p>Output must contain exactly one hex object ID per line, and nothing else. Objects which cannot be found in the repository are ignored. Multiple hooks are supported, but all must exit successfully, else the operation (either generating a cruft pack or unpacking unreachable objects) will be halted.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcrepackFilter"> gc.repackFilter </dt> <dd> <p>When repacking, use the specified filter to move certain objects into a separate packfile. See the <code>--filter=<filter-spec></code> option of <a href="git-repack">git-repack[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcrepackFilterTo"> gc.repackFilterTo </dt> <dd> <p>When repacking and using a filter, see <code>gc.repackFilter</code>, the specified location will be used to create the packfile containing the filtered out objects. <strong>WARNING:</strong> The specified location should be accessible, using for example the Git alternates mechanism, otherwise the repo could be considered corrupt by Git as it migh not be able to access the objects in that packfile. See the <code>--filter-to=<dir></code> option of <a href="git-repack">git-repack[1]</a> and the <code>objects/info/alternates</code> section of <a href="gitrepository-layout">gitrepository-layout[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcrerereResolved"> gc.rerereResolved </dt> <dd> <p>Records of conflicted merge you resolved earlier are kept for this many days when <code>git rerere gc</code> is run. You can also use more human-readable "1.month.ago", etc. The default is 60 days. See <a href="git-rerere">git-rerere[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcrerereUnresolved"> gc.rerereUnresolved </dt> <dd> <p>Records of conflicted merge you have not resolved are kept for this many days when <code>git rerere gc</code> is run. You can also use more human-readable "1.month.ago", etc. The default is 15 days. See <a href="git-rerere">git-rerere[1]</a>.</p> </dd> </dl> </div> </div> <h2 id="_notes">Notes</h2> <div class="sectionbody"> <p><code>git gc</code> tries very hard not to delete objects that are referenced anywhere in your repository. In particular, it will keep not only objects referenced by your current set of branches and tags, but also objects referenced by the index, remote-tracking branches, reflogs (which may reference commits in branches that were later amended or rewound), and anything else in the refs/* namespace. Note that a note (of the kind created by <code>git notes</code>) attached to an object does not contribute in keeping the object alive. If you are expecting some objects to be deleted and they aren’t, check all of those locations and decide whether it makes sense in your case to remove those references.</p> <p>On the other hand, when <code>git gc</code> runs concurrently with another process, there is a risk of it deleting an object that the other process is using but hasn’t created a reference to. This may just cause the other process to fail or may corrupt the repository if the other process later adds a reference to the deleted object. Git has two features that significantly mitigate this problem:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Any object with modification time newer than the <code>--prune</code> date is kept, along with everything reachable from it.</p> </li> <li> <p>Most operations that add an object to the database update the modification time of the object if it is already present so that #1 applies.</p> </li> </ol> </div> <p>However, these features fall short of a complete solution, so users who run commands concurrently have to live with some risk of corruption (which seems to be low in practice).</p> </div> <h2 id="_hooks">Hooks</h2> <div class="sectionbody"> <p>The <code>git gc --auto</code> command will run the <code>pre-auto-gc</code> hook. See <a href="githooks">githooks[5]</a> for more information.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-prune">git-prune[1]</a> <a href="git-reflog">git-reflog[1]</a> <a href="git-repack">git-repack[1]</a> <a href="git-rerere">git-rerere[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-gc" class="_attribution-link">https://git-scm.com/docs/git-gc</a> + </p> +</div> diff --git a/devdocs/git/git-get-tar-commit-id.html b/devdocs/git/git-get-tar-commit-id.html new file mode 100644 index 00000000..2a6f8a56 --- /dev/null +++ b/devdocs/git/git-get-tar-commit-id.html @@ -0,0 +1,6 @@ +<h1>git-get-tar-commit-id</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-get-tar-commit-id - Extract commit ID from an archive created using git-archive</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git get-tar-commit-id</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Read a tar archive created by <code>git archive</code> from the standard input and extract the commit ID stored in it. It reads only the first 1024 bytes of input, thus its runtime is not influenced by the size of the tar archive very much.</p> <p>If no commit ID is found, <code>git get-tar-commit-id</code> quietly exits with a return code of 1. This can happen if the archive had not been created using <code>git archive</code> or if the first parameter of <code>git archive</code> had been a tree ID instead of a commit ID or tag.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-get-tar-commit-id" class="_attribution-link">https://git-scm.com/docs/git-get-tar-commit-id</a> + </p> +</div> diff --git a/devdocs/git/git-grep.html b/devdocs/git/git-grep.html new file mode 100644 index 00000000..5cc0a766 --- /dev/null +++ b/devdocs/git/git-grep.html @@ -0,0 +1,26 @@ +<h1>git-grep</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-grep - Print lines matching a pattern</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git grep [-a | --text] [-I] [--textconv] [-i | --ignore-case] [-w | --word-regexp] + [-v | --invert-match] [-h|-H] [--full-name] + [-E | --extended-regexp] [-G | --basic-regexp] + [-P | --perl-regexp] + [-F | --fixed-strings] [-n | --line-number] [--column] + [-l | --files-with-matches] [-L | --files-without-match] + [(-O | --open-files-in-pager) [<pager>]] + [-z | --null] + [ -o | --only-matching ] [-c | --count] [--all-match] [-q | --quiet] + [--max-depth <depth>] [--[no-]recursive] + [--color[=<when>] | --no-color] + [--break] [--heading] [-p | --show-function] + [-A <post-context>] [-B <pre-context>] [-C <context>] + [-W | --function-context] + [(-m | --max-count) <num>] + [--threads <num>] + [-f <file>] [-e] <pattern> + [--and|--or|--not|(|)|-e <pattern>…] + [--recurse-submodules] [--parent-basename <basename>] + [ [--[no-]exclude-standard] [--cached | --no-index | --untracked] | <tree>…] + [--] [<pathspec>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Look for specified patterns in the tracked files in the work tree, blobs registered in the index file, or blobs in given tree objects. Patterns are lists of one or more search expressions separated by newline characters. An empty string as search expression matches all lines.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-grep.txt---cached"> --cached </dt> <dd> <p>Instead of searching tracked files in the working tree, search blobs registered in the index file.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---no-index"> --no-index </dt> <dd> <p>Search files in the current directory that is not managed by Git.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---untracked"> --untracked </dt> <dd> <p>In addition to searching in the tracked files in the working tree, search also in untracked files.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---no-exclude-standard"> --no-exclude-standard </dt> <dd> <p>Also search in ignored files by not honoring the <code>.gitignore</code> mechanism. Only useful with <code>--untracked</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---exclude-standard"> --exclude-standard </dt> <dd> <p>Do not pay attention to ignored files specified via the <code>.gitignore</code> mechanism. Only useful when searching files in the current directory with <code>--no-index</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---recurse-submodules"> --recurse-submodules </dt> <dd> <p>Recursively search in each submodule that is active and checked out in the repository. When used in combination with the <tree> option the prefix of all submodule output will be the name of the parent project’s <tree> object. This option has no effect if <code>--no-index</code> is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---text"> --text </dt> <dd> <p>Process binary files as if they were text.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---textconv"> --textconv </dt> <dd> <p>Honor textconv filter settings.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---no-textconv"> --no-textconv </dt> <dd> <p>Do not honor textconv filter settings. This is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--i"> -i </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---ignore-case"> --ignore-case </dt> <dd> <p>Ignore case differences between the patterns and the files.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--I"> -I </dt> <dd> <p>Don’t match the pattern in binary files.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---max-depthltdepthgt"> --max-depth <depth> </dt> <dd> <p>For each <pathspec> given on command line, descend at most <depth> levels of directories. A value of -1 means no limit. This option is ignored if <pathspec> contains active wildcards. In other words if "a*" matches a directory named "a*", "*" is matched literally so --max-depth is still effective.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--r"> -r </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---recursive"> --recursive </dt> <dd> <p>Same as <code>--max-depth=-1</code>; this is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---no-recursive"> --no-recursive </dt> <dd> <p>Same as <code>--max-depth=0</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--w"> -w </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---word-regexp"> --word-regexp </dt> <dd> <p>Match the pattern only at word boundary (either begin at the beginning of a line, or preceded by a non-word character; end at the end of a line or followed by a non-word character).</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---invert-match"> --invert-match </dt> <dd> <p>Select non-matching lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--h"> -h </dt> <dt class="hdlist1" id="Documentation/git-grep.txt--H"> -H </dt> <dd> <p>By default, the command shows the filename for each match. <code>-h</code> option is used to suppress this output. <code>-H</code> is there for completeness and does not do anything except it overrides <code>-h</code> given earlier on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---full-name"> --full-name </dt> <dd> <p>When run from a subdirectory, the command usually outputs paths relative to the current directory. This option forces paths to be output relative to the project top directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--E"> -E </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---extended-regexp"> --extended-regexp </dt> <dt class="hdlist1" id="Documentation/git-grep.txt--G"> -G </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---basic-regexp"> --basic-regexp </dt> <dd> <p>Use POSIX extended/basic regexp for patterns. Default is to use basic regexp.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--P"> -P </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---perl-regexp"> --perl-regexp </dt> <dd> <p>Use Perl-compatible regular expressions for patterns.</p> <p>Support for these types of regular expressions is an optional compile-time dependency. If Git wasn’t compiled with support for them providing this option will cause it to die.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--F"> -F </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---fixed-strings"> --fixed-strings </dt> <dd> <p>Use fixed strings for patterns (don’t interpret pattern as a regex).</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---line-number"> --line-number </dt> <dd> <p>Prefix the line number to matching lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---column"> --column </dt> <dd> <p>Prefix the 1-indexed byte-offset of the first match from the start of the matching line.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--l"> -l </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---files-with-matches"> --files-with-matches </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---name-only"> --name-only </dt> <dt class="hdlist1" id="Documentation/git-grep.txt--L"> -L </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---files-without-match"> --files-without-match </dt> <dd> <p>Instead of showing every matched line, show only the names of files that contain (or do not contain) matches. For better compatibility with <code>git diff</code>, <code>--name-only</code> is a synonym for <code>--files-with-matches</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--Oltpagergt"> -O[<pager>] </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---open-files-in-pagerltpagergt"> --open-files-in-pager[=<pager>] </dt> <dd> <p>Open the matching files in the pager (not the output of <code>grep</code>). If the pager happens to be "less" or "vi", and the user specified only one pattern, the first file is positioned at the first match automatically. The <code>pager</code> argument is optional; if specified, it must be stuck to the option without a space. If <code>pager</code> is unspecified, the default pager will be used (see <code>core.pager</code> in <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--z"> -z </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---null"> --null </dt> <dd> <p>Use \0 as the delimiter for pathnames in the output, and print them verbatim. Without this option, pathnames with "unusual" characters are quoted as explained for the configuration variable core.quotePath (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--o"> -o </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---only-matching"> --only-matching </dt> <dd> <p>Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--c"> -c </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---count"> --count </dt> <dd> <p>Instead of showing every matched line, show the number of lines that match.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---colorltwhengt"> --color[=<when>] </dt> <dd> <p>Show colored matches. The value must be always (the default), never, or auto.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---no-color"> --no-color </dt> <dd> <p>Turn off match highlighting, even when the configuration file gives the default to color output. Same as <code>--color=never</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---break"> --break </dt> <dd> <p>Print an empty line between matches from different files.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---heading"> --heading </dt> <dd> <p>Show the filename above the matches in that file instead of at the start of each shown line.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---show-function"> --show-function </dt> <dd> <p>Show the preceding line that contains the function name of the match, unless the matching line is a function name itself. The name is determined in the same way as <code>git diff</code> works out patch hunk headers (see <code>Defining a custom hunk-header</code> in <a href="gitattributes">gitattributes[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--ltnumgt"> -<num> </dt> <dt class="hdlist1" id="Documentation/git-grep.txt--Cltnumgt"> -C <num> </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---contextltnumgt"> --context <num> </dt> <dd> <p>Show <num> leading and trailing lines, and place a line containing <code>--</code> between contiguous groups of matches.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--Altnumgt"> -A <num> </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---after-contextltnumgt"> --after-context <num> </dt> <dd> <p>Show <num> trailing lines, and place a line containing <code>--</code> between contiguous groups of matches.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--Bltnumgt"> -B <num> </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---before-contextltnumgt"> --before-context <num> </dt> <dd> <p>Show <num> leading lines, and place a line containing <code>--</code> between contiguous groups of matches.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--W"> -W </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---function-context"> --function-context </dt> <dd> <p>Show the surrounding text from the previous line containing a function name up to the one before the next function name, effectively showing the whole function in which the match was found. The function names are determined in the same way as <code>git diff</code> works out patch hunk headers (see <code>Defining a custom hunk-header</code> in <a href="gitattributes">gitattributes[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--mltnumgt"> -m <num> </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---max-countltnumgt"> --max-count <num> </dt> <dd> <p>Limit the amount of matches per file. When using the <code>-v</code> or <code>--invert-match</code> option, the search stops after the specified number of non-matches. A value of -1 will return unlimited results (the default). A value of 0 will exit immediately with a non-zero status.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---threadsltnumgt"> --threads <num> </dt> <dd> <p>Number of grep worker threads to use. See <code>grep.threads</code> in <code>CONFIGURATION</code> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--fltfilegt"> -f <file> </dt> <dd> <p>Read patterns from <file>, one per line.</p> <p>Passing the pattern via <file> allows for providing a search pattern containing a \0.</p> <p>Not all pattern types support patterns containing \0. Git will error out if a given pattern type can’t support such a pattern. The <code>--perl-regexp</code> pattern type when compiled against the PCRE v2 backend has the widest support for these types of patterns.</p> <p>In versions of Git before 2.23.0 patterns containing \0 would be silently considered fixed. This was never documented, there were also odd and undocumented interactions between e.g. non-ASCII patterns containing \0 and <code>--ignore-case</code>.</p> <p>In future versions we may learn to support patterns containing \0 for more search backends, until then we’ll die when the pattern type in question doesn’t support them.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--e"> -e </dt> <dd> <p>The next parameter is the pattern. This option has to be used for patterns starting with <code>-</code> and should be used in scripts passing user input to grep. Multiple patterns are combined by <code>or</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---and"> --and </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---or"> --or </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---not"> --not </dt> <dt class="hdlist1" id="Documentation/git-grep.txt-82308203"> ( … ) </dt> <dd> <p>Specify how multiple patterns are combined using Boolean expressions. <code>--or</code> is the default operator. <code>--and</code> has higher precedence than <code>--or</code>. <code>-e</code> has to be used for all patterns.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---all-match"> --all-match </dt> <dd> <p>When giving multiple pattern expressions combined with <code>--or</code>, this flag is specified to limit the match to files that have lines to match all of them.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-grep.txt---quiet"> --quiet </dt> <dd> <p>Do not output matched lines; instead, exit with status 0 when there is a match and with non-zero status when there isn’t.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt-lttreegt82308203"> <tree>… </dt> <dd> <p>Instead of searching tracked files in the working tree, search blobs in the given trees.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt---"> -- </dt> <dd> <p>Signals the end of options; the rest of the parameters are <pathspec> limiters.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt-ltpathspecgt82308203"> <pathspec>… </dt> <dd> <p>If given, limit the search to paths matching at least one pattern. Both leading paths match and glob(7) patterns are supported.</p> <p>For more details about the <pathspec> syntax, see the <code>pathspec</code> entry in <a href="gitglossary">gitglossary[7]</a>.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-grep.txt-codegitgreptimet--chcode"> <code>git grep 'time_t' -- '*.[ch]'</code> </dt> <dd> <p>Looks for <code>time_t</code> in all tracked .c and .h files in the working directory and its subdirectories.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt-codegitgrep-edefine--and-eMAXPATH-ePATHMAXcode"> <code>git grep -e '#define' --and \( -e MAX_PATH -e PATH_MAX \)</code> </dt> <dd> <p>Looks for a line that has <code>#define</code> and either <code>MAX_PATH</code> or <code>PATH_MAX</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt-codegitgrep--all-match-eNODE-eUnexpectedcode"> <code>git grep --all-match -e NODE -e Unexpected</code> </dt> <dd> <p>Looks for a line that has <code>NODE</code> or <code>Unexpected</code> in files that have lines that match both.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt-codegitgrepsolution--Documentationcode"> <code>git grep solution -- :^Documentation</code> </dt> <dd> <p>Looks for <code>solution</code>, excluding files in <code>Documentation</code>.</p> </dd> </dl> </div> </div> <h2 id="_notes_on_threads">Notes on threads</h2> <div class="sectionbody"> <p>The <code>--threads</code> option (and the grep.threads configuration) will be ignored when <code>--open-files-in-pager</code> is used, forcing a single-threaded execution.</p> <p>When grepping the object store (with <code>--cached</code> or giving tree objects), running with multiple threads might perform slower than single threaded if <code>--textconv</code> is given and there are too many text conversions. So if you experience low performance in this case, it might be desirable to use <code>--threads=1</code>.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-grep.txt-greplineNumber"> grep.lineNumber </dt> <dd> <p>If set to true, enable <code>-n</code> option by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt-grepcolumn"> grep.column </dt> <dd> <p>If set to true, enable the <code>--column</code> option by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt-greppatternType"> grep.patternType </dt> <dd> <p>Set the default matching behavior. Using a value of <code>basic</code>, <code>extended</code>, <code>fixed</code>, or <code>perl</code> will enable the <code>--basic-regexp</code>, <code>--extended-regexp</code>, <code>--fixed-strings</code>, or <code>--perl-regexp</code> option accordingly, while the value <code>default</code> will use the <code>grep.extendedRegexp</code> option to choose between <code>basic</code> and <code>extended</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt-grepextendedRegexp"> grep.extendedRegexp </dt> <dd> <p>If set to true, enable <code>--extended-regexp</code> option by default. This option is ignored when the <code>grep.patternType</code> option is set to a value other than <code>default</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt-grepthreads"> grep.threads </dt> <dd> <p>Number of grep worker threads to use. If unset (or set to 0), Git will use as many threads as the number of logical cores available.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt-grepfullName"> grep.fullName </dt> <dd> <p>If set to true, enable <code>--full-name</code> option by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-grep.txt-grepfallbackToNoIndex"> grep.fallbackToNoIndex </dt> <dd> <p>If set to true, fall back to git grep --no-index if git grep is executed outside of a git repository. Defaults to false.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-grep" class="_attribution-link">https://git-scm.com/docs/git-grep</a> + </p> +</div> diff --git a/devdocs/git/git-gui.html b/devdocs/git/git-gui.html new file mode 100644 index 00000000..91820442 --- /dev/null +++ b/devdocs/git/git-gui.html @@ -0,0 +1,6 @@ +<h1>git-gui</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-gui - A portable graphical interface to Git</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git gui [<command>] [<arguments>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>A Tcl/Tk based graphical user interface to Git. <code>git gui</code> focuses on allowing users to make changes to their repository by making new commits, amending existing ones, creating branches, performing local merges, and fetching/pushing to remote repositories.</p> <p>Unlike <code>gitk</code>, <code>git gui</code> focuses on commit generation and single file annotation and does not show project history. It does however supply menu actions to start a <code>gitk</code> session from within <code>git gui</code>.</p> <p><code>git gui</code> is known to work on all popular UNIX systems, Mac OS X, and Windows (under both Cygwin and MSYS). To the extent possible OS specific user interface guidelines are followed, making <code>git gui</code> a fairly native interface for users.</p> </div> <h2 id="_commands">Commands</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-gui.txt-blame"> blame </dt> <dd> <p>Start a blame viewer on the specified file on the given version (or working directory if not specified).</p> </dd> <dt class="hdlist1" id="Documentation/git-gui.txt-browser"> browser </dt> <dd> <p>Start a tree browser showing all files in the specified commit. Files selected through the browser are opened in the blame viewer.</p> </dd> <dt class="hdlist1" id="Documentation/git-gui.txt-citool"> citool </dt> <dd> <p>Start <code>git gui</code> and arrange to make exactly one commit before exiting and returning to the shell. The interface is limited to only commit actions, slightly reducing the application’s startup time and simplifying the menubar.</p> </dd> <dt class="hdlist1" id="Documentation/git-gui.txt-version"> version </dt> <dd> <p>Display the currently running version of <code>git gui</code>.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-gui.txt-codegitguiblameMakefilecode"> <code>git gui blame Makefile</code> </dt> <dd> <p>Show the contents of the file <code>Makefile</code> in the current working directory, and provide annotations for both the original author of each line, and who moved the line to its current location. The uncommitted file is annotated, and uncommitted changes (if any) are explicitly attributed to <code>Not Yet Committed</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gui.txt-codegitguiblamev0998Makefilecode"> <code>git gui blame v0.99.8 Makefile</code> </dt> <dd> <p>Show the contents of <code>Makefile</code> in revision <code>v0.99.8</code> and provide annotations for each line. Unlike the above example the file is read from the object database and not the working directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-gui.txt-codegitguiblame--line100Makefilecode"> <code>git gui blame --line=100 Makefile</code> </dt> <dd> <p>Loads annotations as described above and automatically scrolls the view to center on line <code>100</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gui.txt-codegitguicitoolcode"> <code>git gui citool</code> </dt> <dd> <p>Make one commit and return to the shell when it is complete. This command returns a non-zero exit code if the window was closed in any way other than by making a commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-gui.txt-codegitguicitool--amendcode"> <code>git gui citool --amend</code> </dt> <dd> <p>Automatically enter the <code>Amend Last Commit</code> mode of the interface.</p> </dd> <dt class="hdlist1" id="Documentation/git-gui.txt-codegitguicitool--nocommitcode"> <code>git gui citool --nocommit</code> </dt> <dd> <p>Behave as normal citool, but instead of making a commit simply terminate with a zero exit code. It still checks that the index does not contain any unmerged entries, so you can use it as a GUI version of <a href="git-mergetool">git-mergetool[1]</a></p> </dd> <dt class="hdlist1" id="Documentation/git-gui.txt-codegitcitoolcode"> <code>git citool</code> </dt> <dd> <p>Same as <code>git gui citool</code> (above).</p> </dd> <dt class="hdlist1" id="Documentation/git-gui.txt-codegitguibrowsermaintcode"> <code>git gui browser maint</code> </dt> <dd> <p>Show a browser for the tree of the <code>maint</code> branch. Files selected in the browser can be viewed with the internal blame viewer.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-gui.txt-ahrefdocsgitkgitk1a"> <a href="gitk">gitk[1]</a> </dt> <dd> <p>The Git repository browser. Shows branches, commit history and file differences. gitk is the utility started by <code>git gui</code>'s Repository Visualize actions.</p> </dd> </dl> </div> </div> <h2 id="_other">Other</h2> <div class="sectionbody"> <p><code>git gui</code> is actually maintained as an independent project, but stable versions are distributed as part of the Git suite for the convenience of end users.</p> <p>The official repository of the <code>git gui</code> project can be found at:</p> <div class="literalblock"> <div class="content"> <pre>https://github.com/prati0100/git-gui.git/</pre> </div> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-gui" class="_attribution-link">https://git-scm.com/docs/git-gui</a> + </p> +</div> diff --git a/devdocs/git/git-hash-object.html b/devdocs/git/git-hash-object.html new file mode 100644 index 00000000..1d8406b3 --- /dev/null +++ b/devdocs/git/git-hash-object.html @@ -0,0 +1,8 @@ +<h1>git-hash-object</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-hash-object - Compute object ID and optionally create an object from a file</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git hash-object [-t <type>] [-w] [--path=<file> | --no-filters] + [--stdin [--literally]] [--] <file>… +git hash-object [-t <type>] [-w] --stdin-paths [--no-filters]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Computes the object ID value for an object with specified type with the contents of the named file (which can be outside of the work tree), and optionally writes the resulting object into the object database. Reports its object ID to its standard output. When <type> is not specified, it defaults to "blob".</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-hash-object.txt--tlttypegt"> -t <type> </dt> <dd> <p>Specify the type of object to be created (default: "blob"). Possible values are <code>commit</code>, <code>tree</code>, <code>blob</code>, and <code>tag</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-hash-object.txt--w"> -w </dt> <dd> <p>Actually write the object into the object database.</p> </dd> <dt class="hdlist1" id="Documentation/git-hash-object.txt---stdin"> --stdin </dt> <dd> <p>Read the object from standard input instead of from a file.</p> </dd> <dt class="hdlist1" id="Documentation/git-hash-object.txt---stdin-paths"> --stdin-paths </dt> <dd> <p>Read file names from the standard input, one per line, instead of from the command-line.</p> </dd> <dt class="hdlist1" id="Documentation/git-hash-object.txt---path"> --path </dt> <dd> <p>Hash object as if it were located at the given path. The location of the file does not directly influence the hash value, but the path is used to determine which Git filters should be applied to the object before it can be placed in the object database. As a result of applying filters, the actual blob put into the object database may differ from the given file. This option is mainly useful for hashing temporary files located outside of the working directory or files read from stdin.</p> </dd> <dt class="hdlist1" id="Documentation/git-hash-object.txt---no-filters"> --no-filters </dt> <dd> <p>Hash the contents as is, ignoring any input filter that would have been chosen by the attributes mechanism, including the end-of-line conversion. If the file is read from standard input then this is always implied, unless the <code>--path</code> option is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-hash-object.txt---literally"> --literally </dt> <dd> <p>Allow <code>--stdin</code> to hash any garbage into a loose object which might not otherwise pass standard object parsing or git-fsck checks. Useful for stress-testing Git itself or reproducing characteristics of corrupt or bogus objects encountered in the wild.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-hash-object" class="_attribution-link">https://git-scm.com/docs/git-hash-object</a> + </p> +</div> diff --git a/devdocs/git/git-help.html b/devdocs/git/git-help.html new file mode 100644 index 00000000..2ef3a310 --- /dev/null +++ b/devdocs/git/git-help.html @@ -0,0 +1,25 @@ +<h1>git-help</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-help - Display help information about Git</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git help [-a|--all] [--[no-]verbose] [--[no-]external-commands] [--[no-]aliases] +git help [[-i|--info] [-m|--man] [-w|--web]] [<command>|<doc>] +git help [-g|--guides] +git help [-c|--config] +git help [--user-interfaces] +git help [--developer-interfaces]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>With no options and no <code><command></code> or <code><doc></code> given, the synopsis of the <code>git</code> command and a list of the most commonly used Git commands are printed on the standard output.</p> <p>If the option <code>--all</code> or <code>-a</code> is given, all available commands are printed on the standard output.</p> <p>If the option <code>--guides</code> or <code>-g</code> is given, a list of the Git concept guides is also printed on the standard output.</p> <p>If a command or other documentation is given, the relevant manual page will be brought up. The <code>man</code> program is used by default for this purpose, but this can be overridden by other options or configuration variables.</p> <p>If an alias is given, git shows the definition of the alias on standard output. To get the manual page for the aliased command, use <code>git <command> --help</code>.</p> <p>Note that <code>git --help ...</code> is identical to <code>git help ...</code> because the former is internally converted into the latter.</p> <p>To display the <a href="git">git[1]</a> man page, use <code>git help git</code>.</p> <p>This page can be displayed with <code>git help help</code> or <code>git help --help</code>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-help.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-help.txt---all"> --all </dt> <dd> <p>Print all the available commands on the standard output.</p> </dd> <dt class="hdlist1" id="Documentation/git-help.txt---no-external-commands"> --no-external-commands </dt> <dd> <p>When used with <code>--all</code>, exclude the listing of external "git-*" commands found in the <code>$PATH</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-help.txt---no-aliases"> --no-aliases </dt> <dd> <p>When used with <code>--all</code>, exclude the listing of configured aliases.</p> </dd> <dt class="hdlist1" id="Documentation/git-help.txt---verbose"> --verbose </dt> <dd> <p>When used with <code>--all</code>, print description for all recognized commands. This is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-help.txt--c"> -c </dt> <dt class="hdlist1" id="Documentation/git-help.txt---config"> --config </dt> <dd> <p>List all available configuration variables. This is a short summary of the list in <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-help.txt--g"> -g </dt> <dt class="hdlist1" id="Documentation/git-help.txt---guides"> --guides </dt> <dd> <p>Print a list of the Git concept guides on the standard output.</p> </dd> <dt class="hdlist1" id="Documentation/git-help.txt---user-interfaces"> --user-interfaces </dt> <dd> <p>Print a list of the repository, command and file interfaces documentation on the standard output.</p> <p>In-repository file interfaces such as <code>.git/info/exclude</code> are documented here (see <a href="gitrepository-layout">gitrepository-layout[5]</a>), as well as in-tree configuration such as <code>.mailmap</code> (see <a href="gitmailmap">gitmailmap[5]</a>).</p> <p>This section of the documentation also covers general or widespread user-interface conventions (e.g. <a href="gitcli">gitcli[7]</a>), and pseudo-configuration such as the file-based <code>.git/hooks/*</code> interface described in <a href="githooks">githooks[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-help.txt---developer-interfaces"> --developer-interfaces </dt> <dd> <p>Print a list of file formats, protocols and other developer interfaces documentation on the standard output.</p> </dd> <dt class="hdlist1" id="Documentation/git-help.txt--i"> -i </dt> <dt class="hdlist1" id="Documentation/git-help.txt---info"> --info </dt> <dd> <p>Display manual page for the command in the <code>info</code> format. The <code>info</code> program will be used for that purpose.</p> </dd> <dt class="hdlist1" id="Documentation/git-help.txt--m"> -m </dt> <dt class="hdlist1" id="Documentation/git-help.txt---man"> --man </dt> <dd> <p>Display manual page for the command in the <code>man</code> format. This option may be used to override a value set in the <code>help.format</code> configuration variable.</p> <p>By default the <code>man</code> program will be used to display the manual page, but the <code>man.viewer</code> configuration variable may be used to choose other display programs (see below).</p> </dd> <dt class="hdlist1" id="Documentation/git-help.txt--w"> -w </dt> <dt class="hdlist1" id="Documentation/git-help.txt---web"> --web </dt> <dd> <p>Display manual page for the command in the <code>web</code> (HTML) format. A web browser will be used for that purpose.</p> <p>The web browser can be specified using the configuration variable <code>help.browser</code>, or <code>web.browser</code> if the former is not set. If neither of these config variables is set, the <code>git web--browse</code> helper script (called by <code>git help</code>) will pick a suitable default. See <a href="git-web--browse">git-web--browse[1]</a> for more information about this.</p> </dd> </dl> </div> </div> <h2 id="_configuration_variables">Configuration variables</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_help_format"> +help.format</h3> <p>If no command-line option is passed, the <code>help.format</code> configuration variable will be checked. The following values are supported for this variable; they make <code>git help</code> behave as their corresponding command- line option:</p> <div class="ulist"> <ul> <li> <p>"man" corresponds to <code>-m|--man</code>,</p> </li> <li> <p>"info" corresponds to <code>-i|--info</code>,</p> </li> <li> <p>"web" or "html" correspond to <code>-w|--web</code>.</p> </li> </ul> </div> </div> <div class="sect2"> <h3 id="_help_browser_web_browser_and_browser_tool_path"> +help.browser, web.browser, and browser.<tool>.path</h3> <p>The <code>help.browser</code>, <code>web.browser</code> and <code>browser.<tool>.path</code> will also be checked if the <code>web</code> format is chosen (either by command-line option or configuration variable). See <code>-w|--web</code> in the OPTIONS section above and <a href="git-web--browse">git-web--browse[1]</a>.</p> </div> <div class="sect2"> <h3 id="_man_viewer"> +man.viewer</h3> <p>The <code>man.viewer</code> configuration variable will be checked if the <code>man</code> format is chosen. The following values are currently supported:</p> <div class="ulist"> <ul> <li> <p>"man": use the <code>man</code> program as usual,</p> </li> <li> <p>"woman": use <code>emacsclient</code> to launch the "woman" mode in emacs (this only works starting with emacsclient versions 22),</p> </li> <li> <p>"konqueror": use <code>kfmclient</code> to open the man page in a new konqueror tab (see <code>Note about konqueror</code> below).</p> </li> </ul> </div> <p>Values for other tools can be used if there is a corresponding <code>man.<tool>.cmd</code> configuration entry (see below).</p> <p>Multiple values may be given to the <code>man.viewer</code> configuration variable. Their corresponding programs will be tried in the order listed in the configuration file.</p> <p>For example, this configuration:</p> <div class="listingblock"> <div class="content"> <pre> [man] + viewer = konqueror + viewer = woman</pre> </div> </div> <p>will try to use konqueror first. But this may fail (for example, if DISPLAY is not set) and in that case emacs' woman mode will be tried.</p> <p>If everything fails, or if no viewer is configured, the viewer specified in the <code>GIT_MAN_VIEWER</code> environment variable will be tried. If that fails too, the <code>man</code> program will be tried anyway.</p> </div> <div class="sect2"> <h3 id="_man_tool_path"> +man.<tool>.path</h3> <p>You can explicitly provide a full path to your preferred man viewer by setting the configuration variable <code>man.<tool>.path</code>. For example, you can configure the absolute path to konqueror by setting <code>man.konqueror.path</code>. Otherwise, <code>git help</code> assumes the tool is available in PATH.</p> </div> <div class="sect2"> <h3 id="_man_tool_cmd"> +man.<tool>.cmd</h3> <p>When the man viewer, specified by the <code>man.viewer</code> configuration variables, is not among the supported ones, then the corresponding <code>man.<tool>.cmd</code> configuration variable will be looked up. If this variable exists then the specified tool will be treated as a custom command and a shell eval will be used to run the command with the man page passed as arguments.</p> </div> <div class="sect2"> <h3 id="_note_about_konqueror"> +Note about konqueror</h3> <p>When <code>konqueror</code> is specified in the <code>man.viewer</code> configuration variable, we launch <code>kfmclient</code> to try to open the man page on an already opened konqueror in a new tab if possible.</p> <p>For consistency, we also try such a trick if <code>man.konqueror.path</code> is set to something like <code>A_PATH_TO/konqueror</code>. That means we will try to launch <code>A_PATH_TO/kfmclient</code> instead.</p> <p>If you really want to use <code>konqueror</code>, then you can use something like the following:</p> <div class="listingblock"> <div class="content"> <pre> [man] + viewer = konq + + [man "konq"] + cmd = A_PATH_TO/konqueror</pre> </div> </div> </div> <div class="sect2"> <h3 id="_note_about_git_config_global"> +Note about git config --global</h3> <p>Note that all these configuration variables should probably be set using the <code>--global</code> flag, for example like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config --global help.format web +$ git config --global web.browser firefox</pre> </div> </div> <p>as they are probably more user specific than repository specific. See <a href="git-config">git-config[1]</a> for more information about this.</p> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-help" class="_attribution-link">https://git-scm.com/docs/git-help</a> + </p> +</div> diff --git a/devdocs/git/git-hook.html b/devdocs/git/git-hook.html new file mode 100644 index 00000000..7cf8e1d3 --- /dev/null +++ b/devdocs/git/git-hook.html @@ -0,0 +1,6 @@ +<h1>git-hook</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-hook - Run git hooks</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git hook run [--ignore-missing] [--to-stdin=<path>] <hook-name> [-- <hook-args>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>A command interface for running git hooks (see <a href="githooks">githooks[5]</a>), for use by other scripted git commands.</p> </div> <h2 id="_subcommands">Subcommands</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-hook.txt-run"> run </dt> <dd> <p>Run the <code><hook-name></code> hook. See <a href="githooks">githooks[5]</a> for supported hook names.</p> <p>Any positional arguments to the hook should be passed after a mandatory <code>--</code> (or <code>--end-of-options</code>, see <a href="gitcli">gitcli[7]</a>). See <a href="githooks">githooks[5]</a> for arguments hooks might expect (if any).</p> </dd> </dl> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-hook.txt---to-stdin"> --to-stdin </dt> <dd> <p>For "run"; specify a file which will be streamed into the hook’s stdin. The hook will receive the entire file from beginning to EOF.</p> </dd> <dt class="hdlist1" id="Documentation/git-hook.txt---ignore-missing"> --ignore-missing </dt> <dd> <p>Ignore any missing hook by quietly returning zero. Used for tools that want to do a blind one-shot run of a hook that may or may not be present.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="githooks">githooks[5]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-hook" class="_attribution-link">https://git-scm.com/docs/git-hook</a> + </p> +</div> diff --git a/devdocs/git/git-http-backend.html b/devdocs/git/git-http-backend.html new file mode 100644 index 00000000..98c1a814 --- /dev/null +++ b/devdocs/git/git-http-backend.html @@ -0,0 +1,88 @@ +<h1>git-http-backend</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-http-backend - Server side implementation of Git over HTTP</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git http-backend</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>A simple CGI program to serve the contents of a Git repository to Git clients accessing the repository over http:// and https:// protocols. The program supports clients fetching using both the smart HTTP protocol and the backwards-compatible dumb HTTP protocol, as well as clients pushing using the smart HTTP protocol. It also supports Git’s more-efficient "v2" protocol if properly configured; see the discussion of <code>GIT_PROTOCOL</code> in the ENVIRONMENT section below.</p> <p>It verifies that the directory has the magic file "git-daemon-export-ok", and it will refuse to export any Git directory that hasn’t explicitly been marked for export this way (unless the <code>GIT_HTTP_EXPORT_ALL</code> environment variable is set).</p> <p>By default, only the <code>upload-pack</code> service is enabled, which serves <code>git fetch-pack</code> and <code>git ls-remote</code> clients, which are invoked from <code>git fetch</code>, <code>git pull</code>, and <code>git clone</code>. If the client is authenticated, the <code>receive-pack</code> service is enabled, which serves <code>git send-pack</code> clients, which is invoked from <code>git push</code>.</p> </div> <h2 id="_services">Services</h2> <div class="sectionbody"> <p>These services can be enabled/disabled using the per-repository configuration file:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-http-backend.txt-httpgetanyfile"> http.getanyfile </dt> <dd> <p>This serves Git clients older than version 1.6.6 that are unable to use the upload pack service. When enabled, clients are able to read any file within the repository, including objects that are no longer reachable from a branch but are still present. It is enabled by default, but a repository can disable it by setting this configuration value to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-http-backend.txt-httpuploadpack"> http.uploadpack </dt> <dd> <p>This serves <code>git fetch-pack</code> and <code>git ls-remote</code> clients. It is enabled by default, but a repository can disable it by setting this configuration value to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-http-backend.txt-httpreceivepack"> http.receivepack </dt> <dd> <p>This serves <code>git send-pack</code> clients, allowing push. It is disabled by default for anonymous users, and enabled by default for users authenticated by the web server. It can be disabled by setting this item to <code>false</code>, or enabled for all users, including anonymous users, by setting it to <code>true</code>.</p> </dd> </dl> </div> </div> <h2 id="_url_translation">Url translation</h2> <div class="sectionbody"> <p>To determine the location of the repository on disk, <code>git http-backend</code> concatenates the environment variables PATH_INFO, which is set automatically by the web server, and GIT_PROJECT_ROOT, which must be set manually in the web server configuration. If GIT_PROJECT_ROOT is not set, <code>git http-backend</code> reads PATH_TRANSLATED, which is also set automatically by the web server.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>All of the following examples map <code>http://$hostname/git/foo/bar.git</code> to <code>/var/www/git/foo/bar.git</code>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-http-backend.txt-Apache2x"> Apache 2.x </dt> <dd> <p>Ensure mod_cgi, mod_alias, and mod_env are enabled, set GIT_PROJECT_ROOT (or DocumentRoot) appropriately, and create a ScriptAlias to the CGI:</p> <div class="listingblock"> <div class="content"> <pre>SetEnv GIT_PROJECT_ROOT /var/www/git +SetEnv GIT_HTTP_EXPORT_ALL +ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/ + +# This is not strictly necessary using Apache and a modern version of +# git-http-backend, as the webserver will pass along the header in the +# environment as HTTP_GIT_PROTOCOL, and http-backend will copy that into +# GIT_PROTOCOL. But you may need this line (or something similar if you +# are using a different webserver), or if you want to support older Git +# versions that did not do that copying. +# +# Having the webserver set up GIT_PROTOCOL is perfectly fine even with +# modern versions (and will take precedence over HTTP_GIT_PROTOCOL, +# which means it can be used to override the client's request). +SetEnvIf Git-Protocol ".*" GIT_PROTOCOL=$0</pre> </div> </div> <p>To enable anonymous read access but authenticated write access, require authorization for both the initial ref advertisement (which we detect as a push via the service parameter in the query string), and the receive-pack invocation itself:</p> <div class="listingblock"> <div class="content"> <pre>RewriteCond %{QUERY_STRING} service=git-receive-pack [OR] +RewriteCond %{REQUEST_URI} /git-receive-pack$ +RewriteRule ^/git/ - [E=AUTHREQUIRED:yes] + +<LocationMatch "^/git/"> + Order Deny,Allow + Deny from env=AUTHREQUIRED + + AuthType Basic + AuthName "Git Access" + Require group committers + Satisfy Any + ... +</LocationMatch></pre> </div> </div> <p>If you do not have <code>mod_rewrite</code> available to match against the query string, it is sufficient to just protect <code>git-receive-pack</code> itself, like:</p> <div class="listingblock"> <div class="content"> <pre><LocationMatch "^/git/.*/git-receive-pack$"> + AuthType Basic + AuthName "Git Access" + Require group committers + ... +</LocationMatch></pre> </div> </div> <p>In this mode, the server will not request authentication until the client actually starts the object negotiation phase of the push, rather than during the initial contact. For this reason, you must also enable the <code>http.receivepack</code> config option in any repositories that should accept a push. The default behavior, if <code>http.receivepack</code> is not set, is to reject any pushes by unauthenticated users; the initial request will therefore report <code>403 Forbidden</code> to the client, without even giving an opportunity for authentication.</p> <p>To require authentication for both reads and writes, use a Location directive around the repository, or one of its parent directories:</p> <div class="listingblock"> <div class="content"> <pre><Location /git/private> + AuthType Basic + AuthName "Private Git Access" + Require group committers + ... +</Location></pre> </div> </div> <p>To serve gitweb at the same url, use a ScriptAliasMatch to only those URLs that <code>git http-backend</code> can handle, and forward the rest to gitweb:</p> <div class="listingblock"> <div class="content"> <pre>ScriptAliasMatch \ + "(?x)^/git/(.*/(HEAD | \ + info/refs | \ + objects/(info/[^/]+ | \ + [0-9a-f]{2}/[0-9a-f]{38} | \ + pack/pack-[0-9a-f]{40}\.(pack|idx)) | \ + git-(upload|receive)-pack))$" \ + /usr/libexec/git-core/git-http-backend/$1 + +ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/</pre> </div> </div> <p>To serve multiple repositories from different <a href="gitnamespaces">gitnamespaces[7]</a> in a single repository:</p> <div class="listingblock"> <div class="content"> <pre>SetEnvIf Request_URI "^/git/([^/]*)" GIT_NAMESPACE=$1 +ScriptAliasMatch ^/git/[^/]*(.*) /usr/libexec/git-core/git-http-backend/storage.git$1</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-http-backend.txt-AcceleratedstaticApache2x"> Accelerated static Apache 2.x </dt> <dd> <p>Similar to the above, but Apache can be used to return static files that are stored on disk. On many systems this may be more efficient as Apache can ask the kernel to copy the file contents from the file system directly to the network:</p> <div class="listingblock"> <div class="content"> <pre>SetEnv GIT_PROJECT_ROOT /var/www/git + +AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /var/www/git/$1 +AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1 +ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/</pre> </div> </div> <p>This can be combined with the gitweb configuration:</p> <div class="listingblock"> <div class="content"> <pre>SetEnv GIT_PROJECT_ROOT /var/www/git + +AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /var/www/git/$1 +AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1 +ScriptAliasMatch \ + "(?x)^/git/(.*/(HEAD | \ + info/refs | \ + objects/info/[^/]+ | \ + git-(upload|receive)-pack))$" \ + /usr/libexec/git-core/git-http-backend/$1 +ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-http-backend.txt-Lighttpd"> Lighttpd </dt> <dd> <p>Ensure that <code>mod_cgi</code>, <code>mod_alias</code>, <code>mod_auth</code>, <code>mod_setenv</code> are loaded, then set <code>GIT_PROJECT_ROOT</code> appropriately and redirect all requests to the CGI:</p> <div class="listingblock"> <div class="content"> <pre>alias.url += ( "/git" => "/usr/lib/git-core/git-http-backend" ) +$HTTP["url"] =~ "^/git" { + cgi.assign = ("" => "") + setenv.add-environment = ( + "GIT_PROJECT_ROOT" => "/var/www/git", + "GIT_HTTP_EXPORT_ALL" => "" + ) +}</pre> </div> </div> <p>To enable anonymous read access but authenticated write access:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$HTTP["querystring"] =~ "service=git-receive-pack" { + include "git-auth.conf" +} +$HTTP["url"] =~ "^/git/.*/git-receive-pack$" { + include "git-auth.conf" +}</pre> </div> </div> <p>where <code>git-auth.conf</code> looks something like:</p> <div class="listingblock"> <div class="content"> <pre>auth.require = ( + "/" => ( + "method" => "basic", + "realm" => "Git Access", + "require" => "valid-user" + ) +) +# ...and set up auth.backend here</pre> </div> </div> <p>To require authentication for both reads and writes:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$HTTP["url"] =~ "^/git/private" { + include "git-auth.conf" +}</pre> </div> </div> </dd> </dl> </div> </div> <h2 id="_environment">Environment</h2> <div class="sectionbody"> <p><code>git http-backend</code> relies upon the <code>CGI</code> environment variables set by the invoking web server, including:</p> <div class="ulist"> <ul> <li> <p>PATH_INFO (if GIT_PROJECT_ROOT is set, otherwise PATH_TRANSLATED)</p> </li> <li> <p>REMOTE_USER</p> </li> <li> <p>REMOTE_ADDR</p> </li> <li> <p>CONTENT_TYPE</p> </li> <li> <p>QUERY_STRING</p> </li> <li> <p>REQUEST_METHOD</p> </li> </ul> </div> <p>The <code>GIT_HTTP_EXPORT_ALL</code> environment variable may be passed to <code>git-http-backend</code> to bypass the check for the "git-daemon-export-ok" file in each repository before allowing export of that repository.</p> <p>The <code>GIT_HTTP_MAX_REQUEST_BUFFER</code> environment variable (or the <code>http.maxRequestBuffer</code> config option) may be set to change the largest ref negotiation request that git will handle during a fetch; any fetch requiring a larger buffer will not succeed. This value should not normally need to be changed, but may be helpful if you are fetching from a repository with an extremely large number of refs. The value can be specified with a unit (e.g., <code>100M</code> for 100 megabytes). The default is 10 megabytes.</p> <p>Clients may probe for optional protocol capabilities (like the v2 protocol) using the <code>Git-Protocol</code> HTTP header. In order to support these, the contents of that header must appear in the <code>GIT_PROTOCOL</code> environment variable. Most webservers will pass this header to the CGI via the <code>HTTP_GIT_PROTOCOL</code> variable, and <code>git-http-backend</code> will automatically copy that to <code>GIT_PROTOCOL</code>. However, some webservers may be more selective about which headers they’ll pass, in which case they need to be configured explicitly (see the mention of <code>Git-Protocol</code> in the Apache config from the earlier EXAMPLES section).</p> <p>The backend process sets GIT_COMMITTER_NAME to <code>$REMOTE_USER</code> and GIT_COMMITTER_EMAIL to <code>${REMOTE_USER}@http.${REMOTE_ADDR}</code>, ensuring that any reflogs created by <code>git-receive-pack</code> contain some identifying information of the remote user who performed the push.</p> <p>All <code>CGI</code> environment variables are available to each of the hooks invoked by the <code>git-receive-pack</code>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-http-backend" class="_attribution-link">https://git-scm.com/docs/git-http-backend</a> + </p> +</div> diff --git a/devdocs/git/git-http-fetch.html b/devdocs/git/git-http-fetch.html new file mode 100644 index 00000000..16aad9e6 --- /dev/null +++ b/devdocs/git/git-http-fetch.html @@ -0,0 +1,6 @@ +<h1>git-http-fetch</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-http-fetch - Download from a remote Git repository via HTTP</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git http-fetch [-c] [-t] [-a] [-d] [-v] [-w <filename>] [--recover] [--stdin | --packfile=<hash> | <commit>] <URL></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Downloads a remote Git repository via HTTP.</p> <p>This command always gets all objects. Historically, there were three options <code>-a</code>, <code>-c</code> and <code>-t</code> for choosing which objects to download. They are now silently ignored.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-http-fetch.txt-commit-id"> commit-id </dt> <dd> <p>Either the hash or the filename under [URL]/refs/ to pull.</p> </dd> <dt class="hdlist1" id="Documentation/git-http-fetch.txt--a-c-t"> -a, -c, -t </dt> <dd> <p>These options are ignored for historical reasons.</p> </dd> <dt class="hdlist1" id="Documentation/git-http-fetch.txt--v"> -v </dt> <dd> <p>Report what is downloaded.</p> </dd> <dt class="hdlist1" id="Documentation/git-http-fetch.txt--wltfilenamegt"> -w <filename> </dt> <dd> <p>Writes the commit-id into the specified filename under $GIT_DIR/refs/<filename> on the local end after the transfer is complete.</p> </dd> <dt class="hdlist1" id="Documentation/git-http-fetch.txt---stdin"> --stdin </dt> <dd> <p>Instead of a commit id on the command line (which is not expected in this case), <code>git http-fetch</code> expects lines on stdin in the format</p> <div class="literalblock"> <div class="content"> <pre><commit-id>['\t'<filename-as-in--w>]</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-http-fetch.txt---packfilelthashgt"> --packfile=<hash> </dt> <dd> <p>For internal use only. Instead of a commit id on the command line (which is not expected in this case), <code>git http-fetch</code> fetches the packfile directly at the given URL and uses index-pack to generate corresponding .idx and .keep files. The hash is used to determine the name of the temporary file and is arbitrary. The output of index-pack is printed to stdout. Requires --index-pack-args.</p> </dd> <dt class="hdlist1" id="Documentation/git-http-fetch.txt---index-pack-argsltargsgt"> --index-pack-args=<args> </dt> <dd> <p>For internal use only. The command to run on the contents of the downloaded pack. Arguments are URL-encoded separated by spaces.</p> </dd> <dt class="hdlist1" id="Documentation/git-http-fetch.txt---recover"> --recover </dt> <dd> <p>Verify that everything reachable from target is fetched. Used after an earlier fetch is interrupted.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-http-fetch" class="_attribution-link">https://git-scm.com/docs/git-http-fetch</a> + </p> +</div> diff --git a/devdocs/git/git-http-push.html b/devdocs/git/git-http-push.html new file mode 100644 index 00000000..85c56bc9 --- /dev/null +++ b/devdocs/git/git-http-push.html @@ -0,0 +1,6 @@ +<h1>git-http-push</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-http-push - Push objects over HTTP/DAV to another repository</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git http-push [--all] [--dry-run] [--force] [--verbose] <URL> <ref> [<ref>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Sends missing objects to the remote repository, and updates the remote branch.</p> <p><strong>NOTE</strong>: This command is temporarily disabled if your libcurl is older than 7.16, as the combination has been reported not to work and sometimes corrupts the repository.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-http-push.txt---all"> --all </dt> <dd> <p>Do not assume that the remote repository is complete in its current state, and verify all objects in the entire local ref’s history exist in the remote repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-http-push.txt---force"> --force </dt> <dd> <p>Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. This flag disables the check. What this means is that the remote repository can lose commits; use it with care.</p> </dd> <dt class="hdlist1" id="Documentation/git-http-push.txt---dry-run"> --dry-run </dt> <dd> <p>Do everything except actually send the updates.</p> </dd> <dt class="hdlist1" id="Documentation/git-http-push.txt---verbose"> --verbose </dt> <dd> <p>Report the list of objects being walked locally and the list of objects successfully sent to the remote repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-http-push.txt--d"> -d </dt> <dt class="hdlist1" id="Documentation/git-http-push.txt--D"> -D </dt> <dd> <p>Remove <ref> from remote repository. The specified branch cannot be the remote HEAD. If -d is specified, the following other conditions must also be met:</p> <div class="ulist"> <ul> <li> <p>Remote HEAD must resolve to an object that exists locally</p> </li> <li> <p>Specified branch resolves to an object that exists locally</p> </li> <li> <p>Specified branch is an ancestor of the remote HEAD</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-http-push.txt-ltrefgt82308203"> <ref>… </dt> <dd> <p>The remote refs to update.</p> </dd> </dl> </div> </div> <h2 id="_specifying_the_refs">Specifying the refs</h2> <div class="sectionbody"> <p>A <code><ref></code> specification can be either a single pattern, or a pair of such patterns separated by a colon ":" (this means that a ref name cannot have a colon in it). A single pattern <code><name></code> is just a shorthand for <code><name>:<name></code>.</p> <p>Each pattern pair <code><src>:<dst></code> consists of the source side (before the colon) and the destination side (after the colon). The ref to be pushed is determined by finding a match that matches the source side, and where it is pushed is determined by using the destination side.</p> <div class="ulist"> <ul> <li> <p>It is an error if <code><src></code> does not match exactly one of the local refs.</p> </li> <li> <p>If <code><dst></code> does not match any remote ref, either</p> <div class="ulist"> <ul> <li> <p>it has to start with "refs/"; <dst> is used as the destination literally in this case.</p> </li> <li> <p><src> == <dst> and the ref that matched the <src> must not exist in the set of remote refs; the ref matched <src> locally is used as the name of the destination.</p> </li> </ul> </div> </li> </ul> </div> <p>Without <code>--force</code>, the <src> ref is stored at the remote only if <dst> does not exist, or <dst> is a proper subset (i.e. an ancestor) of <src>. This check, known as "fast-forward check", is performed to avoid accidentally overwriting the remote ref and losing other peoples' commits from there.</p> <p>With <code>--force</code>, the fast-forward check is disabled for all refs.</p> <p>Optionally, a <ref> parameter can be prefixed with a plus <code>+</code> sign to disable the fast-forward check only on that ref.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-http-push" class="_attribution-link">https://git-scm.com/docs/git-http-push</a> + </p> +</div> diff --git a/devdocs/git/git-imap-send.html b/devdocs/git/git-imap-send.html new file mode 100644 index 00000000..7d30962d --- /dev/null +++ b/devdocs/git/git-imap-send.html @@ -0,0 +1,22 @@ +<h1>git-imap-send</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-imap-send - Send a collection of patches from stdin to an IMAP folder</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git imap-send [-v] [-q] [--[no-]curl]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This command uploads a mailbox generated with <code>git format-patch</code> into an IMAP drafts folder. This allows patches to be sent as other email is when using mail clients that cannot read mailbox files directly. The command also works with any general mailbox in which emails have the fields "From", "Date", and "Subject" in that order.</p> <p>Typical usage is something like:</p> <p>git format-patch --signoff --stdout --attach origin | git imap-send</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-imap-send.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-imap-send.txt---verbose"> --verbose </dt> <dd> <p>Be verbose.</p> </dd> <dt class="hdlist1" id="Documentation/git-imap-send.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-imap-send.txt---quiet"> --quiet </dt> <dd> <p>Be quiet.</p> </dd> <dt class="hdlist1" id="Documentation/git-imap-send.txt---curl"> --curl </dt> <dd> <p>Use libcurl to communicate with the IMAP server, unless tunneling into it. Ignored if Git was built without the USE_CURL_FOR_IMAP_SEND option set.</p> </dd> <dt class="hdlist1" id="Documentation/git-imap-send.txt---no-curl"> --no-curl </dt> <dd> <p>Talk to the IMAP server using git’s own IMAP routines instead of using libcurl. Ignored if Git was built with the NO_OPENSSL option set.</p> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>To use the tool, <code>imap.folder</code> and either <code>imap.tunnel</code> or <code>imap.host</code> must be set to appropriate values.</p> <p>Everything above this line in this section isn’t included from the <a href="git-config">git-config[1]</a> documentation. The content that follows is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-imap-send.txt-imapfolder"> imap.folder </dt> <dd> <p>The folder to drop the mails into, which is typically the Drafts folder. For example: "INBOX.Drafts", "INBOX/Drafts" or "[Gmail]/Drafts". Required.</p> </dd> <dt class="hdlist1" id="Documentation/git-imap-send.txt-imaptunnel"> imap.tunnel </dt> <dd> <p>Command used to set up a tunnel to the IMAP server through which commands will be piped instead of using a direct network connection to the server. Required when imap.host is not set.</p> </dd> <dt class="hdlist1" id="Documentation/git-imap-send.txt-imaphost"> imap.host </dt> <dd> <p>A URL identifying the server. Use an <code>imap://</code> prefix for non-secure connections and an <code>imaps://</code> prefix for secure connections. Ignored when imap.tunnel is set, but required otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/git-imap-send.txt-imapuser"> imap.user </dt> <dd> <p>The username to use when logging in to the server.</p> </dd> <dt class="hdlist1" id="Documentation/git-imap-send.txt-imappass"> imap.pass </dt> <dd> <p>The password to use when logging in to the server.</p> </dd> <dt class="hdlist1" id="Documentation/git-imap-send.txt-imapport"> imap.port </dt> <dd> <p>An integer port number to connect to on the server. Defaults to 143 for imap:// hosts and 993 for imaps:// hosts. Ignored when imap.tunnel is set.</p> </dd> <dt class="hdlist1" id="Documentation/git-imap-send.txt-imapsslverify"> imap.sslverify </dt> <dd> <p>A boolean to enable/disable verification of the server certificate used by the SSL/TLS connection. Default is <code>true</code>. Ignored when imap.tunnel is set.</p> </dd> <dt class="hdlist1" id="Documentation/git-imap-send.txt-imappreformattedHTML"> imap.preformattedHTML </dt> <dd> <p>A boolean to enable/disable the use of html encoding when sending a patch. An html encoded patch will be bracketed with <pre> and have a content type of text/html. Ironically, enabling this option causes Thunderbird to send the patch as a plain/text, format=fixed email. Default is <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-imap-send.txt-imapauthMethod"> imap.authMethod </dt> <dd> <p>Specify the authentication method for authenticating with the IMAP server. If Git was built with the NO_CURL option, or if your curl version is older than 7.34.0, or if you’re running git-imap-send with the <code>--no-curl</code> option, the only supported method is <code>CRAM-MD5</code>. If this is not set then <code>git imap-send</code> uses the basic IMAP plaintext LOGIN command.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>Using tunnel mode:</p> <div class="literalblock"> <div class="content"> <pre>[imap] + folder = "INBOX.Drafts" + tunnel = "ssh -q -C user@example.com /usr/bin/imapd ./Maildir 2> /dev/null"</pre> </div> </div> <p>Using direct mode:</p> <div class="literalblock"> <div class="content"> <pre>[imap] + folder = "INBOX.Drafts" + host = imap://imap.example.com + user = bob + pass = p4ssw0rd</pre> </div> </div> <p>Using direct mode with SSL:</p> <div class="literalblock"> <div class="content"> <pre>[imap] + folder = "INBOX.Drafts" + host = imaps://imap.example.com + user = bob + pass = p4ssw0rd + port = 123 + ; sslVerify = false</pre> </div> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> You may want to use <code>sslVerify=false</code> while troubleshooting, if you suspect that the reason you are having trouble connecting is because the certificate you use at the private server <code>example.com</code> you are trying to set up (or have set up) may not be verified correctly. </td> </tr> </table> </div> <p>Using Gmail’s IMAP interface:</p> <div class="listingblock"> <div class="content"> <pre>[imap] + folder = "[Gmail]/Drafts" + host = imaps://imap.gmail.com + user = user@gmail.com + port = 993</pre> </div> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> You might need to instead use: <code>folder = "[Google Mail]/Drafts"</code> if you get an error that the "Folder doesn’t exist". </td> </tr> </table> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> If your Gmail account is set to another language than English, the name of the "Drafts" folder will be localized. </td> </tr> </table> </div> <p>Once the commits are ready to be sent, run the following command:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$ git format-patch --cover-letter -M --stdout origin/master | git imap-send</pre> </div> </div> <p>Just make sure to disable line wrapping in the email client (Gmail’s web interface will wrap lines no matter what, so you need to use a real IMAP client).</p> </div> <h2 id="_caution">Caution</h2> <div class="sectionbody"> <p>It is still your responsibility to make sure that the email message sent by your email program meets the standards of your project. Many projects do not like patches to be attached. Some mail agents will transform patches (e.g. wrap lines, send them as format=flowed) in ways that make them fail. You will get angry flames ridiculing you if you don’t check this.</p> <p>Thunderbird in particular is known to be problematic. Thunderbird users may wish to visit this web page for more information: <a href="https://kb.mozillazine.org/Plain_text_e-mail_-_Thunderbird#Completely_plain_email" class="bare">https://kb.mozillazine.org/Plain_text_e-mail_-_Thunderbird#Completely_plain_email</a></p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-format-patch">git-format-patch[1]</a>, <a href="git-send-email">git-send-email[1]</a>, mbox(5)</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-imap-send" class="_attribution-link">https://git-scm.com/docs/git-imap-send</a> + </p> +</div> diff --git a/devdocs/git/git-index-pack.html b/devdocs/git/git-index-pack.html new file mode 100644 index 00000000..e7b9bace --- /dev/null +++ b/devdocs/git/git-index-pack.html @@ -0,0 +1,8 @@ +<h1>git-index-pack</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-index-pack - Build pack index file for an existing packed archive</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git index-pack [-v] [-o <index-file>] [--[no-]rev-index] <pack-file> +git index-pack --stdin [--fix-thin] [--keep] [-v] [-o <index-file>] + [--[no-]rev-index] [<pack-file>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Reads a packed archive (.pack) from the specified file, builds a pack index file (.idx) for it, and optionally writes a reverse-index (.rev) for the specified pack. The packed archive, together with the pack index, can then be placed in the objects/pack/ directory of a Git repository.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-index-pack.txt--v"> -v </dt> <dd> <p>Be verbose about what is going on, including progress status.</p> </dd> <dt class="hdlist1" id="Documentation/git-index-pack.txt--oltindex-filegt"> -o <index-file> </dt> <dd> <p>Write the generated pack index into the specified file. Without this option the name of pack index file is constructed from the name of packed archive file by replacing .pack with .idx (and the program fails if the name of packed archive does not end with .pack).</p> </dd> <dt class="hdlist1" id="Documentation/git-index-pack.txt---no-rev-index"> --[no-]rev-index </dt> <dd> <p>When this flag is provided, generate a reverse index (a <code>.rev</code> file) corresponding to the given pack. If <code>--verify</code> is given, ensure that the existing reverse index is correct. Takes precedence over <code>pack.writeReverseIndex</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-index-pack.txt---stdin"> --stdin </dt> <dd> <p>When this flag is provided, the pack is read from stdin instead and a copy is then written to <pack-file>. If <pack-file> is not specified, the pack is written to objects/pack/ directory of the current Git repository with a default name determined from the pack content. If <pack-file> is not specified consider using --keep to prevent a race condition between this process and <code>git repack</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-index-pack.txt---fix-thin"> --fix-thin </dt> <dd> <p>Fix a "thin" pack produced by <code>git pack-objects --thin</code> (see <a href="git-pack-objects">git-pack-objects[1]</a> for details) by adding the excluded objects the deltified objects are based on to the pack. This option only makes sense in conjunction with --stdin.</p> </dd> <dt class="hdlist1" id="Documentation/git-index-pack.txt---keep"> --keep </dt> <dd> <p>Before moving the index into its final destination create an empty .keep file for the associated pack file. This option is usually necessary with --stdin to prevent a simultaneous <code>git repack</code> process from deleting the newly constructed pack and index before refs can be updated to use objects contained in the pack.</p> </dd> <dt class="hdlist1" id="Documentation/git-index-pack.txt---keepltmsggt"> --keep=<msg> </dt> <dd> <p>Like --keep, create a .keep file before moving the index into its final destination. However, instead of creating an empty file place <code><msg></code> followed by an LF into the .keep file. The <code><msg></code> message can later be searched for within all .keep files to locate any which have outlived their usefulness.</p> </dd> <dt class="hdlist1" id="Documentation/git-index-pack.txt---index-versionltversiongtltoffsetgt"> --index-version=<version>[,<offset>] </dt> <dd> <p>This is intended to be used by the test suite only. It allows to force the version for the generated pack index, and to force 64-bit index entries on objects located above the given offset.</p> </dd> <dt class="hdlist1" id="Documentation/git-index-pack.txt---strict"> --strict </dt> <dd> <p>Die, if the pack contains broken objects or links.</p> </dd> <dt class="hdlist1" id="Documentation/git-index-pack.txt---progress-title"> --progress-title </dt> <dd> <p>For internal use only.</p> <p>Set the title of the progress bar. The title is "Receiving objects" by default and "Indexing objects" when <code>--stdin</code> is specified.</p> </dd> <dt class="hdlist1" id="Documentation/git-index-pack.txt---check-self-contained-and-connected"> --check-self-contained-and-connected </dt> <dd> <p>Die if the pack contains broken links. For internal use only.</p> </dd> <dt class="hdlist1" id="Documentation/git-index-pack.txt---fsck-objects"> --fsck-objects </dt> <dd> <p>For internal use only.</p> <p>Die if the pack contains broken objects. If the pack contains a tree pointing to a .gitmodules blob that does not exist, prints the hash of that blob (for the caller to check) after the hash that goes into the name of the pack/idx file (see "Notes").</p> </dd> <dt class="hdlist1" id="Documentation/git-index-pack.txt---threadsltngt"> --threads=<n> </dt> <dd> <p>Specifies the number of threads to spawn when resolving deltas. This requires that index-pack be compiled with pthreads otherwise this option is ignored with a warning. This is meant to reduce packing time on multiprocessor machines. The required amount of memory for the delta search window is however multiplied by the number of threads. Specifying 0 will cause Git to auto-detect the number of CPU’s and use maximum 3 threads.</p> </dd> <dt class="hdlist1" id="Documentation/git-index-pack.txt---max-input-sizeltsizegt"> --max-input-size=<size> </dt> <dd> <p>Die, if the pack is larger than <size>.</p> </dd> <dt class="hdlist1" id="Documentation/git-index-pack.txt---object-formatlthash-algorithmgt"> --object-format=<hash-algorithm> </dt> <dd> <p>Specify the given object format (hash algorithm) for the pack. The valid values are <code>sha1</code> and (if enabled) <code>sha256</code>. The default is the algorithm for the current repository (set by <code>extensions.objectFormat</code>), or <code>sha1</code> if no value is set or outside a repository.</p> <p>This option cannot be used with --stdin.</p> <p>Note: At present, there is no interoperability between SHA-256 repositories and SHA-1 repositories.</p> </dd> </dl> </div> <p>Historically, we warned that SHA-256 repositories may later need backward incompatible changes when we introduce such interoperability features. Today, we only expect compatible changes. Furthermore, if such changes prove to be necessary, it can be expected that SHA-256 repositories created with today’s Git will be usable by future versions of Git without data loss.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-index-pack.txt---promisorltmessagegt"> --promisor[=<message>] </dt> <dd> <p>Before committing the pack-index, create a .promisor file for this pack. Particularly helpful when writing a promisor pack with --fix-thin since the name of the pack is not final until the pack has been fully written. If a <code><message></code> is provided, then that content will be written to the .promisor file for future reference. See <a href="partial-clone">partial clone</a> for more information.</p> </dd> </dl> </div> </div> <h2 id="_notes">Notes</h2> <div class="sectionbody"> <p>Once the index has been created, the hash that goes into the name of the pack/idx file is printed to stdout. If --stdin was also used then this is prefixed by either "pack\t", or "keep\t" if a new .keep file was successfully created. This is useful to remove a .keep file used as a lock to prevent the race with <code>git repack</code> mentioned above.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-index-pack" class="_attribution-link">https://git-scm.com/docs/git-index-pack</a> + </p> +</div> diff --git a/devdocs/git/git-init.html b/devdocs/git/git-init.html new file mode 100644 index 00000000..556426e8 --- /dev/null +++ b/devdocs/git/git-init.html @@ -0,0 +1,12 @@ +<h1>git-init</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-init - Create an empty Git repository or reinitialize an existing one</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git init [-q | --quiet] [--bare] [--template=<template-directory>] + [--separate-git-dir <git-dir>] [--object-format=<format>] + [-b <branch-name> | --initial-branch=<branch-name>] + [--shared[=<permissions>]] [<directory>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This command creates an empty Git repository - basically a <code>.git</code> directory with subdirectories for <code>objects</code>, <code>refs/heads</code>, <code>refs/tags</code>, and template files. An initial branch without any commits will be created (see the <code>--initial-branch</code> option below for its name).</p> <p>If the <code>$GIT_DIR</code> environment variable is set then it specifies a path to use instead of <code>./.git</code> for the base of the repository.</p> <p>If the object storage directory is specified via the <code>$GIT_OBJECT_DIRECTORY</code> environment variable then the sha1 directories are created underneath; otherwise, the default <code>$GIT_DIR/objects</code> directory is used.</p> <p>Running <code>git init</code> in an existing repository is safe. It will not overwrite things that are already there. The primary reason for rerunning <code>git init</code> is to pick up newly added templates (or to move the repository to another place if --separate-git-dir is given).</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-init.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-init.txt---quiet"> --quiet </dt> <dd> <p>Only print error and warning messages; all other output will be suppressed.</p> </dd> <dt class="hdlist1" id="Documentation/git-init.txt---bare"> --bare </dt> <dd> <p>Create a bare repository. If <code>GIT_DIR</code> environment is not set, it is set to the current working directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-init.txt---object-formatltformatgt"> --object-format=<format> </dt> <dd> <p>Specify the given object format (hash algorithm) for the repository. The valid values are <code>sha1</code> and (if enabled) <code>sha256</code>. <code>sha1</code> is the default.</p> <p>Note: At present, there is no interoperability between SHA-256 repositories and SHA-1 repositories.</p> </dd> </dl> </div> <p>Historically, we warned that SHA-256 repositories may later need backward incompatible changes when we introduce such interoperability features. Today, we only expect compatible changes. Furthermore, if such changes prove to be necessary, it can be expected that SHA-256 repositories created with today’s Git will be usable by future versions of Git without data loss.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-init.txt---templatelttemplate-directorygt"> --template=<template-directory> </dt> <dd> <p>Specify the directory from which templates will be used. (See the "TEMPLATE DIRECTORY" section below.)</p> </dd> <dt class="hdlist1" id="Documentation/git-init.txt---separate-git-dirltgit-dirgt"> --separate-git-dir=<git-dir> </dt> <dd> <p>Instead of initializing the repository as a directory to either <code>$GIT_DIR</code> or <code>./.git/</code>, create a text file there containing the path to the actual repository. This file acts as a filesystem-agnostic Git symbolic link to the repository.</p> <p>If this is a reinitialization, the repository will be moved to the specified path.</p> </dd> <dt class="hdlist1" id="Documentation/git-init.txt--bltbranch-namegt"> -b <branch-name> </dt> <dt class="hdlist1" id="Documentation/git-init.txt---initial-branchltbranch-namegt"> --initial-branch=<branch-name> </dt> <dd> <p>Use the specified name for the initial branch in the newly created repository. If not specified, fall back to the default name (currently <code>master</code>, but this is subject to change in the future; the name can be customized via the <code>init.defaultBranch</code> configuration variable).</p> </dd> <dt class="hdlist1" id="Documentation/git-init.txt---sharedfalsetrueumaskgroupallworldeverybodyltpermgt"> --shared[=(false|true|umask|group|all|world|everybody|<perm>)] </dt> <dd> <p>Specify that the Git repository is to be shared amongst several users. This allows users belonging to the same group to push into that repository. When specified, the config variable "core.sharedRepository" is set so that files and directories under <code>$GIT_DIR</code> are created with the requested permissions. When not specified, Git will use permissions reported by umask(2).</p> <p>The option can have the following values, defaulting to <code>group</code> if no value is given:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-init.txt-emumaskemoremfalseem"> <em>umask</em> (or <em>false</em>) </dt> <dd> <p>Use permissions reported by umask(2). The default, when <code>--shared</code> is not specified.</p> </dd> <dt class="hdlist1" id="Documentation/git-init.txt-emgroupemoremtrueem"> <em>group</em> (or <em>true</em>) </dt> <dd> <p>Make the repository group-writable, (and g+sx, since the git group may not be the primary group of all users). This is used to loosen the permissions of an otherwise safe umask(2) value. Note that the umask still applies to the other permission bits (e.g. if umask is <code>0022</code>, using <code>group</code> will not remove read privileges from other (non-group) users). See <code>0xxx</code> for how to exactly specify the repository permissions.</p> </dd> <dt class="hdlist1" id="Documentation/git-init.txt-emallemoremworldemoremeverybodyem"> <em>all</em> (or <em>world</em> or <em>everybody</em>) </dt> <dd> <p>Same as <code>group</code>, but make the repository readable by all users.</p> </dd> <dt class="hdlist1" id="Documentation/git-init.txt-emltpermgtem"> <em><perm></em> </dt> <dd> <p><code><perm></code> is a 3-digit octal number prefixed with <code>0</code> and each file will have mode <code><perm></code>. <code><perm></code> will override users' umask(2) value (and not only loosen permissions as <code>group</code> and <code>all</code> do). <code>0640</code> will create a repository which is group-readable, but not group-writable or accessible to others. <code>0660</code> will create a repo that is readable and writable to the current user and group, but inaccessible to others (directories and executable files get their <code>x</code> bit from the <code>r</code> bit for corresponding classes of users).</p> </dd> </dl> </div> </div> </div> </dd> </dl> </div> <p>By default, the configuration flag <code>receive.denyNonFastForwards</code> is enabled in shared repositories, so that you cannot force a non fast-forwarding push into it.</p> <p>If you provide a <code>directory</code>, the command is run inside it. If this directory does not exist, it will be created.</p> </div> <h2 id="_template_directory">Template directory</h2> <div class="sectionbody"> <p>Files and directories in the template directory whose name do not start with a dot will be copied to the <code>$GIT_DIR</code> after it is created.</p> <p>The template directory will be one of the following (in order):</p> <div class="ulist"> <ul> <li> <p>the argument given with the <code>--template</code> option;</p> </li> <li> <p>the contents of the <code>$GIT_TEMPLATE_DIR</code> environment variable;</p> </li> <li> <p>the <code>init.templateDir</code> configuration variable; or</p> </li> <li> <p>the default template directory: <code>/usr/share/git-core/templates</code>.</p> </li> </ul> </div> <p>The default template directory includes some directory structure, suggested "exclude patterns" (see <a href="gitignore">gitignore[5]</a>), and sample hook files.</p> <p>The sample hooks are all disabled by default. To enable one of the sample hooks rename it by removing its <code>.sample</code> suffix.</p> <p>See <a href="githooks">githooks[5]</a> for more general info on hook execution.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-init.txt-StartanewGitrepositoryforanexistingcodebase"> Start a new Git repository for an existing code base </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cd /path/to/my/codebase +$ git init (1) +$ git add . (2) +$ git commit (3)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>Create a /path/to/my/codebase/.git directory.</p> </li> <li> <p>Add all existing files to the index.</p> </li> <li> <p>Record the pristine state as the first commit in the history.</p> </li> </ol> </div> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-init.txt-inittemplateDir"> init.templateDir </dt> <dd> <p>Specify the directory from which templates will be copied. (See the "TEMPLATE DIRECTORY" section of <a href="git-init">git-init[1]</a>.)</p> </dd> <dt class="hdlist1" id="Documentation/git-init.txt-initdefaultBranch"> init.defaultBranch </dt> <dd> <p>Allows overriding the default branch name e.g. when initializing a new repository.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-init" class="_attribution-link">https://git-scm.com/docs/git-init</a> + </p> +</div> diff --git a/devdocs/git/git-instaweb.html b/devdocs/git/git-instaweb.html new file mode 100644 index 00000000..313d0217 --- /dev/null +++ b/devdocs/git/git-instaweb.html @@ -0,0 +1,13 @@ +<h1>git-instaweb</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-instaweb - Instantly browse your working repository in gitweb</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git instaweb [--local] [--httpd=<httpd>] [--port=<port>] + [--browser=<browser>] +git instaweb [--start] [--stop] [--restart]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>A simple script to set up <code>gitweb</code> and a web server for browsing the local repository.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-instaweb.txt--l"> -l </dt> <dt class="hdlist1" id="Documentation/git-instaweb.txt---local"> --local </dt> <dd> <p>Only bind the web server to the local IP (127.0.0.1).</p> </dd> <dt class="hdlist1" id="Documentation/git-instaweb.txt--d"> -d </dt> <dt class="hdlist1" id="Documentation/git-instaweb.txt---httpd"> --httpd </dt> <dd> <p>The HTTP daemon command-line that will be executed. Command-line options may be specified here, and the configuration file will be added at the end of the command-line. Currently apache2, lighttpd, mongoose, plackup, python and webrick are supported. (Default: lighttpd)</p> </dd> <dt class="hdlist1" id="Documentation/git-instaweb.txt--m"> -m </dt> <dt class="hdlist1" id="Documentation/git-instaweb.txt---module-path"> --module-path </dt> <dd> <p>The module path (only needed if httpd is Apache). (Default: /usr/lib/apache2/modules)</p> </dd> <dt class="hdlist1" id="Documentation/git-instaweb.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-instaweb.txt---port"> --port </dt> <dd> <p>The port number to bind the httpd to. (Default: 1234)</p> </dd> <dt class="hdlist1" id="Documentation/git-instaweb.txt--b"> -b </dt> <dt class="hdlist1" id="Documentation/git-instaweb.txt---browser"> --browser </dt> <dd> <p>The web browser that should be used to view the gitweb page. This will be passed to the <code>git web--browse</code> helper script along with the URL of the gitweb instance. See <a href="git-web--browse">git-web--browse[1]</a> for more information about this. If the script fails, the URL will be printed to stdout.</p> </dd> <dt class="hdlist1" id="Documentation/git-instaweb.txt-start"> start </dt> <dt class="hdlist1" id="Documentation/git-instaweb.txt---start"> --start </dt> <dd> <p>Start the httpd instance and exit. Regenerate configuration files as necessary for spawning a new instance.</p> </dd> <dt class="hdlist1" id="Documentation/git-instaweb.txt-stop"> stop </dt> <dt class="hdlist1" id="Documentation/git-instaweb.txt---stop"> --stop </dt> <dd> <p>Stop the httpd instance and exit. This does not generate any of the configuration files for spawning a new instance, nor does it close the browser.</p> </dd> <dt class="hdlist1" id="Documentation/git-instaweb.txt-restart"> restart </dt> <dt class="hdlist1" id="Documentation/git-instaweb.txt---restart"> --restart </dt> <dd> <p>Restart the httpd instance and exit. Regenerate configuration files as necessary for spawning a new instance.</p> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>You may specify configuration in your .git/config</p> <div class="listingblock"> <div class="content"> <pre>[instaweb] + local = true + httpd = apache2 -f + port = 4321 + browser = konqueror + modulePath = /usr/lib/apache2/modules</pre> </div> </div> <p>If the configuration variable <code>instaweb.browser</code> is not set, <code>web.browser</code> will be used instead if it is defined. See <a href="git-web--browse">git-web--browse[1]</a> for more information about this.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gitweb">gitweb[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-instaweb" class="_attribution-link">https://git-scm.com/docs/git-instaweb</a> + </p> +</div> diff --git a/devdocs/git/git-interpret-trailers.html b/devdocs/git/git-interpret-trailers.html new file mode 100644 index 00000000..b3faffdd --- /dev/null +++ b/devdocs/git/git-interpret-trailers.html @@ -0,0 +1,136 @@ +<h1>git-interpret-trailers</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-interpret-trailers - Add or parse structured information in commit messages</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git interpret-trailers [--in-place] [--trim-empty] + [(--trailer (<key>|<keyAlias>)[(=|:)<value>])…] + [--parse] [<file>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Add or parse <code>trailer</code> lines that look similar to RFC 822 e-mail headers, at the end of the otherwise free-form part of a commit message. For example, in the following commit message</p> <div class="listingblock"> <div class="content"> <pre>subject + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. + +Signed-off-by: Alice <alice@example.com> +Signed-off-by: Bob <bob@example.com></pre> </div> </div> <p>the last two lines starting with "Signed-off-by" are trailers.</p> <p>This command reads commit messages from either the <file> arguments or the standard input if no <file> is specified. If <code>--parse</code> is specified, the output consists of the parsed trailers coming from the input, without influencing them with any command line options or configuration variables.</p> <p>Otherwise, this command applies <code>trailer.*</code> configuration variables (which could potentially add new trailers, as well as reposition them), as well as any command line arguments that can override configuration variables (such as <code>--trailer=...</code> which could also add new trailers), to each input file. The result is emitted on the standard output.</p> <p>This command can also operate on the output of <a href="git-format-patch">git-format-patch[1]</a>, which is more elaborate than a plain commit message. Namely, such output includes a commit message (as above), a "---" divider line, and a patch part. For these inputs, the divider and patch parts are not modified by this command and are emitted as is on the output, unless <code>--no-divider</code> is specified.</p> <p>Some configuration variables control the way the <code>--trailer</code> arguments are applied to each input and the way any existing trailer in the input is changed. They also make it possible to automatically add some trailers.</p> <p>By default, a <code><key>=<value></code> or <code><key>:<value></code> argument given using <code>--trailer</code> will be appended after the existing trailers only if the last trailer has a different (<key>, <value>) pair (or if there is no existing trailer). The <key> and <value> parts will be trimmed to remove starting and trailing whitespace, and the resulting trimmed <key> and <value> will appear in the output like this:</p> <div class="listingblock"> <div class="content"> <pre>key: value</pre> </div> </div> <p>This means that the trimmed <key> and <value> will be separated by <code>': '</code> (one colon followed by one space).</p> <p>For convenience, a <keyAlias> can be configured to make using <code>--trailer</code> shorter to type on the command line. This can be configured using the <code>trailer.<keyAlias>.key</code> configuration variable. The <keyAlias> must be a prefix of the full <key> string, although case sensitivity does not matter. For example, if you have</p> <div class="listingblock"> <div class="content"> <pre>trailer.sign.key "Signed-off-by: "</pre> </div> </div> <p>in your configuration, you only need to specify <code>--trailer="sign: foo"</code> on the command line instead of <code>--trailer="Signed-off-by: foo"</code>.</p> <p>By default the new trailer will appear at the end of all the existing trailers. If there is no existing trailer, the new trailer will appear at the end of the input. A blank line will be added before the new trailer if there isn’t one already.</p> <p>Existing trailers are extracted from the input by looking for a group of one or more lines that (i) is all trailers, or (ii) contains at least one Git-generated or user-configured trailer and consists of at least 25% trailers. The group must be preceded by one or more empty (or whitespace-only) lines. The group must either be at the end of the input or be the last non-whitespace lines before a line that starts with <code>---</code> (followed by a space or the end of the line).</p> <p>When reading trailers, there can be no whitespace before or inside the <key>, but any number of regular space and tab characters are allowed between the <key> and the separator. There can be whitespaces before, inside or after the <value>. The <value> may be split over multiple lines with each subsequent line starting with at least one whitespace, like the "folding" in RFC 822. Example:</p> <div class="listingblock"> <div class="content"> <pre>key: This is a very long value, with spaces and + newlines in it.</pre> </div> </div> <p>Note that trailers do not follow (nor are they intended to follow) many of the rules for RFC 822 headers. For example they do not follow the encoding rule.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt---in-place"> --in-place </dt> <dd> <p>Edit the files in place.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt---trim-empty"> --trim-empty </dt> <dd> <p>If the <value> part of any trailer contains only whitespace, the whole trailer will be removed from the output. This applies to existing trailers as well as new trailers.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt---trailerltkeygtltvaluegt"> --trailer <key>[(=|:)<value>] </dt> <dd> <p>Specify a (<key>, <value>) pair that should be applied as a trailer to the inputs. See the description of this command.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt---whereltplacementgt"> --where <placement> </dt> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt---no-where"> --no-where </dt> <dd> <p>Specify where all new trailers will be added. A setting provided with <code>--where</code> overrides the <code>trailer.where</code> and any applicable <code>trailer.<keyAlias>.where</code> configuration variables and applies to all <code>--trailer</code> options until the next occurrence of <code>--where</code> or <code>--no-where</code>. Upon encountering <code>--no-where</code>, clear the effect of any previous use of <code>--where</code>, such that the relevant configuration variables are no longer overridden. Possible placements are <code>after</code>, <code>before</code>, <code>end</code> or <code>start</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt---if-existsltactiongt"> --if-exists <action> </dt> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt---no-if-exists"> --no-if-exists </dt> <dd> <p>Specify what action will be performed when there is already at least one trailer with the same <key> in the input. A setting provided with <code>--if-exists</code> overrides the <code>trailer.ifExists</code> and any applicable <code>trailer.<keyAlias>.ifExists</code> configuration variables and applies to all <code>--trailer</code> options until the next occurrence of <code>--if-exists</code> or <code>--no-if-exists</code>. Upon encountering '--no-if-exists, clear the effect of any previous use of '--if-exists, such that the relevant configuration variables are no longer overridden. Possible actions are <code>addIfDifferent</code>, <code>addIfDifferentNeighbor</code>, <code>add</code>, <code>replace</code> and <code>doNothing</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt---if-missingltactiongt"> --if-missing <action> </dt> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt---no-if-missing"> --no-if-missing </dt> <dd> <p>Specify what action will be performed when there is no other trailer with the same <key> in the input. A setting provided with <code>--if-missing</code> overrides the <code>trailer.ifMissing</code> and any applicable <code>trailer.<keyAlias>.ifMissing</code> configuration variables and applies to all <code>--trailer</code> options until the next occurrence of <code>--if-missing</code> or <code>--no-if-missing</code>. Upon encountering '--no-if-missing, clear the effect of any previous use of '--if-missing, such that the relevant configuration variables are no longer overridden. Possible actions are <code>doNothing</code> or <code>add</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt---only-trailers"> --only-trailers </dt> <dd> <p>Output only the trailers, not any other parts of the input.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt---only-input"> --only-input </dt> <dd> <p>Output only trailers that exist in the input; do not add any from the command-line or by applying <code>trailer.*</code> configuration variables.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt---unfold"> --unfold </dt> <dd> <p>If a trailer has a value that runs over multiple lines (aka "folded"), reformat the value into a single line.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt---parse"> --parse </dt> <dd> <p>A convenience alias for <code>--only-trailers --only-input +--unfold</code>. This makes it easier to only see the trailers coming from the input without influencing them with any command line options or configuration variables, while also making the output machine-friendly with --unfold.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt---no-divider"> --no-divider </dt> <dd> <p>Do not treat <code>---</code> as the end of the commit message. Use this when you know your input contains just the commit message itself (and not an email or the output of <code>git format-patch</code>).</p> </dd> </dl> </div> </div> <h2 id="_configuration_variables">Configuration variables</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt-trailerseparators"> trailer.separators </dt> <dd> <p>This option tells which characters are recognized as trailer separators. By default only <code>:</code> is recognized as a trailer separator, except that <code>=</code> is always accepted on the command line for compatibility with other git commands.</p> <p>The first character given by this option will be the default character used when another separator is not specified in the config for this trailer.</p> <p>For example, if the value for this option is "%=$", then only lines using the format <code><key><sep><value></code> with <sep> containing <code>%</code>, <code>=</code> or <code>$</code> and then spaces will be considered trailers. And <code>%</code> will be the default separator used, so by default trailers will appear like: <code><key>% <value></code> (one percent sign and one space will appear between the key and the value).</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt-trailerwhere"> trailer.where </dt> <dd> <p>This option tells where a new trailer will be added.</p> <p>This can be <code>end</code>, which is the default, <code>start</code>, <code>after</code> or <code>before</code>.</p> <p>If it is <code>end</code>, then each new trailer will appear at the end of the existing trailers.</p> <p>If it is <code>start</code>, then each new trailer will appear at the start, instead of the end, of the existing trailers.</p> <p>If it is <code>after</code>, then each new trailer will appear just after the last trailer with the same <key>.</p> <p>If it is <code>before</code>, then each new trailer will appear just before the first trailer with the same <key>.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt-trailerifexists"> trailer.ifexists </dt> <dd> <p>This option makes it possible to choose what action will be performed when there is already at least one trailer with the same <key> in the input.</p> <p>The valid values for this option are: <code>addIfDifferentNeighbor</code> (this is the default), <code>addIfDifferent</code>, <code>add</code>, <code>replace</code> or <code>doNothing</code>.</p> <p>With <code>addIfDifferentNeighbor</code>, a new trailer will be added only if no trailer with the same (<key>, <value>) pair is above or below the line where the new trailer will be added.</p> <p>With <code>addIfDifferent</code>, a new trailer will be added only if no trailer with the same (<key>, <value>) pair is already in the input.</p> <p>With <code>add</code>, a new trailer will be added, even if some trailers with the same (<key>, <value>) pair are already in the input.</p> <p>With <code>replace</code>, an existing trailer with the same <key> will be deleted and the new trailer will be added. The deleted trailer will be the closest one (with the same <key>) to the place where the new one will be added.</p> <p>With <code>doNothing</code>, nothing will be done; that is no new trailer will be added if there is already one with the same <key> in the input.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt-trailerifmissing"> trailer.ifmissing </dt> <dd> <p>This option makes it possible to choose what action will be performed when there is not yet any trailer with the same <key> in the input.</p> <p>The valid values for this option are: <code>add</code> (this is the default) and <code>doNothing</code>.</p> <p>With <code>add</code>, a new trailer will be added.</p> <p>With <code>doNothing</code>, nothing will be done.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt-trailerltkeyAliasgtkey"> trailer.<keyAlias>.key </dt> <dd> <p>Defines a <keyAlias> for the <key>. The <keyAlias> must be a prefix (case does not matter) of the <key>. For example, in <code>git +config trailer.ack.key "Acked-by"</code> the "Acked-by" is the <key> and the "ack" is the <keyAlias>. This configuration allows the shorter <code>--trailer "ack:..."</code> invocation on the command line using the "ack" <keyAlias> instead of the longer <code>--trailer "Acked-by:..."</code>.</p> <p>At the end of the <key>, a separator can appear and then some space characters. By default the only valid separator is <code>:</code>, but this can be changed using the <code>trailer.separators</code> config variable.</p> <p>If there is a separator in the key, then it overrides the default separator when adding the trailer.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt-trailerltkeyAliasgtwhere"> trailer.<keyAlias>.where </dt> <dd> <p>This option takes the same values as the <code>trailer.where</code> configuration variable and it overrides what is specified by that option for trailers with the specified <keyAlias>.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt-trailerltkeyAliasgtifexists"> trailer.<keyAlias>.ifexists </dt> <dd> <p>This option takes the same values as the <code>trailer.ifexists</code> configuration variable and it overrides what is specified by that option for trailers with the specified <keyAlias>.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt-trailerltkeyAliasgtifmissing"> trailer.<keyAlias>.ifmissing </dt> <dd> <p>This option takes the same values as the <code>trailer.ifmissing</code> configuration variable and it overrides what is specified by that option for trailers with the specified <keyAlias>.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt-trailerltkeyAliasgtcommand"> trailer.<keyAlias>.command </dt> <dd> <p>Deprecated in favor of <code>trailer.<keyAlias>.cmd</code>. This option behaves in the same way as <code>trailer.<keyAlias>.cmd</code>, except that it doesn’t pass anything as argument to the specified command. Instead the first occurrence of substring $ARG is replaced by the <value> that would be passed as argument.</p> <p>Note that $ARG in the user’s command is only replaced once and that the original way of replacing $ARG is not safe.</p> <p>When both <code>trailer.<keyAlias>.cmd</code> and <code>trailer.<keyAlias>.command</code> are given for the same <keyAlias>, <code>trailer.<keyAlias>.cmd</code> is used and <code>trailer.<keyAlias>.command</code> is ignored.</p> </dd> <dt class="hdlist1" id="Documentation/git-interpret-trailers.txt-trailerltkeyAliasgtcmd"> trailer.<keyAlias>.cmd </dt> <dd> <p>This option can be used to specify a shell command that will be called once to automatically add a trailer with the specified <keyAlias>, and then called each time a <code>--trailer <keyAlias>=<value></code> argument is specified to modify the <value> of the trailer that this option would produce.</p> <p>When the specified command is first called to add a trailer with the specified <keyAlias>, the behavior is as if a special <code>--trailer <keyAlias>=<value></code> argument was added at the beginning of the "git interpret-trailers" command, where <value> is taken to be the standard output of the command with any leading and trailing whitespace trimmed off.</p> <p>If some <code>--trailer <keyAlias>=<value></code> arguments are also passed on the command line, the command is called again once for each of these arguments with the same <keyAlias>. And the <value> part of these arguments, if any, will be passed to the command as its first argument. This way the command can produce a <value> computed from the <value> passed in the <code>--trailer <keyAlias>=<value></code> argument.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Configure a <code>sign</code> trailer with a <code>Signed-off-by</code> key, and then add two of these trailers to a commit message file:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config trailer.sign.key "Signed-off-by" +$ cat msg.txt +subject + +body text +$ git interpret-trailers --trailer 'sign: Alice <alice@example.com>' --trailer 'sign: Bob <bob@example.com>' <msg.txt +subject + +body text + +Signed-off-by: Alice <alice@example.com> +Signed-off-by: Bob <bob@example.com></pre> </div> </div> </li> <li> <p>Use the <code>--in-place</code> option to edit a commit message file in place:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat msg.txt +subject + +body text + +Signed-off-by: Bob <bob@example.com> +$ git interpret-trailers --trailer 'Acked-by: Alice <alice@example.com>' --in-place msg.txt +$ cat msg.txt +subject + +body text + +Signed-off-by: Bob <bob@example.com> +Acked-by: Alice <alice@example.com></pre> </div> </div> </li> <li> <p>Extract the last commit as a patch, and add a <code>Cc</code> and a <code>Reviewed-by</code> trailer to it:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git format-patch -1 +0001-foo.patch +$ git interpret-trailers --trailer 'Cc: Alice <alice@example.com>' --trailer 'Reviewed-by: Bob <bob@example.com>' 0001-foo.patch >0001-bar.patch</pre> </div> </div> </li> <li> <p>Configure a <code>sign</code> trailer with a command to automatically add a 'Signed-off-by: ' with the author information only if there is no 'Signed-off-by: ' already, and show how it works:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat msg1.txt +subject + +body text +$ git config trailer.sign.key "Signed-off-by: " +$ git config trailer.sign.ifmissing add +$ git config trailer.sign.ifexists doNothing +$ git config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"' +$ git interpret-trailers --trailer sign <msg1.txt +subject + +body text + +Signed-off-by: Bob <bob@example.com> +$ cat msg2.txt +subject + +body text + +Signed-off-by: Alice <alice@example.com> +$ git interpret-trailers --trailer sign <msg2.txt +subject + +body text + +Signed-off-by: Alice <alice@example.com></pre> </div> </div> </li> <li> <p>Configure a <code>fix</code> trailer with a key that contains a <code>#</code> and no space after this character, and show how it works:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config trailer.separators ":#" +$ git config trailer.fix.key "Fix #" +$ echo "subject" | git interpret-trailers --trailer fix=42 +subject + +Fix #42</pre> </div> </div> </li> <li> <p>Configure a <code>help</code> trailer with a cmd use a script <code>glog-find-author</code> which search specified author identity from git log in git repository and show how it works:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat ~/bin/glog-find-author +#!/bin/sh +test -n "$1" && git log --author="$1" --pretty="%an <%ae>" -1 || true +$ cat msg.txt +subject + +body text +$ git config trailer.help.key "Helped-by: " +$ git config trailer.help.ifExists "addIfDifferentNeighbor" +$ git config trailer.help.cmd "~/bin/glog-find-author" +$ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" <msg.txt +subject + +body text + +Helped-by: Junio C Hamano <gitster@pobox.com> +Helped-by: Christian Couder <christian.couder@gmail.com></pre> </div> </div> </li> <li> <p>Configure a <code>ref</code> trailer with a cmd use a script <code>glog-grep</code> to grep last relevant commit from git log in the git repository and show how it works:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat ~/bin/glog-grep +#!/bin/sh +test -n "$1" && git log --grep "$1" --pretty=reference -1 || true +$ cat msg.txt +subject + +body text +$ git config trailer.ref.key "Reference-to: " +$ git config trailer.ref.ifExists "replace" +$ git config trailer.ref.cmd "~/bin/glog-grep" +$ git interpret-trailers --trailer="ref:Add copyright notices." <msg.txt +subject + +body text + +Reference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07)</pre> </div> </div> </li> <li> <p>Configure a <code>see</code> trailer with a command to show the subject of a commit that is related, and show how it works:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat msg.txt +subject + +body text + +see: HEAD~2 +$ cat ~/bin/glog-ref +#!/bin/sh +git log -1 --oneline --format="%h (%s)" --abbrev-commit --abbrev=14 +$ git config trailer.see.key "See-also: " +$ git config trailer.see.ifExists "replace" +$ git config trailer.see.ifMissing "doNothing" +$ git config trailer.see.cmd "glog-ref" +$ git interpret-trailers --trailer=see <msg.txt +subject + +body text + +See-also: fe3187489d69c4 (subject of related commit)</pre> </div> </div> </li> <li> <p>Configure a commit template with some trailers with empty values (using sed to show and keep the trailing spaces at the end of the trailers), then configure a commit-msg hook that uses <code>git interpret-trailers</code> to remove trailers with empty values and to add a <code>git-version</code> trailer:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat temp.txt +***subject*** + +***message*** + +Fixes: Z +Cc: Z +Reviewed-by: Z +Signed-off-by: Z +$ sed -e 's/ Z$/ /' temp.txt > commit_template.txt +$ git config commit.template commit_template.txt +$ cat .git/hooks/commit-msg +#!/bin/sh +git interpret-trailers --trim-empty --trailer "git-version: \$(git describe)" "\$1" > "\$1.new" +mv "\$1.new" "\$1" +$ chmod +x .git/hooks/commit-msg</pre> </div> </div> </li> </ul> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-commit">git-commit[1]</a>, <a href="git-format-patch">git-format-patch[1]</a>, <a href="git-config">git-config[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-interpret-trailers" class="_attribution-link">https://git-scm.com/docs/git-interpret-trailers</a> + </p> +</div> diff --git a/devdocs/git/git-log.html b/devdocs/git/git-log.html new file mode 100644 index 00000000..d95f0a3a --- /dev/null +++ b/devdocs/git/git-log.html @@ -0,0 +1,149 @@ +<h1>git-log</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-log - Show commit logs</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git log [<options>] [<revision-range>] [[--] <path>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Shows the commit logs.</p> <p>List commits that are reachable by following the <code>parent</code> links from the given commit(s), but exclude commits that are reachable from the one(s) given with a <code>^</code> in front of them. The output is given in reverse chronological order by default.</p> <p>You can think of this as a set operation. Commits reachable from any of the commits given on the command line form a set, and then commits reachable from any of the ones given with <code>^</code> in front are subtracted from that set. The remaining commits are what comes out in the command’s output. Various other options and paths parameters can be used to further limit the result.</p> <p>Thus, the following command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log foo bar ^baz</pre> </div> </div> <p>means "list all the commits which are reachable from <code>foo</code> or <code>bar</code>, but not from <code>baz</code>".</p> <p>A special notation "<code><commit1></code>..<code><commit2></code>" can be used as a short-hand for "^<code><commit1></code> <code><commit2></code>". For example, either of the following may be used interchangeably:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log origin..HEAD +$ git log HEAD ^origin</pre> </div> </div> <p>Another special notation is "<code><commit1></code>…<code><commit2></code>" which is useful for merges. The resulting set of commits is the symmetric difference between the two operands. The following two commands are equivalent:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log A B --not $(git merge-base --all A B) +$ git log A...B</pre> </div> </div> <p>The command takes options applicable to the <a href="git-rev-list">git-rev-list[1]</a> command to control what is shown and how, and options applicable to the <a href="git-diff">git-diff[1]</a> command to control how the changes each commit introduces are shown.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt---follow"> --follow </dt> <dd> <p>Continue listing the history of a file beyond renames (works only for a single file).</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---no-decorate"> --no-decorate </dt> <dt class="hdlist1" id="Documentation/git-log.txt---decorateshortfullautono"> --decorate[=short|full|auto|no] </dt> <dd> <p>Print out the ref names of any commits that are shown. If <code>short</code> is specified, the ref name prefixes <code>refs/heads/</code>, <code>refs/tags/</code> and <code>refs/remotes/</code> will not be printed. If <code>full</code> is specified, the full ref name (including prefix) will be printed. If <code>auto</code> is specified, then if the output is going to a terminal, the ref names are shown as if <code>short</code> were given, otherwise no ref names are shown. The option <code>--decorate</code> is short-hand for <code>--decorate=short</code>. Default to configuration value of <code>log.decorate</code> if configured, otherwise, <code>auto</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---decorate-refsltpatterngt"> --decorate-refs=<pattern> </dt> <dt class="hdlist1" id="Documentation/git-log.txt---decorate-refs-excludeltpatterngt"> --decorate-refs-exclude=<pattern> </dt> <dd> <p>For each candidate reference, do not use it for decoration if it matches any patterns given to <code>--decorate-refs-exclude</code> or if it doesn’t match any of the patterns given to <code>--decorate-refs</code>. The <code>log.excludeDecoration</code> config option allows excluding refs from the decorations, but an explicit <code>--decorate-refs</code> pattern will override a match in <code>log.excludeDecoration</code>.</p> <p>If none of these options or config settings are given, then references are used as decoration if they match <code>HEAD</code>, <code>refs/heads/</code>, <code>refs/remotes/</code>, <code>refs/stash/</code>, or <code>refs/tags/</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---clear-decorations"> --clear-decorations </dt> <dd> <p>When specified, this option clears all previous <code>--decorate-refs</code> or <code>--decorate-refs-exclude</code> options and relaxes the default decoration filter to include all references. This option is assumed if the config value <code>log.initialDecorationSet</code> is set to <code>all</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---source"> --source </dt> <dd> <p>Print out the ref name given on the command line by which each commit was reached.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---no-mailmap"> --[no-]mailmap </dt> <dt class="hdlist1" id="Documentation/git-log.txt---no-use-mailmap"> --[no-]use-mailmap </dt> <dd> <p>Use mailmap file to map author and committer names and email addresses to canonical real names and email addresses. See <a href="git-shortlog">git-shortlog[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---full-diff"> --full-diff </dt> <dd> <p>Without this flag, <code>git log -p <path>...</code> shows commits that touch the specified paths, and diffs about the same specified paths. With this, the full diff is shown for commits that touch the specified paths; this means that "<path>…" limits only commits, and doesn’t limit diff for those commits.</p> <p>Note that this affects all diff-based output types, e.g. those produced by <code>--stat</code>, etc.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---log-size"> --log-size </dt> <dd> <p>Include a line “log size <number>” in the output for each commit, where <number> is the length of that commit’s message in bytes. Intended to speed up tools that read log messages from <code>git log</code> output by allowing them to allocate space in advance.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--Lltstartgtltendgtltfilegt"> -L<start>,<end>:<file> </dt> <dt class="hdlist1" id="Documentation/git-log.txt--Lltfuncnamegtltfilegt"> -L:<funcname>:<file> </dt> <dd> <p>Trace the evolution of the line range given by <code><start>,<end></code>, or by the function name regex <code><funcname></code>, within the <code><file></code>. You may not give any pathspec limiters. This is currently limited to a walk starting from a single revision, i.e., you may only give zero or one positive revision arguments, and <code><start></code> and <code><end></code> (or <code><funcname></code>) must exist in the starting revision. You can specify this option more than once. Implies <code>--patch</code>. Patch output can be suppressed using <code>--no-patch</code>, but other diff formats (namely <code>--raw</code>, <code>--numstat</code>, <code>--shortstat</code>, <code>--dirstat</code>, <code>--summary</code>, <code>--name-only</code>, <code>--name-status</code>, <code>--check</code>) are not currently implemented.</p> <p><code><start></code> and <code><end></code> can take one of these forms:</p> <div class="ulist"> <ul> <li> <p>number</p> <p>If <code><start></code> or <code><end></code> is a number, it specifies an absolute line number (lines count from 1).</p> </li> <li> <p><code>/regex/</code></p> <p>This form will use the first line matching the given POSIX regex. If <code><start></code> is a regex, it will search from the end of the previous <code>-L</code> range, if any, otherwise from the start of file. If <code><start></code> is <code>^/regex/</code>, it will search from the start of file. If <code><end></code> is a regex, it will search starting at the line given by <code><start></code>.</p> </li> <li> <p>+offset or -offset</p> <p>This is only valid for <code><end></code> and will specify a number of lines before or after the line given by <code><start></code>.</p> </li> </ul> </div> <p>If <code>:<funcname></code> is given in place of <code><start></code> and <code><end></code>, it is a regular expression that denotes the range from the first funcname line that matches <code><funcname></code>, up to the next funcname line. <code>:<funcname></code> searches from the end of the previous <code>-L</code> range, if any, otherwise from the start of file. <code>^:<funcname></code> searches from the start of file. The function names are determined in the same way as <code>git diff</code> works out patch hunk headers (see <code>Defining a custom hunk-header</code> in <a href="gitattributes">gitattributes[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-ltrevision-rangegt"> <revision-range> </dt> <dd> <p>Show only commits in the specified revision range. When no <revision-range> is specified, it defaults to <code>HEAD</code> (i.e. the whole history leading to the current commit). <code>origin..HEAD</code> specifies all the commits reachable from the current commit (i.e. <code>HEAD</code>), but not from <code>origin</code>. For a complete list of ways to spell <revision-range>, see the <code>Specifying Ranges</code> section of <a href="gitrevisions">gitrevisions[7]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---ltpathgt82308203"> [--] <path>… </dt> <dd> <p>Show only commits that are enough to explain how the files that match the specified paths came to be. See <code>History Simplification</code> below for details and other simplification modes.</p> <p>Paths may need to be prefixed with <code>--</code> to separate them from options or the revision range, when confusion arises.</p> </dd> </dl> </div> <div class="sect2"> <h3 id="_commit_limiting"> +Commit Limiting</h3> <p>Besides specifying a range of commits that should be listed using the special notations explained in the description, additional commit limiting may be applied.</p> <p>Using more options generally further limits the output (e.g. <code>--since=<date1></code> limits to commits newer than <code><date1></code>, and using it with <code>--grep=<pattern></code> further limits to commits whose log message has a line that matches <code><pattern></code>), unless otherwise noted.</p> <p>Note that these are applied before commit ordering and formatting options, such as <code>--reverse</code>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt--ltnumbergt"> -<number> </dt> <dt class="hdlist1" id="Documentation/git-log.txt--nltnumbergt"> -n <number> </dt> <dt class="hdlist1" id="Documentation/git-log.txt---max-countltnumbergt"> --max-count=<number> </dt> <dd> <p>Limit the number of commits to output.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---skipltnumbergt"> --skip=<number> </dt> <dd> <p>Skip <code>number</code> commits before starting to show the commit output.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---sinceltdategt"> --since=<date> </dt> <dt class="hdlist1" id="Documentation/git-log.txt---afterltdategt"> --after=<date> </dt> <dd> <p>Show commits more recent than a specific date.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---since-as-filterltdategt"> --since-as-filter=<date> </dt> <dd> <p>Show all commits more recent than a specific date. This visits all commits in the range, rather than stopping at the first commit which is older than a specific date.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---untilltdategt"> --until=<date> </dt> <dt class="hdlist1" id="Documentation/git-log.txt---beforeltdategt"> --before=<date> </dt> <dd> <p>Show commits older than a specific date.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---authorltpatterngt"> --author=<pattern> </dt> <dt class="hdlist1" id="Documentation/git-log.txt---committerltpatterngt"> --committer=<pattern> </dt> <dd> <p>Limit the commits output to ones with author/committer header lines that match the specified pattern (regular expression). With more than one <code>--author=<pattern></code>, commits whose author matches any of the given patterns are chosen (similarly for multiple <code>--committer=<pattern></code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---grep-reflogltpatterngt"> --grep-reflog=<pattern> </dt> <dd> <p>Limit the commits output to ones with reflog entries that match the specified pattern (regular expression). With more than one <code>--grep-reflog</code>, commits whose reflog message matches any of the given patterns are chosen. It is an error to use this option unless <code>--walk-reflogs</code> is in use.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---grepltpatterngt"> --grep=<pattern> </dt> <dd> <p>Limit the commits output to ones with a log message that matches the specified pattern (regular expression). With more than one <code>--grep=<pattern></code>, commits whose message matches any of the given patterns are chosen (but see <code>--all-match</code>).</p> <p>When <code>--notes</code> is in effect, the message from the notes is matched as if it were part of the log message.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---all-match"> --all-match </dt> <dd> <p>Limit the commits output to ones that match all given <code>--grep</code>, instead of ones that match at least one.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---invert-grep"> --invert-grep </dt> <dd> <p>Limit the commits output to ones with a log message that do not match the pattern specified with <code>--grep=<pattern></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--i"> -i </dt> <dt class="hdlist1" id="Documentation/git-log.txt---regexp-ignore-case"> --regexp-ignore-case </dt> <dd> <p>Match the regular expression limiting patterns without regard to letter case.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---basic-regexp"> --basic-regexp </dt> <dd> <p>Consider the limiting patterns to be basic regular expressions; this is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--E"> -E </dt> <dt class="hdlist1" id="Documentation/git-log.txt---extended-regexp"> --extended-regexp </dt> <dd> <p>Consider the limiting patterns to be extended regular expressions instead of the default basic regular expressions.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--F"> -F </dt> <dt class="hdlist1" id="Documentation/git-log.txt---fixed-strings"> --fixed-strings </dt> <dd> <p>Consider the limiting patterns to be fixed strings (don’t interpret pattern as a regular expression).</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--P"> -P </dt> <dt class="hdlist1" id="Documentation/git-log.txt---perl-regexp"> --perl-regexp </dt> <dd> <p>Consider the limiting patterns to be Perl-compatible regular expressions.</p> <p>Support for these types of regular expressions is an optional compile-time dependency. If Git wasn’t compiled with support for them providing this option will cause it to die.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---remove-empty"> --remove-empty </dt> <dd> <p>Stop when a given path disappears from the tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---merges"> --merges </dt> <dd> <p>Print only merge commits. This is exactly the same as <code>--min-parents=2</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---no-merges"> --no-merges </dt> <dd> <p>Do not print commits with more than one parent. This is exactly the same as <code>--max-parents=1</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---min-parentsltnumbergt"> --min-parents=<number> </dt> <dt class="hdlist1" id="Documentation/git-log.txt---max-parentsltnumbergt"> --max-parents=<number> </dt> <dt class="hdlist1" id="Documentation/git-log.txt---no-min-parents"> --no-min-parents </dt> <dt class="hdlist1" id="Documentation/git-log.txt---no-max-parents"> --no-max-parents </dt> <dd> <p>Show only commits which have at least (or at most) that many parent commits. In particular, <code>--max-parents=1</code> is the same as <code>--no-merges</code>, <code>--min-parents=2</code> is the same as <code>--merges</code>. <code>--max-parents=0</code> gives all root commits and <code>--min-parents=3</code> all octopus merges.</p> <p><code>--no-min-parents</code> and <code>--no-max-parents</code> reset these limits (to no limit) again. Equivalent forms are <code>--min-parents=0</code> (any commit has 0 or more parents) and <code>--max-parents=-1</code> (negative numbers denote no upper limit).</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---first-parent"> --first-parent </dt> <dd> <p>When finding commits to include, follow only the first parent commit upon seeing a merge commit. This option can give a better overview when viewing the evolution of a particular topic branch, because merges into a topic branch tend to be only about adjusting to updated upstream from time to time, and this option allows you to ignore the individual commits brought in to your history by such a merge.</p> <p>This option also changes default diff format for merge commits to <code>first-parent</code>, see <code>--diff-merges=first-parent</code> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---exclude-first-parent-only"> --exclude-first-parent-only </dt> <dd> <p>When finding commits to exclude (with a <code>^</code>), follow only the first parent commit upon seeing a merge commit. This can be used to find the set of changes in a topic branch from the point where it diverged from the remote branch, given that arbitrary merges can be valid topic branch changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---not"> --not </dt> <dd> <p>Reverses the meaning of the <code>^</code> prefix (or lack thereof) for all following revision specifiers, up to the next <code>--not</code>. When used on the command line before --stdin, the revisions passed through stdin will not be affected by it. Conversely, when passed via standard input, the revisions passed on the command line will not be affected by it.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---all"> --all </dt> <dd> <p>Pretend as if all the refs in <code>refs/</code>, along with <code>HEAD</code>, are listed on the command line as <code><commit></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---branchesltpatterngt"> --branches[=<pattern>] </dt> <dd> <p>Pretend as if all the refs in <code>refs/heads</code> are listed on the command line as <code><commit></code>. If <code><pattern></code> is given, limit branches to ones matching given shell glob. If pattern lacks <code>?</code>, <code>*</code>, or <code>[</code>, <code>/*</code> at the end is implied.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---tagsltpatterngt"> --tags[=<pattern>] </dt> <dd> <p>Pretend as if all the refs in <code>refs/tags</code> are listed on the command line as <code><commit></code>. If <code><pattern></code> is given, limit tags to ones matching given shell glob. If pattern lacks <code>?</code>, <code>*</code>, or <code>[</code>, <code>/*</code> at the end is implied.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---remotesltpatterngt"> --remotes[=<pattern>] </dt> <dd> <p>Pretend as if all the refs in <code>refs/remotes</code> are listed on the command line as <code><commit></code>. If <code><pattern></code> is given, limit remote-tracking branches to ones matching given shell glob. If pattern lacks <code>?</code>, <code>*</code>, or <code>[</code>, <code>/*</code> at the end is implied.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---globltglob-patterngt"> --glob=<glob-pattern> </dt> <dd> <p>Pretend as if all the refs matching shell glob <code><glob-pattern></code> are listed on the command line as <code><commit></code>. Leading <code>refs/</code>, is automatically prepended if missing. If pattern lacks <code>?</code>, <code>*</code>, or <code>[</code>, <code>/*</code> at the end is implied.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---excludeltglob-patterngt"> --exclude=<glob-pattern> </dt> <dd> <p>Do not include refs matching <code><glob-pattern></code> that the next <code>--all</code>, <code>--branches</code>, <code>--tags</code>, <code>--remotes</code>, or <code>--glob</code> would otherwise consider. Repetitions of this option accumulate exclusion patterns up to the next <code>--all</code>, <code>--branches</code>, <code>--tags</code>, <code>--remotes</code>, or <code>--glob</code> option (other options or arguments do not clear accumulated patterns).</p> <p>The patterns given should not begin with <code>refs/heads</code>, <code>refs/tags</code>, or <code>refs/remotes</code> when applied to <code>--branches</code>, <code>--tags</code>, or <code>--remotes</code>, respectively, and they must begin with <code>refs/</code> when applied to <code>--glob</code> or <code>--all</code>. If a trailing <code>/*</code> is intended, it must be given explicitly.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---exclude-hiddenfetchreceiveuploadpack"> --exclude-hidden=[fetch|receive|uploadpack] </dt> <dd> <p>Do not include refs that would be hidden by <code>git-fetch</code>, <code>git-receive-pack</code> or <code>git-upload-pack</code> by consulting the appropriate <code>fetch.hideRefs</code>, <code>receive.hideRefs</code> or <code>uploadpack.hideRefs</code> configuration along with <code>transfer.hideRefs</code> (see <a href="git-config">git-config[1]</a>). This option affects the next pseudo-ref option <code>--all</code> or <code>--glob</code> and is cleared after processing them.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---reflog"> --reflog </dt> <dd> <p>Pretend as if all objects mentioned by reflogs are listed on the command line as <code><commit></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---alternate-refs"> --alternate-refs </dt> <dd> <p>Pretend as if all objects mentioned as ref tips of alternate repositories were listed on the command line. An alternate repository is any repository whose object directory is specified in <code>objects/info/alternates</code>. The set of included objects may be modified by <code>core.alternateRefsCommand</code>, etc. See <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---single-worktree"> --single-worktree </dt> <dd> <p>By default, all working trees will be examined by the following options when there are more than one (see <a href="git-worktree">git-worktree[1]</a>): <code>--all</code>, <code>--reflog</code> and <code>--indexed-objects</code>. This option forces them to examine the current working tree only.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---ignore-missing"> --ignore-missing </dt> <dd> <p>Upon seeing an invalid object name in the input, pretend as if the bad input was not given.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---bisect"> --bisect </dt> <dd> <p>Pretend as if the bad bisection ref <code>refs/bisect/bad</code> was listed and as if it was followed by <code>--not</code> and the good bisection refs <code>refs/bisect/good-*</code> on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---stdin"> --stdin </dt> <dd> <p>In addition to getting arguments from the command line, read them from standard input as well. This accepts commits and pseudo-options like <code>--all</code> and <code>--glob=</code>. When a <code>--</code> separator is seen, the following input is treated as paths and used to limit the result. Flags like <code>--not</code> which are read via standard input are only respected for arguments passed in the same way and will not influence any subsequent command line arguments.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---cherry-mark"> --cherry-mark </dt> <dd> <p>Like <code>--cherry-pick</code> (see below) but mark equivalent commits with <code>=</code> rather than omitting them, and inequivalent ones with <code>+</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---cherry-pick"> --cherry-pick </dt> <dd> <p>Omit any commit that introduces the same change as another commit on the “other side” when the set of commits are limited with symmetric difference.</p> <p>For example, if you have two branches, <code>A</code> and <code>B</code>, a usual way to list all commits on only one side of them is with <code>--left-right</code> (see the example below in the description of the <code>--left-right</code> option). However, it shows the commits that were cherry-picked from the other branch (for example, “3rd on b” may be cherry-picked from branch A). With this option, such pairs of commits are excluded from the output.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---left-only"> --left-only </dt> <dt class="hdlist1" id="Documentation/git-log.txt---right-only"> --right-only </dt> <dd> <p>List only commits on the respective side of a symmetric difference, i.e. only those which would be marked <code><</code> resp. <code>></code> by <code>--left-right</code>.</p> <p>For example, <code>--cherry-pick --right-only A...B</code> omits those commits from <code>B</code> which are in <code>A</code> or are patch-equivalent to a commit in <code>A</code>. In other words, this lists the <code>+</code> commits from <code>git cherry A B</code>. More precisely, <code>--cherry-pick --right-only --no-merges</code> gives the exact list.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---cherry"> --cherry </dt> <dd> <p>A synonym for <code>--right-only --cherry-mark --no-merges</code>; useful to limit the output to the commits on our side and mark those that have been applied to the other side of a forked history with <code>git log --cherry upstream...mybranch</code>, similar to <code>git cherry upstream mybranch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--g"> -g </dt> <dt class="hdlist1" id="Documentation/git-log.txt---walk-reflogs"> --walk-reflogs </dt> <dd> <p>Instead of walking the commit ancestry chain, walk reflog entries from the most recent one to older ones. When this option is used you cannot specify commits to exclude (that is, <code>^commit</code>, <code>commit1..commit2</code>, and <code>commit1...commit2</code> notations cannot be used).</p> <p>With <code>--pretty</code> format other than <code>oneline</code> and <code>reference</code> (for obvious reasons), this causes the output to have two extra lines of information taken from the reflog. The reflog designator in the output may be shown as <code>ref@{Nth}</code> (where <code>Nth</code> is the reverse-chronological index in the reflog) or as <code>ref@{timestamp}</code> (with the timestamp for that entry), depending on a few rules:</p> <div class="openblock"> <div class="content"> <div class="olist arabic"> <ol class="arabic"> <li> <p>If the starting point is specified as <code>ref@{Nth}</code>, show the index format.</p> </li> <li> <p>If the starting point was specified as <code>ref@{now}</code>, show the timestamp format.</p> </li> <li> <p>If neither was used, but <code>--date</code> was given on the command line, show the timestamp in the format requested by <code>--date</code>.</p> </li> <li> <p>Otherwise, show the index format.</p> </li> </ol> </div> </div> </div> <p>Under <code>--pretty=oneline</code>, the commit message is prefixed with this information on the same line. This option cannot be combined with <code>--reverse</code>. See also <a href="git-reflog">git-reflog[1]</a>.</p> <p>Under <code>--pretty=reference</code>, this information will not be shown at all.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---merge"> --merge </dt> <dd> <p>After a failed merge, show refs that touch files having a conflict and don’t exist on all heads to merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---boundary"> --boundary </dt> <dd> <p>Output excluded boundary commits. Boundary commits are prefixed with <code>-</code>.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_history_simplification"> +History Simplification</h3> <p>Sometimes you are only interested in parts of the history, for example the commits modifying a particular <path>. But there are two parts of <code>History Simplification</code>, one part is selecting the commits and the other is how to do it, as there are various strategies to simplify the history.</p> <p>The following options select the commits to be shown:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-ltpathsgt"> <paths> </dt> <dd> <p>Commits modifying the given <paths> are selected.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---simplify-by-decoration"> --simplify-by-decoration </dt> <dd> <p>Commits that are referred by some branch or tag are selected.</p> </dd> </dl> </div> <p>Note that extra commits can be shown to give a meaningful history.</p> <p>The following options affect the way the simplification is performed:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-Defaultmode"> Default mode </dt> <dd> <p>Simplifies the history to the simplest history explaining the final state of the tree. Simplest because it prunes some side branches if the end result is the same (i.e. merging branches with the same content)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---show-pulls"> --show-pulls </dt> <dd> <p>Include all commits from the default mode, but also any merge commits that are not TREESAME to the first parent but are TREESAME to a later parent. This mode is helpful for showing the merge commits that "first introduced" a change to a branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---full-history"> --full-history </dt> <dd> <p>Same as the default mode, but does not prune some history.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---dense"> --dense </dt> <dd> <p>Only the selected commits are shown, plus some to have a meaningful history.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---sparse"> --sparse </dt> <dd> <p>All commits in the simplified history are shown.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---simplify-merges"> --simplify-merges </dt> <dd> <p>Additional option to <code>--full-history</code> to remove some needless merges from the resulting history, as there are no selected commits contributing to this merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---ancestry-pathltcommitgt"> --ancestry-path[=<commit>] </dt> <dd> <p>When given a range of commits to display (e.g. <code>commit1..commit2</code> or <code>commit2 ^commit1</code>), only display commits in that range that are ancestors of <commit>, descendants of <commit>, or <commit> itself. If no commit is specified, use <code>commit1</code> (the excluded part of the range) as <commit>. Can be passed multiple times; if so, a commit is included if it is any of the commits given or if it is an ancestor or descendant of one of them.</p> </dd> </dl> </div> <p>A more detailed explanation follows.</p> <p>Suppose you specified <code>foo</code> as the <paths>. We shall call commits that modify <code>foo</code> !TREESAME, and the rest TREESAME. (In a diff filtered for <code>foo</code>, they look different and equal, respectively.)</p> <p>In the following, we will always refer to the same example history to illustrate the differences between simplification settings. We assume that you are filtering for a file <code>foo</code> in this commit graph:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M---N---O---P---Q + / / / / / / + I B C D E Y + \ / / / / / + `-------------' X</pre> </div> </div> <p>The horizontal line of history A---Q is taken to be the first parent of each merge. The commits are:</p> <div class="ulist"> <ul> <li> <p><code>I</code> is the initial commit, in which <code>foo</code> exists with contents “asdf”, and a file <code>quux</code> exists with contents “quux”. Initial commits are compared to an empty tree, so <code>I</code> is !TREESAME.</p> </li> <li> <p>In <code>A</code>, <code>foo</code> contains just “foo”.</p> </li> <li> <p><code>B</code> contains the same change as <code>A</code>. Its merge <code>M</code> is trivial and hence TREESAME to all parents.</p> </li> <li> <p><code>C</code> does not change <code>foo</code>, but its merge <code>N</code> changes it to “foobar”, so it is not TREESAME to any parent.</p> </li> <li> <p><code>D</code> sets <code>foo</code> to “baz”. Its merge <code>O</code> combines the strings from <code>N</code> and <code>D</code> to “foobarbaz”; i.e., it is not TREESAME to any parent.</p> </li> <li> <p><code>E</code> changes <code>quux</code> to “xyzzy”, and its merge <code>P</code> combines the strings to “quux xyzzy”. <code>P</code> is TREESAME to <code>O</code>, but not to <code>E</code>.</p> </li> <li> <p><code>X</code> is an independent root commit that added a new file <code>side</code>, and <code>Y</code> modified it. <code>Y</code> is TREESAME to <code>X</code>. Its merge <code>Q</code> added <code>side</code> to <code>P</code>, and <code>Q</code> is TREESAME to <code>P</code>, but not to <code>Y</code>.</p> </li> </ul> </div> <p><code>rev-list</code> walks backwards through history, including or excluding commits based on whether <code>--full-history</code> and/or parent rewriting (via <code>--parents</code> or <code>--children</code>) are used. The following settings are available.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-Defaultmode-1"> Default mode </dt> <dd> <p>Commits are included if they are not TREESAME to any parent (though this can be changed, see <code>--sparse</code> below). If the commit was a merge, and it was TREESAME to one parent, follow only that parent. (Even if there are several TREESAME parents, follow only one of them.) Otherwise, follow all parents.</p> <p>This results in:</p> <div class="listingblock"> <div class="content"> <pre> .-A---N---O + / / / + I---------D</pre> </div> </div> <p>Note how the rule to only follow the TREESAME parent, if one is available, removed <code>B</code> from consideration entirely. <code>C</code> was considered via <code>N</code>, but is TREESAME. Root commits are compared to an empty tree, so <code>I</code> is !TREESAME.</p> <p>Parent/child relations are only visible with <code>--parents</code>, but that does not affect the commits selected in default mode, so we have shown the parent lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---full-historywithoutparentrewriting"> --full-history without parent rewriting </dt> <dd> <p>This mode differs from the default in one point: always follow all parents of a merge, even if it is TREESAME to one of them. Even if more than one side of the merge has commits that are included, this does not imply that the merge itself is! In the example, we get</p> <div class="listingblock"> <div class="content"> <pre> I A B N D O P Q</pre> </div> </div> <p><code>M</code> was excluded because it is TREESAME to both parents. <code>E</code>, <code>C</code> and <code>B</code> were all walked, but only <code>B</code> was !TREESAME, so the others do not appear.</p> <p>Note that without parent rewriting, it is not really possible to talk about the parent/child relationships between the commits, so we show them disconnected.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---full-historywithparentrewriting"> --full-history with parent rewriting </dt> <dd> <p>Ordinary commits are only included if they are !TREESAME (though this can be changed, see <code>--sparse</code> below).</p> <p>Merges are always included. However, their parent list is rewritten: Along each parent, prune away commits that are not included themselves. This results in</p> <div class="listingblock"> <div class="content"> <pre> .-A---M---N---O---P---Q + / / / / / + I B / D / + \ / / / / + `-------------'</pre> </div> </div> <p>Compare to <code>--full-history</code> without rewriting above. Note that <code>E</code> was pruned away because it is TREESAME, but the parent list of P was rewritten to contain <code>E</code>'s parent <code>I</code>. The same happened for <code>C</code> and <code>N</code>, and <code>X</code>, <code>Y</code> and <code>Q</code>.</p> </dd> </dl> </div> <p>In addition to the above settings, you can change whether TREESAME affects inclusion:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt---dense-1"> --dense </dt> <dd> <p>Commits that are walked are included if they are not TREESAME to any parent.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---sparse-1"> --sparse </dt> <dd> <p>All commits that are walked are included.</p> <p>Note that without <code>--full-history</code>, this still simplifies merges: if one of the parents is TREESAME, we follow only that one, so the other sides of the merge are never walked.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---simplify-merges-1"> --simplify-merges </dt> <dd> <p>First, build a history graph in the same way that <code>--full-history</code> with parent rewriting does (see above).</p> <p>Then simplify each commit <code>C</code> to its replacement <code>C'</code> in the final history according to the following rules:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>Set <code>C'</code> to <code>C</code>.</p> </li> <li> <p>Replace each parent <code>P</code> of <code>C'</code> with its simplification <code>P'</code>. In the process, drop parents that are ancestors of other parents or that are root commits TREESAME to an empty tree, and remove duplicates, but take care to never drop all parents that we are TREESAME to.</p> </li> <li> <p>If after this parent rewriting, <code>C'</code> is a root or merge commit (has zero or >1 parents), a boundary commit, or !TREESAME, it remains. Otherwise, it is replaced with its only parent.</p> </li> </ul> </div> </div> </div> <p>The effect of this is best shown by way of comparing to <code>--full-history</code> with parent rewriting. The example turns into:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M---N---O + / / / + I B D + \ / / + `---------'</pre> </div> </div> <p>Note the major differences in <code>N</code>, <code>P</code>, and <code>Q</code> over <code>--full-history</code>:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>N</code>'s parent list had <code>I</code> removed, because it is an ancestor of the other parent <code>M</code>. Still, <code>N</code> remained because it is !TREESAME.</p> </li> <li> <p><code>P</code>'s parent list similarly had <code>I</code> removed. <code>P</code> was then removed completely, because it had one parent and is TREESAME.</p> </li> <li> <p><code>Q</code>'s parent list had <code>Y</code> simplified to <code>X</code>. <code>X</code> was then removed, because it was a TREESAME root. <code>Q</code> was then removed completely, because it had one parent and is TREESAME.</p> </li> </ul> </div> </div> </div> </dd> </dl> </div> <p>There is another simplification mode available:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt---ancestry-pathltcommitgt-1"> --ancestry-path[=<commit>] </dt> <dd> <p>Limit the displayed commits to those which are an ancestor of <commit>, or which are a descendant of <commit>, or are <commit> itself.</p> <p>As an example use case, consider the following commit history:</p> <div class="listingblock"> <div class="content"> <pre> D---E-------F + / \ \ + B---C---G---H---I---J + / \ + A-------K---------------L--M</pre> </div> </div> <p>A regular <code>D..M</code> computes the set of commits that are ancestors of <code>M</code>, but excludes the ones that are ancestors of <code>D</code>. This is useful to see what happened to the history leading to <code>M</code> since <code>D</code>, in the sense that “what does <code>M</code> have that did not exist in <code>D</code>”. The result in this example would be all the commits, except <code>A</code> and <code>B</code> (and <code>D</code> itself, of course).</p> <p>When we want to find out what commits in <code>M</code> are contaminated with the bug introduced by <code>D</code> and need fixing, however, we might want to view only the subset of <code>D..M</code> that are actually descendants of <code>D</code>, i.e. excluding <code>C</code> and <code>K</code>. This is exactly what the <code>--ancestry-path</code> option does. Applied to the <code>D..M</code> range, it results in:</p> <div class="listingblock"> <div class="content"> <pre> E-------F + \ \ + G---H---I---J + \ + L--M</pre> </div> </div> <p>We can also use <code>--ancestry-path=D</code> instead of <code>--ancestry-path</code> which means the same thing when applied to the <code>D..M</code> range but is just more explicit.</p> <p>If we instead are interested in a given topic within this range, and all commits affected by that topic, we may only want to view the subset of <code>D..M</code> which contain that topic in their ancestry path. So, using <code>--ancestry-path=H D..M</code> for example would result in:</p> <div class="listingblock"> <div class="content"> <pre> E + \ + G---H---I---J + \ + L--M</pre> </div> </div> <p>Whereas <code>--ancestry-path=K D..M</code> would result in</p> <div class="listingblock"> <div class="content"> <pre> K---------------L--M</pre> </div> </div> </dd> </dl> </div> <p>Before discussing another option, <code>--show-pulls</code>, we need to create a new example history.</p> <p>A common problem users face when looking at simplified history is that a commit they know changed a file somehow does not appear in the file’s simplified history. Let’s demonstrate a new example and show how options such as <code>--full-history</code> and <code>--simplify-merges</code> works in that case:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M-----C--N---O---P + / / \ \ \/ / / + I B \ R-'`-Z' / + \ / \/ / + \ / /\ / + `---X--' `---Y--'</pre> </div> </div> <p>For this example, suppose <code>I</code> created <code>file.txt</code> which was modified by <code>A</code>, <code>B</code>, and <code>X</code> in different ways. The single-parent commits <code>C</code>, <code>Z</code>, and <code>Y</code> do not change <code>file.txt</code>. The merge commit <code>M</code> was created by resolving the merge conflict to include both changes from <code>A</code> and <code>B</code> and hence is not TREESAME to either. The merge commit <code>R</code>, however, was created by ignoring the contents of <code>file.txt</code> at <code>M</code> and taking only the contents of <code>file.txt</code> at <code>X</code>. Hence, <code>R</code> is TREESAME to <code>X</code> but not <code>M</code>. Finally, the natural merge resolution to create <code>N</code> is to take the contents of <code>file.txt</code> at <code>R</code>, so <code>N</code> is TREESAME to <code>R</code> but not <code>C</code>. The merge commits <code>O</code> and <code>P</code> are TREESAME to their first parents, but not to their second parents, <code>Z</code> and <code>Y</code> respectively.</p> <p>When using the default mode, <code>N</code> and <code>R</code> both have a TREESAME parent, so those edges are walked and the others are ignored. The resulting history graph is:</p> <div class="listingblock"> <div class="content"> <pre> I---X</pre> </div> </div> <p>When using <code>--full-history</code>, Git walks every edge. This will discover the commits <code>A</code> and <code>B</code> and the merge <code>M</code>, but also will reveal the merge commits <code>O</code> and <code>P</code>. With parent rewriting, the resulting graph is:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M--------N---O---P + / / \ \ \/ / / + I B \ R-'`--' / + \ / \/ / + \ / /\ / + `---X--' `------'</pre> </div> </div> <p>Here, the merge commits <code>O</code> and <code>P</code> contribute extra noise, as they did not actually contribute a change to <code>file.txt</code>. They only merged a topic that was based on an older version of <code>file.txt</code>. This is a common issue in repositories using a workflow where many contributors work in parallel and merge their topic branches along a single trunk: many unrelated merges appear in the <code>--full-history</code> results.</p> <p>When using the <code>--simplify-merges</code> option, the commits <code>O</code> and <code>P</code> disappear from the results. This is because the rewritten second parents of <code>O</code> and <code>P</code> are reachable from their first parents. Those edges are removed and then the commits look like single-parent commits that are TREESAME to their parent. This also happens to the commit <code>N</code>, resulting in a history view as follows:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M--. + / / \ + I B R + \ / / + \ / / + `---X--'</pre> </div> </div> <p>In this view, we see all of the important single-parent changes from <code>A</code>, <code>B</code>, and <code>X</code>. We also see the carefully-resolved merge <code>M</code> and the not-so-carefully-resolved merge <code>R</code>. This is usually enough information to determine why the commits <code>A</code> and <code>B</code> "disappeared" from history in the default view. However, there are a few issues with this approach.</p> <p>The first issue is performance. Unlike any previous option, the <code>--simplify-merges</code> option requires walking the entire commit history before returning a single result. This can make the option difficult to use for very large repositories.</p> <p>The second issue is one of auditing. When many contributors are working on the same repository, it is important which merge commits introduced a change into an important branch. The problematic merge <code>R</code> above is not likely to be the merge commit that was used to merge into an important branch. Instead, the merge <code>N</code> was used to merge <code>R</code> and <code>X</code> into the important branch. This commit may have information about why the change <code>X</code> came to override the changes from <code>A</code> and <code>B</code> in its commit message.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt---show-pulls-1"> --show-pulls </dt> <dd> <p>In addition to the commits shown in the default history, show each merge commit that is not TREESAME to its first parent but is TREESAME to a later parent.</p> <p>When a merge commit is included by <code>--show-pulls</code>, the merge is treated as if it "pulled" the change from another branch. When using <code>--show-pulls</code> on this example (and no other options) the resulting graph is:</p> <div class="listingblock"> <div class="content"> <pre> I---X---R---N</pre> </div> </div> <p>Here, the merge commits <code>R</code> and <code>N</code> are included because they pulled the commits <code>X</code> and <code>R</code> into the base branch, respectively. These merges are the reason the commits <code>A</code> and <code>B</code> do not appear in the default history.</p> <p>When <code>--show-pulls</code> is paired with <code>--simplify-merges</code>, the graph includes all of the necessary information:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M--. N + / / \ / + I B R + \ / / + \ / / + `---X--'</pre> </div> </div> <p>Notice that since <code>M</code> is reachable from <code>R</code>, the edge from <code>N</code> to <code>M</code> was simplified away. However, <code>N</code> still appears in the history as an important commit because it "pulled" the change <code>R</code> into the main branch.</p> </dd> </dl> </div> <p>The <code>--simplify-by-decoration</code> option allows you to view only the big picture of the topology of the history, by omitting commits that are not referenced by tags. Commits are marked as !TREESAME (in other words, kept after history simplification rules described above) if (1) they are referenced by tags, or (2) they change the contents of the paths given on the command line. All other commits are marked as TREESAME (subject to be simplified away).</p> </div> <div class="sect2"> <h3 id="_commit_ordering"> +Commit Ordering</h3> <p>By default, the commits are shown in reverse chronological order.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt---date-order"> --date-order </dt> <dd> <p>Show no parents before all of its children are shown, but otherwise show commits in the commit timestamp order.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---author-date-order"> --author-date-order </dt> <dd> <p>Show no parents before all of its children are shown, but otherwise show commits in the author timestamp order.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---topo-order"> --topo-order </dt> <dd> <p>Show no parents before all of its children are shown, and avoid showing commits on multiple lines of history intermixed.</p> <p>For example, in a commit history like this:</p> <div class="listingblock"> <div class="content"> <pre> ---1----2----4----7 + \ \ + 3----5----6----8---</pre> </div> </div> <p>where the numbers denote the order of commit timestamps, <code>git +rev-list</code> and friends with <code>--date-order</code> show the commits in the timestamp order: 8 7 6 5 4 3 2 1.</p> <p>With <code>--topo-order</code>, they would show 8 6 5 3 7 4 2 1 (or 8 7 4 2 6 5 3 1); some older commits are shown before newer ones in order to avoid showing the commits from two parallel development track mixed together.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---reverse"> --reverse </dt> <dd> <p>Output the commits chosen to be shown (see Commit Limiting section above) in reverse order. Cannot be combined with <code>--walk-reflogs</code>.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_object_traversal"> +Object Traversal</h3> <p>These options are mostly targeted for packing of Git repositories.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt---no-walksortedunsorted"> --no-walk[=(sorted|unsorted)] </dt> <dd> <p>Only show the given commits, but do not traverse their ancestors. This has no effect if a range is specified. If the argument <code>unsorted</code> is given, the commits are shown in the order they were given on the command line. Otherwise (if <code>sorted</code> or no argument was given), the commits are shown in reverse chronological order by commit time. Cannot be combined with <code>--graph</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---do-walk"> --do-walk </dt> <dd> <p>Overrides a previous <code>--no-walk</code>.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_commit_formatting"> +Commit Formatting</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt---prettyltformatgt"> --pretty[=<format>] </dt> <dt class="hdlist1" id="Documentation/git-log.txt---formatltformatgt"> --format=<format> </dt> <dd> <p>Pretty-print the contents of the commit logs in a given format, where <code><format></code> can be one of <code>oneline</code>, <code>short</code>, <code>medium</code>, <code>full</code>, <code>fuller</code>, <code>reference</code>, <code>email</code>, <code>raw</code>, <code>format:<string></code> and <code>tformat:<string></code>. When <code><format></code> is none of the above, and has <code>%placeholder</code> in it, it acts as if <code>--pretty=tformat:<format></code> were given.</p> <p>See the "PRETTY FORMATS" section for some additional details for each format. When <code>=<format></code> part is omitted, it defaults to <code>medium</code>.</p> <p>Note: you can specify the default pretty format in the repository configuration (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---abbrev-commit"> --abbrev-commit </dt> <dd> <p>Instead of showing the full 40-byte hexadecimal commit object name, show a prefix that names the object uniquely. "--abbrev=<n>" (which also modifies diff output, if it is displayed) option can be used to specify the minimum length of the prefix.</p> <p>This should make "--pretty=oneline" a whole lot more readable for people using 80-column terminals.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---no-abbrev-commit"> --no-abbrev-commit </dt> <dd> <p>Show the full 40-byte hexadecimal commit object name. This negates <code>--abbrev-commit</code>, either explicit or implied by other options such as "--oneline". It also overrides the <code>log.abbrevCommit</code> variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---oneline"> --oneline </dt> <dd> <p>This is a shorthand for "--pretty=oneline --abbrev-commit" used together.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---encodingltencodinggt"> --encoding=<encoding> </dt> <dd> <p>Commit objects record the character encoding used for the log message in their encoding header; this option can be used to tell the command to re-code the commit log message in the encoding preferred by the user. For non plumbing commands this defaults to UTF-8. Note that if an object claims to be encoded in <code>X</code> and we are outputting in <code>X</code>, we will output the object verbatim; this means that invalid sequences in the original commit may be copied to the output. Likewise, if iconv(3) fails to convert the commit, we will quietly output the original object verbatim.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---expand-tabsltngt"> --expand-tabs=<n> </dt> <dt class="hdlist1" id="Documentation/git-log.txt---expand-tabs"> --expand-tabs </dt> <dt class="hdlist1" id="Documentation/git-log.txt---no-expand-tabs"> --no-expand-tabs </dt> <dd> <p>Perform a tab expansion (replace each tab with enough spaces to fill to the next display column that is a multiple of <code><n></code>) in the log message before showing it in the output. <code>--expand-tabs</code> is a short-hand for <code>--expand-tabs=8</code>, and <code>--no-expand-tabs</code> is a short-hand for <code>--expand-tabs=0</code>, which disables tab expansion.</p> <p>By default, tabs are expanded in pretty formats that indent the log message by 4 spaces (i.e. <code>medium</code>, which is the default, <code>full</code>, and <code>fuller</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---notesltrefgt"> --notes[=<ref>] </dt> <dd> <p>Show the notes (see <a href="git-notes">git-notes[1]</a>) that annotate the commit, when showing the commit log message. This is the default for <code>git log</code>, <code>git show</code> and <code>git whatchanged</code> commands when there is no <code>--pretty</code>, <code>--format</code>, or <code>--oneline</code> option given on the command line.</p> <p>By default, the notes shown are from the notes refs listed in the <code>core.notesRef</code> and <code>notes.displayRef</code> variables (or corresponding environment overrides). See <a href="git-config">git-config[1]</a> for more details.</p> <p>With an optional <code><ref></code> argument, use the ref to find the notes to display. The ref can specify the full refname when it begins with <code>refs/notes/</code>; when it begins with <code>notes/</code>, <code>refs/</code> and otherwise <code>refs/notes/</code> is prefixed to form the full name of the ref.</p> <p>Multiple --notes options can be combined to control which notes are being displayed. Examples: "--notes=foo" will show only notes from "refs/notes/foo"; "--notes=foo --notes" will show both notes from "refs/notes/foo" and from the default notes ref(s).</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---no-notes"> --no-notes </dt> <dd> <p>Do not show notes. This negates the above <code>--notes</code> option, by resetting the list of notes refs from which notes are shown. Options are parsed in the order given on the command line, so e.g. "--notes --notes=foo --no-notes --notes=bar" will only show notes from "refs/notes/bar".</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---show-notes-by-default"> --show-notes-by-default </dt> <dd> <p>Show the default notes unless options for displaying specific notes are given.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---show-notesltrefgt"> --show-notes[=<ref>] </dt> <dt class="hdlist1" id="Documentation/git-log.txt---no-standard-notes"> --[no-]standard-notes </dt> <dd> <p>These options are deprecated. Use the above --notes/--no-notes options instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---show-signature"> --show-signature </dt> <dd> <p>Check the validity of a signed commit object by passing the signature to <code>gpg --verify</code> and show the output.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---relative-date"> --relative-date </dt> <dd> <p>Synonym for <code>--date=relative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---dateltformatgt"> --date=<format> </dt> <dd> <p>Only takes effect for dates shown in human-readable format, such as when using <code>--pretty</code>. <code>log.date</code> config variable sets a default value for the log command’s <code>--date</code> option. By default, dates are shown in the original time zone (either committer’s or author’s). If <code>-local</code> is appended to the format (e.g., <code>iso-local</code>), the user’s local time zone is used instead.</p> <div class="openblock"> <div class="content"> <p><code>--date=relative</code> shows dates relative to the current time, e.g. “2 hours ago”. The <code>-local</code> option has no effect for <code>--date=relative</code>.</p> <p><code>--date=local</code> is an alias for <code>--date=default-local</code>.</p> <p><code>--date=iso</code> (or <code>--date=iso8601</code>) shows timestamps in a ISO 8601-like format. The differences to the strict ISO 8601 format are:</p> <div class="ulist"> <ul> <li> <p>a space instead of the <code>T</code> date/time delimiter</p> </li> <li> <p>a space between time and time zone</p> </li> <li> <p>no colon between hours and minutes of the time zone</p> </li> </ul> </div> <p><code>--date=iso-strict</code> (or <code>--date=iso8601-strict</code>) shows timestamps in strict ISO 8601 format.</p> <p><code>--date=rfc</code> (or <code>--date=rfc2822</code>) shows timestamps in RFC 2822 format, often found in email messages.</p> <p><code>--date=short</code> shows only the date, but not the time, in <code>YYYY-MM-DD</code> format.</p> <p><code>--date=raw</code> shows the date as seconds since the epoch (1970-01-01 00:00:00 UTC), followed by a space, and then the timezone as an offset from UTC (a <code>+</code> or <code>-</code> with four digits; the first two are hours, and the second two are minutes). I.e., as if the timestamp were formatted with <code>strftime("%s %z")</code>). Note that the <code>-local</code> option does not affect the seconds-since-epoch value (which is always measured in UTC), but does switch the accompanying timezone value.</p> <p><code>--date=human</code> shows the timezone if the timezone does not match the current time-zone, and doesn’t print the whole date if that matches (ie skip printing year for dates that are "this year", but also skip the whole date itself if it’s in the last few days and we can just say what weekday it was). For older dates the hour and minute is also omitted.</p> <p><code>--date=unix</code> shows the date as a Unix epoch timestamp (seconds since 1970). As with <code>--raw</code>, this is always in UTC and therefore <code>-local</code> has no effect.</p> <p><code>--date=format:...</code> feeds the format <code>...</code> to your system <code>strftime</code>, except for %s, %z, and %Z, which are handled internally. Use <code>--date=format:%c</code> to show the date in your system locale’s preferred format. See the <code>strftime</code> manual for a complete list of format placeholders. When using <code>-local</code>, the correct syntax is <code>--date=format-local:...</code>.</p> <p><code>--date=default</code> is the default format, and is based on ctime(3) output. It shows a single line with three-letter day of the week, three-letter month, day-of-month, hour-minute-seconds in "HH:MM:SS" format, followed by 4-digit year, plus timezone information, unless the local time zone is used, e.g. <code>Thu Jan 1 00:00:00 1970 +0000</code>.</p> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---parents"> --parents </dt> <dd> <p>Print also the parents of the commit (in the form "commit parent…"). Also enables parent rewriting, see <code>History Simplification</code> above.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---children"> --children </dt> <dd> <p>Print also the children of the commit (in the form "commit child…"). Also enables parent rewriting, see <code>History Simplification</code> above.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---left-right"> --left-right </dt> <dd> <p>Mark which side of a symmetric difference a commit is reachable from. Commits from the left side are prefixed with <code><</code> and those from the right with <code>></code>. If combined with <code>--boundary</code>, those commits are prefixed with <code>-</code>.</p> <p>For example, if you have this topology:</p> <div class="listingblock"> <div class="content"> <pre> y---b---b branch B + / \ / + / . + / / \ + o---x---a---a branch A</pre> </div> </div> <p>you would get an output like this:</p> <div class="listingblock"> <div class="content"> <pre> $ git rev-list --left-right --boundary --pretty=oneline A...B + + >bbbbbbb... 3rd on b + >bbbbbbb... 2nd on b + <aaaaaaa... 3rd on a + <aaaaaaa... 2nd on a + -yyyyyyy... 1st on b + -xxxxxxx... 1st on a</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---graph"> --graph </dt> <dd> <p>Draw a text-based graphical representation of the commit history on the left hand side of the output. This may cause extra lines to be printed in between commits, in order for the graph history to be drawn properly. Cannot be combined with <code>--no-walk</code>.</p> <p>This enables parent rewriting, see <code>History Simplification</code> above.</p> <p>This implies the <code>--topo-order</code> option by default, but the <code>--date-order</code> option may also be specified.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---show-linear-breakltbarriergt"> --show-linear-break[=<barrier>] </dt> <dd> <p>When --graph is not used, all history branches are flattened which can make it hard to see that the two consecutive commits do not belong to a linear branch. This option puts a barrier in between them in that case. If <code><barrier></code> is specified, it is the string that will be shown instead of the default one.</p> </dd> </dl> </div> </div> </div> <h2 id="_pretty_formats">Pretty formats</h2> <div class="sectionbody"> <p>If the commit is a merge, and if the pretty-format is not <code>oneline</code>, <code>email</code> or <code>raw</code>, an additional line is inserted before the <code>Author:</code> line. This line begins with "Merge: " and the hashes of ancestral commits are printed, separated by spaces. Note that the listed commits may not necessarily be the list of the <strong>direct</strong> parent commits if you have limited your view of history: for example, if you are only interested in changes related to a certain directory or file.</p> <p>There are several built-in formats, and you can define additional formats by setting a pretty.<name> config option to either another format name, or a <code>format:</code> string, as described below (see <a href="git-config">git-config[1]</a>). Here are the details of the built-in formats:</p> <div class="ulist"> <ul> <li> <p><code>oneline</code></p> <div class="literalblock"> <div class="content"> <pre><hash> <title-line></pre> </div> </div> <p>This is designed to be as compact as possible.</p> </li> <li> <p><code>short</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> </li> <li> <p><code>medium</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author> +Date: <author-date></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>full</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author> +Commit: <committer></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>fuller</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author> +AuthorDate: <author-date> +Commit: <committer> +CommitDate: <committer-date></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>reference</code></p> <div class="literalblock"> <div class="content"> <pre><abbrev-hash> (<title-line>, <short-author-date>)</pre> </div> </div> <p>This format is used to refer to another commit in a commit message and is the same as <code>--pretty='format:%C(auto)%h (%s, %ad)'</code>. By default, the date is formatted with <code>--date=short</code> unless another <code>--date</code> option is explicitly specified. As with any <code>format:</code> with format placeholders, its output is not affected by other options like <code>--decorate</code> and <code>--walk-reflogs</code>.</p> </li> <li> <p><code>email</code></p> <div class="literalblock"> <div class="content"> <pre>From <hash> <date> +From: <author> +Date: <author-date> +Subject: [PATCH] <title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>mboxrd</code></p> <p>Like <code>email</code>, but lines in the commit message starting with "From " (preceded by zero or more ">") are quoted with ">" so they aren’t confused as starting a new commit.</p> </li> <li> <p><code>raw</code></p> <p>The <code>raw</code> format shows the entire commit exactly as stored in the commit object. Notably, the hashes are displayed in full, regardless of whether --abbrev or --no-abbrev are used, and <code>parents</code> information show the true parent commits, without taking grafts or history simplification into account. Note that this format affects the way commits are displayed, but not the way the diff is shown e.g. with <code>git log --raw</code>. To get full object names in a raw diff format, use <code>--no-abbrev</code>.</p> </li> <li> <p><code>format:<format-string></code></p> <p>The <code>format:<format-string></code> format allows you to specify which information you want to show. It works a little bit like printf format, with the notable exception that you get a newline with <code>%n</code> instead of <code>\n</code>.</p> <p>E.g, <code>format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"</code> would show something like this:</p> <div class="listingblock"> <div class="content"> <pre>The author of fe6e0ee was Junio C Hamano, 23 hours ago +The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<</pre> </div> </div> <p>The placeholders are:</p> <div class="ulist"> <ul> <li> <p>Placeholders that expand to a single literal character:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-emnem"> <em>%n</em> </dt> <dd> <p>newline</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emem"> <em>%%</em> </dt> <dd> <p>a raw <code>%</code></p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emx00em"> <em>%x00</em> </dt> <dd> <p><code>%x</code> followed by two hexadecimal digits is replaced with a byte with the hexadecimal digits' value (we will call this "literal formatting code" in the rest of this document).</p> </dd> </dl> </div> </li> <li> <p>Placeholders that affect formatting of later placeholders:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-emCredem"> <em>%Cred</em> </dt> <dd> <p>switch color to red</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emCgreenem"> <em>%Cgreen</em> </dt> <dd> <p>switch color to green</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emCblueem"> <em>%Cblue</em> </dt> <dd> <p>switch color to blue</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emCresetem"> <em>%Creset</em> </dt> <dd> <p>reset color</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emC82308203em"> <em>%C(…)</em> </dt> <dd> <p>color specification, as described under Values in the "CONFIGURATION FILE" section of <a href="git-config">git-config[1]</a>. By default, colors are shown only when enabled for log output (by <code>color.diff</code>, <code>color.ui</code>, or <code>--color</code>, and respecting the <code>auto</code> settings of the former if we are going to a terminal). <code>%C(auto,...)</code> is accepted as a historical synonym for the default (e.g., <code>%C(auto,red)</code>). Specifying <code>%C(always,...)</code> will show the colors even when color is not otherwise enabled (though consider just using <code>--color=always</code> to enable color for the whole output, including this format and anything else git might color). <code>auto</code> alone (i.e. <code>%C(auto)</code>) will turn on auto coloring on the next placeholders until the color is switched again.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emmem"> <em>%m</em> </dt> <dd> <p>left (<code><</code>), right (<code>></code>) or boundary (<code>-</code>) mark</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emwltwgtlti1gtlti2gtem"> <em>%w([<w>[,<i1>[,<i2>]]])</em> </dt> <dd> <p>switch line wrapping, like the -w option of <a href="git-shortlog">git-shortlog[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emltltNgttruncltruncmtruncem"> <em>%<( <N> [,trunc|ltrunc|mtrunc])</em> </dt> <dd> <p>make the next placeholder take at least N column widths, padding spaces on the right if necessary. Optionally truncate (with ellipsis <code>..</code>) at the left (ltrunc) <code>..ft</code>, the middle (mtrunc) <code>mi..le</code>, or the end (trunc) <code>rig..</code>, if the output is longer than N columns. Note 1: that truncating only works correctly with N >= 2. Note 2: spaces around the N and M (see below) values are optional. Note 3: Emojis and other wide characters will take two display columns, which may over-run column boundaries. Note 4: decomposed character combining marks may be misplaced at padding boundaries.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emltltMgtem"> <em>%<|( <M> )</em> </dt> <dd> <p>make the next placeholder take at least until Mth display column, padding spaces on the right if necessary. Use negative M values for column positions measured from the right hand edge of the terminal window.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emgtltNgtememgtltMgtem"> <em>%>( <N> )</em>, <em>%>|( <M> )</em> </dt> <dd> <p>similar to <code>%<( <N> )</code>, <code>%<|( <M> )</code> respectively, but padding spaces on the left</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emgtgtltNgtememgtgtltMgtem"> <em>%>>( <N> )</em>, <em>%>>|( <M> )</em> </dt> <dd> <p>similar to <code>%>( <N> )</code>, <code>%>|( <M> )</code> respectively, except that if the next placeholder takes more spaces than given and there are spaces on its left, use those spaces</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emgtltltNgtememgtltltMgtem"> <em>%><( <N> )</em>, <em>%><|( <M> )</em> </dt> <dd> <p>similar to <code>%<( <N> )</code>, <code>%<|( <M> )</code> respectively, but padding both sides (i.e. the text is centered)</p> </dd> </dl> </div> </li> <li> <p>Placeholders that expand to information extracted from the commit:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-emHem"> <em>%H</em> </dt> <dd> <p>commit hash</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emhem"> <em>%h</em> </dt> <dd> <p>abbreviated commit hash</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emTem"> <em>%T</em> </dt> <dd> <p>tree hash</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emtem"> <em>%t</em> </dt> <dd> <p>abbreviated tree hash</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emPem"> <em>%P</em> </dt> <dd> <p>parent hashes</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-empem"> <em>%p</em> </dt> <dd> <p>abbreviated parent hashes</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emanem"> <em>%an</em> </dt> <dd> <p>author name</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emaNem"> <em>%aN</em> </dt> <dd> <p>author name (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emaeem"> <em>%ae</em> </dt> <dd> <p>author email</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emaEem"> <em>%aE</em> </dt> <dd> <p>author email (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emalem"> <em>%al</em> </dt> <dd> <p>author email local-part (the part before the <code>@</code> sign)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emaLem"> <em>%aL</em> </dt> <dd> <p>author local-part (see <code>%al</code>) respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emadem"> <em>%ad</em> </dt> <dd> <p>author date (format respects --date= option)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emaDem"> <em>%aD</em> </dt> <dd> <p>author date, RFC2822 style</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emarem"> <em>%ar</em> </dt> <dd> <p>author date, relative</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-ematem"> <em>%at</em> </dt> <dd> <p>author date, UNIX timestamp</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emaiem"> <em>%ai</em> </dt> <dd> <p>author date, ISO 8601-like format</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emaIem"> <em>%aI</em> </dt> <dd> <p>author date, strict ISO 8601 format</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emasem"> <em>%as</em> </dt> <dd> <p>author date, short format (<code>YYYY-MM-DD</code>)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emahem"> <em>%ah</em> </dt> <dd> <p>author date, human style (like the <code>--date=human</code> option of <a href="git-rev-list">git-rev-list[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emcnem"> <em>%cn</em> </dt> <dd> <p>committer name</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emcNem"> <em>%cN</em> </dt> <dd> <p>committer name (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emceem"> <em>%ce</em> </dt> <dd> <p>committer email</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emcEem"> <em>%cE</em> </dt> <dd> <p>committer email (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emclem"> <em>%cl</em> </dt> <dd> <p>committer email local-part (the part before the <code>@</code> sign)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emcLem"> <em>%cL</em> </dt> <dd> <p>committer local-part (see <code>%cl</code>) respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emcdem"> <em>%cd</em> </dt> <dd> <p>committer date (format respects --date= option)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emcDem"> <em>%cD</em> </dt> <dd> <p>committer date, RFC2822 style</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emcrem"> <em>%cr</em> </dt> <dd> <p>committer date, relative</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emctem"> <em>%ct</em> </dt> <dd> <p>committer date, UNIX timestamp</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emciem"> <em>%ci</em> </dt> <dd> <p>committer date, ISO 8601-like format</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emcIem"> <em>%cI</em> </dt> <dd> <p>committer date, strict ISO 8601 format</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emcsem"> <em>%cs</em> </dt> <dd> <p>committer date, short format (<code>YYYY-MM-DD</code>)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emchem"> <em>%ch</em> </dt> <dd> <p>committer date, human style (like the <code>--date=human</code> option of <a href="git-rev-list">git-rev-list[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emdem"> <em>%d</em> </dt> <dd> <p>ref names, like the --decorate option of <a href="git-log">git-log[1]</a></p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emDem"> <em>%D</em> </dt> <dd> <p>ref names without the " (", ")" wrapping.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emdecorateltoptionsgtem"> <em>%(decorate[:<options>])</em> </dt> <dd> <p>ref names with custom decorations. The <code>decorate</code> string may be followed by a colon and zero or more comma-separated options. Option values may contain literal formatting codes. These must be used for commas (<code>%x2C</code>) and closing parentheses (<code>%x29</code>), due to their role in the option syntax.</p> <div class="ulist"> <ul> <li> <p><code>prefix=<value></code>: Shown before the list of ref names. Defaults to " <code>(</code>".</p> </li> <li> <p><code>suffix=<value></code>: Shown after the list of ref names. Defaults to "<code>)</code>".</p> </li> <li> <p><code>separator=<value></code>: Shown between ref names. Defaults to "<code>,</code> ".</p> </li> <li> <p><code>pointer=<value></code>: Shown between HEAD and the branch it points to, if any. Defaults to " <code>-></code> ".</p> </li> <li> <p><code>tag=<value></code>: Shown before tag names. Defaults to "<code>tag:</code> ".</p> </li> </ul> </div> </dd> </dl> </div> </li> </ul> </div> <p>For example, to produce decorations with no wrapping or tag annotations, and spaces as separators:</p> <p>+ <code>%(decorate:prefix=,suffix=,tag=,separator= )</code></p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-emdescribeltoptionsgtem"> <em>%(describe[:<options>])</em> </dt> <dd> <p>human-readable name, like <a href="git-describe">git-describe[1]</a>; empty string for undescribable commits. The <code>describe</code> string may be followed by a colon and zero or more comma-separated options. Descriptions can be inconsistent when tags are added or removed at the same time.</p> <div class="ulist"> <ul> <li> <p><code>tags[=<bool-value>]</code>: Instead of only considering annotated tags, consider lightweight tags as well.</p> </li> <li> <p><code>abbrev=<number></code>: Instead of using the default number of hexadecimal digits (which will vary according to the number of objects in the repository with a default of 7) of the abbreviated object name, use <number> digits, or as many digits as needed to form a unique object name.</p> </li> <li> <p><code>match=<pattern></code>: Only consider tags matching the given <code>glob(7)</code> pattern, excluding the "refs/tags/" prefix.</p> </li> <li> <p><code>exclude=<pattern></code>: Do not consider tags matching the given <code>glob(7)</code> pattern, excluding the "refs/tags/" prefix.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emSem"> <em>%S</em> </dt> <dd> <p>ref name given on the command line by which the commit was reached (like <code>git log --source</code>), only works with <code>git log</code></p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emeem"> <em>%e</em> </dt> <dd> <p>encoding</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emsem"> <em>%s</em> </dt> <dd> <p>subject</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emfem"> <em>%f</em> </dt> <dd> <p>sanitized subject line, suitable for a filename</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-embem"> <em>%b</em> </dt> <dd> <p>body</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emBem"> <em>%B</em> </dt> <dd> <p>raw body (unwrapped subject and body)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emNem"> <em>%N</em> </dt> <dd> <p>commit notes</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emGGem"> <em>%GG</em> </dt> <dd> <p>raw verification message from GPG for a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emGem"> <em>%G?</em> </dt> <dd> <p>show "G" for a good (valid) signature, "B" for a bad signature, "U" for a good signature with unknown validity, "X" for a good signature that has expired, "Y" for a good signature made by an expired key, "R" for a good signature made by a revoked key, "E" if the signature cannot be checked (e.g. missing key) and "N" for no signature</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emGSem"> <em>%GS</em> </dt> <dd> <p>show the name of the signer for a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emGKem"> <em>%GK</em> </dt> <dd> <p>show the key used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emGFem"> <em>%GF</em> </dt> <dd> <p>show the fingerprint of the key used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emGPem"> <em>%GP</em> </dt> <dd> <p>show the fingerprint of the primary key whose subkey was used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emGTem"> <em>%GT</em> </dt> <dd> <p>show the trust level for the key used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emgDem"> <em>%gD</em> </dt> <dd> <p>reflog selector, e.g., <code>refs/stash@{1}</code> or <code>refs/stash@{2 +minutes ago}</code>; the format follows the rules described for the <code>-g</code> option. The portion before the <code>@</code> is the refname as given on the command line (so <code>git log -g refs/heads/master</code> would yield <code>refs/heads/master@{0}</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emgdem"> <em>%gd</em> </dt> <dd> <p>shortened reflog selector; same as <code>%gD</code>, but the refname portion is shortened for human readability (so <code>refs/heads/master</code> becomes just <code>master</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emgnem"> <em>%gn</em> </dt> <dd> <p>reflog identity name</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emgNem"> <em>%gN</em> </dt> <dd> <p>reflog identity name (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emgeem"> <em>%ge</em> </dt> <dd> <p>reflog identity email</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emgEem"> <em>%gE</em> </dt> <dd> <p>reflog identity email (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emgsem"> <em>%gs</em> </dt> <dd> <p>reflog subject</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-emtrailersltoptionsgtem"> <em>%(trailers[:<options>])</em> </dt> <dd> <p>display the trailers of the body as interpreted by <a href="git-interpret-trailers">git-interpret-trailers[1]</a>. The <code>trailers</code> string may be followed by a colon and zero or more comma-separated options. If any option is provided multiple times, the last occurrence wins.</p> <div class="ulist"> <ul> <li> <p><code>key=<key></code>: only show trailers with specified <key>. Matching is done case-insensitively and trailing colon is optional. If option is given multiple times trailer lines matching any of the keys are shown. This option automatically enables the <code>only</code> option so that non-trailer lines in the trailer block are hidden. If that is not desired it can be disabled with <code>only=false</code>. E.g., <code>%(trailers:key=Reviewed-by)</code> shows trailer lines with key <code>Reviewed-by</code>.</p> </li> <li> <p><code>only[=<bool>]</code>: select whether non-trailer lines from the trailer block should be included.</p> </li> <li> <p><code>separator=<sep></code>: specify a separator inserted between trailer lines. When this option is not given each trailer line is terminated with a line feed character. The string <sep> may contain the literal formatting codes described above. To use comma as separator one must use <code>%x2C</code> as it would otherwise be parsed as next option. E.g., <code>%(trailers:key=Ticket,separator=%x2C )</code> shows all trailer lines whose key is "Ticket" separated by a comma and a space.</p> </li> <li> <p><code>unfold[=<bool>]</code>: make it behave as if interpret-trailer’s <code>--unfold</code> option was given. E.g., <code>%(trailers:only,unfold=true)</code> unfolds and shows all trailer lines.</p> </li> <li> <p><code>keyonly[=<bool>]</code>: only show the key part of the trailer.</p> </li> <li> <p><code>valueonly[=<bool>]</code>: only show the value part of the trailer.</p> </li> <li> <p><code>key_value_separator=<sep></code>: specify a separator inserted between trailer lines. When this option is not given each trailer key-value pair is separated by ": ". Otherwise it shares the same semantics as <code>separator=<sep></code> above.</p> </li> </ul> </div> </dd> </dl> </div> </li> </ul> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> Some placeholders may depend on other options given to the revision traversal engine. For example, the <code>%g*</code> reflog options will insert an empty string unless we are traversing reflog entries (e.g., by <code>git log -g</code>). The <code>%d</code> and <code>%D</code> placeholders will use the "short" decoration format if <code>--decorate</code> was not already provided on the command line. </td> </tr> </table> </div> <p>The boolean options accept an optional value <code>[=<bool-value>]</code>. The values <code>true</code>, <code>false</code>, <code>on</code>, <code>off</code> etc. are all accepted. See the "boolean" sub-section in "EXAMPLES" in <a href="git-config">git-config[1]</a>. If a boolean option is given with no value, it’s enabled.</p> <p>If you add a <code>+</code> (plus sign) after <code>%</code> of a placeholder, a line-feed is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.</p> <p>If you add a <code>-</code> (minus sign) after <code>%</code> of a placeholder, all consecutive line-feeds immediately preceding the expansion are deleted if and only if the placeholder expands to an empty string.</p> <p>If you add a ` ` (space) after <code>%</code> of a placeholder, a space is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.</p> <div class="ulist"> <ul> <li> <p><code>tformat:</code></p> <p>The <code>tformat:</code> format works exactly like <code>format:</code>, except that it provides "terminator" semantics instead of "separator" semantics. In other words, each commit has the message terminator character (usually a newline) appended, rather than a separator placed between entries. This means that the final entry of a single-line format will be properly terminated with a new line, just as the "oneline" format does. For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log -2 --pretty=format:%h 4da45bef \ + | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/' +4da45be +7134973 -- NO NEWLINE + +$ git log -2 --pretty=tformat:%h 4da45bef \ + | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/' +4da45be +7134973</pre> </div> </div> <p>In addition, any unrecognized string that has a <code>%</code> in it is interpreted as if it has <code>tformat:</code> in front of it. For example, these two are equivalent:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log -2 --pretty=tformat:%h 4da45bef +$ git log -2 --pretty=%h 4da45bef</pre> </div> </div> </li> </ul> </div> </div> <h2 id="_diff_formatting">Diff formatting</h2> <div class="sectionbody"> <p>By default, <code>git log</code> does not generate any diff output. The options below can be used to show the changes made by each commit.</p> <p>Note that unless one of <code>--diff-merges</code> variants (including short <code>-m</code>, <code>-c</code>, <code>--cc</code>, and <code>--dd</code> options) is explicitly given, merge commits will not show a diff, even if a diff format like <code>--patch</code> is selected, nor will they match search options like <code>-S</code>. The exception is when <code>--first-parent</code> is in use, in which case <code>first-parent</code> is the default format for merge commits.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-log.txt--u"> -u </dt> <dt class="hdlist1" id="Documentation/git-log.txt---patch"> --patch </dt> <dd> <p>Generate patch (see <a href="#generate_patch_text_with_p">Generating patch text with -p</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-log.txt---no-patch"> --no-patch </dt> <dd> <p>Suppress all output from the diff machinery. Useful for commands like <code>git show</code> that show the patch by default to squelch their output, or to cancel the effect of options like <code>--patch</code>, <code>--stat</code> earlier on the command line in an alias.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--m"> -m </dt> <dd> <p>Show diffs for merge commits in the default format. This is similar to <code>--diff-merges=on</code>, except <code>-m</code> will produce no output unless <code>-p</code> is given as well.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--c"> -c </dt> <dd> <p>Produce combined diff output for merge commits. Shortcut for <code>--diff-merges=combined -p</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---cc"> --cc </dt> <dd> <p>Produce dense combined diff output for merge commits. Shortcut for <code>--diff-merges=dense-combined -p</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---dd"> --dd </dt> <dd> <p>Produce diff with respect to first parent for both merge and regular commits. Shortcut for <code>--diff-merges=first-parent -p</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---remerge-diff"> --remerge-diff </dt> <dd> <p>Produce remerge-diff output for merge commits. Shortcut for <code>--diff-merges=remerge -p</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---no-diff-merges"> --no-diff-merges </dt> <dd> <p>Synonym for <code>--diff-merges=off</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---diff-mergesltformatgt"> --diff-merges=<format> </dt> <dd> <p>Specify diff format to be used for merge commits. Default is `off` unless <code>--first-parent</code> is in use, in which case <code>first-parent</code> is the default.</p> <p>The following formats are supported:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-offnone"> off, none </dt> <dd> <p>Disable output of diffs for merge commits. Useful to override implied value.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-onm"> on, m </dt> <dd> <p>Make diff output for merge commits to be shown in the default format. The default format can be changed using <code>log.diffMerges</code> configuration variable, whose default value is <code>separate</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-first-parent1"> first-parent, 1 </dt> <dd> <p>Show full diff with respect to first parent. This is the same format as <code>--patch</code> produces for non-merge commits.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-separate"> separate </dt> <dd> <p>Show full diff with respect to each of parents. Separate log entry and diff is generated for each parent.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-combinedc"> combined, c </dt> <dd> <p>Show differences from each of the parents to the merge result simultaneously instead of showing pairwise diff between a parent and the result one at a time. Furthermore, it lists only files which were modified from all parents.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-dense-combinedcc"> dense-combined, cc </dt> <dd> <p>Further compress output produced by <code>--diff-merges=combined</code> by omitting uninteresting hunks whose contents in the parents have only two variants and the merge result picks one of them without modification.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-remerger"> remerge, r </dt> <dd> <p>Remerge two-parent merge commits to create a temporary tree object—potentially containing files with conflict markers and such. A diff is then shown between that temporary tree and the actual merge commit.</p> <p>The output emitted when this option is used is subject to change, and so is its interaction with other options (unless explicitly documented).</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---combined-all-paths"> --combined-all-paths </dt> <dd> <p>This flag causes combined diffs (used for merge commits) to list the name of the file from all parents. It thus only has effect when <code>--diff-merges=[dense-]combined</code> is in use, and is likely only useful if filename changes are detected (i.e. when either rename or copy detection have been requested).</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--Ultngt"> -U<n> </dt> <dt class="hdlist1" id="Documentation/git-log.txt---unifiedltngt"> --unified=<n> </dt> <dd> <p>Generate diffs with <n> lines of context instead of the usual three. Implies <code>--patch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---outputltfilegt"> --output=<file> </dt> <dd> <p>Output to a specific file instead of stdout.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---output-indicator-newltchargt"> --output-indicator-new=<char> </dt> <dt class="hdlist1" id="Documentation/git-log.txt---output-indicator-oldltchargt"> --output-indicator-old=<char> </dt> <dt class="hdlist1" id="Documentation/git-log.txt---output-indicator-contextltchargt"> --output-indicator-context=<char> </dt> <dd> <p>Specify the character used to indicate new, old or context lines in the generated patch. Normally they are <code>+</code>, <code>-</code> and ' ' respectively.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---raw"> --raw </dt> <dd> <p>For each commit, show a summary of changes using the raw diff format. See the "RAW OUTPUT FORMAT" section of <a href="git-diff">git-diff[1]</a>. This is different from showing the log itself in raw format, which you can achieve with <code>--format=raw</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---patch-with-raw"> --patch-with-raw </dt> <dd> <p>Synonym for <code>-p --raw</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--t"> -t </dt> <dd> <p>Show the tree objects in the diff output.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---indent-heuristic"> --indent-heuristic </dt> <dd> <p>Enable the heuristic that shifts diff hunk boundaries to make patches easier to read. This is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---no-indent-heuristic"> --no-indent-heuristic </dt> <dd> <p>Disable the indent heuristic.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---minimal"> --minimal </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---patience"> --patience </dt> <dd> <p>Generate a diff using the "patience diff" algorithm.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---histogram"> --histogram </dt> <dd> <p>Generate a diff using the "histogram diff" algorithm.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---anchoredlttextgt"> --anchored=<text> </dt> <dd> <p>Generate a diff using the "anchored diff" algorithm.</p> <p>This option may be specified more than once.</p> <p>If a line exists in both the source and destination, exists only once, and starts with this text, this algorithm attempts to prevent it from appearing as a deletion or addition in the output. It uses the "patience diff" algorithm internally.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---diff-algorithmpatienceminimalhistogrammyers"> --diff-algorithm={patience|minimal|histogram|myers} </dt> <dd> <p>Choose a diff algorithm. The variants are as follows:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-codedefaultcodecodemyerscode"> <code>default</code>, <code>myers</code> </dt> <dd> <p>The basic greedy diff algorithm. Currently, this is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-codeminimalcode"> <code>minimal</code> </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-codepatiencecode"> <code>patience</code> </dt> <dd> <p>Use "patience diff" algorithm when generating patches.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-codehistogramcode"> <code>histogram</code> </dt> <dd> <p>This algorithm extends the patience algorithm to "support low-occurrence common elements".</p> </dd> </dl> </div> </div> </div> <p>For instance, if you configured the <code>diff.algorithm</code> variable to a non-default value and want to use the default one, then you have to use <code>--diff-algorithm=default</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---statltwidthgtltname-widthgtltcountgt"> --stat[=<width>[,<name-width>[,<count>]]] </dt> <dd> <p>Generate a diffstat. By default, as much space as necessary will be used for the filename part, and the rest for the graph part. Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden by <code><width></code>. The width of the filename part can be limited by giving another width <code><name-width></code> after a comma or by setting <code>diff.statNameWidth=<width></code>. The width of the graph part can be limited by using <code>--stat-graph-width=<width></code> or by setting <code>diff.statGraphWidth=<width></code>. Using <code>--stat</code> or <code>--stat-graph-width</code> affects all commands generating a stat graph, while setting <code>diff.statNameWidth</code> or <code>diff.statGraphWidth</code> does not affect <code>git format-patch</code>. By giving a third parameter <code><count></code>, you can limit the output to the first <code><count></code> lines, followed by <code>...</code> if there are more.</p> <p>These parameters can also be set individually with <code>--stat-width=<width></code>, <code>--stat-name-width=<name-width></code> and <code>--stat-count=<count></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---compact-summary"> --compact-summary </dt> <dd> <p>Output a condensed summary of extended header information such as file creations or deletions ("new" or "gone", optionally "+l" if it’s a symlink) and mode changes ("+x" or "-x" for adding or removing executable bit respectively) in diffstat. The information is put between the filename part and the graph part. Implies <code>--stat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---numstat"> --numstat </dt> <dd> <p>Similar to <code>--stat</code>, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly. For binary files, outputs two <code>-</code> instead of saying <code>0 0</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---shortstat"> --shortstat </dt> <dd> <p>Output only the last line of the <code>--stat</code> format containing total number of modified files, as well as number of added and deleted lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--Xltparam1param282308203gt"> -X[<param1,param2,…>] </dt> <dt class="hdlist1" id="Documentation/git-log.txt---dirstatltparam1param282308203gt"> --dirstat[=<param1,param2,…>] </dt> <dd> <p>Output the distribution of relative amount of changes for each sub-directory. The behavior of <code>--dirstat</code> can be customized by passing it a comma separated list of parameters. The defaults are controlled by the <code>diff.dirstat</code> configuration variable (see <a href="git-config">git-config[1]</a>). The following parameters are available:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-codechangescode"> <code>changes</code> </dt> <dd> <p>Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination. This ignores the amount of pure code movements within a file. In other words, rearranging lines in a file is not counted as much as other changes. This is the default behavior when no parameter is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-codelinescode"> <code>lines</code> </dt> <dd> <p>Compute the dirstat numbers by doing the regular line-based diff analysis, and summing the removed/added line counts. (For binary files, count 64-byte chunks instead, since binary files have no natural concept of lines). This is a more expensive <code>--dirstat</code> behavior than the <code>changes</code> behavior, but it does count rearranged lines within a file as much as other changes. The resulting output is consistent with what you get from the other <code>--*stat</code> options.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-codefilescode"> <code>files</code> </dt> <dd> <p>Compute the dirstat numbers by counting the number of files changed. Each changed file counts equally in the dirstat analysis. This is the computationally cheapest <code>--dirstat</code> behavior, since it does not have to look at the file contents at all.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-codecumulativecode"> <code>cumulative</code> </dt> <dd> <p>Count changes in a child directory for the parent directory as well. Note that when using <code>cumulative</code>, the sum of the percentages reported may exceed 100%. The default (non-cumulative) behavior can be specified with the <code>noncumulative</code> parameter.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-ltlimitgt"> <limit> </dt> <dd> <p>An integer parameter specifies a cut-off percent (3% by default). Directories contributing less than this percentage of the changes are not shown in the output.</p> </dd> </dl> </div> </div> </div> <p>Example: The following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories: <code>--dirstat=files,10,cumulative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---cumulative"> --cumulative </dt> <dd> <p>Synonym for --dirstat=cumulative</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---dirstat-by-fileltparam1param2gt82308203"> --dirstat-by-file[=<param1,param2>…] </dt> <dd> <p>Synonym for --dirstat=files,param1,param2…</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---summary"> --summary </dt> <dd> <p>Output a condensed summary of extended header information such as creations, renames and mode changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---patch-with-stat"> --patch-with-stat </dt> <dd> <p>Synonym for <code>-p --stat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--z"> -z </dt> <dd> <p>Separate the commits with NULs instead of newlines.</p> <p>Also, when <code>--raw</code> or <code>--numstat</code> has been given, do not munge pathnames and use NULs as output field terminators.</p> <p>Without this option, pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---name-only"> --name-only </dt> <dd> <p>Show only names of changed files. The file names are often encoded in UTF-8. For more information see the discussion about encoding in the <a href="git-log">git-log[1]</a> manual page.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---name-status"> --name-status </dt> <dd> <p>Show only names and status of changed files. See the description of the <code>--diff-filter</code> option on what the status letters mean. Just like <code>--name-only</code> the file names are often encoded in UTF-8.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---submoduleltformatgt"> --submodule[=<format>] </dt> <dd> <p>Specify how differences in submodules are shown. When specifying <code>--submodule=short</code> the <code>short</code> format is used. This format just shows the names of the commits at the beginning and end of the range. When <code>--submodule</code> or <code>--submodule=log</code> is specified, the <code>log</code> format is used. This format lists the commits in the range like <a href="git-submodule">git-submodule[1]</a> <code>summary</code> does. When <code>--submodule=diff</code> is specified, the <code>diff</code> format is used. This format shows an inline diff of the changes in the submodule contents between the commit range. Defaults to <code>diff.submodule</code> or the <code>short</code> format if the config option is unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---colorltwhengt"> --color[=<when>] </dt> <dd> <p>Show colored diff. <code>--color</code> (i.e. without <code>=<when></code>) is the same as <code>--color=always</code>. <code><when></code> can be one of <code>always</code>, <code>never</code>, or <code>auto</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---no-color"> --no-color </dt> <dd> <p>Turn off colored diff. It is the same as <code>--color=never</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---color-movedltmodegt"> --color-moved[=<mode>] </dt> <dd> <p>Moved lines of code are colored differently. The <mode> defaults to <code>no</code> if the option is not given and to <code>zebra</code> if the option with no mode is given. The mode must be one of:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-no"> no </dt> <dd> <p>Moved lines are not highlighted.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-default"> default </dt> <dd> <p>Is a synonym for <code>zebra</code>. This may change to a more sensible mode in the future.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-plain"> plain </dt> <dd> <p>Any line that is added in one location and was removed in another location will be colored with <code>color.diff.newMoved</code>. Similarly <code>color.diff.oldMoved</code> will be used for removed lines that are added somewhere else in the diff. This mode picks up any moved line, but it is not very useful in a review to determine if a block of code was moved without permutation.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-blocks"> blocks </dt> <dd> <p>Blocks of moved text of at least 20 alphanumeric characters are detected greedily. The detected blocks are painted using either the <code>color.diff.{old,new}Moved</code> color. Adjacent blocks cannot be told apart.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-zebra"> zebra </dt> <dd> <p>Blocks of moved text are detected as in <code>blocks</code> mode. The blocks are painted using either the <code>color.diff.{old,new}Moved</code> color or <code>color.diff.{old,new}MovedAlternative</code>. The change between the two colors indicates that a new block was detected.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-dimmed-zebra"> dimmed-zebra </dt> <dd> <p>Similar to <code>zebra</code>, but additional dimming of uninteresting parts of moved code is performed. The bordering lines of two adjacent blocks are considered interesting, the rest is uninteresting. <code>dimmed_zebra</code> is a deprecated synonym.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---no-color-moved"> --no-color-moved </dt> <dd> <p>Turn off move detection. This can be used to override configuration settings. It is the same as <code>--color-moved=no</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---color-moved-wsltmodesgt"> --color-moved-ws=<modes> </dt> <dd> <p>This configures how whitespace is ignored when performing the move detection for <code>--color-moved</code>. These modes can be given as a comma separated list:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-no-1"> no </dt> <dd> <p>Do not ignore whitespace when performing move detection.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-ignore-space-at-eol"> ignore-space-at-eol </dt> <dd> <p>Ignore changes in whitespace at EOL.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-ignore-space-change"> ignore-space-change </dt> <dd> <p>Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-ignore-all-space"> ignore-all-space </dt> <dd> <p>Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-allow-indentation-change"> allow-indentation-change </dt> <dd> <p>Initially ignore any whitespace in the move detection, then group the moved code blocks only into a block if the change in whitespace is the same per line. This is incompatible with the other modes.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---no-color-moved-ws"> --no-color-moved-ws </dt> <dd> <p>Do not ignore whitespace when performing move detection. This can be used to override configuration settings. It is the same as <code>--color-moved-ws=no</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---word-diffltmodegt"> --word-diff[=<mode>] </dt> <dd> <p>Show a word diff, using the <mode> to delimit changed words. By default, words are delimited by whitespace; see <code>--word-diff-regex</code> below. The <mode> defaults to <code>plain</code>, and must be one of:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-color"> color </dt> <dd> <p>Highlight changed words using only colors. Implies <code>--color</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-plain-1"> plain </dt> <dd> <p>Show words as <code>[-removed-]</code> and <code>{+added+}</code>. Makes no attempts to escape the delimiters if they appear in the input, so the output may be ambiguous.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-porcelain"> porcelain </dt> <dd> <p>Use a special line-based format intended for script consumption. Added/removed/unchanged runs are printed in the usual unified diff format, starting with a <code>+</code>/<code>-</code>/` ` character at the beginning of the line and extending to the end of the line. Newlines in the input are represented by a tilde <code>~</code> on a line of its own.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-none"> none </dt> <dd> <p>Disable word diff again.</p> </dd> </dl> </div> </div> </div> <p>Note that despite the name of the first mode, color is used to highlight the changed parts in all modes if enabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---word-diff-regexltregexgt"> --word-diff-regex=<regex> </dt> <dd> <p>Use <regex> to decide what a word is, instead of considering runs of non-whitespace to be a word. Also implies <code>--word-diff</code> unless it was already enabled.</p> <p>Every non-overlapping match of the <regex> is considered a word. Anything between these matches is considered whitespace and ignored(!) for the purposes of finding differences. You may want to append <code>|[^[:space:]]</code> to your regular expression to make sure that it matches all non-whitespace characters. A match that contains a newline is silently truncated(!) at the newline.</p> <p>For example, <code>--word-diff-regex=.</code> will treat each character as a word and, correspondingly, show differences character by character.</p> <p>The regex can also be set via a diff driver or configuration option, see <a href="gitattributes">gitattributes[5]</a> or <a href="git-config">git-config[1]</a>. Giving it explicitly overrides any diff driver or configuration setting. Diff drivers override configuration settings.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---color-wordsltregexgt"> --color-words[=<regex>] </dt> <dd> <p>Equivalent to <code>--word-diff=color</code> plus (if a regex was specified) <code>--word-diff-regex=<regex></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---no-renames"> --no-renames </dt> <dd> <p>Turn off rename detection, even when the configuration file gives the default to do so.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---no-rename-empty"> --[no-]rename-empty </dt> <dd> <p>Whether to use empty blobs as rename source.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---check"> --check </dt> <dd> <p>Warn if changes introduce conflict markers or whitespace errors. What are considered whitespace errors is controlled by <code>core.whitespace</code> configuration. By default, trailing whitespaces (including lines that consist solely of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors. Exits with non-zero status if problems are found. Not compatible with --exit-code.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---ws-error-highlightltkindgt"> --ws-error-highlight=<kind> </dt> <dd> <p>Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code> lines of the diff. Multiple values are separated by comma, <code>none</code> resets previous values, <code>default</code> reset the list to <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. When this option is not given, and the configuration variable <code>diff.wsErrorHighlight</code> is not set, only whitespace errors in <code>new</code> lines are highlighted. The whitespace errors are colored with <code>color.diff.whitespace</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---full-index"> --full-index </dt> <dd> <p>Instead of the first handful of characters, show the full pre- and post-image blob object names on the "index" line when generating patch format output.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---binary"> --binary </dt> <dd> <p>In addition to <code>--full-index</code>, output a binary diff that can be applied with <code>git-apply</code>. Implies <code>--patch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---abbrevltngt"> --abbrev[=<n>] </dt> <dd> <p>Instead of showing the full 40-byte hexadecimal object name in diff-raw format output and diff-tree header lines, show the shortest prefix that is at least <code><n></code> hexdigits long that uniquely refers the object. In diff-patch output format, <code>--full-index</code> takes higher precedence, i.e. if <code>--full-index</code> is specified, full blob names will be shown regardless of <code>--abbrev</code>. Non default number of digits can be specified with <code>--abbrev=<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--Bltngtltmgt"> -B[<n>][/<m>] </dt> <dt class="hdlist1" id="Documentation/git-log.txt---break-rewritesltngtltmgt"> --break-rewrites[=[<n>][/<m>]] </dt> <dd> <p>Break complete rewrite changes into pairs of delete and create. This serves two purposes:</p> <p>It affects the way a change that amounts to a total rewrite of a file not as a series of deletion and insertion mixed together with a very few lines that happen to match textually as the context, but as a single deletion of everything old followed by a single insertion of everything new, and the number <code>m</code> controls this aspect of the -B option (defaults to 60%). <code>-B/70%</code> specifies that less than 30% of the original should remain in the result for Git to consider it a total rewrite (i.e. otherwise the resulting patch will be a series of deletion and insertion mixed together with context lines).</p> <p>When used with -M, a totally-rewritten file is also considered as the source of a rename (usually -M only considers a file that disappeared as the source of a rename), and the number <code>n</code> controls this aspect of the -B option (defaults to 50%). <code>-B20%</code> specifies that a change with addition and deletion compared to 20% or more of the file’s size are eligible for being picked up as a possible source of a rename to another file.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--Mltngt"> -M[<n>] </dt> <dt class="hdlist1" id="Documentation/git-log.txt---find-renamesltngt"> --find-renames[=<n>] </dt> <dd> <p>If generating diffs, detect and report renames for each commit. For following files across renames while traversing history, see <code>--follow</code>. If <code>n</code> is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file’s size). For example, <code>-M90%</code> means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn’t changed. Without a <code>%</code> sign, the number is to be read as a fraction, with a decimal point before it. I.e., <code>-M5</code> becomes 0.5, and is thus the same as <code>-M50%</code>. Similarly, <code>-M05</code> is the same as <code>-M5%</code>. To limit detection to exact renames, use <code>-M100%</code>. The default similarity index is 50%.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--Cltngt"> -C[<n>] </dt> <dt class="hdlist1" id="Documentation/git-log.txt---find-copiesltngt"> --find-copies[=<n>] </dt> <dd> <p>Detect copies as well as renames. See also <code>--find-copies-harder</code>. If <code>n</code> is specified, it has the same meaning as for <code>-M<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---find-copies-harder"> --find-copies-harder </dt> <dd> <p>For performance reasons, by default, <code>-C</code> option finds copies only if the original file of the copy was modified in the same changeset. This flag makes the command inspect unmodified files as candidates for the source of copy. This is a very expensive operation for large projects, so use it with caution. Giving more than one <code>-C</code> option has the same effect.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--D"> -D </dt> <dt class="hdlist1" id="Documentation/git-log.txt---irreversible-delete"> --irreversible-delete </dt> <dd> <p>Omit the preimage for deletes, i.e. print only the header but not the diff between the preimage and <code>/dev/null</code>. The resulting patch is not meant to be applied with <code>patch</code> or <code>git apply</code>; this is solely for people who want to just concentrate on reviewing the text after the change. In addition, the output obviously lacks enough information to apply such a patch in reverse, even manually, hence the name of the option.</p> <p>When used together with <code>-B</code>, omit also the preimage in the deletion part of a delete/create pair.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--lltnumgt"> -l<num> </dt> <dd> <p>The <code>-M</code> and <code>-C</code> options involve some preliminary steps that can detect subsets of renames/copies cheaply, followed by an exhaustive fallback portion that compares all remaining unpaired destinations to all relevant sources. (For renames, only remaining unpaired sources are relevant; for copies, all original sources are relevant.) For N sources and destinations, this exhaustive check is O(N^2). This option prevents the exhaustive portion of rename/copy detection from running if the number of source/destination files involved exceeds the specified number. Defaults to diff.renameLimit. Note that a value of 0 is treated as unlimited.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---diff-filterACDMRTUXB82308203"> --diff-filter=[(A|C|D|M|R|T|U|X|B)…[*]] </dt> <dd> <p>Select only files that are Added (<code>A</code>), Copied (<code>C</code>), Deleted (<code>D</code>), Modified (<code>M</code>), Renamed (<code>R</code>), have their type (i.e. regular file, symlink, submodule, …) changed (<code>T</code>), are Unmerged (<code>U</code>), are Unknown (<code>X</code>), or have had their pairing Broken (<code>B</code>). Any combination of the filter characters (including none) can be used. When <code>*</code> (All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.</p> <p>Also, these upper-case letters can be downcased to exclude. E.g. <code>--diff-filter=ad</code> excludes added and deleted paths.</p> <p>Note that not all diffs can feature all types. For instance, copied and renamed entries cannot appear if detection for those types is disabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--Sltstringgt"> -S<string> </dt> <dd> <p>Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file. Intended for the scripter’s use.</p> <p>It is useful when you’re looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting block in the preimage back into <code>-S</code>, and keep going until you get the very first version of the block.</p> <p>Binary files are searched as well.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--Gltregexgt"> -G<regex> </dt> <dd> <p>Look for differences whose patch text contains added/removed lines that match <regex>.</p> <p>To illustrate the difference between <code>-S<regex> --pickaxe-regex</code> and <code>-G<regex></code>, consider a commit with the following diff in the same file:</p> <div class="listingblock"> <div class="content"> <pre>+ return frotz(nitfol, two->ptr, 1, 0); +... +- hit = frotz(nitfol, mf2.ptr, 1, 0);</pre> </div> </div> <p>While <code>git log -G"frotz\(nitfol"</code> will show this commit, <code>git log +-S"frotz\(nitfol" --pickaxe-regex</code> will not (because the number of occurrences of that string did not change).</p> <p>Unless <code>--text</code> is supplied patches of binary files without a textconv filter will be ignored.</p> <p>See the <code>pickaxe</code> entry in <a href="gitdiffcore">gitdiffcore[7]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---find-objectltobject-idgt"> --find-object=<object-id> </dt> <dd> <p>Look for differences that change the number of occurrences of the specified object. Similar to <code>-S</code>, just the argument is different in that it doesn’t search for a specific string but for a specific object id.</p> <p>The object can be a blob or a submodule commit. It implies the <code>-t</code> option in <code>git-log</code> to also find trees.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---pickaxe-all"> --pickaxe-all </dt> <dd> <p>When <code>-S</code> or <code>-G</code> finds a change, show all the changes in that changeset, not just the files that contain the change in <string>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---pickaxe-regex"> --pickaxe-regex </dt> <dd> <p>Treat the <string> given to <code>-S</code> as an extended POSIX regular expression to match.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--Oltorderfilegt"> -O<orderfile> </dt> <dd> <p>Control the order in which files appear in the output. This overrides the <code>diff.orderFile</code> configuration variable (see <a href="git-config">git-config[1]</a>). To cancel <code>diff.orderFile</code>, use <code>-O/dev/null</code>.</p> <p>The output order is determined by the order of glob patterns in <orderfile>. All files with pathnames that match the first pattern are output first, all files with pathnames that match the second pattern (but not the first) are output next, and so on. All files with pathnames that do not match any pattern are output last, as if there was an implicit match-all pattern at the end of the file. If multiple pathnames have the same rank (they match the same pattern but no earlier patterns), their output order relative to each other is the normal order.</p> <p><orderfile> is parsed as follows:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>Blank lines are ignored, so they can be used as separators for readability.</p> </li> <li> <p>Lines starting with a hash ("<code>#</code>") are ignored, so they can be used for comments. Add a backslash ("<code>\</code>") to the beginning of the pattern if it starts with a hash.</p> </li> <li> <p>Each other line contains a single pattern.</p> </li> </ul> </div> </div> </div> <p>Patterns have the same syntax and semantics as patterns used for fnmatch(3) without the FNM_PATHNAME flag, except a pathname also matches a pattern if removing any number of the final pathname components matches the pattern. For example, the pattern "<code>foo*bar</code>" matches "<code>fooasdfbar</code>" and "<code>foo/bar/baz/asdf</code>" but not "<code>foobarx</code>".</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---skip-toltfilegt"> --skip-to=<file> </dt> <dt class="hdlist1" id="Documentation/git-log.txt---rotate-toltfilegt"> --rotate-to=<file> </dt> <dd> <p>Discard the files before the named <file> from the output (i.e. <code>skip to</code>), or move them to the end of the output (i.e. <code>rotate to</code>). These options were invented primarily for the use of the <code>git difftool</code> command, and may not be very useful otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--R"> -R </dt> <dd> <p>Swap two inputs; that is, show differences from index or on-disk file to tree contents.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---relativeltpathgt"> --relative[=<path>] </dt> <dt class="hdlist1" id="Documentation/git-log.txt---no-relative"> --no-relative </dt> <dd> <p>When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option. When you are not in a subdirectory (e.g. in a bare repository), you can name which subdirectory to make the output relative to by giving a <path> as an argument. <code>--no-relative</code> can be used to countermand both <code>diff.relative</code> config option and previous <code>--relative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-log.txt---text"> --text </dt> <dd> <p>Treat all files as text.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---ignore-cr-at-eol"> --ignore-cr-at-eol </dt> <dd> <p>Ignore carriage-return at the end of line when doing a comparison.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---ignore-space-at-eol"> --ignore-space-at-eol </dt> <dd> <p>Ignore changes in whitespace at EOL.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--b"> -b </dt> <dt class="hdlist1" id="Documentation/git-log.txt---ignore-space-change"> --ignore-space-change </dt> <dd> <p>Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--w"> -w </dt> <dt class="hdlist1" id="Documentation/git-log.txt---ignore-all-space"> --ignore-all-space </dt> <dd> <p>Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---ignore-blank-lines"> --ignore-blank-lines </dt> <dd> <p>Ignore changes whose lines are all blank.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--Iltregexgt"> -I<regex> </dt> <dt class="hdlist1" id="Documentation/git-log.txt---ignore-matching-linesltregexgt"> --ignore-matching-lines=<regex> </dt> <dd> <p>Ignore changes whose all lines match <regex>. This option may be specified more than once.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---inter-hunk-contextltlinesgt"> --inter-hunk-context=<lines> </dt> <dd> <p>Show the context between diff hunks, up to the specified number of lines, thereby fusing hunks that are close to each other. Defaults to <code>diff.interHunkContext</code> or 0 if the config option is unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt--W"> -W </dt> <dt class="hdlist1" id="Documentation/git-log.txt---function-context"> --function-context </dt> <dd> <p>Show whole function as context lines for each change. The function names are determined in the same way as <code>git diff</code> works out patch hunk headers (see <code>Defining a custom hunk-header</code> in <a href="gitattributes">gitattributes[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---ext-diff"> --ext-diff </dt> <dd> <p>Allow an external diff helper to be executed. If you set an external diff driver with <a href="gitattributes">gitattributes[5]</a>, you need to use this option with <a href="git-log">git-log[1]</a> and friends.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---no-ext-diff"> --no-ext-diff </dt> <dd> <p>Disallow external diff drivers.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---textconv"> --textconv </dt> <dt class="hdlist1" id="Documentation/git-log.txt---no-textconv"> --no-textconv </dt> <dd> <p>Allow (or disallow) external text conversion filters to be run when comparing binary files. See <a href="gitattributes">gitattributes[5]</a> for details. Because textconv filters are typically a one-way conversion, the resulting diff is suitable for human consumption, but cannot be applied. For this reason, textconv filters are enabled by default only for <a href="git-diff">git-diff[1]</a> and <a href="git-log">git-log[1]</a>, but not for <a href="git-format-patch">git-format-patch[1]</a> or diff plumbing commands.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---ignore-submodulesltwhengt"> --ignore-submodules[=<when>] </dt> <dd> <p>Ignore changes to submodules in the diff generation. <when> can be either "none", "untracked", "dirty" or "all", which is the default. Using "none" will consider the submodule modified when it either contains untracked or modified files or its HEAD differs from the commit recorded in the superproject and can be used to override any settings of the <code>ignore</code> option in <a href="git-config">git-config[1]</a> or <a href="gitmodules">gitmodules[5]</a>. When "untracked" is used submodules are not considered dirty when they only contain untracked content (but they are still scanned for modified content). Using "dirty" ignores all changes to the work tree of submodules, only changes to the commits stored in the superproject are shown (this was the behavior until 1.7.0). Using "all" hides all changes to submodules.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---src-prefixltprefixgt"> --src-prefix=<prefix> </dt> <dd> <p>Show the given source prefix instead of "a/".</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---dst-prefixltprefixgt"> --dst-prefix=<prefix> </dt> <dd> <p>Show the given destination prefix instead of "b/".</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---no-prefix"> --no-prefix </dt> <dd> <p>Do not show any source or destination prefix.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---default-prefix"> --default-prefix </dt> <dd> <p>Use the default source and destination prefixes ("a/" and "b/"). This is usually the default already, but may be used to override config such as <code>diff.noprefix</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---line-prefixltprefixgt"> --line-prefix=<prefix> </dt> <dd> <p>Prepend an additional prefix to every line of output.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt---ita-invisible-in-index"> --ita-invisible-in-index </dt> <dd> <p>By default entries added by "git add -N" appear as an existing empty file in "git diff" and a new file in "git diff --cached". This option makes the entry appear as a new file in "git diff" and non-existent in "git diff --cached". This option could be reverted with <code>--ita-visible-in-index</code>. Both options are experimental and could be removed in future.</p> </dd> </dl> </div> <p>For more detailed explanation on these common options, see also <a href="gitdiffcore">gitdiffcore[7]</a>.</p> </div> <h2 id="generate_patch_text_with_p">Generating patch text with -p</h2> <div class="sectionbody"> <p>Running <a href="git-diff">git-diff[1]</a>, <a href="git-log">git-log[1]</a>, <a href="git-show">git-show[1]</a>, <a href="git-diff-index">git-diff-index[1]</a>, <a href="git-diff-tree">git-diff-tree[1]</a>, or <a href="git-diff-files">git-diff-files[1]</a> with the <code>-p</code> option produces patch text. You can customize the creation of patch text via the <code>GIT_EXTERNAL_DIFF</code> and the <code>GIT_DIFF_OPTS</code> environment variables (see <a href="git">git[1]</a>), and the <code>diff</code> attribute (see <a href="gitattributes">gitattributes[5]</a>).</p> <p>What the -p option produces is slightly different from the traditional diff format:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>It is preceded by a "git diff" header that looks like this:</p> <div class="literalblock"> <div class="content"> <pre>diff --git a/file1 b/file2</pre> </div> </div> <p>The <code>a/</code> and <code>b/</code> filenames are the same unless rename/copy is involved. Especially, even for a creation or a deletion, <code>/dev/null</code> is <code>not</code> used in place of the <code>a/</code> or <code>b/</code> filenames.</p> <p>When a rename/copy is involved, <code>file1</code> and <code>file2</code> show the name of the source file of the rename/copy and the name of the file that the rename/copy produces, respectively.</p> </li> <li> <p>It is followed by one or more extended header lines:</p> <div class="literalblock"> <div class="content"> <pre>old mode <mode> +new mode <mode> +deleted file mode <mode> +new file mode <mode> +copy from <path> +copy to <path> +rename from <path> +rename to <path> +similarity index <number> +dissimilarity index <number> +index <hash>..<hash> <mode></pre> </div> </div> <p>File modes are printed as 6-digit octal numbers including the file type and file permission bits.</p> <p>Path names in extended headers do not include the <code>a/</code> and <code>b/</code> prefixes.</p> <p>The similarity index is the percentage of unchanged lines, and the dissimilarity index is the percentage of changed lines. It is a rounded down integer, followed by a percent sign. The similarity index value of 100% is thus reserved for two equal files, while 100% dissimilarity means that no line from the old file made it into the new one.</p> <p>The index line includes the blob object names before and after the change. The <mode> is included if the file mode does not change; otherwise, separate lines indicate the old and the new mode.</p> </li> <li> <p>Pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>).</p> </li> <li> <p>All the <code>file1</code> files in the output refer to files before the commit, and all the <code>file2</code> files refer to files after the commit. It is incorrect to apply each change to each file sequentially. For example, this patch will swap a and b:</p> <div class="literalblock"> <div class="content"> <pre>diff --git a/a b/b +rename from a +rename to b +diff --git a/b b/a +rename from b +rename to a</pre> </div> </div> </li> <li> <p>Hunk headers mention the name of the function to which the hunk applies. See "Defining a custom hunk-header" in <a href="gitattributes">gitattributes[5]</a> for details of how to tailor this to specific languages.</p> </li> </ol> </div> </div> <h2 id="_combined_diff_format">Combined diff format</h2> <div class="sectionbody"> <p>Any diff-generating command can take the <code>-c</code> or <code>--cc</code> option to produce a <code>combined diff</code> when showing a merge. This is the default format when showing merges with <a href="git-diff">git-diff[1]</a> or <a href="git-show">git-show[1]</a>. Note also that you can give suitable <code>--diff-merges</code> option to any of these commands to force generation of diffs in a specific format.</p> <p>A "combined diff" format looks like this:</p> <div class="listingblock"> <div class="content"> <pre>diff --combined describe.c +index fabadb8,cc95eb0..4866510 +--- a/describe.c ++++ b/describe.c +@@@ -98,20 -98,12 +98,20 @@@ + return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; + } + +- static void describe(char *arg) + -static void describe(struct commit *cmit, int last_one) +++static void describe(char *arg, int last_one) + { + + unsigned char sha1[20]; + + struct commit *cmit; + struct commit_list *list; + static int initialized = 0; + struct commit_name *n; + + + if (get_sha1(arg, sha1) < 0) + + usage(describe_usage); + + cmit = lookup_commit_reference(sha1); + + if (!cmit) + + usage(describe_usage); + + + if (!initialized) { + initialized = 1; + for_each_ref(get_name);</pre> </div> </div> <div class="olist arabic"> <ol class="arabic"> <li> <p>It is preceded by a "git diff" header, that looks like this (when the <code>-c</code> option is used):</p> <div class="literalblock"> <div class="content"> <pre>diff --combined file</pre> </div> </div> <p>or like this (when the <code>--cc</code> option is used):</p> <div class="literalblock"> <div class="content"> <pre>diff --cc file</pre> </div> </div> </li> <li> <p>It is followed by one or more extended header lines (this example shows a merge with two parents):</p> <div class="literalblock"> <div class="content"> <pre>index <hash>,<hash>..<hash> +mode <mode>,<mode>..<mode> +new file mode <mode> +deleted file mode <mode>,<mode></pre> </div> </div> <p>The <code>mode <mode>,<mode>..<mode></code> line appears only if at least one of the <mode> is different from the rest. Extended headers with information about detected content movement (renames and copying detection) are designed to work with the diff of two <tree-ish> and are not used by combined diff format.</p> </li> <li> <p>It is followed by a two-line from-file/to-file header:</p> <div class="literalblock"> <div class="content"> <pre>--- a/file ++++ b/file</pre> </div> </div> <p>Similar to the two-line header for the traditional <code>unified</code> diff format, <code>/dev/null</code> is used to signal created or deleted files.</p> <p>However, if the --combined-all-paths option is provided, instead of a two-line from-file/to-file, you get an N+1 line from-file/to-file header, where N is the number of parents in the merge commit:</p> <div class="literalblock"> <div class="content"> <pre>--- a/file +--- a/file +--- a/file ++++ b/file</pre> </div> </div> <p>This extended format can be useful if rename or copy detection is active, to allow you to see the original name of the file in different parents.</p> </li> <li> <p>Chunk header format is modified to prevent people from accidentally feeding it to <code>patch -p1</code>. Combined diff format was created for review of merge commit changes, and was not meant to be applied. The change is similar to the change in the extended <code>index</code> header:</p> <div class="literalblock"> <div class="content"> <pre>@@@ <from-file-range> <from-file-range> <to-file-range> @@@</pre> </div> </div> <p>There are (number of parents + 1) <code>@</code> characters in the chunk header for combined diff format.</p> </li> </ol> </div> <p>Unlike the traditional <code>unified</code> diff format, which shows two files A and B with a single column that has <code>-</code> (minus — appears in A but removed in B), <code>+</code> (plus — missing in A but added to B), or <code>" "</code> (space — unchanged) prefix, this format compares two or more files file1, file2,… with one file X, and shows how X differs from each of fileN. One column for each of fileN is prepended to the output line to note how X’s line is different from it.</p> <p>A <code>-</code> character in the column N means that the line appears in fileN but it does not appear in the result. A <code>+</code> character in the column N means that the line appears in the result, and fileN does not have that line (in other words, the line was added, from the point of view of that parent).</p> <p>In the above example output, the function signature was changed from both files (hence two <code>-</code> removals from both file1 and file2, plus <code>++</code> to mean one line that was added does not appear in either file1 or file2). Also, eight other lines are the same from file1 but do not appear in file2 (hence prefixed with <code>+</code>).</p> <p>When shown by <code>git diff-tree -c</code>, it compares the parents of a merge commit with the merge result (i.e. file1..fileN are the parents). When shown by <code>git diff-files -c</code>, it compares the two unresolved merge parents with the working tree file (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka "their version").</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-codegitlog--no-mergescode"> <code>git log --no-merges</code> </dt> <dd> <p>Show the whole commit history, but skip any merges</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-codegitlogv2612includescsidriversscsicode"> <code>git log v2.6.12.. include/scsi drivers/scsi</code> </dt> <dd> <p>Show all commits since version <code>v2.6.12</code> that changed any file in the <code>include/scsi</code> or <code>drivers/scsi</code> subdirectories</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-codegitlog--since2weeksago--gitkcode"> <code>git log --since="2 weeks ago" -- gitk</code> </dt> <dd> <p>Show the changes during the last two weeks to the file <code>gitk</code>. The <code>--</code> is necessary to avoid confusion with the <strong>branch</strong> named <code>gitk</code></p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-codegitlog--name-statusreleasetestcode"> <code>git log --name-status release..test</code> </dt> <dd> <p>Show the commits that are in the "test" branch but not yet in the "release" branch, along with the list of paths each commit modifies.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-codegitlog--followbuiltinrev-listccode"> <code>git log --follow builtin/rev-list.c</code> </dt> <dd> <p>Shows the commits that changed <code>builtin/rev-list.c</code>, including those commits that occurred before the file was given its present name.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-codegitlog--branches--not--remotesorigincode"> <code>git log --branches --not --remotes=origin</code> </dt> <dd> <p>Shows all commits that are in any of local branches but not in any of remote-tracking branches for <code>origin</code> (what you have that origin doesn’t).</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-codegitlogmaster--not--remotesmastercode"> <code>git log master --not --remotes=*/master</code> </dt> <dd> <p>Shows all commits that are in local master but not in any remote repository master branches.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-codegitlog-p-m--first-parentcode"> <code>git log -p -m --first-parent</code> </dt> <dd> <p>Shows the history including change diffs, but only from the “main branch” perspective, skipping commits that come from merged branches, and showing full diffs of changes introduced by the merges. This makes sense only when following a strict policy of merging all topic branches when staying on a single integration branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-codegitlog-Lintmainmainccode"> <code>git log -L '/int main/',/^}/:main.c</code> </dt> <dd> <p>Shows how the function <code>main()</code> in the file <code>main.c</code> evolved over time.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-codegitlog-3code"> <code>git log -3</code> </dt> <dd> <p>Limits the number of commits to show to 3.</p> </dd> </dl> </div> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>Git is to some extent character encoding agnostic.</p> <div class="ulist"> <ul> <li> <p>The contents of the blob objects are uninterpreted sequences of bytes. There is no encoding translation at the core level.</p> </li> <li> <p>Path names are encoded in UTF-8 normalization form C. This applies to tree objects, the index file, ref names, as well as path names in command line arguments, environment variables and config files (<code>.git/config</code> (see <a href="git-config">git-config[1]</a>), <a href="gitignore">gitignore[5]</a>, <a href="gitattributes">gitattributes[5]</a> and <a href="gitmodules">gitmodules[5]</a>).</p> <p>Note that Git at the core level treats path names simply as sequences of non-NUL bytes, there are no path name encoding conversions (except on Mac and Windows). Therefore, using non-ASCII path names will mostly work even on platforms and file systems that use legacy extended ASCII encodings. However, repositories created on such systems will not work properly on UTF-8-based systems (e.g. Linux, Mac, Windows) and vice versa. Additionally, many Git-based tools simply assume path names to be UTF-8 and will fail to display other encodings correctly.</p> </li> <li> <p>Commit log messages are typically encoded in UTF-8, but other extended ASCII encodings are also supported. This includes ISO-8859-x, CP125x and many others, but <code>not</code> UTF-16/32, EBCDIC and CJK multi-byte encodings (GBK, Shift-JIS, Big5, EUC-x, CP9xx etc.).</p> </li> </ul> </div> <p>Although we encourage that the commit log messages are encoded in UTF-8, both the core and Git Porcelain are designed not to force UTF-8 on projects. If all participants of a particular project find it more convenient to use legacy encodings, Git does not forbid it. However, there are a few things to keep in mind.</p> <div class="olist arabic"> <ol class="arabic"> <li> <p><code>git commit</code> and <code>git commit-tree</code> issue a warning if the commit log message given to it does not look like a valid UTF-8 string, unless you explicitly say your project uses a legacy encoding. The way to say this is to have <code>i18n.commitEncoding</code> in <code>.git/config</code> file, like this:</p> <div class="listingblock"> <div class="content"> <pre>[i18n] + commitEncoding = ISO-8859-1</pre> </div> </div> <p>Commit objects created with the above setting record the value of <code>i18n.commitEncoding</code> in their <code>encoding</code> header. This is to help other people who look at them later. Lack of this header implies that the commit log message is encoded in UTF-8.</p> </li> <li> <p><code>git log</code>, <code>git show</code>, <code>git blame</code> and friends look at the <code>encoding</code> header of a commit object, and try to re-code the log message into UTF-8 unless otherwise specified. You can specify the desired output encoding with <code>i18n.logOutputEncoding</code> in <code>.git/config</code> file, like this:</p> <div class="listingblock"> <div class="content"> <pre>[i18n] + logOutputEncoding = ISO-8859-1</pre> </div> </div> <p>If you do not have this configuration variable, the value of <code>i18n.commitEncoding</code> is used instead.</p> </li> </ol> </div> <p>Note that we deliberately chose not to re-code the commit log message when a commit is made to force UTF-8 at the commit object level, because re-coding to UTF-8 is not necessarily a reversible operation.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>See <a href="git-config">git-config[1]</a> for core variables and <a href="git-diff">git-diff[1]</a> for settings related to diff generation.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-formatpretty"> format.pretty </dt> <dd> <p>Default for the <code>--format</code> option. (See <code>Pretty Formats</code> above.) Defaults to <code>medium</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-i18nlogOutputEncoding"> i18n.logOutputEncoding </dt> <dd> <p>Encoding to use when displaying logs. (See <code>Discussion</code> above.) Defaults to the value of <code>i18n.commitEncoding</code> if set, and UTF-8 otherwise.</p> </dd> </dl> </div> <p>Everything above this line in this section isn’t included from the <a href="git-config">git-config[1]</a> documentation. The content that follows is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-log.txt-logabbrevCommit"> log.abbrevCommit </dt> <dd> <p>If true, makes <a href="git-log">git-log[1]</a>, <a href="git-show">git-show[1]</a>, and <a href="git-whatchanged">git-whatchanged[1]</a> assume <code>--abbrev-commit</code>. You may override this option with <code>--no-abbrev-commit</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-logdate"> log.date </dt> <dd> <p>Set the default date-time mode for the <code>log</code> command. Setting a value for log.date is similar to using <code>git log</code>'s <code>--date</code> option. See <a href="git-log">git-log[1]</a> for details.</p> <p>If the format is set to "auto:foo" and the pager is in use, format "foo" will be used for the date format. Otherwise, "default" will be used.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-logdecorate"> log.decorate </dt> <dd> <p>Print out the ref names of any commits that are shown by the log command. If <code>short</code> is specified, the ref name prefixes <code>refs/heads/</code>, <code>refs/tags/</code> and <code>refs/remotes/</code> will not be printed. If <code>full</code> is specified, the full ref name (including prefix) will be printed. If <code>auto</code> is specified, then if the output is going to a terminal, the ref names are shown as if <code>short</code> were given, otherwise no ref names are shown. This is the same as the <code>--decorate</code> option of the <code>git log</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-loginitialDecorationSet"> log.initialDecorationSet </dt> <dd> <p>By default, <code>git log</code> only shows decorations for certain known ref namespaces. If <code>all</code> is specified, then show all refs as decorations.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-logexcludeDecoration"> log.excludeDecoration </dt> <dd> <p>Exclude the specified patterns from the log decorations. This is similar to the <code>--decorate-refs-exclude</code> command-line option, but the config option can be overridden by the <code>--decorate-refs</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-logdiffMerges"> log.diffMerges </dt> <dd> <p>Set diff format to be used when <code>--diff-merges=on</code> is specified, see <code>--diff-merges</code> in <a href="git-log">git-log[1]</a> for details. Defaults to <code>separate</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-logfollow"> log.follow </dt> <dd> <p>If <code>true</code>, <code>git log</code> will act as if the <code>--follow</code> option was used when a single <path> is given. This has the same limitations as <code>--follow</code>, i.e. it cannot be used to follow multiple files and does not work well on non-linear history.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-loggraphColors"> log.graphColors </dt> <dd> <p>A list of colors, separated by commas, that can be used to draw history lines in <code>git log --graph</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-logshowRoot"> log.showRoot </dt> <dd> <p>If true, the initial commit will be shown as a big creation event. This is equivalent to a diff against an empty tree. Tools like <a href="git-log">git-log[1]</a> or <a href="git-whatchanged">git-whatchanged[1]</a>, which normally hide the root commit will now show it. True by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-logshowSignature"> log.showSignature </dt> <dd> <p>If true, makes <a href="git-log">git-log[1]</a>, <a href="git-show">git-show[1]</a>, and <a href="git-whatchanged">git-whatchanged[1]</a> assume <code>--show-signature</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-logmailmap"> log.mailmap </dt> <dd> <p>If true, makes <a href="git-log">git-log[1]</a>, <a href="git-show">git-show[1]</a>, and <a href="git-whatchanged">git-whatchanged[1]</a> assume <code>--use-mailmap</code>, otherwise assume <code>--no-use-mailmap</code>. True by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-notesmergeStrategy"> notes.mergeStrategy </dt> <dd> <p>Which merge strategy to choose by default when resolving notes conflicts. Must be one of <code>manual</code>, <code>ours</code>, <code>theirs</code>, <code>union</code>, or <code>cat_sort_uniq</code>. Defaults to <code>manual</code>. See the "NOTES MERGE STRATEGIES" section of <a href="git-notes">git-notes[1]</a> for more information on each strategy.</p> <p>This setting can be overridden by passing the <code>--strategy</code> option to <a href="git-notes">git-notes[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-notesltnamegtmergeStrategy"> notes.<name>.mergeStrategy </dt> <dd> <p>Which merge strategy to choose when doing a notes merge into refs/notes/<name>. This overrides the more general "notes.mergeStrategy". See the "NOTES MERGE STRATEGIES" section in <a href="git-notes">git-notes[1]</a> for more information on the available strategies.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-notesdisplayRef"> notes.displayRef </dt> <dd> <p>Which ref (or refs, if a glob or specified more than once), in addition to the default set by <code>core.notesRef</code> or <code>GIT_NOTES_REF</code>, to read notes from when showing commit messages with the <code>git log</code> family of commands.</p> <p>This setting can be overridden with the <code>GIT_NOTES_DISPLAY_REF</code> environment variable, which must be a colon separated list of refs or globs.</p> <p>A warning will be issued for refs that do not exist, but a glob that does not match any refs is silently ignored.</p> <p>This setting can be disabled by the <code>--no-notes</code> option to the <code>git log</code> family of commands, or by the <code>--notes=<ref></code> option accepted by those commands.</p> <p>The effective value of "core.notesRef" (possibly overridden by GIT_NOTES_REF) is also implicitly added to the list of refs to be displayed.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-notesrewriteltcommandgt"> notes.rewrite.<command> </dt> <dd> <p>When rewriting commits with <command> (currently <code>amend</code> or <code>rebase</code>), if this variable is <code>false</code>, git will not copy notes from the original to the rewritten commit. Defaults to <code>true</code>. See also "<code>notes.rewriteRef</code>" below.</p> <p>This setting can be overridden with the <code>GIT_NOTES_REWRITE_REF</code> environment variable, which must be a colon separated list of refs or globs.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-notesrewriteMode"> notes.rewriteMode </dt> <dd> <p>When copying notes during a rewrite (see the "notes.rewrite.<command>" option), determines what to do if the target commit already has a note. Must be one of <code>overwrite</code>, <code>concatenate</code>, <code>cat_sort_uniq</code>, or <code>ignore</code>. Defaults to <code>concatenate</code>.</p> <p>This setting can be overridden with the <code>GIT_NOTES_REWRITE_MODE</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-log.txt-notesrewriteRef"> notes.rewriteRef </dt> <dd> <p>When copying notes during a rewrite, specifies the (fully qualified) ref whose notes should be copied. May be a glob, in which case notes in all matching refs will be copied. You may also specify this configuration several times.</p> <p>Does not have a default value; you must configure this variable to enable note rewriting. Set it to <code>refs/notes/commits</code> to enable rewriting for the default commit notes.</p> <p>Can be overridden with the <code>GIT_NOTES_REWRITE_REF</code> environment variable. See <code>notes.rewrite.<command></code> above for a further description of its format.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-log" class="_attribution-link">https://git-scm.com/docs/git-log</a> + </p> +</div> diff --git a/devdocs/git/git-ls-files.html b/devdocs/git/git-ls-files.html new file mode 100644 index 00000000..09697b1e --- /dev/null +++ b/devdocs/git/git-ls-files.html @@ -0,0 +1,18 @@ +<h1>git-ls-files</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-ls-files - Show information about files in the index and the working tree</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git ls-files [-z] [-t] [-v] [-f] + [-c|--cached] [-d|--deleted] [-o|--others] [-i|--ignored] + [-s|--stage] [-u|--unmerged] [-k|--killed] [-m|--modified] + [--resolve-undo] + [--directory [--no-empty-directory]] [--eol] + [--deduplicate] + [-x <pattern>|--exclude=<pattern>] + [-X <file>|--exclude-from=<file>] + [--exclude-per-directory=<file>] + [--exclude-standard] + [--error-unmatch] [--with-tree=<tree-ish>] + [--full-name] [--recurse-submodules] + [--abbrev[=<n>]] [--format=<format>] [--] [<file>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This command merges the file listing in the index with the actual working directory list, and shows different combinations of the two.</p> <p>Several flags can be used to determine which files are shown, and each file may be printed multiple times if there are multiple entries in the index or if multiple statuses are applicable for the relevant file selection options.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-ls-files.txt--c"> -c </dt> <dt class="hdlist1" id="Documentation/git-ls-files.txt---cached"> --cached </dt> <dd> <p>Show all files cached in Git’s index, i.e. all tracked files. (This is the default if no -c/-s/-d/-o/-u/-k/-m/--resolve-undo options are specified.)</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt--d"> -d </dt> <dt class="hdlist1" id="Documentation/git-ls-files.txt---deleted"> --deleted </dt> <dd> <p>Show files with an unstaged deletion</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt--m"> -m </dt> <dt class="hdlist1" id="Documentation/git-ls-files.txt---modified"> --modified </dt> <dd> <p>Show files with an unstaged modification (note that an unstaged deletion also counts as an unstaged modification)</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt--o"> -o </dt> <dt class="hdlist1" id="Documentation/git-ls-files.txt---others"> --others </dt> <dd> <p>Show other (i.e. untracked) files in the output</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt--i"> -i </dt> <dt class="hdlist1" id="Documentation/git-ls-files.txt---ignored"> --ignored </dt> <dd> <p>Show only ignored files in the output. Must be used with either an explicit <code>-c</code> or <code>-o</code>. When showing files in the index (i.e. when used with <code>-c</code>), print only those files matching an exclude pattern. When showing "other" files (i.e. when used with <code>-o</code>), show only those matched by an exclude pattern. Standard ignore rules are not automatically activated; therefore, at least one of the <code>--exclude*</code> options is required.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-ls-files.txt---stage"> --stage </dt> <dd> <p>Show staged contents' mode bits, object name and stage number in the output.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---directory"> --directory </dt> <dd> <p>If a whole directory is classified as "other", show just its name (with a trailing slash) and not its whole contents. Has no effect without -o/--others.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---no-empty-directory"> --no-empty-directory </dt> <dd> <p>Do not list empty directories. Has no effect without --directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt--u"> -u </dt> <dt class="hdlist1" id="Documentation/git-ls-files.txt---unmerged"> --unmerged </dt> <dd> <p>Show information about unmerged files in the output, but do not show any other tracked files (forces --stage, overrides --cached).</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt--k"> -k </dt> <dt class="hdlist1" id="Documentation/git-ls-files.txt---killed"> --killed </dt> <dd> <p>Show untracked files on the filesystem that need to be removed due to file/directory conflicts for tracked files to be able to be written to the filesystem.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---resolve-undo"> --resolve-undo </dt> <dd> <p>Show files having resolve-undo information in the index together with their resolve-undo information. (resolve-undo information is what is used to implement "git checkout -m $PATH", i.e. to recreate merge conflicts that were accidentally resolved)</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt--z"> -z </dt> <dd> <p>\0 line termination on output and do not quote filenames. See OUTPUT below for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---deduplicate"> --deduplicate </dt> <dd> <p>When only filenames are shown, suppress duplicates that may come from having multiple stages during a merge, or giving <code>--deleted</code> and <code>--modified</code> option at the same time. When any of the <code>-t</code>, <code>--unmerged</code>, or <code>--stage</code> option is in use, this option has no effect.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt--xltpatterngt"> -x <pattern> </dt> <dt class="hdlist1" id="Documentation/git-ls-files.txt---excludeltpatterngt"> --exclude=<pattern> </dt> <dd> <p>Skip untracked files matching pattern. Note that pattern is a shell wildcard pattern. See EXCLUDE PATTERNS below for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt--Xltfilegt"> -X <file> </dt> <dt class="hdlist1" id="Documentation/git-ls-files.txt---exclude-fromltfilegt"> --exclude-from=<file> </dt> <dd> <p>Read exclude patterns from <file>; 1 per line.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---exclude-per-directoryltfilegt"> --exclude-per-directory=<file> </dt> <dd> <p>Read additional exclude patterns that apply only to the directory and its subdirectories in <file>. Deprecated; use --exclude-standard instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---exclude-standard"> --exclude-standard </dt> <dd> <p>Add the standard Git exclusions: .git/info/exclude, .gitignore in each directory, and the user’s global exclusion file.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---error-unmatch"> --error-unmatch </dt> <dd> <p>If any <file> does not appear in the index, treat this as an error (return 1).</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---with-treelttree-ishgt"> --with-tree=<tree-ish> </dt> <dd> <p>When using --error-unmatch to expand the user supplied <file> (i.e. path pattern) arguments to paths, pretend that paths which were removed in the index since the named <tree-ish> are still present. Using this option with <code>-s</code> or <code>-u</code> options does not make any sense.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt--t"> -t </dt> <dd> <p>Show status tags together with filenames. Note that for scripting purposes, <a href="git-status">git-status[1]</a> <code>--porcelain</code> and <a href="git-diff-files">git-diff-files[1]</a> <code>--name-status</code> are almost always superior alternatives; users should look at <a href="git-status">git-status[1]</a> <code>--short</code> or <a href="git-diff">git-diff[1]</a> <code>--name-status</code> for more user-friendly alternatives.</p> <div class="openblock"> <div class="content"> <p>This option provides a reason for showing each filename, in the form of a status tag (which is followed by a space and then the filename). The status tags are all single characters from the following list:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-ls-files.txt-H"> H </dt> <dd> <p>tracked file that is not either unmerged or skip-worktree</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt-S"> S </dt> <dd> <p>tracked file that is skip-worktree</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt-M"> M </dt> <dd> <p>tracked file that is unmerged</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt-R"> R </dt> <dd> <p>tracked file with unstaged removal/deletion</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt-C"> C </dt> <dd> <p>tracked file with unstaged modification/change</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt-K"> K </dt> <dd> <p>untracked paths which are part of file/directory conflicts which prevent checking out tracked files</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt-"> ? </dt> <dd> <p>untracked file</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt-U"> U </dt> <dd> <p>file with resolve-undo information</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt--v"> -v </dt> <dd> <p>Similar to <code>-t</code>, but use lowercase letters for files that are marked as <code>assume unchanged</code> (see <a href="git-update-index">git-update-index[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt--f"> -f </dt> <dd> <p>Similar to <code>-t</code>, but use lowercase letters for files that are marked as <code>fsmonitor valid</code> (see <a href="git-update-index">git-update-index[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---full-name"> --full-name </dt> <dd> <p>When run from a subdirectory, the command usually outputs paths relative to the current directory. This option forces paths to be output relative to the project top directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---recurse-submodules"> --recurse-submodules </dt> <dd> <p>Recursively calls ls-files on each active submodule in the repository. Currently there is only support for the --cached and --stage modes.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---abbrevltngt"> --abbrev[=<n>] </dt> <dd> <p>Instead of showing the full 40-byte hexadecimal object lines, show the shortest prefix that is at least <code><n></code> hexdigits long that uniquely refers the object. Non default number of digits can be specified with --abbrev=<n>.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---debug"> --debug </dt> <dd> <p>After each line that describes a file, add more data about its cache entry. This is intended to show as much information as possible for manual inspection; the exact format may change at any time.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---eol"> --eol </dt> <dd> <p>Show <eolinfo> and <eolattr> of files. <eolinfo> is the file content identification used by Git when the "text" attribute is "auto" (or not set and core.autocrlf is not false). <eolinfo> is either "-text", "none", "lf", "crlf", "mixed" or "".</p> <p>"" means the file is not a regular file, it is not in the index or not accessible in the working tree.</p> <p><eolattr> is the attribute that is used when checking out or committing, it is either "", "-text", "text", "text=auto", "text eol=lf", "text eol=crlf". Since Git 2.10 "text=auto eol=lf" and "text=auto eol=crlf" are supported.</p> <p>Both the <eolinfo> in the index ("i/<eolinfo>") and in the working tree ("w/<eolinfo>") are shown for regular files, followed by the ("attr/<eolattr>").</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---sparse"> --sparse </dt> <dd> <p>If the index is sparse, show the sparse directories without expanding to the contained files. Sparse directories will be shown with a trailing slash, such as "x/" for a sparse directory "x".</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---formatltformatgt"> --format=<format> </dt> <dd> <p>A string that interpolates <code>%(fieldname)</code> from the result being shown. It also interpolates <code>%%</code> to <code>%</code>, and <code>%xx</code> where <code>xx</code> are hex digits interpolates to character with hex code <code>xx</code>; for example <code>%00</code> interpolates to <code>\0</code> (NUL), <code>%09</code> to <code>\t</code> (TAB) and %0a to <code>\n</code> (LF). --format cannot be combined with <code>-s</code>, <code>-o</code>, <code>-k</code>, <code>-t</code>, <code>--resolve-undo</code> and <code>--eol</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt---"> -- </dt> <dd> <p>Do not interpret any more arguments as options.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt-ltfilegt"> <file> </dt> <dd> <p>Files to show. If no files are given all files which match the other specified criteria are shown.</p> </dd> </dl> </div> </div> <h2 id="_output">Output</h2> <div class="sectionbody"> <p><code>git ls-files</code> just outputs the filenames unless <code>--stage</code> is specified in which case it outputs:</p> <div class="literalblock"> <div class="content"> <pre>[<tag> ]<mode> <object> <stage> <file></pre> </div> </div> <p><code>git ls-files --eol</code> will show i/<eolinfo><SPACES>w/<eolinfo><SPACES>attr/<eolattr><SPACE*><TAB><file></p> <p><code>git ls-files --unmerged</code> and <code>git ls-files --stage</code> can be used to examine detailed information on unmerged paths.</p> <p>For an unmerged path, instead of recording a single mode/SHA-1 pair, the index records up to three such pairs; one from tree O in stage 1, A in stage 2, and B in stage 3. This information can be used by the user (or the porcelain) to see what should eventually be recorded at the path. (see <a href="git-read-tree">git-read-tree[1]</a> for more information on state)</p> <p>Without the <code>-z</code> option, pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>). Using <code>-z</code> the filename is output verbatim and the line is terminated by a NUL byte.</p> <p>It is possible to print in a custom format by using the <code>--format</code> option, which is able to interpolate different fields using a <code>%(fieldname)</code> notation. For example, if you only care about the "objectname" and "path" fields, you can execute with a specific "--format" like</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git ls-files --format='%(objectname) %(path)'</pre> </div> </div> </div> <h2 id="_field_names">Field names</h2> <div class="sectionbody"> <p>The way each path is shown can be customized by using the <code>--format=<format></code> option, where the %(fieldname) in the <format> string for various aspects of the index entry are interpolated. The following "fieldname" are understood:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-ls-files.txt-objectmode"> objectmode </dt> <dd> <p>The mode of the file which is recorded in the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt-objecttype"> objecttype </dt> <dd> <p>The object type of the file which is recorded in the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt-objectname"> objectname </dt> <dd> <p>The name of the file which is recorded in the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt-objectsizepadded"> objectsize[:padded] </dt> <dd> <p>The object size of the file which is recorded in the index ("-" if the object is a <code>commit</code> or <code>tree</code>). It also supports a padded format of size with "%(objectsize:padded)".</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt-stage"> stage </dt> <dd> <p>The stage of the file which is recorded in the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt-eolinfoindex"> eolinfo:index </dt> <dt class="hdlist1" id="Documentation/git-ls-files.txt-eolinfoworktree"> eolinfo:worktree </dt> <dd> <p>The <eolinfo> (see the description of the <code>--eol</code> option) of the contents in the index or in the worktree for the path.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt-eolattr"> eolattr </dt> <dd> <p>The <eolattr> (see the description of the <code>--eol</code> option) that applies to the path.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-files.txt-path"> path </dt> <dd> <p>The pathname of the file which is recorded in the index.</p> </dd> </dl> </div> </div> <h2 id="_exclude_patterns">Exclude patterns</h2> <div class="sectionbody"> <p><code>git ls-files</code> can use a list of "exclude patterns" when traversing the directory tree and finding files to show when the flags --others or --ignored are specified. <a href="gitignore">gitignore[5]</a> specifies the format of exclude patterns.</p> <p>Generally, you should just use --exclude-standard, but for historical reasons the exclude patterns can be specified from the following places, in order:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>The command-line flag --exclude=<pattern> specifies a single pattern. Patterns are ordered in the same order they appear in the command line.</p> </li> <li> <p>The command-line flag --exclude-from=<file> specifies a file containing a list of patterns. Patterns are ordered in the same order they appear in the file.</p> </li> <li> <p>The command-line flag --exclude-per-directory=<name> specifies a name of the file in each directory <code>git ls-files</code> examines, normally <code>.gitignore</code>. Files in deeper directories take precedence. Patterns are ordered in the same order they appear in the files.</p> </li> </ol> </div> <p>A pattern specified on the command line with --exclude or read from the file specified with --exclude-from is relative to the top of the directory tree. A pattern read from a file specified by --exclude-per-directory is relative to the directory that the pattern file appears in.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-read-tree">git-read-tree[1]</a>, <a href="gitignore">gitignore[5]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-ls-files" class="_attribution-link">https://git-scm.com/docs/git-ls-files</a> + </p> +</div> diff --git a/devdocs/git/git-ls-remote.html b/devdocs/git/git-ls-remote.html new file mode 100644 index 00000000..0530d85a --- /dev/null +++ b/devdocs/git/git-ls-remote.html @@ -0,0 +1,19 @@ +<h1>git-ls-remote</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-ls-remote - List references in a remote repository</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>] + [-q | --quiet] [--exit-code] [--get-url] [--sort=<key>] + [--symref] [<repository> [<patterns>…]]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Displays references available in a remote repository along with the associated commit IDs.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-ls-remote.txt--h"> -h </dt> <dt class="hdlist1" id="Documentation/git-ls-remote.txt---heads"> --heads </dt> <dt class="hdlist1" id="Documentation/git-ls-remote.txt--t"> -t </dt> <dt class="hdlist1" id="Documentation/git-ls-remote.txt---tags"> --tags </dt> <dd> <p>Limit to only refs/heads and refs/tags, respectively. These options are <code>not</code> mutually exclusive; when given both, references stored in refs/heads and refs/tags are displayed. Note that <code>git ls-remote -h</code> used without anything else on the command line gives help, consistent with other git subcommands.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-remote.txt---refs"> --refs </dt> <dd> <p>Do not show peeled tags or pseudorefs like <code>HEAD</code> in the output.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-remote.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-ls-remote.txt---quiet"> --quiet </dt> <dd> <p>Do not print remote URL to stderr.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-remote.txt---upload-packltexecgt"> --upload-pack=<exec> </dt> <dd> <p>Specify the full path of <code>git-upload-pack</code> on the remote host. This allows listing references from repositories accessed via SSH and where the SSH daemon does not use the PATH configured by the user.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-remote.txt---exit-code"> --exit-code </dt> <dd> <p>Exit with status "2" when no matching refs are found in the remote repository. Usually the command exits with status "0" to indicate it successfully talked with the remote repository, whether it found any matching refs.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-remote.txt---get-url"> --get-url </dt> <dd> <p>Expand the URL of the given remote repository taking into account any "url.<base>.insteadOf" config setting (See <a href="git-config">git-config[1]</a>) and exit without talking to the remote.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-remote.txt---symref"> --symref </dt> <dd> <p>In addition to the object pointed by it, show the underlying ref pointed by it when showing a symbolic ref. Currently, upload-pack only shows the symref HEAD, so it will be the only one shown by ls-remote.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-remote.txt---sortltkeygt"> --sort=<key> </dt> <dd> <p>Sort based on the key given. Prefix <code>-</code> to sort in descending order of the value. Supports "version:refname" or "v:refname" (tag names are treated as versions). The "version:refname" sort order can also be affected by the "versionsort.suffix" configuration variable. See <a href="git-for-each-ref">git-for-each-ref[1]</a> for more sort options, but be aware keys like <code>committerdate</code> that require access to the objects themselves will not work for refs whose objects have not yet been fetched from the remote, and will give a <code>missing object</code> error.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-remote.txt--oltoptiongt"> -o <option> </dt> <dt class="hdlist1" id="Documentation/git-ls-remote.txt---server-optionltoptiongt"> --server-option=<option> </dt> <dd> <p>Transmit the given string to the server when communicating using protocol version 2. The given string must not contain a NUL or LF character. When multiple <code>--server-option=<option></code> are given, they are all sent to the other side in the order listed on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-remote.txt-ltrepositorygt"> <repository> </dt> <dd> <p>The "remote" repository to query. This parameter can be either a URL or the name of a remote (see the GIT URLS and REMOTES sections of <a href="git-fetch">git-fetch[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-remote.txt-ltpatternsgt82308203"> <patterns>… </dt> <dd> <p>When unspecified, all references, after filtering done with --heads and --tags, are shown. When <patterns>… are specified, only references matching one or more of the given patterns are displayed. Each pattern is interpreted as a glob (see <code>glob</code> in <a href="gitglossary">gitglossary[7]</a>) which is matched against the "tail" of a ref, starting either from the start of the ref (so a full name like <code>refs/heads/foo</code> matches) or from a slash separator (so <code>bar</code> matches <code>refs/heads/bar</code> but not <code>refs/heads/foobar</code>).</p> </dd> </dl> </div> </div> <h2 id="_output">Output</h2> <div class="sectionbody"> <p>The output is in the format:</p> <div class="listingblock"> <div class="content"> <pre><oid> TAB <ref> LF</pre> </div> </div> <p>When showing an annotated tag, unless <code>--refs</code> is given, two such lines are shown: one with the refname for the tag itself as <code><ref></code>, and another with <code><ref></code> followed by <code>^{}</code>. The <code><oid></code> on the latter line shows the name of the object the tag points at.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>List all references (including symbolics and pseudorefs), peeling tags:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-remote +27d43aaaf50ef0ae014b88bba294f93658016a2e HEAD +950264636c68591989456e3ba0a5442f93152c1a refs/heads/main +d9ab777d41f92a8c1684c91cfb02053d7dd1046b refs/heads/next +d4ca2e3147b409459955613c152220f4db848ee1 refs/tags/v2.40.0 +73876f4861cd3d187a4682290ab75c9dccadbc56 refs/tags/v2.40.0^{}</pre> </div> </div> </li> <li> <p>List all references matching given patterns:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-remote http://www.kernel.org/pub/scm/git/git.git master seen rc +5fe978a5381f1fbad26a80e682ddd2a401966740 refs/heads/master +c781a84b5204fb294c9ccc79f8b3baceeb32c061 refs/heads/seen</pre> </div> </div> </li> <li> <p>List only tags matching a given wildcard pattern:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-remote --tags http://www.kernel.org/pub/scm/git/git.git v\* +485a869c64a68cc5795dd99689797c5900f4716d refs/tags/v2.39.2 +cbf04937d5b9fcf0a76c28f69e6294e9e3ecd7e6 refs/tags/v2.39.2^{} +d4ca2e3147b409459955613c152220f4db848ee1 refs/tags/v2.40.0 +73876f4861cd3d187a4682290ab75c9dccadbc56 refs/tags/v2.40.0^{}</pre> </div> </div> </li> </ul> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-check-ref-format">git-check-ref-format[1]</a>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-ls-remote" class="_attribution-link">https://git-scm.com/docs/git-ls-remote</a> + </p> +</div> diff --git a/devdocs/git/git-ls-tree.html b/devdocs/git/git-ls-tree.html new file mode 100644 index 00000000..5bdf960b --- /dev/null +++ b/devdocs/git/git-ls-tree.html @@ -0,0 +1,8 @@ +<h1>git-ls-tree</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-ls-tree - List the contents of a tree object</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git ls-tree [-d] [-r] [-t] [-l] [-z] + [--name-only] [--name-status] [--object-only] [--full-name] [--full-tree] [--abbrev[=<n>]] [--format=<format>] + <tree-ish> [<path>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Lists the contents of a given tree object, like what "/bin/ls -a" does in the current working directory. Note that:</p> <div class="ulist"> <ul> <li> <p>the behaviour is slightly different from that of "/bin/ls" in that the <code><path></code> denotes just a list of patterns to match, e.g. so specifying directory name (without <code>-r</code>) will behave differently, and order of the arguments does not matter.</p> </li> <li> <p>the behaviour is similar to that of "/bin/ls" in that the <code><path></code> is taken as relative to the current working directory. E.g. when you are in a directory <code>sub</code> that has a directory <code>dir</code>, you can run <code>git ls-tree -r HEAD dir</code> to list the contents of the tree (that is <code>sub/dir</code> in <code>HEAD</code>). You don’t want to give a tree that is not at the root level (e.g. <code>git ls-tree -r HEAD:sub dir</code>) in this case, as that would result in asking for <code>sub/sub/dir</code> in the <code>HEAD</code> commit. However, the current working directory can be ignored by passing --full-tree option.</p> </li> </ul> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-ls-tree.txt-lttree-ishgt"> <tree-ish> </dt> <dd> <p>Id of a tree-ish.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt--d"> -d </dt> <dd> <p>Show only the named tree entry itself, not its children.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt--r"> -r </dt> <dd> <p>Recurse into sub-trees.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt--t"> -t </dt> <dd> <p>Show tree entries even when going to recurse them. Has no effect if <code>-r</code> was not passed. <code>-d</code> implies <code>-t</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt--l"> -l </dt> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---long"> --long </dt> <dd> <p>Show object size of blob (file) entries.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt--z"> -z </dt> <dd> <p>\0 line termination on output and do not quote filenames. See OUTPUT FORMAT below for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---name-only"> --name-only </dt> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---name-status"> --name-status </dt> <dd> <p>List only filenames (instead of the "long" output), one per line. Cannot be combined with <code>--object-only</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---object-only"> --object-only </dt> <dd> <p>List only names of the objects, one per line. Cannot be combined with <code>--name-only</code> or <code>--name-status</code>. This is equivalent to specifying <code>--format='%(objectname)'</code>, but for both this option and that exact format the command takes a hand-optimized codepath instead of going through the generic formatting mechanism.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---abbrevltngt"> --abbrev[=<n>] </dt> <dd> <p>Instead of showing the full 40-byte hexadecimal object lines, show the shortest prefix that is at least <code><n></code> hexdigits long that uniquely refers the object. Non default number of digits can be specified with --abbrev=<n>.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---full-name"> --full-name </dt> <dd> <p>Instead of showing the path names relative to the current working directory, show the full path names.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---full-tree"> --full-tree </dt> <dd> <p>Do not limit the listing to the current working directory. Implies --full-name.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt---formatltformatgt"> --format=<format> </dt> <dd> <p>A string that interpolates <code>%(fieldname)</code> from the result being shown. It also interpolates <code>%%</code> to <code>%</code>, and <code>%xNN</code> where <code>NN</code> are hex digits interpolates to character with hex code <code>NN</code>; for example <code>%x00</code> interpolates to <code>\0</code> (NUL), <code>%x09</code> to <code>\t</code> (TAB) and <code>%x0a</code> to <code>\n</code> (LF). When specified, <code>--format</code> cannot be combined with other format-altering options, including <code>--long</code>, <code>--name-only</code> and <code>--object-only</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt-ltpathgt82308203"> [<path>…] </dt> <dd> <p>When paths are given, show them (note that this isn’t really raw pathnames, but rather a list of patterns to match). Otherwise implicitly uses the root level of the tree as the sole path argument.</p> </dd> </dl> </div> </div> <h2 id="_output_format">Output format</h2> <div class="sectionbody"> <p>The output format of <code>ls-tree</code> is determined by either the <code>--format</code> option, or other format-altering options such as <code>--name-only</code> etc. (see <code>--format</code> above).</p> <p>The use of certain <code>--format</code> directives is equivalent to using those options, but invoking the full formatting machinery can be slower than using an appropriate formatting option.</p> <p>In cases where the <code>--format</code> would exactly map to an existing option <code>ls-tree</code> will use the appropriate faster path. Thus the default format is equivalent to:</p> <div class="literalblock"> <div class="content"> <pre>%(objectmode) %(objecttype) %(objectname)%x09%(path)</pre> </div> </div> <p>This output format is compatible with what <code>--index-info --stdin</code> of <code>git update-index</code> expects.</p> <p>When the <code>-l</code> option is used, format changes to</p> <div class="literalblock"> <div class="content"> <pre>%(objectmode) %(objecttype) %(objectname) %(objectsize:padded)%x09%(path)</pre> </div> </div> <p>Object size identified by <objectname> is given in bytes, and right-justified with minimum width of 7 characters. Object size is given only for blobs (file) entries; for other entries <code>-</code> character is used in place of size.</p> <p>Without the <code>-z</code> option, pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>). Using <code>-z</code> the filename is output verbatim and the line is terminated by a NUL byte.</p> <p>Customized format:</p> <p>It is possible to print in a custom format by using the <code>--format</code> option, which is able to interpolate different fields using a <code>%(fieldname)</code> notation. For example, if you only care about the "objectname" and "path" fields, you can execute with a specific "--format" like</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git ls-tree --format='%(objectname) %(path)' <tree-ish></pre> </div> </div> </div> <h2 id="_field_names">Field names</h2> <div class="sectionbody"> <p>Various values from structured fields can be used to interpolate into the resulting output. For each outputting line, the following names can be used:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-ls-tree.txt-objectmode"> objectmode </dt> <dd> <p>The mode of the object.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt-objecttype"> objecttype </dt> <dd> <p>The type of the object (<code>commit</code>, <code>blob</code> or <code>tree</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt-objectname"> objectname </dt> <dd> <p>The name of the object.</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt-objectsizepadded"> objectsize[:padded] </dt> <dd> <p>The size of a <code>blob</code> object ("-" if it’s a <code>commit</code> or <code>tree</code>). It also supports a padded format of size with "%(objectsize:padded)".</p> </dd> <dt class="hdlist1" id="Documentation/git-ls-tree.txt-path"> path </dt> <dd> <p>The pathname of the object.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-ls-tree" class="_attribution-link">https://git-scm.com/docs/git-ls-tree</a> + </p> +</div> diff --git a/devdocs/git/git-mailinfo.html b/devdocs/git/git-mailinfo.html new file mode 100644 index 00000000..ddefb524 --- /dev/null +++ b/devdocs/git/git-mailinfo.html @@ -0,0 +1,8 @@ +<h1>git-mailinfo</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-mailinfo - Extracts patch and authorship from a single e-mail message</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git mailinfo [-k|-b] [-u | --encoding=<encoding> | -n] + [--[no-]scissors] [--quoted-cr=<action>] + <msg> <patch></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Reads a single e-mail message from the standard input, and writes the commit log message in <msg> file, and the patches in <patch> file. The author name, e-mail and e-mail subject are written out to the standard output to be used by <code>git am</code> to create a commit. It is usually not necessary to use this command directly. See <a href="git-am">git-am[1]</a> instead.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-mailinfo.txt--k"> -k </dt> <dd> <p>Usually the program removes email cruft from the Subject: header line to extract the title line for the commit log message. This option prevents this munging, and is most useful when used to read back <code>git format-patch -k</code> output.</p> <p>Specifically, the following are removed until none of them remain:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>Leading and trailing whitespace.</p> </li> <li> <p>Leading <code>Re:</code>, <code>re:</code>, and <code>:</code>.</p> </li> <li> <p>Leading bracketed strings (between <code>[</code> and <code>]</code>, usually <code>[PATCH]</code>).</p> </li> </ul> </div> </div> </div> <p>Finally, runs of whitespace are normalized to a single ASCII space character.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailinfo.txt--b"> -b </dt> <dd> <p>When -k is not in effect, all leading strings bracketed with <code>[</code> and <code>]</code> pairs are stripped. This option limits the stripping to only the pairs whose bracketed string contains the word "PATCH".</p> </dd> <dt class="hdlist1" id="Documentation/git-mailinfo.txt--u"> -u </dt> <dd> <p>The commit log message, author name and author email are taken from the e-mail, and after minimally decoding MIME transfer encoding, re-coded in the charset specified by <code>i18n.commitEncoding</code> (defaulting to UTF-8) by transliterating them. This used to be optional but now it is the default.</p> <p>Note that the patch is always used as-is without charset conversion, even with this flag.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailinfo.txt---encodingltencodinggt"> --encoding=<encoding> </dt> <dd> <p>Similar to -u. But when re-coding, the charset specified here is used instead of the one specified by <code>i18n.commitEncoding</code> or UTF-8.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailinfo.txt--n"> -n </dt> <dd> <p>Disable all charset re-coding of the metadata.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailinfo.txt--m"> -m </dt> <dt class="hdlist1" id="Documentation/git-mailinfo.txt---message-id"> --message-id </dt> <dd> <p>Copy the Message-ID header at the end of the commit message. This is useful in order to associate commits with mailing list discussions.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailinfo.txt---scissors"> --scissors </dt> <dd> <p>Remove everything in body before a scissors line (e.g. "-- >8 --"). The line represents scissors and perforation marks, and is used to request the reader to cut the message at that line. If that line appears in the body of the message before the patch, everything before it (including the scissors line itself) is ignored when this option is used.</p> <p>This is useful if you want to begin your message in a discussion thread with comments and suggestions on the message you are responding to, and to conclude it with a patch submission, separating the discussion and the beginning of the proposed commit log message with a scissors line.</p> <p>This can be enabled by default with the configuration option mailinfo.scissors.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailinfo.txt---no-scissors"> --no-scissors </dt> <dd> <p>Ignore scissors lines. Useful for overriding mailinfo.scissors settings.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailinfo.txt---quoted-crltactiongt"> --quoted-cr=<action> </dt> <dd> <p>Action when processes email messages sent with base64 or quoted-printable encoding, and the decoded lines end with a CRLF instead of a simple LF.</p> <p>The valid actions are:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>nowarn</code>: Git will do nothing when such a CRLF is found.</p> </li> <li> <p><code>warn</code>: Git will issue a warning for each message if such a CRLF is found.</p> </li> <li> <p><code>strip</code>: Git will convert those CRLF to LF.</p> </li> </ul> </div> </div> </div> <p>The default action could be set by configuration option <code>mailinfo.quotedCR</code>. If no such configuration option has been set, <code>warn</code> will be used.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailinfo.txt-ltmsggt"> <msg> </dt> <dd> <p>The commit log message extracted from e-mail, usually except the title line which comes from e-mail Subject.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailinfo.txt-ltpatchgt"> <patch> </dt> <dd> <p>The patch extracted from e-mail.</p> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-mailinfo.txt-mailinfoscissors"> mailinfo.scissors </dt> <dd> <p>If true, makes <a href="git-mailinfo">git-mailinfo[1]</a> (and therefore <a href="git-am">git-am[1]</a>) act by default as if the --scissors option was provided on the command-line. When active, this feature removes everything from the message body before a scissors line (i.e. consisting mainly of ">8", "8<" and "-").</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-mailinfo" class="_attribution-link">https://git-scm.com/docs/git-mailinfo</a> + </p> +</div> diff --git a/devdocs/git/git-mailsplit.html b/devdocs/git/git-mailsplit.html new file mode 100644 index 00000000..64c6edff --- /dev/null +++ b/devdocs/git/git-mailsplit.html @@ -0,0 +1,7 @@ +<h1>git-mailsplit</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-mailsplit - Simple UNIX mbox splitter program</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git mailsplit [-b] [-f<nn>] [-d<prec>] [--keep-cr] [--mboxrd] + -o<directory> [--] [(<mbox>|<Maildir>)…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Splits a mbox file or a Maildir into a list of files: "0001" "0002" .. in the specified directory so you can process them further from there.</p> <div class="admonitionblock important"> <table> <tr> <td class="icon"> <div class="title">Important</div> </td> <td class="content"> Maildir splitting relies upon filenames being sorted to output patches in the correct order. </td> </tr> </table> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-mailsplit.txt-ltmboxgt"> <mbox> </dt> <dd> <p>Mbox file to split. If not given, the mbox is read from the standard input.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailsplit.txt-ltMaildirgt"> <Maildir> </dt> <dd> <p>Root of the Maildir to split. This directory should contain the cur, tmp and new subdirectories.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailsplit.txt--oltdirectorygt"> -o<directory> </dt> <dd> <p>Directory in which to place the individual messages.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailsplit.txt--b"> -b </dt> <dd> <p>If any file doesn’t begin with a From line, assume it is a single mail message instead of signaling an error.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailsplit.txt--dltprecgt"> -d<prec> </dt> <dd> <p>Instead of the default 4 digits with leading zeros, different precision can be specified for the generated filenames.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailsplit.txt--fltnngt"> -f<nn> </dt> <dd> <p>Skip the first <nn> numbers, for example if -f3 is specified, start the numbering with 0004.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailsplit.txt---keep-cr"> --keep-cr </dt> <dd> <p>Do not remove <code>\r</code> from lines ending with <code>\r\n</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-mailsplit.txt---mboxrd"> --mboxrd </dt> <dd> <p>Input is of the "mboxrd" format and "^>+From " line escaping is reversed.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-mailsplit" class="_attribution-link">https://git-scm.com/docs/git-mailsplit</a> + </p> +</div> diff --git a/devdocs/git/git-maintenance.html b/devdocs/git/git-maintenance.html new file mode 100644 index 00000000..c0e514c7 --- /dev/null +++ b/devdocs/git/git-maintenance.html @@ -0,0 +1,29 @@ +<h1>git-maintenance</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-maintenance - Run tasks to optimize Git repository data</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git maintenance run [<options>] +git maintenance start [--scheduler=<scheduler>] +git maintenance (stop|register|unregister) [<options>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Run tasks to optimize Git repository data, speeding up other Git commands and reducing storage requirements for the repository.</p> <p>Git commands that add repository data, such as <code>git add</code> or <code>git fetch</code>, are optimized for a responsive user experience. These commands do not take time to optimize the Git data, since such optimizations scale with the full size of the repository while these user commands each perform a relatively small action.</p> <p>The <code>git maintenance</code> command provides flexibility for how to optimize the Git repository.</p> </div> <h2 id="_subcommands">Subcommands</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-maintenance.txt-run"> run </dt> <dd> <p>Run one or more maintenance tasks. If one or more <code>--task</code> options are specified, then those tasks are run in that order. Otherwise, the tasks are determined by which <code>maintenance.<task>.enabled</code> config options are true. By default, only <code>maintenance.gc.enabled</code> is true.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt-start"> start </dt> <dd> <p>Start running maintenance on the current repository. This performs the same config updates as the <code>register</code> subcommand, then updates the background scheduler to run <code>git maintenance run --scheduled</code> on an hourly basis.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt-stop"> stop </dt> <dd> <p>Halt the background maintenance schedule. The current repository is not removed from the list of maintained repositories, in case the background maintenance is restarted later.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt-register"> register </dt> <dd> <p>Initialize Git config values so any scheduled maintenance will start running on this repository. This adds the repository to the <code>maintenance.repo</code> config variable in the current user’s global config, or the config specified by --config-file option, and enables some recommended configuration values for <code>maintenance.<task>.schedule</code>. The tasks that are enabled are safe for running in the background without disrupting foreground processes.</p> <p>The <code>register</code> subcommand will also set the <code>maintenance.strategy</code> config value to <code>incremental</code>, if this value is not previously set. The <code>incremental</code> strategy uses the following schedule for each maintenance task:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>gc</code>: disabled.</p> </li> <li> <p><code>commit-graph</code>: hourly.</p> </li> <li> <p><code>prefetch</code>: hourly.</p> </li> <li> <p><code>loose-objects</code>: daily.</p> </li> <li> <p><code>incremental-repack</code>: daily.</p> </li> </ul> </div> </div> </div> <p><code>git maintenance register</code> will also disable foreground maintenance by setting <code>maintenance.auto = false</code> in the current repository. This config setting will remain after a <code>git maintenance unregister</code> command.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt-unregister"> unregister </dt> <dd> <p>Remove the current repository from background maintenance. This only removes the repository from the configured list. It does not stop the background maintenance processes from running.</p> <p>The <code>unregister</code> subcommand will report an error if the current repository is not already registered. Use the <code>--force</code> option to return success even when the current repository is not registered.</p> </dd> </dl> </div> </div> <h2 id="_tasks">Tasks</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-maintenance.txt-commit-graph"> commit-graph </dt> <dd> <p>The <code>commit-graph</code> job updates the <code>commit-graph</code> files incrementally, then verifies that the written data is correct. The incremental write is safe to run alongside concurrent Git processes since it will not expire <code>.graph</code> files that were in the previous <code>commit-graph-chain</code> file. They will be deleted by a later run based on the expiration delay.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt-prefetch"> prefetch </dt> <dd> <p>The <code>prefetch</code> task updates the object directory with the latest objects from all registered remotes. For each remote, a <code>git fetch</code> command is run. The configured refspec is modified to place all requested refs within <code>refs/prefetch/</code>. Also, tags are not updated.</p> <p>This is done to avoid disrupting the remote-tracking branches. The end users expect these refs to stay unmoved unless they initiate a fetch. However, with the prefetch task, the objects necessary to complete a later real fetch would already be obtained, making the real fetch faster. In the ideal case, it will just become an update to a bunch of remote-tracking branches without any object transfer.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt-gc"> gc </dt> <dd> <p>Clean up unnecessary files and optimize the local repository. "GC" stands for "garbage collection," but this task performs many smaller tasks. This task can be expensive for large repositories, as it repacks all Git objects into a single pack-file. It can also be disruptive in some situations, as it deletes stale data. See <a href="git-gc">git-gc[1]</a> for more details on garbage collection in Git.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt-loose-objects"> loose-objects </dt> <dd> <p>The <code>loose-objects</code> job cleans up loose objects and places them into pack-files. In order to prevent race conditions with concurrent Git commands, it follows a two-step process. First, it deletes any loose objects that already exist in a pack-file; concurrent Git processes will examine the pack-file for the object data instead of the loose object. Second, it creates a new pack-file (starting with "loose-") containing a batch of loose objects. The batch size is limited to 50 thousand objects to prevent the job from taking too long on a repository with many loose objects. The <code>gc</code> task writes unreachable objects as loose objects to be cleaned up by a later step only if they are not re-added to a pack-file; for this reason it is not advisable to enable both the <code>loose-objects</code> and <code>gc</code> tasks at the same time.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt-incremental-repack"> incremental-repack </dt> <dd> <p>The <code>incremental-repack</code> job repacks the object directory using the <code>multi-pack-index</code> feature. In order to prevent race conditions with concurrent Git commands, it follows a two-step process. First, it calls <code>git multi-pack-index expire</code> to delete pack-files unreferenced by the <code>multi-pack-index</code> file. Second, it calls <code>git multi-pack-index repack</code> to select several small pack-files and repack them into a bigger one, and then update the <code>multi-pack-index</code> entries that refer to the small pack-files to refer to the new pack-file. This prepares those small pack-files for deletion upon the next run of <code>git multi-pack-index expire</code>. The selection of the small pack-files is such that the expected size of the big pack-file is at least the batch size; see the <code>--batch-size</code> option for the <code>repack</code> subcommand in <a href="git-multi-pack-index">git-multi-pack-index[1]</a>. The default batch-size is zero, which is a special case that attempts to repack all pack-files into a single pack-file.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt-pack-refs"> pack-refs </dt> <dd> <p>The <code>pack-refs</code> task collects the loose reference files and collects them into a single file. This speeds up operations that need to iterate across many references. See <a href="git-pack-refs">git-pack-refs[1]</a> for more information.</p> </dd> </dl> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-maintenance.txt---auto"> --auto </dt> <dd> <p>When combined with the <code>run</code> subcommand, run maintenance tasks only if certain thresholds are met. For example, the <code>gc</code> task runs when the number of loose objects exceeds the number stored in the <code>gc.auto</code> config setting, or when the number of pack-files exceeds the <code>gc.autoPackLimit</code> config setting. Not compatible with the <code>--schedule</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt---schedule"> --schedule </dt> <dd> <p>When combined with the <code>run</code> subcommand, run maintenance tasks only if certain time conditions are met, as specified by the <code>maintenance.<task>.schedule</code> config value for each <code><task></code>. This config value specifies a number of seconds since the last time that task ran, according to the <code>maintenance.<task>.lastRun</code> config value. The tasks that are tested are those provided by the <code>--task=<task></code> option(s) or those with <code>maintenance.<task>.enabled</code> set to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt---quiet"> --quiet </dt> <dd> <p>Do not report progress or other information over <code>stderr</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt---tasklttaskgt"> --task=<task> </dt> <dd> <p>If this option is specified one or more times, then only run the specified tasks in the specified order. If no <code>--task=<task></code> arguments are specified, then only the tasks with <code>maintenance.<task>.enabled</code> configured as <code>true</code> are considered. See the <code>TASKS</code> section for the list of accepted <code><task></code> values.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt---schedulerautocrontabsystemd-timerlaunchctlschtasks"> --scheduler=auto|crontab|systemd-timer|launchctl|schtasks </dt> <dd> <p>When combined with the <code>start</code> subcommand, specify the scheduler for running the hourly, daily and weekly executions of <code>git maintenance run</code>. Possible values for <code><scheduler></code> are <code>auto</code>, <code>crontab</code> (POSIX), <code>systemd-timer</code> (Linux), <code>launchctl</code> (macOS), and <code>schtasks</code> (Windows). When <code>auto</code> is specified, the appropriate platform-specific scheduler is used; on Linux, <code>systemd-timer</code> is used if available, otherwise <code>crontab</code>. Default is <code>auto</code>.</p> </dd> </dl> </div> </div> <h2 id="_troubleshooting">Troubleshooting</h2> <div class="sectionbody"> <p>The <code>git maintenance</code> command is designed to simplify the repository maintenance patterns while minimizing user wait time during Git commands. A variety of configuration options are available to allow customizing this process. The default maintenance options focus on operations that complete quickly, even on large repositories.</p> <p>Users may find some cases where scheduled maintenance tasks do not run as frequently as intended. Each <code>git maintenance run</code> command takes a lock on the repository’s object database, and this prevents other concurrent <code>git maintenance run</code> commands from running on the same repository. Without this safeguard, competing processes could leave the repository in an unpredictable state.</p> <p>The background maintenance schedule runs <code>git maintenance run</code> processes on an hourly basis. Each run executes the "hourly" tasks. At midnight, that process also executes the "daily" tasks. At midnight on the first day of the week, that process also executes the "weekly" tasks. A single process iterates over each registered repository, performing the scheduled tasks for that frequency. Depending on the number of registered repositories and their sizes, this process may take longer than an hour. In this case, multiple <code>git maintenance run</code> commands may run on the same repository at the same time, colliding on the object database lock. This results in one of the two tasks not running.</p> <p>If you find that some maintenance windows are taking longer than one hour to complete, then consider reducing the complexity of your maintenance tasks. For example, the <code>gc</code> task is much slower than the <code>incremental-repack</code> task. However, this comes at a cost of a slightly larger object database. Consider moving more expensive tasks to be run less frequently.</p> <p>Expert users may consider scheduling their own maintenance tasks using a different schedule than is available through <code>git maintenance start</code> and Git configuration options. These users should be aware of the object database lock and how concurrent <code>git maintenance run</code> commands behave. Further, the <code>git gc</code> command should not be combined with <code>git maintenance run</code> commands. <code>git gc</code> modifies the object database but does not take the lock in the same way as <code>git maintenance run</code>. If possible, use <code>git maintenance run --task=gc</code> instead of <code>git gc</code>.</p> <p>The following sections describe the mechanisms put in place to run background maintenance by <code>git maintenance start</code> and how to customize them.</p> </div> <h2 id="_background_maintenance_on_posix_systems">Background maintenance on posix systems</h2> <div class="sectionbody"> <p>The standard mechanism for scheduling background tasks on POSIX systems is cron(8). This tool executes commands based on a given schedule. The current list of user-scheduled tasks can be found by running <code>crontab -l</code>. The schedule written by <code>git maintenance start</code> is similar to this:</p> <div class="listingblock"> <div class="content"> <pre># BEGIN GIT MAINTENANCE SCHEDULE +# The following schedule was created by Git +# Any edits made in this region might be +# replaced in the future by a Git command. + +0 1-23 * * * "/<path>/git" --exec-path="/<path>" for-each-repo --config=maintenance.repo maintenance run --schedule=hourly +0 0 * * 1-6 "/<path>/git" --exec-path="/<path>" for-each-repo --config=maintenance.repo maintenance run --schedule=daily +0 0 * * 0 "/<path>/git" --exec-path="/<path>" for-each-repo --config=maintenance.repo maintenance run --schedule=weekly + +# END GIT MAINTENANCE SCHEDULE</pre> </div> </div> <p>The comments are used as a region to mark the schedule as written by Git. Any modifications within this region will be completely deleted by <code>git maintenance stop</code> or overwritten by <code>git maintenance start</code>.</p> <p>The <code>crontab</code> entry specifies the full path of the <code>git</code> executable to ensure that the executed <code>git</code> command is the same one with which <code>git maintenance start</code> was issued independent of <code>PATH</code>. If the same user runs <code>git maintenance start</code> with multiple Git executables, then only the latest executable is used.</p> <p>These commands use <code>git for-each-repo --config=maintenance.repo</code> to run <code>git maintenance run --schedule=<frequency></code> on each repository listed in the multi-valued <code>maintenance.repo</code> config option. These are typically loaded from the user-specific global config. The <code>git maintenance</code> process then determines which maintenance tasks are configured to run on each repository with each <code><frequency></code> using the <code>maintenance.<task>.schedule</code> config options. These values are loaded from the global or repository config values.</p> <p>If the config values are insufficient to achieve your desired background maintenance schedule, then you can create your own schedule. If you run <code>crontab -e</code>, then an editor will load with your user-specific <code>cron</code> schedule. In that editor, you can add your own schedule lines. You could start by adapting the default schedule listed earlier, or you could read the crontab(5) documentation for advanced scheduling techniques. Please do use the full path and <code>--exec-path</code> techniques from the default schedule to ensure you are executing the correct binaries in your schedule.</p> </div> <h2 id="_background_maintenance_on_linux_systemd_systems">Background maintenance on linux systemd systems</h2> <div class="sectionbody"> <p>While Linux supports <code>cron</code>, depending on the distribution, <code>cron</code> may be an optional package not necessarily installed. On modern Linux distributions, systemd timers are superseding it.</p> <p>If user systemd timers are available, they will be used as a replacement of <code>cron</code>.</p> <p>In this case, <code>git maintenance start</code> will create user systemd timer units and start the timers. The current list of user-scheduled tasks can be found by running <code>systemctl --user list-timers</code>. The timers written by <code>git +maintenance start</code> are similar to this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ systemctl --user list-timers +NEXT LEFT LAST PASSED UNIT ACTIVATES +Thu 2021-04-29 19:00:00 CEST 42min left Thu 2021-04-29 18:00:11 CEST 17min ago git-maintenance@hourly.timer git-maintenance@hourly.service +Fri 2021-04-30 00:00:00 CEST 5h 42min left Thu 2021-04-29 00:00:11 CEST 18h ago git-maintenance@daily.timer git-maintenance@daily.service +Mon 2021-05-03 00:00:00 CEST 3 days left Mon 2021-04-26 00:00:11 CEST 3 days ago git-maintenance@weekly.timer git-maintenance@weekly.service</pre> </div> </div> <p>One timer is registered for each <code>--schedule=<frequency></code> option.</p> <p>The definition of the systemd units can be inspected in the following files:</p> <div class="listingblock"> <div class="content"> <pre>~/.config/systemd/user/git-maintenance@.timer +~/.config/systemd/user/git-maintenance@.service +~/.config/systemd/user/timers.target.wants/git-maintenance@hourly.timer +~/.config/systemd/user/timers.target.wants/git-maintenance@daily.timer +~/.config/systemd/user/timers.target.wants/git-maintenance@weekly.timer</pre> </div> </div> <p><code>git maintenance start</code> will overwrite these files and start the timer again with <code>systemctl --user</code>, so any customization should be done by creating a drop-in file, i.e. a <code>.conf</code> suffixed file in the <code>~/.config/systemd/user/git-maintenance@.service.d</code> directory.</p> <p><code>git maintenance stop</code> will stop the user systemd timers and delete the above mentioned files.</p> <p>For more details, see <code>systemd.timer(5)</code>.</p> </div> <h2 id="_background_maintenance_on_macos_systems">Background maintenance on macos systems</h2> <div class="sectionbody"> <p>While macOS technically supports <code>cron</code>, using <code>crontab -e</code> requires elevated privileges and the executed process does not have a full user context. Without a full user context, Git and its credential helpers cannot access stored credentials, so some maintenance tasks are not functional.</p> <p>Instead, <code>git maintenance start</code> interacts with the <code>launchctl</code> tool, which is the recommended way to schedule timed jobs in macOS. Scheduling maintenance through <code>git maintenance (start|stop)</code> requires some <code>launchctl</code> features available only in macOS 10.11 or later.</p> <p>Your user-specific scheduled tasks are stored as XML-formatted <code>.plist</code> files in <code>~/Library/LaunchAgents/</code>. You can see the currently-registered tasks using the following command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ ls ~/Library/LaunchAgents/org.git-scm.git* +org.git-scm.git.daily.plist +org.git-scm.git.hourly.plist +org.git-scm.git.weekly.plist</pre> </div> </div> <p>One task is registered for each <code>--schedule=<frequency></code> option. To inspect how the XML format describes each schedule, open one of these <code>.plist</code> files in an editor and inspect the <code><array></code> element following the <code><key>StartCalendarInterval</key></code> element.</p> <p><code>git maintenance start</code> will overwrite these files and register the tasks again with <code>launchctl</code>, so any customizations should be done by creating your own <code>.plist</code> files with distinct names. Similarly, the <code>git maintenance stop</code> command will unregister the tasks with <code>launchctl</code> and delete the <code>.plist</code> files.</p> <p>To create more advanced customizations to your background tasks, see launchctl.plist(5) for more information.</p> </div> <h2 id="_background_maintenance_on_windows_systems">Background maintenance on windows systems</h2> <div class="sectionbody"> <p>Windows does not support <code>cron</code> and instead has its own system for scheduling background tasks. The <code>git maintenance start</code> command uses the <code>schtasks</code> command to submit tasks to this system. You can inspect all background tasks using the Task Scheduler application. The tasks added by Git have names of the form <code>Git Maintenance (<frequency>)</code>. The Task Scheduler GUI has ways to inspect these tasks, but you can also export the tasks to XML files and view the details there.</p> <p>Note that since Git is a console application, these background tasks create a console window visible to the current user. This can be changed manually by selecting the "Run whether user is logged in or not" option in Task Scheduler. This change requires a password input, which is why <code>git maintenance start</code> does not select it by default.</p> <p>If you want to customize the background tasks, please rename the tasks so future calls to <code>git maintenance (start|stop)</code> do not overwrite your custom tasks.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-maintenance.txt-maintenanceauto"> maintenance.auto </dt> <dd> <p>This boolean config option controls whether some commands run <code>git maintenance run --auto</code> after doing their normal work. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt-maintenancestrategy"> maintenance.strategy </dt> <dd> <p>This string config option provides a way to specify one of a few recommended schedules for background maintenance. This only affects which tasks are run during <code>git maintenance run --schedule=X</code> commands, provided no <code>--task=<task></code> arguments are provided. Further, if a <code>maintenance.<task>.schedule</code> config value is set, then that value is used instead of the one provided by <code>maintenance.strategy</code>. The possible strategy strings are:</p> <div class="ulist"> <ul> <li> <p><code>none</code>: This default setting implies no tasks are run at any schedule.</p> </li> <li> <p><code>incremental</code>: This setting optimizes for performing small maintenance activities that do not delete any data. This does not schedule the <code>gc</code> task, but runs the <code>prefetch</code> and <code>commit-graph</code> tasks hourly, the <code>loose-objects</code> and <code>incremental-repack</code> tasks daily, and the <code>pack-refs</code> task weekly.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt-maintenancelttaskgtenabled"> maintenance.<task>.enabled </dt> <dd> <p>This boolean config option controls whether the maintenance task with name <code><task></code> is run when no <code>--task</code> option is specified to <code>git maintenance run</code>. These config values are ignored if a <code>--task</code> option exists. By default, only <code>maintenance.gc.enabled</code> is true.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt-maintenancelttaskgtschedule"> maintenance.<task>.schedule </dt> <dd> <p>This config option controls whether or not the given <code><task></code> runs during a <code>git maintenance run --schedule=<frequency></code> command. The value must be one of "hourly", "daily", or "weekly".</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt-maintenancecommit-graphauto"> maintenance.commit-graph.auto </dt> <dd> <p>This integer config option controls how often the <code>commit-graph</code> task should be run as part of <code>git maintenance run --auto</code>. If zero, then the <code>commit-graph</code> task will not run with the <code>--auto</code> option. A negative value will force the task to run every time. Otherwise, a positive value implies the command should run when the number of reachable commits that are not in the commit-graph file is at least the value of <code>maintenance.commit-graph.auto</code>. The default value is 100.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt-maintenanceloose-objectsauto"> maintenance.loose-objects.auto </dt> <dd> <p>This integer config option controls how often the <code>loose-objects</code> task should be run as part of <code>git maintenance run --auto</code>. If zero, then the <code>loose-objects</code> task will not run with the <code>--auto</code> option. A negative value will force the task to run every time. Otherwise, a positive value implies the command should run when the number of loose objects is at least the value of <code>maintenance.loose-objects.auto</code>. The default value is 100.</p> </dd> <dt class="hdlist1" id="Documentation/git-maintenance.txt-maintenanceincremental-repackauto"> maintenance.incremental-repack.auto </dt> <dd> <p>This integer config option controls how often the <code>incremental-repack</code> task should be run as part of <code>git maintenance run --auto</code>. If zero, then the <code>incremental-repack</code> task will not run with the <code>--auto</code> option. A negative value will force the task to run every time. Otherwise, a positive value implies the command should run when the number of pack-files not in the multi-pack-index is at least the value of <code>maintenance.incremental-repack.auto</code>. The default value is 10.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-maintenance" class="_attribution-link">https://git-scm.com/docs/git-maintenance</a> + </p> +</div> diff --git a/devdocs/git/git-merge-base.html b/devdocs/git/git-merge-base.html new file mode 100644 index 00000000..e881866e --- /dev/null +++ b/devdocs/git/git-merge-base.html @@ -0,0 +1,44 @@ +<h1>git-merge-base</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-merge-base - Find as good common ancestors as possible for a merge</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git merge-base [-a | --all] <commit> <commit>… +git merge-base [-a | --all] --octopus <commit>… +git merge-base --is-ancestor <commit> <commit> +git merge-base --independent <commit>… +git merge-base --fork-point <ref> [<commit>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p><code>git merge-base</code> finds the best common ancestor(s) between two commits to use in a three-way merge. One common ancestor is <code>better</code> than another common ancestor if the latter is an ancestor of the former. A common ancestor that does not have any better common ancestor is a <code>best common ancestor</code>, i.e. a <code>merge base</code>. Note that there can be more than one merge base for a pair of commits.</p> </div> <h2 id="_operation_modes">Operation modes</h2> <div class="sectionbody"> <p>In the most common special case, specifying only two commits on the command line means computing the merge base between the given two commits.</p> <p>More generally, among the two commits to compute the merge base from, one is specified by the first commit argument on the command line; the other commit is a (possibly hypothetical) commit that is a merge across all the remaining commits on the command line.</p> <p>As a consequence, the <code>merge base</code> is not necessarily contained in each of the commit arguments if more than two commits are specified. This is different from <a href="git-show-branch">git-show-branch[1]</a> when used with the <code>--merge-base</code> option.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-merge-base.txt---octopus"> --octopus </dt> <dd> <p>Compute the best common ancestors of all supplied commits, in preparation for an n-way merge. This mimics the behavior of <code>git show-branch --merge-base</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-base.txt---independent"> --independent </dt> <dd> <p>Instead of printing merge bases, print a minimal subset of the supplied commits with the same ancestors. In other words, among the commits given, list those which cannot be reached from any other. This mimics the behavior of <code>git show-branch --independent</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-base.txt---is-ancestor"> --is-ancestor </dt> <dd> <p>Check if the first <commit> is an ancestor of the second <commit>, and exit with status 0 if true, or with status 1 if not. Errors are signaled by a non-zero status that is not 1.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-base.txt---fork-point"> --fork-point </dt> <dd> <p>Find the point at which a branch (or any history that leads to <commit>) forked from another branch (or any reference) <ref>. This does not just look for the common ancestor of the two commits, but also takes into account the reflog of <ref> to see if the history leading to <commit> forked from an earlier incarnation of the branch <ref> (see discussion of this mode below).</p> </dd> </dl> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-merge-base.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-merge-base.txt---all"> --all </dt> <dd> <p>Output all merge bases for the commits, instead of just one.</p> </dd> </dl> </div> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>Given two commits <code>A</code> and <code>B</code>, <code>git merge-base A B</code> will output a commit which is reachable from both <code>A</code> and <code>B</code> through the parent relationship.</p> <p>For example, with this topology:</p> <div class="literalblock"> <div class="content"> <pre> o---o---o---B + / +---o---1---o---o---o---A</pre> </div> </div> <p>the merge base between <code>A</code> and <code>B</code> is <code>1</code>.</p> <p>Given three commits <code>A</code>, <code>B</code>, and <code>C</code>, <code>git merge-base A B C</code> will compute the merge base between <code>A</code> and a hypothetical commit <code>M</code>, which is a merge between <code>B</code> and <code>C</code>. For example, with this topology:</p> <div class="literalblock"> <div class="content"> <pre> o---o---o---o---C + / + / o---o---o---B + / / +---2---1---o---o---o---A</pre> </div> </div> <p>the result of <code>git merge-base A B C</code> is <code>1</code>. This is because the equivalent topology with a merge commit <code>M</code> between <code>B</code> and <code>C</code> is:</p> <div class="literalblock"> <div class="content"> <pre> o---o---o---o---o + / \ + / o---o---o---o---M + / / +---2---1---o---o---o---A</pre> </div> </div> <p>and the result of <code>git merge-base A M</code> is <code>1</code>. Commit <code>2</code> is also a common ancestor between <code>A</code> and <code>M</code>, but <code>1</code> is a better common ancestor, because <code>2</code> is an ancestor of <code>1</code>. Hence, <code>2</code> is not a merge base.</p> <p>The result of <code>git merge-base --octopus A B C</code> is <code>2</code>, because <code>2</code> is the best common ancestor of all commits.</p> <p>When the history involves criss-cross merges, there can be more than one <code>best</code> common ancestor for two commits. For example, with this topology:</p> <div class="literalblock"> <div class="content"> <pre>---1---o---A + \ / + X + / \ +---2---o---o---B</pre> </div> </div> <p>both <code>1</code> and <code>2</code> are merge bases of A and B. Neither one is better than the other (both are <code>best</code> merge bases). When the <code>--all</code> option is not given, it is unspecified which best one is output.</p> <p>A common idiom to check "fast-forward-ness" between two commits A and B is (or at least used to be) to compute the merge base between A and B, and check if it is the same as A, in which case, A is an ancestor of B. You will see this idiom used often in older scripts.</p> <div class="literalblock"> <div class="content"> <pre>A=$(git rev-parse --verify A) +if test "$A" = "$(git merge-base A B)" +then + ... A is an ancestor of B ... +fi</pre> </div> </div> <p>In modern git, you can say this in a more direct way:</p> <div class="literalblock"> <div class="content"> <pre>if git merge-base --is-ancestor A B +then + ... A is an ancestor of B ... +fi</pre> </div> </div> <p>instead.</p> </div> <h2 id="_discussion_on_fork_point_mode">Discussion on fork-point mode</h2> <div class="sectionbody"> <p>After working on the <code>topic</code> branch created with <code>git switch -c +topic origin/master</code>, the history of remote-tracking branch <code>origin/master</code> may have been rewound and rebuilt, leading to a history of this shape:</p> <div class="literalblock"> <div class="content"> <pre> o---B2 + / +---o---o---B1--o---o---o---B (origin/master) + \ + B0 + \ + D0---D1---D (topic)</pre> </div> </div> <p>where <code>origin/master</code> used to point at commits B0, B1, B2 and now it points at B, and your <code>topic</code> branch was started on top of it back when <code>origin/master</code> was at B0, and you built three commits, D0, D1, and D, on top of it. Imagine that you now want to rebase the work you did on the topic on top of the updated origin/master.</p> <p>In such a case, <code>git merge-base origin/master topic</code> would return the parent of B0 in the above picture, but B0^..D is <strong>not</strong> the range of commits you would want to replay on top of B (it includes B0, which is not what you wrote; it is a commit the other side discarded when it moved its tip from B0 to B1).</p> <p><code>git merge-base --fork-point origin/master topic</code> is designed to help in such a case. It takes not only B but also B0, B1, and B2 (i.e. old tips of the remote-tracking branches your repository’s reflog knows about) into account to see on which commit your topic branch was built and finds B0, allowing you to replay only the commits on your topic, excluding the commits the other side later discarded.</p> <p>Hence</p> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$ fork_point=$(git merge-base --fork-point origin/master topic)</pre> </div> </div> <p>will find B0, and</p> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$ git rebase --onto origin/master $fork_point topic</pre> </div> </div> <p>will replay D0, D1, and D on top of B to create a new history of this shape:</p> <div class="literalblock"> <div class="content"> <pre> o---B2 + / +---o---o---B1--o---o---o---B (origin/master) + \ \ + B0 D0'--D1'--D' (topic - updated) + \ + D0---D1---D (topic - old)</pre> </div> </div> <p>A caveat is that older reflog entries in your repository may be expired by <code>git gc</code>. If B0 no longer appears in the reflog of the remote-tracking branch <code>origin/master</code>, the <code>--fork-point</code> mode obviously cannot find it and fails, avoiding to give a random and useless result (such as the parent of B0, like the same command without the <code>--fork-point</code> option gives).</p> <p>Also, the remote-tracking branch you use the <code>--fork-point</code> mode with must be the one your topic forked from its tip. If you forked from an older commit than the tip, this mode would not find the fork point (imagine in the above sample history B0 did not exist, origin/master started at B1, moved to B2 and then B, and you forked your topic at origin/master^ when origin/master was B1; the shape of the history would be the same as above, without B0, and the parent of B1 is what <code>git merge-base origin/master topic</code> correctly finds, but the <code>--fork-point</code> mode will not, because it is not one of the commits that used to be at the tip of origin/master).</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-rev-list">git-rev-list[1]</a>, <a href="git-show-branch">git-show-branch[1]</a>, <a href="git-merge">git-merge[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-merge-base" class="_attribution-link">https://git-scm.com/docs/git-merge-base</a> + </p> +</div> diff --git a/devdocs/git/git-merge-file.html b/devdocs/git/git-merge-file.html new file mode 100644 index 00000000..4e35dfd8 --- /dev/null +++ b/devdocs/git/git-merge-file.html @@ -0,0 +1,12 @@ +<h1>git-merge-file</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-merge-file - Run a three-way file merge</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git merge-file [-L <current-name> [-L <base-name> [-L <other-name>]]] + [--ours|--theirs|--union] [-p|--stdout] [-q|--quiet] [--marker-size=<n>] + [--[no-]diff3] [--object-id] <current> <base> <other></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Given three files <code><current></code>, <code><base></code> and <code><other></code>, <code>git merge-file</code> incorporates all changes that lead from <code><base></code> to <code><other></code> into <code><current></code>. The result ordinarily goes into <code><current></code>. <code>git merge-file</code> is useful for combining separate changes to an original. Suppose <code><base></code> is the original, and both <code><current></code> and <code><other></code> are modifications of <code><base></code>, then <code>git merge-file</code> combines both changes.</p> <p>A conflict occurs if both <code><current></code> and <code><other></code> have changes in a common segment of lines. If a conflict is found, <code>git merge-file</code> normally outputs a warning and brackets the conflict with lines containing <<<<<<< and >>>>>>> markers. A typical conflict will look like this:</p> <div class="literalblock"> <div class="content"> <pre><<<<<<< A +lines in file A +======= +lines in file B +>>>>>>> B</pre> </div> </div> <p>If there are conflicts, the user should edit the result and delete one of the alternatives. When <code>--ours</code>, <code>--theirs</code>, or <code>--union</code> option is in effect, however, these conflicts are resolved favouring lines from <code><current></code>, lines from <code><other></code>, or lines from both respectively. The length of the conflict markers can be given with the <code>--marker-size</code> option.</p> <p>If <code>--object-id</code> is specified, exactly the same behavior occurs, except that instead of specifying what to merge as files, it is specified as a list of object IDs referring to blobs.</p> <p>The exit value of this program is negative on error, and the number of conflicts otherwise (truncated to 127 if there are more than that many conflicts). If the merge was clean, the exit value is 0.</p> <p><code>git merge-file</code> is designed to be a minimal clone of RCS <code>merge</code>; that is, it implements all of RCS <code>merge</code>'s functionality which is needed by <a href="git">git[1]</a>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-merge-file.txt---object-id"> --object-id </dt> <dd> <p>Specify the contents to merge as blobs in the current repository instead of files. In this case, the operation must take place within a valid repository.</p> <p>If the <code>-p</code> option is specified, the merged file (including conflicts, if any) goes to standard output as normal; otherwise, the merged file is written to the object store and the object ID of its blob is written to standard output.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-file.txt--Lltlabelgt"> -L <label> </dt> <dd> <p>This option may be given up to three times, and specifies labels to be used in place of the corresponding file names in conflict reports. That is, <code>git merge-file -L x -L y -L z a b c</code> generates output that looks like it came from files x, y and z instead of from files a, b and c.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-file.txt--p"> -p </dt> <dd> <p>Send results to standard output instead of overwriting <code><current></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-file.txt--q"> -q </dt> <dd> <p>Quiet; do not warn about conflicts.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-file.txt---diff3"> --diff3 </dt> <dd> <p>Show conflicts in "diff3" style.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-file.txt---zdiff3"> --zdiff3 </dt> <dd> <p>Show conflicts in "zdiff3" style.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-file.txt---ours"> --ours </dt> <dt class="hdlist1" id="Documentation/git-merge-file.txt---theirs"> --theirs </dt> <dt class="hdlist1" id="Documentation/git-merge-file.txt---union"> --union </dt> <dd> <p>Instead of leaving conflicts in the file, resolve conflicts favouring our (or their or both) side of the lines.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-merge-file.txt-codegitmerge-fileREADMEmyREADMEREADMEupstreamcode"> <code>git merge-file README.my README README.upstream</code> </dt> <dd> <p>combines the changes of README.my and README.upstream since README, tries to merge them and writes the result into README.my.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-file.txt-codegitmerge-file-La-Lb-Lctmpa123tmpb234tmpc345code"> <code>git merge-file -L a -L b -L c tmp/a123 tmp/b234 tmp/c345</code> </dt> <dd> <p>merges tmp/a123 and tmp/c345 with the base tmp/b234, but uses labels <code>a</code> and <code>c</code> instead of <code>tmp/a123</code> and <code>tmp/c345</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-file.txt-codegitmerge-file-p--object-idabc1234def567890abcdcode"> <code>git merge-file -p --object-id abc1234 def567 890abcd</code> </dt> <dd> <p>combines the changes of the blob abc1234 and 890abcd since def567, tries to merge them and writes the result to standard output</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-merge-file" class="_attribution-link">https://git-scm.com/docs/git-merge-file</a> + </p> +</div> diff --git a/devdocs/git/git-merge-index.html b/devdocs/git/git-merge-index.html new file mode 100644 index 00000000..61f07ac3 --- /dev/null +++ b/devdocs/git/git-merge-index.html @@ -0,0 +1,15 @@ +<h1>git-merge-index</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-merge-index - Run a merge for files needing merging</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git merge-index [-o] [-q] <merge-program> (-a | ( [--] <file>…) )</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This looks up the <file>(s) in the index and, if there are any merge entries, passes the SHA-1 hash for those files as arguments 1, 2, 3 (empty argument if no file), and <file> as argument 4. File modes for the three files are passed as arguments 5, 6 and 7.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-merge-index.txt---"> -- </dt> <dd> <p>Do not interpret any more arguments as options.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-index.txt--a"> -a </dt> <dd> <p>Run merge against all files in the index that need merging.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-index.txt--o"> -o </dt> <dd> <p>Instead of stopping at the first failed merge, do all of them in one shot - continue with merging even when previous merges returned errors, and only return the error code after all the merges.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-index.txt--q"> -q </dt> <dd> <p>Do not complain about a failed merge program (a merge program failure usually indicates conflicts during the merge). This is for porcelains which might want to emit custom messages.</p> </dd> </dl> </div> <p>If <code>git merge-index</code> is called with multiple <file>s (or -a) then it processes them in turn only stopping if merge returns a non-zero exit code.</p> <p>Typically this is run with a script calling Git’s imitation of the <code>merge</code> command from the RCS package.</p> <p>A sample script called <code>git merge-one-file</code> is included in the distribution.</p> <p>ALERT ALERT ALERT! The Git "merge object order" is different from the RCS <code>merge</code> program merge object order. In the above ordering, the original is first. But the argument order to the 3-way merge program <code>merge</code> is to have the original in the middle. Don’t ask me why.</p> <p>Examples:</p> <div class="listingblock"> <div class="content"> <pre>torvalds@ppc970:~/merge-test> git merge-index cat MM +This is MM from the original tree. # original +This is modified MM in the branch A. # merge1 +This is modified MM in the branch B. # merge2 +This is modified MM in the branch B. # current contents</pre> </div> </div> <p>or</p> <div class="listingblock"> <div class="content"> <pre>torvalds@ppc970:~/merge-test> git merge-index cat AA MM +cat: : No such file or directory +This is added AA in the branch A. +This is added AA in the branch B. +This is added AA in the branch B. +fatal: merge program failed</pre> </div> </div> <p>where the latter example shows how <code>git merge-index</code> will stop trying to merge once anything has returned an error (i.e., <code>cat</code> returned an error for the AA file, because it didn’t exist in the original, and thus <code>git merge-index</code> didn’t even try to merge the MM thing).</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-merge-index" class="_attribution-link">https://git-scm.com/docs/git-merge-index</a> + </p> +</div> diff --git a/devdocs/git/git-merge-one-file.html b/devdocs/git/git-merge-one-file.html new file mode 100644 index 00000000..96385823 --- /dev/null +++ b/devdocs/git/git-merge-one-file.html @@ -0,0 +1,6 @@ +<h1>git-merge-one-file</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-merge-one-file - The standard helper program to use with git-merge-index</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git merge-one-file</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This is the standard helper program to use with <code>git merge-index</code> to resolve a merge after the trivial merge done with <code>git read-tree -m</code>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-merge-one-file" class="_attribution-link">https://git-scm.com/docs/git-merge-one-file</a> + </p> +</div> diff --git a/devdocs/git/git-merge-tree.html b/devdocs/git/git-merge-tree.html new file mode 100644 index 00000000..f250109a --- /dev/null +++ b/devdocs/git/git-merge-tree.html @@ -0,0 +1,26 @@ +<h1>git-merge-tree</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-merge-tree - Perform merge without touching index or working tree</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git merge-tree [--write-tree] [<options>] <branch1> <branch2> +git merge-tree [--trivial-merge] <base-tree> <branch1> <branch2> (deprecated)</pre> </div> </div> <h2 id="NEWMERGE">Description</h2> <div class="sectionbody"> <p>This command has a modern <code>--write-tree</code> mode and a deprecated <code>--trivial-merge</code> mode. With the exception of the <a href="#DEPMERGE">DEPRECATED DESCRIPTION</a> section at the end, the rest of this documentation describes the modern <code>--write-tree</code> mode.</p> <p>Performs a merge, but does not make any new commits and does not read from or write to either the working tree or index.</p> <p>The performed merge will use the same features as the "real" <a href="git-merge">git-merge[1]</a>, including:</p> <div class="ulist"> <ul> <li> <p>three way content merges of individual files</p> </li> <li> <p>rename detection</p> </li> <li> <p>proper directory/file conflict handling</p> </li> <li> <p>recursive ancestor consolidation (i.e. when there is more than one merge base, creating a virtual merge base by merging the merge bases)</p> </li> <li> <p>etc.</p> </li> </ul> </div> <p>After the merge completes, a new toplevel tree object is created. See <code>OUTPUT</code> below for details.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-merge-tree.txt--z"> -z </dt> <dd> <p>Do not quote filenames in the <Conflicted file info> section, and end each filename with a NUL character rather than newline. Also begin the messages section with a NUL character instead of a newline. See <a href="#OUTPUT">OUTPUT</a> below for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-tree.txt---name-only"> --name-only </dt> <dd> <p>In the Conflicted file info section, instead of writing a list of (mode, oid, stage, path) tuples to output for conflicted files, just provide a list of filenames with conflicts (and do not list filenames multiple times if they have multiple conflicting stages).</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-tree.txt---no-messages"> --[no-]messages </dt> <dd> <p>Write any informational messages such as "Auto-merging <path>" or CONFLICT notices to the end of stdout. If unspecified, the default is to include these messages if there are merge conflicts, and to omit them otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-tree.txt---allow-unrelated-histories"> --allow-unrelated-histories </dt> <dd> <p>merge-tree will by default error out if the two branches specified share no common history. This flag can be given to override that check and make the merge proceed anyway.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge-tree.txt---merge-baseltcommitgt"> --merge-base=<commit> </dt> <dd> <p>Instead of finding the merge-bases for <branch1> and <branch2>, specify a merge-base for the merge, and specifying multiple bases is currently not supported. This option is incompatible with <code>--stdin</code>.</p> </dd> </dl> </div> </div> <h2 id="OUTPUT">Output</h2> <div class="sectionbody"> <p>For a successful merge, the output from git-merge-tree is simply one line:</p> <div class="literalblock"> <div class="content"> <pre><OID of toplevel tree></pre> </div> </div> <p>Whereas for a conflicted merge, the output is by default of the form:</p> <div class="literalblock"> <div class="content"> <pre><OID of toplevel tree> +<Conflicted file info> +<Informational messages></pre> </div> </div> <p>These are discussed individually below.</p> <p>However, there is an exception. If <code>--stdin</code> is passed, then there is an extra section at the beginning, a NUL character at the end, and then all the sections repeat for each line of input. Thus, if the first merge is conflicted and the second is clean, the output would be of the form:</p> <div class="literalblock"> <div class="content"> <pre><Merge status> +<OID of toplevel tree> +<Conflicted file info> +<Informational messages> +NUL +<Merge status> +<OID of toplevel tree> +NUL</pre> </div> </div> <div class="sect2"> <h3 id="MS"> +Merge status</h3> <p>This is an integer status followed by a NUL character. The integer status is:</p> <div class="literalblock"> <div class="content"> <pre> 0: merge had conflicts + 1: merge was clean + <0: something prevented the merge from running (e.g. access to repository +objects denied by filesystem)</pre> </div> </div> </div> <div class="sect2"> <h3 id="OIDTLT"> +OID of toplevel tree</h3> <p>This is a tree object that represents what would be checked out in the working tree at the end of <code>git merge</code>. If there were conflicts, then files within this tree may have embedded conflict markers. This section is always followed by a newline (or NUL if <code>-z</code> is passed).</p> </div> <div class="sect2"> <h3 id="CFI"> +Conflicted file info</h3> <p>This is a sequence of lines with the format</p> <div class="literalblock"> <div class="content"> <pre><mode> <object> <stage> <filename></pre> </div> </div> <p>The filename will be quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>). However, if the <code>--name-only</code> option is passed, the mode, object, and stage will be omitted. If <code>-z</code> is passed, the "lines" are terminated by a NUL character instead of a newline character.</p> </div> <div class="sect2"> <h3 id="IM"> +Informational messages</h3> <p>This section provides informational messages, typically about conflicts. The format of the section varies significantly depending on whether <code>-z</code> is passed.</p> <p>If <code>-z</code> is passed:</p> <p>The output format is zero or more conflict informational records, each of the form:</p> <div class="literalblock"> <div class="content"> <pre><list-of-paths><conflict-type>NUL<conflict-message>NUL</pre> </div> </div> <p>where <list-of-paths> is of the form</p> <div class="literalblock"> <div class="content"> <pre><number-of-paths>NUL<path1>NUL<path2>NUL...<pathN>NUL</pre> </div> </div> <p>and includes paths (or branch names) affected by the conflict or informational message in <conflict-message>. Also, <conflict-type> is a stable string explaining the type of conflict, such as</p> <div class="ulist"> <ul> <li> <p>"Auto-merging"</p> </li> <li> <p>"CONFLICT (rename/delete)"</p> </li> <li> <p>"CONFLICT (submodule lacks merge base)"</p> </li> <li> <p>"CONFLICT (binary)"</p> </li> </ul> </div> <p>and <conflict-message> is a more detailed message about the conflict which often (but not always) embeds the <stable-short-type-description> within it. These strings may change in future Git versions. Some examples:</p> <div class="ulist"> <ul> <li> <p>"Auto-merging <file>"</p> </li> <li> <p>"CONFLICT (rename/delete): <oldfile> renamed…but deleted in…"</p> </li> <li> <p>"Failed to merge submodule <submodule> (no merge base)"</p> </li> <li> <p>"Warning: cannot merge binary files: <filename>"</p> </li> </ul> </div> <p>If <code>-z</code> is NOT passed:</p> <p>This section starts with a blank line to separate it from the previous sections, and then only contains the <conflict-message> information from the previous section (separated by newlines). These are non-stable strings that should not be parsed by scripts, and are just meant for human consumption. Also, note that while <conflict-message> strings usually do not contain embedded newlines, they sometimes do. (However, the free-form messages will never have an embedded NUL character). So, the entire block of information is meant for human readers as an agglomeration of all conflict messages.</p> </div> </div> <h2 id="_exit_status">Exit status</h2> <div class="sectionbody"> <p>For a successful, non-conflicted merge, the exit status is 0. When the merge has conflicts, the exit status is 1. If the merge is not able to complete (or start) due to some kind of error, the exit status is something other than 0 or 1 (and the output is unspecified). When --stdin is passed, the return status is 0 for both successful and conflicted merges, and something other than 0 or 1 if it cannot complete all the requested merges.</p> </div> <h2 id="_usage_notes">Usage notes</h2> <div class="sectionbody"> <p>This command is intended as low-level plumbing, similar to <a href="git-hash-object">git-hash-object[1]</a>, <a href="git-mktree">git-mktree[1]</a>, <a href="git-commit-tree">git-commit-tree[1]</a>, <a href="git-write-tree">git-write-tree[1]</a>, <a href="git-update-ref">git-update-ref[1]</a>, and <a href="git-mktag">git-mktag[1]</a>. Thus, it can be used as a part of a series of steps such as:</p> <div class="literalblock"> <div class="content"> <pre>NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2) +test $? -eq 0 || die "There were conflicts..." +NEWCOMMIT=$(git commit-tree $NEWTREE -p $BRANCH1 -p $BRANCH2) +git update-ref $BRANCH1 $NEWCOMMIT</pre> </div> </div> <p>Note that when the exit status is non-zero, <code>NEWTREE</code> in this sequence will contain a lot more output than just a tree.</p> <p>For conflicts, the output includes the same information that you’d get with <a href="git-merge">git-merge[1]</a>:</p> <div class="ulist"> <ul> <li> <p>what would be written to the working tree (the <a href="#OIDTLT">OID of toplevel tree</a>)</p> </li> <li> <p>the higher order stages that would be written to the index (the <a href="#CFI">Conflicted file info</a>)</p> </li> <li> <p>any messages that would have been printed to stdout (the <a href="#IM">Informational messages</a>)</p> </li> </ul> </div> </div> <h2 id="_input_format">Input format</h2> <div class="sectionbody"> <p><code>git merge-tree --stdin</code> input format is fully text based. Each line has this format:</p> <div class="literalblock"> <div class="content"> <pre>[<base-commit> -- ]<branch1> <branch2></pre> </div> </div> <p>If one line is separated by <code>--</code>, the string before the separator is used for specifying a merge-base for the merge and the string after the separator describes the branches to be merged.</p> </div> <h2 id="_mistakes_to_avoid">Mistakes to avoid</h2> <div class="sectionbody"> <p>Do NOT look through the resulting toplevel tree to try to find which files conflict; parse the <a href="#CFI">Conflicted file info</a> section instead. Not only would parsing an entire tree be horrendously slow in large repositories, there are numerous types of conflicts not representable by conflict markers (modify/delete, mode conflict, binary file changed on both sides, file/directory conflicts, various rename conflict permutations, etc.)</p> <p>Do NOT interpret an empty <a href="#CFI">Conflicted file info</a> list as a clean merge; check the exit status. A merge can have conflicts without having individual files conflict (there are a few types of directory rename conflicts that fall into this category, and others might also be added in the future).</p> <p>Do NOT attempt to guess or make the user guess the conflict types from the <a href="#CFI">Conflicted file info</a> list. The information there is insufficient to do so. For example: Rename/rename(1to2) conflicts (both sides renamed the same file differently) will result in three different files having higher order stages (but each only has one higher order stage), with no way (short of the <a href="#IM">Informational messages</a> section) to determine which three files are related. File/directory conflicts also result in a file with exactly one higher order stage. Possibly-involved-in-directory-rename conflicts (when "merge.directoryRenames" is unset or set to "conflicts") also result in a file with exactly one higher order stage. In all cases, the <a href="#IM">Informational messages</a> section has the necessary info, though it is not designed to be machine parseable.</p> <p>Do NOT assume that each path from <a href="#CFI">Conflicted file info</a>, and the logical conflicts in the <a href="#IM">Informational messages</a> have a one-to-one mapping, nor that there is a one-to-many mapping, nor a many-to-one mapping. Many-to-many mappings exist, meaning that each path can have many logical conflict types in a single merge, and each logical conflict type can affect many paths.</p> <p>Do NOT assume all filenames listed in the <a href="#IM">Informational messages</a> section had conflicts. Messages can be included for files that have no conflicts, such as "Auto-merging <file>".</p> <p>AVOID taking the OIDS from the <a href="#CFI">Conflicted file info</a> and re-merging them to present the conflicts to the user. This will lose information. Instead, look up the version of the file found within the <a href="#OIDTLT">OID of toplevel tree</a> and show that instead. In particular, the latter will have conflict markers annotated with the original branch/commit being merged and, if renames were involved, the original filename. While you could include the original branch/commit in the conflict marker annotations when re-merging, the original filename is not available from the <a href="#CFI">Conflicted file info</a> and thus you would be losing information that might help the user resolve the conflict.</p> </div> <h2 id="DEPMERGE">Deprecated description</h2> <div class="sectionbody"> <p>Per the <a href="#NEWMERGE">DESCRIPTION</a> and unlike the rest of this documentation, this section describes the deprecated <code>--trivial-merge</code> mode.</p> <p>Other than the optional <code>--trivial-merge</code>, this mode accepts no options.</p> <p>This mode reads three tree-ish, and outputs trivial merge results and conflicting stages to the standard output in a semi-diff format. Since this was designed for higher level scripts to consume and merge the results back into the index, it omits entries that match <branch1>. The result of this second form is similar to what three-way <code>git read-tree -m</code> does, but instead of storing the results in the index, the command outputs the entries to the standard output.</p> <p>This form not only has limited applicability (a trivial merge cannot handle content merges of individual files, rename detection, proper directory/file conflict handling, etc.), the output format is also difficult to work with, and it will generally be less performant than the first form even on successful merges (especially if working in large repositories).</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-merge-tree" class="_attribution-link">https://git-scm.com/docs/git-merge-tree</a> + </p> +</div> diff --git a/devdocs/git/git-merge.html b/devdocs/git/git-merge.html new file mode 100644 index 00000000..8f7d4656 --- /dev/null +++ b/devdocs/git/git-merge.html @@ -0,0 +1,54 @@ +<h1>git-merge</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-merge - Join two or more development histories together</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git merge [-n] [--stat] [--no-commit] [--squash] [--[no-]edit] + [--no-verify] [-s <strategy>] [-X <strategy-option>] [-S[<keyid>]] + [--[no-]allow-unrelated-histories] + [--[no-]rerere-autoupdate] [-m <msg>] [-F <file>] + [--into-name <branch>] [<commit>…] +git merge (--continue | --abort | --quit)</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Incorporates changes from the named commits (since the time their histories diverged from the current branch) into the current branch. This command is used by <code>git pull</code> to incorporate changes from another repository and can be used by hand to merge changes from one branch into another.</p> <p>Assume the following history exists and the current branch is <code>master</code>:</p> <div class="listingblock"> <div class="content"> <pre> A---B---C topic + / + D---E---F---G master</pre> </div> </div> <p>Then <code>git merge topic</code> will replay the changes made on the <code>topic</code> branch since it diverged from <code>master</code> (i.e., <code>E</code>) until its current commit (<code>C</code>) on top of <code>master</code>, and record the result in a new commit along with the names of the two parent commits and a log message from the user describing the changes. Before the operation, <code>ORIG_HEAD</code> is set to the tip of the current branch (<code>C</code>).</p> <div class="listingblock"> <div class="content"> <pre> A---B---C topic + / \ + D---E---F---G---H master</pre> </div> </div> <p>A merge stops if there’s a conflict that cannot be resolved automatically or if <code>--no-commit</code> was provided when initiating the merge. At that point you can run <code>git merge --abort</code> or <code>git merge +--continue</code>.</p> <p><code>git merge --abort</code> will abort the merge process and try to reconstruct the pre-merge state. However, if there were uncommitted changes when the merge started (and especially if those changes were further modified after the merge was started), <code>git merge --abort</code> will in some cases be unable to reconstruct the original (pre-merge) changes. Therefore:</p> <p><strong>Warning</strong>: Running <code>git merge</code> with non-trivial uncommitted changes is discouraged: while possible, it may leave you in a state that is hard to back out of in the case of a conflict.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-merge.txt---commit"> --commit </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---no-commit"> --no-commit </dt> <dd> <p>Perform the merge and commit the result. This option can be used to override --no-commit.</p> <p>With --no-commit perform the merge and stop just before creating a merge commit, to give the user a chance to inspect and further tweak the merge result before committing.</p> <p>Note that fast-forward updates do not create a merge commit and therefore there is no way to stop those merges with --no-commit. Thus, if you want to ensure your branch is not changed or updated by the merge command, use --no-ff with --no-commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---edit"> --edit </dt> <dt class="hdlist1" id="Documentation/git-merge.txt--e"> -e </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---no-edit"> --no-edit </dt> <dd> <p> Invoke an editor before committing successful mechanical merge to further edit the auto-generated merge message, so that the user can explain and justify the merge. The <code>--no-edit</code> option can be used to accept the auto-generated message (this is generally discouraged). The <code>--edit</code> (or <code>-e</code>) option is still useful if you are giving a draft message with the <code>-m</code> option from the command line and want to edit it in the editor.</p> <p>Older scripts may depend on the historical behaviour of not allowing the user to edit the merge log message. They will see an editor opened when they run <code>git merge</code>. To make it easier to adjust such scripts to the updated behaviour, the environment variable <code>GIT_MERGE_AUTOEDIT</code> can be set to <code>no</code> at the beginning of them.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---cleanupltmodegt"> --cleanup=<mode> </dt> <dd> <p>This option determines how the merge message will be cleaned up before committing. See <a href="git-commit">git-commit[1]</a> for more details. In addition, if the <code><mode></code> is given a value of <code>scissors</code>, scissors will be appended to <code>MERGE_MSG</code> before being passed on to the commit machinery in the case of a merge conflict.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---ff"> --ff </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---no-ff"> --no-ff </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---ff-only"> --ff-only </dt> <dd> <p>Specifies how a merge is handled when the merged-in history is already a descendant of the current history. <code>--ff</code> is the default unless merging an annotated (and possibly signed) tag that is not stored in its natural place in the <code>refs/tags/</code> hierarchy, in which case <code>--no-ff</code> is assumed.</p> <p>With <code>--ff</code>, when possible resolve the merge as a fast-forward (only update the branch pointer to match the merged branch; do not create a merge commit). When not possible (when the merged-in history is not a descendant of the current history), create a merge commit.</p> <p>With <code>--no-ff</code>, create a merge commit in all cases, even when the merge could instead be resolved as a fast-forward.</p> <p>With <code>--ff-only</code>, resolve the merge as a fast-forward when possible. When not possible, refuse to merge and exit with a non-zero status.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt--Sltkeyidgt"> -S[<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---gpg-signltkeyidgt"> --gpg-sign[=<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---no-gpg-sign"> --no-gpg-sign </dt> <dd> <p>GPG-sign the resulting merge commit. The <code>keyid</code> argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space. <code>--no-gpg-sign</code> is useful to countermand both <code>commit.gpgSign</code> configuration variable, and earlier <code>--gpg-sign</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---logltngt"> --log[=<n>] </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---no-log"> --no-log </dt> <dd> <p>In addition to branch names, populate the log message with one-line descriptions from at most <n> actual commits that are being merged. See also <a href="git-fmt-merge-msg">git-fmt-merge-msg[1]</a>.</p> <p>With --no-log do not list one-line descriptions from the actual commits being merged.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---signoff"> --signoff </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---no-signoff"> --no-signoff </dt> <dd> <p>Add a <code>Signed-off-by</code> trailer by the committer at the end of the commit log message. The meaning of a signoff depends on the project to which you’re committing. For example, it may certify that the committer has the rights to submit the work under the project’s license or agrees to some contributor representation, such as a Developer Certificate of Origin. (See <a href="https://developercertificate.org" class="bare">https://developercertificate.org</a> for the one used by the Linux kernel and Git projects.) Consult the documentation or leadership of the project to which you’re contributing to understand how the signoffs are used in that project.</p> <p>The --no-signoff option can be used to countermand an earlier --signoff option on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---stat"> --stat </dt> <dt class="hdlist1" id="Documentation/git-merge.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---no-stat"> --no-stat </dt> <dd> <p>Show a diffstat at the end of the merge. The diffstat is also controlled by the configuration option merge.stat.</p> <p>With -n or --no-stat do not show a diffstat at the end of the merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---squash"> --squash </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---no-squash"> --no-squash </dt> <dd> <p>Produce the working tree and index state as if a real merge happened (except for the merge information), but do not actually make a commit, move the <code>HEAD</code>, or record <code>$GIT_DIR/MERGE_HEAD</code> (to cause the next <code>git commit</code> command to create a merge commit). This allows you to create a single commit on top of the current branch whose effect is the same as merging another branch (or more in case of an octopus).</p> <p>With --no-squash perform the merge and commit the result. This option can be used to override --squash.</p> <p>With --squash, --commit is not allowed, and will fail.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---no-verify"> --[no-]verify </dt> <dd> <p>By default, the pre-merge and commit-msg hooks are run. When <code>--no-verify</code> is given, these are bypassed. See also <a href="githooks">githooks[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt--sltstrategygt"> -s <strategy> </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---strategyltstrategygt"> --strategy=<strategy> </dt> <dd> <p>Use the given merge strategy; can be supplied more than once to specify them in the order they should be tried. If there is no <code>-s</code> option, a built-in list of strategies is used instead (<code>ort</code> when merging a single head, <code>octopus</code> otherwise).</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt--Xltoptiongt"> -X <option> </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---strategy-optionltoptiongt"> --strategy-option=<option> </dt> <dd> <p>Pass merge strategy specific option through to the merge strategy.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---verify-signatures"> --verify-signatures </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---no-verify-signatures"> --no-verify-signatures </dt> <dd> <p>Verify that the tip commit of the side branch being merged is signed with a valid key, i.e. a key that has a valid uid: in the default trust model, this means the signing key has been signed by a trusted key. If the tip commit of the side branch is not signed with a valid key, the merge is aborted.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---summary"> --summary </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---no-summary"> --no-summary </dt> <dd> <p>Synonyms to --stat and --no-stat; these are deprecated and will be removed in the future.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---quiet"> --quiet </dt> <dd> <p>Operate quietly. Implies --no-progress.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---verbose"> --verbose </dt> <dd> <p>Be verbose.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---progress"> --progress </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---no-progress"> --no-progress </dt> <dd> <p>Turn progress on/off explicitly. If neither is specified, progress is shown if standard error is connected to a terminal. Note that not all merge strategies may support progress reporting.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---autostash"> --autostash </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---no-autostash"> --no-autostash </dt> <dd> <p>Automatically create a temporary stash entry before the operation begins, record it in the ref <code>MERGE_AUTOSTASH</code> and apply it after the operation ends. This means that you can run the operation on a dirty worktree. However, use with care: the final stash application after a successful merge might result in non-trivial conflicts.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---allow-unrelated-histories"> --allow-unrelated-histories </dt> <dd> <p>By default, <code>git merge</code> command refuses to merge histories that do not share a common ancestor. This option can be used to override this safety when merging histories of two projects that started their lives independently. As that is a very rare occasion, no configuration variable to enable this by default exists and will not be added.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt--mltmsggt"> -m <msg> </dt> <dd> <p>Set the commit message to be used for the merge commit (in case one is created).</p> <p>If <code>--log</code> is specified, a shortlog of the commits being merged will be appended to the specified message.</p> <p>The <code>git fmt-merge-msg</code> command can be used to give a good default for automated <code>git merge</code> invocations. The automated message can include the branch description.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---into-nameltbranchgt"> --into-name <branch> </dt> <dd> <p>Prepare the default merge message as if merging to the branch <code><branch></code>, instead of the name of the real branch to which the merge is made.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt--Fltfilegt"> -F <file> </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---fileltfilegt"> --file=<file> </dt> <dd> <p>Read the commit message to be used for the merge commit (in case one is created).</p> <p>If <code>--log</code> is specified, a shortlog of the commits being merged will be appended to the specified message.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---rerere-autoupdate"> --rerere-autoupdate </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---no-rerere-autoupdate"> --no-rerere-autoupdate </dt> <dd> <p>After the rerere mechanism reuses a recorded resolution on the current conflict to update the files in the working tree, allow it to also update the index with the result of resolution. <code>--no-rerere-autoupdate</code> is a good way to double-check what <code>rerere</code> did and catch potential mismerges, before committing the result to the index with a separate <code>git add</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---overwrite-ignore"> --overwrite-ignore </dt> <dt class="hdlist1" id="Documentation/git-merge.txt---no-overwrite-ignore"> --no-overwrite-ignore </dt> <dd> <p>Silently overwrite ignored files from the merge result. This is the default behavior. Use <code>--no-overwrite-ignore</code> to abort.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---abort"> --abort </dt> <dd> <p>Abort the current conflict resolution process, and try to reconstruct the pre-merge state. If an autostash entry is present, apply it to the worktree.</p> <p>If there were uncommitted worktree changes present when the merge started, <code>git merge --abort</code> will in some cases be unable to reconstruct these changes. It is therefore recommended to always commit or stash your changes before running <code>git merge</code>.</p> <p><code>git merge --abort</code> is equivalent to <code>git reset --merge</code> when <code>MERGE_HEAD</code> is present unless <code>MERGE_AUTOSTASH</code> is also present in which case <code>git merge --abort</code> applies the stash entry to the worktree whereas <code>git reset --merge</code> will save the stashed changes in the stash list.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---quit"> --quit </dt> <dd> <p>Forget about the current merge in progress. Leave the index and the working tree as-is. If <code>MERGE_AUTOSTASH</code> is present, the stash entry will be saved to the stash list.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt---continue"> --continue </dt> <dd> <p>After a <code>git merge</code> stops due to conflicts you can conclude the merge by running <code>git merge --continue</code> (see "HOW TO RESOLVE CONFLICTS" section below).</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-ltcommitgt82308203"> <commit>… </dt> <dd> <p>Commits, usually other branch heads, to merge into our branch. Specifying more than one commit will create a merge with more than two parents (affectionately called an Octopus merge).</p> <p>If no commit is given from the command line, merge the remote-tracking branches that the current branch is configured to use as its upstream. See also the configuration section of this manual page.</p> <p>When <code>FETCH_HEAD</code> (and no other commit) is specified, the branches recorded in the <code>.git/FETCH_HEAD</code> file by the previous invocation of <code>git fetch</code> for merging are merged to the current branch.</p> </dd> </dl> </div> </div> <h2 id="_pre_merge_checks">Pre-merge checks</h2> <div class="sectionbody"> <p>Before applying outside changes, you should get your own work in good shape and committed locally, so it will not be clobbered if there are conflicts. See also <a href="git-stash">git-stash[1]</a>. <code>git pull</code> and <code>git merge</code> will stop without doing anything when local uncommitted changes overlap with files that <code>git pull</code>/<code>git +merge</code> may need to update.</p> <p>To avoid recording unrelated changes in the merge commit, <code>git pull</code> and <code>git merge</code> will also abort if there are any changes registered in the index relative to the <code>HEAD</code> commit. (Special narrow exceptions to this rule may exist depending on which merge strategy is in use, but generally, the index must match HEAD.)</p> <p>If all named commits are already ancestors of <code>HEAD</code>, <code>git merge</code> will exit early with the message "Already up to date."</p> </div> <h2 id="_fast_forward_merge">Fast-forward merge</h2> <div class="sectionbody"> <p>Often the current branch head is an ancestor of the named commit. This is the most common case especially when invoked from <code>git +pull</code>: you are tracking an upstream repository, you have committed no local changes, and now you want to update to a newer upstream revision. In this case, a new commit is not needed to store the combined history; instead, the <code>HEAD</code> (along with the index) is updated to point at the named commit, without creating an extra merge commit.</p> <p>This behavior can be suppressed with the <code>--no-ff</code> option.</p> </div> <h2 id="_true_merge">True merge</h2> <div class="sectionbody"> <p>Except in a fast-forward merge (see above), the branches to be merged must be tied together by a merge commit that has both of them as its parents.</p> <p>A merged version reconciling the changes from all branches to be merged is committed, and your <code>HEAD</code>, index, and working tree are updated to it. It is possible to have modifications in the working tree as long as they do not overlap; the update will preserve them.</p> <p>When it is not obvious how to reconcile the changes, the following happens:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>The <code>HEAD</code> pointer stays the same.</p> </li> <li> <p>The <code>MERGE_HEAD</code> ref is set to point to the other branch head.</p> </li> <li> <p>Paths that merged cleanly are updated both in the index file and in your working tree.</p> </li> <li> <p>For conflicting paths, the index file records up to three versions: stage 1 stores the version from the common ancestor, stage 2 from <code>HEAD</code>, and stage 3 from <code>MERGE_HEAD</code> (you can inspect the stages with <code>git ls-files -u</code>). The working tree files contain the result of the merge operation; i.e. 3-way merge results with familiar conflict markers <code><<<</code> <code>===</code> <code>>>></code>.</p> </li> <li> <p>A ref named <code>AUTO_MERGE</code> is written, pointing to a tree corresponding to the current content of the working tree (including conflict markers for textual conflicts). Note that this ref is only written when the <code>ort</code> merge strategy is used (the default).</p> </li> <li> <p>No other changes are made. In particular, the local modifications you had before you started merge will stay the same and the index entries for them stay as they were, i.e. matching <code>HEAD</code>.</p> </li> </ol> </div> <p>If you tried a merge which resulted in complex conflicts and want to start over, you can recover with <code>git merge --abort</code>.</p> </div> <h2 id="_merging_tag">Merging tag</h2> <div class="sectionbody"> <p>When merging an annotated (and possibly signed) tag, Git always creates a merge commit even if a fast-forward merge is possible, and the commit message template is prepared with the tag message. Additionally, if the tag is signed, the signature check is reported as a comment in the message template. See also <a href="git-tag">git-tag[1]</a>.</p> <p>When you want to just integrate with the work leading to the commit that happens to be tagged, e.g. synchronizing with an upstream release point, you may not want to make an unnecessary merge commit.</p> <p>In such a case, you can "unwrap" the tag yourself before feeding it to <code>git merge</code>, or pass <code>--ff-only</code> when you do not have any work on your own. e.g.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git fetch origin +git merge v1.2.3^0 +git merge --ff-only v1.2.3</pre> </div> </div> </div> <h2 id="_how_conflicts_are_presented">How conflicts are presented</h2> <div class="sectionbody"> <p>During a merge, the working tree files are updated to reflect the result of the merge. Among the changes made to the common ancestor’s version, non-overlapping ones (that is, you changed an area of the file while the other side left that area intact, or vice versa) are incorporated in the final result verbatim. When both sides made changes to the same area, however, Git cannot randomly pick one side over the other, and asks you to resolve it by leaving what both sides did to that area.</p> <p>By default, Git uses the same style as the one used by the "merge" program from the RCS suite to present such a conflicted hunk, like this:</p> <div class="listingblock"> <div class="content"> <pre>Here are lines that are either unchanged from the common +ancestor, or cleanly resolved because only one side changed, +or cleanly resolved because both sides changed the same way. +<<<<<<< yours:sample.txt +Conflict resolution is hard; +let's go shopping. +======= +Git makes conflict resolution easy. +>>>>>>> theirs:sample.txt +And here is another line that is cleanly resolved or unmodified.</pre> </div> </div> <p>The area where a pair of conflicting changes happened is marked with markers <code><<<<<<<</code>, <code>=======</code>, and <code>>>>>>>></code>. The part before the <code>=======</code> is typically your side, and the part afterwards is typically their side.</p> <p>The default format does not show what the original said in the conflicting area. You cannot tell how many lines are deleted and replaced with Barbie’s remark on your side. The only thing you can tell is that your side wants to say it is hard and you’d prefer to go shopping, while the other side wants to claim it is easy.</p> <p>An alternative style can be used by setting the <code>merge.conflictStyle</code> configuration variable to either "diff3" or "zdiff3". In "diff3" style, the above conflict may look like this:</p> <div class="listingblock"> <div class="content"> <pre>Here are lines that are either unchanged from the common +ancestor, or cleanly resolved because only one side changed, +<<<<<<< yours:sample.txt +or cleanly resolved because both sides changed the same way. +Conflict resolution is hard; +let's go shopping. +||||||| base:sample.txt +or cleanly resolved because both sides changed identically. +Conflict resolution is hard. +======= +or cleanly resolved because both sides changed the same way. +Git makes conflict resolution easy. +>>>>>>> theirs:sample.txt +And here is another line that is cleanly resolved or unmodified.</pre> </div> </div> <p>while in "zdiff3" style, it may look like this:</p> <div class="listingblock"> <div class="content"> <pre>Here are lines that are either unchanged from the common +ancestor, or cleanly resolved because only one side changed, +or cleanly resolved because both sides changed the same way. +<<<<<<< yours:sample.txt +Conflict resolution is hard; +let's go shopping. +||||||| base:sample.txt +or cleanly resolved because both sides changed identically. +Conflict resolution is hard. +======= +Git makes conflict resolution easy. +>>>>>>> theirs:sample.txt +And here is another line that is cleanly resolved or unmodified.</pre> </div> </div> <p>In addition to the <code><<<<<<<</code>, <code>=======</code>, and <code>>>>>>>></code> markers, it uses another <code>|||||||</code> marker that is followed by the original text. You can tell that the original just stated a fact, and your side simply gave in to that statement and gave up, while the other side tried to have a more positive attitude. You can sometimes come up with a better resolution by viewing the original.</p> </div> <h2 id="_how_to_resolve_conflicts">How to resolve conflicts</h2> <div class="sectionbody"> <p>After seeing a conflict, you can do two things:</p> <div class="ulist"> <ul> <li> <p>Decide not to merge. The only clean-ups you need are to reset the index file to the <code>HEAD</code> commit to reverse 2. and to clean up working tree changes made by 2. and 3.; <code>git merge --abort</code> can be used for this.</p> </li> <li> <p>Resolve the conflicts. Git will mark the conflicts in the working tree. Edit the files into shape and <code>git add</code> them to the index. Use <code>git commit</code> or <code>git merge --continue</code> to seal the deal. The latter command checks whether there is a (interrupted) merge in progress before calling <code>git commit</code>.</p> </li> </ul> </div> <p>You can work through the conflict with a number of tools:</p> <div class="ulist"> <ul> <li> <p>Use a mergetool. <code>git mergetool</code> to launch a graphical mergetool which will work through the merge with you.</p> </li> <li> <p>Look at the diffs. <code>git diff</code> will show a three-way diff, highlighting changes from both the <code>HEAD</code> and <code>MERGE_HEAD</code> versions. <code>git diff AUTO_MERGE</code> will show what changes you’ve made so far to resolve textual conflicts.</p> </li> <li> <p>Look at the diffs from each branch. <code>git log --merge -p <path></code> will show diffs first for the <code>HEAD</code> version and then the <code>MERGE_HEAD</code> version.</p> </li> <li> <p>Look at the originals. <code>git show :1:filename</code> shows the common ancestor, <code>git show :2:filename</code> shows the <code>HEAD</code> version, and <code>git show :3:filename</code> shows the <code>MERGE_HEAD</code> version.</p> </li> </ul> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Merge branches <code>fixes</code> and <code>enhancements</code> on top of the current branch, making an octopus merge:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git merge fixes enhancements</pre> </div> </div> </li> <li> <p>Merge branch <code>obsolete</code> into the current branch, using <code>ours</code> merge strategy:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git merge -s ours obsolete</pre> </div> </div> </li> <li> <p>Merge branch <code>maint</code> into the current branch, but do not make a new commit automatically:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git merge --no-commit maint</pre> </div> </div> <p>This can be used when you want to include further changes to the merge, or want to write your own merge commit message.</p> <p>You should refrain from abusing this option to sneak substantial changes into a merge commit. Small fixups like bumping release/version name would be acceptable.</p> </li> </ul> </div> </div> <h2 id="_merge_strategies">Merge strategies</h2> <div class="sectionbody"> <p>The merge mechanism (<code>git merge</code> and <code>git pull</code> commands) allows the backend <code>merge strategies</code> to be chosen with <code>-s</code> option. Some strategies can also take their own options, which can be passed by giving <code>-X<option></code> arguments to <code>git merge</code> and/or <code>git pull</code>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-merge.txt-ort"> ort </dt> <dd> <p>This is the default merge strategy when pulling or merging one branch. This strategy can only resolve two heads using a 3-way merge algorithm. When there is more than one common ancestor that can be used for 3-way merge, it creates a merged tree of the common ancestors and uses that as the reference tree for the 3-way merge. This has been reported to result in fewer merge conflicts without causing mismerges by tests done on actual merge commits taken from Linux 2.6 kernel development history. Additionally this strategy can detect and handle merges involving renames. It does not make use of detected copies. The name for this algorithm is an acronym ("Ostensibly Recursive’s Twin") and came from the fact that it was written as a replacement for the previous default algorithm, <code>recursive</code>.</p> <p>The <code>ort</code> strategy can take the following options:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-merge.txt-ours"> ours </dt> <dd> <p>This option forces conflicting hunks to be auto-resolved cleanly by favoring <code>our</code> version. Changes from the other tree that do not conflict with our side are reflected in the merge result. For a binary file, the entire contents are taken from our side.</p> <p>This should not be confused with the <code>ours</code> merge strategy, which does not even look at what the other tree contains at all. It discards everything the other tree did, declaring <code>our</code> history contains all that happened in it.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-theirs"> theirs </dt> <dd> <p>This is the opposite of <code>ours</code>; note that, unlike <code>ours</code>, there is no <code>theirs</code> merge strategy to confuse this merge option with.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-ignore-space-change"> ignore-space-change </dt> <dt class="hdlist1" id="Documentation/git-merge.txt-ignore-all-space"> ignore-all-space </dt> <dt class="hdlist1" id="Documentation/git-merge.txt-ignore-space-at-eol"> ignore-space-at-eol </dt> <dt class="hdlist1" id="Documentation/git-merge.txt-ignore-cr-at-eol"> ignore-cr-at-eol </dt> <dd> <p>Treats lines with the indicated type of whitespace change as unchanged for the sake of a three-way merge. Whitespace changes mixed with other changes to a line are not ignored. See also <a href="git-diff">git-diff[1]</a> <code>-b</code>, <code>-w</code>, <code>--ignore-space-at-eol</code>, and <code>--ignore-cr-at-eol</code>.</p> <div class="ulist"> <ul> <li> <p>If <code>their</code> version only introduces whitespace changes to a line, <code>our</code> version is used;</p> </li> <li> <p>If <code>our</code> version introduces whitespace changes but <code>their</code> version includes a substantial change, <code>their</code> version is used;</p> </li> <li> <p>Otherwise, the merge proceeds in the usual way.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-renormalize"> renormalize </dt> <dd> <p>This runs a virtual check-out and check-in of all three stages of a file when resolving a three-way merge. This option is meant to be used when merging branches with different clean filters or end-of-line normalization rules. See "Merging branches with differing checkin/checkout attributes" in <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-no-renormalize"> no-renormalize </dt> <dd> <p>Disables the <code>renormalize</code> option. This overrides the <code>merge.renormalize</code> configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-find-renamesltngt"> find-renames[=<n>] </dt> <dd> <p>Turn on rename detection, optionally setting the similarity threshold. This is the default. This overrides the <code>merge.renames</code> configuration variable. See also <a href="git-diff">git-diff[1]</a> <code>--find-renames</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-rename-thresholdltngt"> rename-threshold=<n> </dt> <dd> <p>Deprecated synonym for <code>find-renames=<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-subtreeltpathgt"> subtree[=<path>] </dt> <dd> <p>This option is a more advanced form of <code>subtree</code> strategy, where the strategy makes a guess on how two trees must be shifted to match with each other when merging. Instead, the specified path is prefixed (or stripped from the beginning) to make the shape of two trees to match.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-recursive"> recursive </dt> <dd> <p>This can only resolve two heads using a 3-way merge algorithm. When there is more than one common ancestor that can be used for 3-way merge, it creates a merged tree of the common ancestors and uses that as the reference tree for the 3-way merge. This has been reported to result in fewer merge conflicts without causing mismerges by tests done on actual merge commits taken from Linux 2.6 kernel development history. Additionally this can detect and handle merges involving renames. It does not make use of detected copies. This was the default strategy for resolving two heads from Git v0.99.9k until v2.33.0.</p> <p>The <code>recursive</code> strategy takes the same options as <code>ort</code>. However, there are three additional options that <code>ort</code> ignores (not documented above) that are potentially useful with the <code>recursive</code> strategy:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-merge.txt-patience"> patience </dt> <dd> <p>Deprecated synonym for <code>diff-algorithm=patience</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-diff-algorithmpatienceminimalhistogrammyers"> diff-algorithm=[patience|minimal|histogram|myers] </dt> <dd> <p>Use a different diff algorithm while merging, which can help avoid mismerges that occur due to unimportant matching lines (such as braces from distinct functions). See also <a href="git-diff">git-diff[1]</a> <code>--diff-algorithm</code>. Note that <code>ort</code> specifically uses <code>diff-algorithm=histogram</code>, while <code>recursive</code> defaults to the <code>diff.algorithm</code> config setting.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-no-renames"> no-renames </dt> <dd> <p>Turn off rename detection. This overrides the <code>merge.renames</code> configuration variable. See also <a href="git-diff">git-diff[1]</a> <code>--no-renames</code>.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-resolve"> resolve </dt> <dd> <p>This can only resolve two heads (i.e. the current branch and another branch you pulled from) using a 3-way merge algorithm. It tries to carefully detect criss-cross merge ambiguities. It does not handle renames.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-octopus"> octopus </dt> <dd> <p>This resolves cases with more than two heads, but refuses to do a complex merge that needs manual resolution. It is primarily meant to be used for bundling topic branch heads together. This is the default merge strategy when pulling or merging more than one branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-ours-1"> ours </dt> <dd> <p>This resolves any number of heads, but the resulting tree of the merge is always that of the current branch head, effectively ignoring all changes from all other branches. It is meant to be used to supersede old development history of side branches. Note that this is different from the -Xours option to the <code>recursive</code> merge strategy.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-subtree"> subtree </dt> <dd> <p>This is a modified <code>ort</code> strategy. When merging trees A and B, if B corresponds to a subtree of A, B is first adjusted to match the tree structure of A, instead of reading the trees at the same level. This adjustment is also done to the common ancestor tree.</p> </dd> </dl> </div> <p>With the strategies that use 3-way merge (including the default, <code>ort</code>), if a change is made on both branches, but later reverted on one of the branches, that change will be present in the merged result; some people find this behavior confusing. It occurs because only the heads and the merge base are considered when performing a merge, not the individual commits. The merge algorithm therefore considers the reverted change as no change at all, and substitutes the changed version instead.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-merge.txt-branchltnamegtmergeOptions"> branch.<name>.mergeOptions </dt> <dd> <p>Sets default options for merging into branch <name>. The syntax and supported options are the same as those of <code>git merge</code>, but option values containing whitespace characters are currently not supported.</p> </dd> </dl> </div> <p>Everything above this line in this section isn’t included from the <a href="git-config">git-config[1]</a> documentation. The content that follows is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-merge.txt-mergeconflictStyle"> merge.conflictStyle </dt> <dd> <p>Specify the style in which conflicted hunks are written out to working tree files upon merge. The default is "merge", which shows a <code><<<<<<<</code> conflict marker, changes made by one side, a <code>=======</code> marker, changes made by the other side, and then a <code>>>>>>>></code> marker. An alternate style, "diff3", adds a <code>|||||||</code> marker and the original text before the <code>=======</code> marker. The "merge" style tends to produce smaller conflict regions than diff3, both because of the exclusion of the original text, and because when a subset of lines match on the two sides, they are just pulled out of the conflict region. Another alternate style, "zdiff3", is similar to diff3 but removes matching lines on the two sides from the conflict region when those matching lines appear near either the beginning or end of a conflict region.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergedefaultToUpstream"> merge.defaultToUpstream </dt> <dd> <p>If merge is called without any commit argument, merge the upstream branches configured for the current branch by using their last observed values stored in their remote-tracking branches. The values of the <code>branch.<current branch>.merge</code> that name the branches at the remote named by <code>branch.<current branch>.remote</code> are consulted, and then they are mapped via <code>remote.<remote>.fetch</code> to their corresponding remote-tracking branches, and the tips of these tracking branches are merged. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergeff"> merge.ff </dt> <dd> <p>By default, Git does not create an extra merge commit when merging a commit that is a descendant of the current commit. Instead, the tip of the current branch is fast-forwarded. When set to <code>false</code>, this variable tells Git to create an extra merge commit in such a case (equivalent to giving the <code>--no-ff</code> option from the command line). When set to <code>only</code>, only such fast-forward merges are allowed (equivalent to giving the <code>--ff-only</code> option from the command line).</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergeverifySignatures"> merge.verifySignatures </dt> <dd> <p>If true, this is equivalent to the --verify-signatures command line option. See <a href="git-merge">git-merge[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergebranchdesc"> merge.branchdesc </dt> <dd> <p>In addition to branch names, populate the log message with the branch description text associated with them. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergelog"> merge.log </dt> <dd> <p>In addition to branch names, populate the log message with at most the specified number of one-line descriptions from the actual commits that are being merged. Defaults to false, and true is a synonym for 20.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergesuppressDest"> merge.suppressDest </dt> <dd> <p>By adding a glob that matches the names of integration branches to this multi-valued configuration variable, the default merge message computed for merges into these integration branches will omit "into <branch name>" from its title.</p> <p>An element with an empty value can be used to clear the list of globs accumulated from previous configuration entries. When there is no <code>merge.suppressDest</code> variable defined, the default value of <code>master</code> is used for backward compatibility.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergerenameLimit"> merge.renameLimit </dt> <dd> <p>The number of files to consider in the exhaustive portion of rename detection during a merge. If not specified, defaults to the value of diff.renameLimit. If neither merge.renameLimit nor diff.renameLimit are specified, currently defaults to 7000. This setting has no effect if rename detection is turned off.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergerenames"> merge.renames </dt> <dd> <p>Whether Git detects renames. If set to "false", rename detection is disabled. If set to "true", basic rename detection is enabled. Defaults to the value of diff.renames.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergedirectoryRenames"> merge.directoryRenames </dt> <dd> <p>Whether Git detects directory renames, affecting what happens at merge time to new files added to a directory on one side of history when that directory was renamed on the other side of history. If merge.directoryRenames is set to "false", directory rename detection is disabled, meaning that such new files will be left behind in the old directory. If set to "true", directory rename detection is enabled, meaning that such new files will be moved into the new directory. If set to "conflict", a conflict will be reported for such paths. If merge.renames is false, merge.directoryRenames is ignored and treated as false. Defaults to "conflict".</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergerenormalize"> merge.renormalize </dt> <dd> <p>Tell Git that canonical representation of files in the repository has changed over time (e.g. earlier commits record text files with CRLF line endings, but recent ones use LF line endings). In such a repository, Git can convert the data recorded in commits to a canonical form before performing a merge to reduce unnecessary conflicts. For more information, see section "Merging branches with differing checkin/checkout attributes" in <a href="gitattributes">gitattributes[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergestat"> merge.stat </dt> <dd> <p>Whether to print the diffstat between ORIG_HEAD and the merge result at the end of the merge. True by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergeautoStash"> merge.autoStash </dt> <dd> <p>When set to true, automatically create a temporary stash entry before the operation begins, and apply it after the operation ends. This means that you can run merge on a dirty worktree. However, use with care: the final stash application after a successful merge might result in non-trivial conflicts. This option can be overridden by the <code>--no-autostash</code> and <code>--autostash</code> options of <a href="git-merge">git-merge[1]</a>. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergetool"> merge.tool </dt> <dd> <p>Controls which merge tool is used by <a href="git-mergetool">git-mergetool[1]</a>. The list below shows the valid built-in values. Any other value is treated as a custom merge tool and requires that a corresponding mergetool.<tool>.cmd variable is defined.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergeguitool"> merge.guitool </dt> <dd> <p>Controls which merge tool is used by <a href="git-mergetool">git-mergetool[1]</a> when the -g/--gui flag is specified. The list below shows the valid built-in values. Any other value is treated as a custom merge tool and requires that a corresponding mergetool.<guitool>.cmd variable is defined.</p> <div class="ulist"> <ul> <li> <p>araxis</p> </li> <li> <p>bc</p> </li> <li> <p>codecompare</p> </li> <li> <p>deltawalker</p> </li> <li> <p>diffmerge</p> </li> <li> <p>diffuse</p> </li> <li> <p>ecmerge</p> </li> <li> <p>emerge</p> </li> <li> <p>examdiff</p> </li> <li> <p>guiffy</p> </li> <li> <p>gvimdiff</p> </li> <li> <p>kdiff3</p> </li> <li> <p>meld</p> </li> <li> <p>nvimdiff</p> </li> <li> <p>opendiff</p> </li> <li> <p>p4merge</p> </li> <li> <p>smerge</p> </li> <li> <p>tkdiff</p> </li> <li> <p>tortoisemerge</p> </li> <li> <p>vimdiff</p> </li> <li> <p>winmerge</p> </li> <li> <p>xxdiff</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergeverbosity"> merge.verbosity </dt> <dd> <p>Controls the amount of output shown by the recursive merge strategy. Level 0 outputs nothing except a final error message if conflicts were detected. Level 1 outputs only conflicts, 2 outputs conflicts and file changes. Level 5 and above outputs debugging information. The default is level 2. Can be overridden by the <code>GIT_MERGE_VERBOSITY</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergeltdrivergtname"> merge.<driver>.name </dt> <dd> <p>Defines a human-readable name for a custom low-level merge driver. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergeltdrivergtdriver"> merge.<driver>.driver </dt> <dd> <p>Defines the command that implements a custom low-level merge driver. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-merge.txt-mergeltdrivergtrecursive"> merge.<driver>.recursive </dt> <dd> <p>Names a low-level merge driver to be used when performing an internal merge between common ancestors. See <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-fmt-merge-msg">git-fmt-merge-msg[1]</a>, <a href="git-pull">git-pull[1]</a>, <a href="gitattributes">gitattributes[5]</a>, <a href="git-reset">git-reset[1]</a>, <a href="git-diff">git-diff[1]</a>, <a href="git-ls-files">git-ls-files[1]</a>, <a href="git-add">git-add[1]</a>, <a href="git-rm">git-rm[1]</a>, <a href="git-mergetool">git-mergetool[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-merge" class="_attribution-link">https://git-scm.com/docs/git-merge</a> + </p> +</div> diff --git a/devdocs/git/git-mergetool.html b/devdocs/git/git-mergetool.html new file mode 100644 index 00000000..d69168a2 --- /dev/null +++ b/devdocs/git/git-mergetool.html @@ -0,0 +1,76 @@ +<h1>git-mergetool</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-mergetool - Run merge conflict resolution tools to resolve merge conflicts</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git mergetool [--tool=<tool>] [-y | --[no-]prompt] [<file>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Use <code>git mergetool</code> to run one of several merge utilities to resolve merge conflicts. It is typically run after <code>git merge</code>.</p> <p>If one or more <file> parameters are given, the merge tool program will be run to resolve differences in each file (skipping those without conflicts). Specifying a directory will include all unresolved files in that path. If no <file> names are specified, <code>git mergetool</code> will run the merge tool program on every file with merge conflicts.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-mergetool.txt--tlttoolgt"> -t <tool> </dt> <dt class="hdlist1" id="Documentation/git-mergetool.txt---toollttoolgt"> --tool=<tool> </dt> <dd> <p>Use the merge resolution program specified by <tool>. Valid values include emerge, gvimdiff, kdiff3, meld, vimdiff, and tortoisemerge. Run <code>git mergetool --tool-help</code> for the list of valid <tool> settings.</p> <p>If a merge resolution program is not specified, <code>git mergetool</code> will use the configuration variable <code>merge.tool</code>. If the configuration variable <code>merge.tool</code> is not set, <code>git mergetool</code> will pick a suitable default.</p> <p>You can explicitly provide a full path to the tool by setting the configuration variable <code>mergetool.<tool>.path</code>. For example, you can configure the absolute path to kdiff3 by setting <code>mergetool.kdiff3.path</code>. Otherwise, <code>git mergetool</code> assumes the tool is available in PATH.</p> <p>Instead of running one of the known merge tool programs, <code>git mergetool</code> can be customized to run an alternative program by specifying the command line to invoke in a configuration variable <code>mergetool.<tool>.cmd</code>.</p> <p>When <code>git mergetool</code> is invoked with this tool (either through the <code>-t</code> or <code>--tool</code> option or the <code>merge.tool</code> configuration variable), the configured command line will be invoked with <code>$BASE</code> set to the name of a temporary file containing the common base for the merge, if available; <code>$LOCAL</code> set to the name of a temporary file containing the contents of the file on the current branch; <code>$REMOTE</code> set to the name of a temporary file containing the contents of the file to be merged, and <code>$MERGED</code> set to the name of the file to which the merge tool should write the result of the merge resolution.</p> <p>If the custom merge tool correctly indicates the success of a merge resolution with its exit code, then the configuration variable <code>mergetool.<tool>.trustExitCode</code> can be set to <code>true</code>. Otherwise, <code>git mergetool</code> will prompt the user to indicate the success of the resolution after the custom tool has exited.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt---tool-help"> --tool-help </dt> <dd> <p>Print a list of merge tools that may be used with <code>--tool</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt--y"> -y </dt> <dt class="hdlist1" id="Documentation/git-mergetool.txt---no-prompt"> --no-prompt </dt> <dd> <p>Don’t prompt before each invocation of the merge resolution program. This is the default if the merge resolution program is explicitly specified with the <code>--tool</code> option or with the <code>merge.tool</code> configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt---prompt"> --prompt </dt> <dd> <p>Prompt before each invocation of the merge resolution program to give the user a chance to skip the path.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt--g"> -g </dt> <dt class="hdlist1" id="Documentation/git-mergetool.txt---gui"> --gui </dt> <dd> <p>When <code>git-mergetool</code> is invoked with the <code>-g</code> or <code>--gui</code> option, the default merge tool will be read from the configured <code>merge.guitool</code> variable instead of <code>merge.tool</code>. If <code>merge.guitool</code> is not set, we will fallback to the tool configured under <code>merge.tool</code>. This may be autoselected using the configuration variable <code>mergetool.guiDefault</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt---no-gui"> --no-gui </dt> <dd> <p>This overrides a previous <code>-g</code> or <code>--gui</code> setting or <code>mergetool.guiDefault</code> configuration and reads the default merge tool from the configured <code>merge.tool</code> variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt--Oltorderfilegt"> -O<orderfile> </dt> <dd> <p>Process files in the order specified in the <orderfile>, which has one shell glob pattern per line. This overrides the <code>diff.orderFile</code> configuration variable (see <a href="git-config">git-config[1]</a>). To cancel <code>diff.orderFile</code>, use <code>-O/dev/null</code>.</p> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-mergetool.txt-mergetoollttoolgtpath"> mergetool.<tool>.path </dt> <dd> <p>Override the path for the given tool. This is useful in case your tool is not in the PATH.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt-mergetoollttoolgtcmd"> mergetool.<tool>.cmd </dt> <dd> <p>Specify the command to invoke the specified merge tool. The specified command is evaluated in shell with the following variables available: <code>BASE</code> is the name of a temporary file containing the common base of the files to be merged, if available; <code>LOCAL</code> is the name of a temporary file containing the contents of the file on the current branch; <code>REMOTE</code> is the name of a temporary file containing the contents of the file from the branch being merged; <code>MERGED</code> contains the name of the file to which the merge tool should write the results of a successful merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt-mergetoollttoolgthideResolved"> mergetool.<tool>.hideResolved </dt> <dd> <p>Allows the user to override the global <code>mergetool.hideResolved</code> value for a specific tool. See <code>mergetool.hideResolved</code> for the full description.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt-mergetoollttoolgttrustExitCode"> mergetool.<tool>.trustExitCode </dt> <dd> <p>For a custom merge command, specify whether the exit code of the merge command can be used to determine whether the merge was successful. If this is not set to true then the merge target file timestamp is checked, and the merge is assumed to have been successful if the file has been updated; otherwise, the user is prompted to indicate the success of the merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt-mergetoolmeldhasOutput"> mergetool.meld.hasOutput </dt> <dd> <p>Older versions of <code>meld</code> do not support the <code>--output</code> option. Git will attempt to detect whether <code>meld</code> supports <code>--output</code> by inspecting the output of <code>meld --help</code>. Configuring <code>mergetool.meld.hasOutput</code> will make Git skip these checks and use the configured value instead. Setting <code>mergetool.meld.hasOutput</code> to <code>true</code> tells Git to unconditionally use the <code>--output</code> option, and <code>false</code> avoids using <code>--output</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt-mergetoolmelduseAutoMerge"> mergetool.meld.useAutoMerge </dt> <dd> <p>When the <code>--auto-merge</code> is given, meld will merge all non-conflicting parts automatically, highlight the conflicting parts, and wait for user decision. Setting <code>mergetool.meld.useAutoMerge</code> to <code>true</code> tells Git to unconditionally use the <code>--auto-merge</code> option with <code>meld</code>. Setting this value to <code>auto</code> makes git detect whether <code>--auto-merge</code> is supported and will only use <code>--auto-merge</code> when available. A value of <code>false</code> avoids using <code>--auto-merge</code> altogether, and is the default value.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt-mergetoolvimdifflayout"> mergetool.vimdiff.layout </dt> <dd> <p>The vimdiff backend uses this variable to control how its split windows appear. Applies even if you are using Neovim (<code>nvim</code>) or gVim (<code>gvim</code>) as the merge tool. See BACKEND SPECIFIC HINTS section for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt-mergetoolhideResolved"> mergetool.hideResolved </dt> <dd> <p>During a merge, Git will automatically resolve as many conflicts as possible and write the <code>MERGED</code> file containing conflict markers around any conflicts that it cannot resolve; <code>LOCAL</code> and <code>REMOTE</code> normally represent the versions of the file from before Git’s conflict resolution. This flag causes <code>LOCAL</code> and <code>REMOTE</code> to be overwritten so that only the unresolved conflicts are presented to the merge tool. Can be configured per-tool via the <code>mergetool.<tool>.hideResolved</code> configuration variable. Defaults to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt-mergetoolkeepBackup"> mergetool.keepBackup </dt> <dd> <p>After performing a merge, the original file with conflict markers can be saved as a file with a <code>.orig</code> extension. If this variable is set to <code>false</code> then this file is not preserved. Defaults to <code>true</code> (i.e. keep the backup files).</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt-mergetoolkeepTemporaries"> mergetool.keepTemporaries </dt> <dd> <p>When invoking a custom merge tool, Git uses a set of temporary files to pass to the tool. If the tool returns an error and this variable is set to <code>true</code>, then these temporary files will be preserved; otherwise, they will be removed after the tool has exited. Defaults to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt-mergetoolwriteToTemp"> mergetool.writeToTemp </dt> <dd> <p>Git writes temporary <code>BASE</code>, <code>LOCAL</code>, and <code>REMOTE</code> versions of conflicting files in the worktree by default. Git will attempt to use a temporary directory for these files when set <code>true</code>. Defaults to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt-mergetoolprompt"> mergetool.prompt </dt> <dd> <p>Prompt before each invocation of the merge resolution program.</p> </dd> <dt class="hdlist1" id="Documentation/git-mergetool.txt-mergetoolguiDefault"> mergetool.guiDefault </dt> <dd> <p>Set <code>true</code> to use the <code>merge.guitool</code> by default (equivalent to specifying the <code>--gui</code> argument), or <code>auto</code> to select <code>merge.guitool</code> or <code>merge.tool</code> depending on the presence of a <code>DISPLAY</code> environment variable value. The default is <code>false</code>, where the <code>--gui</code> argument must be provided explicitly for the <code>merge.guitool</code> to be used.</p> </dd> </dl> </div> </div> <h2 id="_temporary_files">Temporary files</h2> <div class="sectionbody"> <p><code>git mergetool</code> creates <code>*.orig</code> backup files while resolving merges. These are safe to remove once a file has been merged and its <code>git mergetool</code> session has completed.</p> <p>Setting the <code>mergetool.keepBackup</code> configuration variable to <code>false</code> causes <code>git mergetool</code> to automatically remove the backup files as files are successfully merged.</p> </div> <h2 id="_backend_specific_hints">Backend specific hints</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_vimdiff"> +vimdiff</h3> <div class="sect3"> <h4 id="_description_2"> +Description</h4> <p>When specifying <code>--tool=vimdiff</code> in <code>git mergetool</code> Git will open Vim with a 4 windows layout distributed in the following way:</p> <div class="literalblock"> <div class="content"> <pre>------------------------------------------ +| | | | +| LOCAL | BASE | REMOTE | +| | | | +------------------------------------------ +| | +| MERGED | +| | +------------------------------------------</pre> </div> </div> <p><code>LOCAL</code>, <code>BASE</code> and <code>REMOTE</code> are read-only buffers showing the contents of the conflicting file in specific commits ("commit you are merging into", "common ancestor commit" and "commit you are merging from" respectively)</p> <p><code>MERGED</code> is a writable buffer where you have to resolve the conflicts (using the other read-only buffers as a reference). Once you are done, save and exit Vim as usual (<code>:wq</code>) or, if you want to abort, exit using <code>:cq</code>.</p> </div> <div class="sect3"> <h4 id="_layout_configuration"> +Layout configuration</h4> <p>You can change the windows layout used by Vim by setting configuration variable <code>mergetool.vimdiff.layout</code> which accepts a string where the following separators have special meaning:</p> <div class="ulist"> <ul> <li> <p><code>+</code> is used to "open a new tab"</p> </li> <li> <p><code>,</code> is used to "open a new vertical split"</p> </li> <li> <p><code>/</code> is used to "open a new horizontal split"</p> </li> <li> <p><code>@</code> is used to indicate the file containing the final version after solving the conflicts. If not present, <code>MERGED</code> will be used by default.</p> </li> </ul> </div> <p>The precedence of the operators is as follows (you can use parentheses to change it):</p> <div class="literalblock"> <div class="content"> <pre>`@` > `+` > `/` > `,`</pre> </div> </div> <p>Let’s see some examples to understand how it works:</p> <div class="ulist"> <ul> <li> <p><code>layout = "(LOCAL,BASE,REMOTE)/MERGED"</code></p> <div class="openblock"> <div class="content"> <p>This is exactly the same as the default layout we have already seen.</p> <p>Note that <code>/</code> has precedence over <code>,</code> and thus the parenthesis are not needed in this case. The next layout definition is equivalent:</p> <div class="literalblock"> <div class="content"> <pre>layout = "LOCAL,BASE,REMOTE / MERGED"</pre> </div> </div> </div> </div> </li> <li> <p><code>layout = "LOCAL,MERGED,REMOTE"</code></p> <div class="openblock"> <div class="content"> <p>If, for some reason, we are not interested in the <code>BASE</code> buffer.</p> <div class="literalblock"> <div class="content"> <pre>------------------------------------------ +| | | | +| | | | +| LOCAL | MERGED | REMOTE | +| | | | +| | | | +------------------------------------------</pre> </div> </div> </div> </div> </li> <li> <p><code>layout = "MERGED"</code></p> <div class="openblock"> <div class="content"> <p>Only the <code>MERGED</code> buffer will be shown. Note, however, that all the other ones are still loaded in vim, and you can access them with the "buffers" command.</p> <div class="literalblock"> <div class="content"> <pre>------------------------------------------ +| | +| | +| MERGED | +| | +| | +------------------------------------------</pre> </div> </div> </div> </div> </li> <li> <p><code>layout = "@LOCAL,REMOTE"</code></p> <div class="openblock"> <div class="content"> <p>When <code>MERGED</code> is not present in the layout, you must "mark" one of the buffers with an asterisk. That will become the buffer you need to edit and save after resolving the conflicts.</p> <div class="literalblock"> <div class="content"> <pre>------------------------------------------ +| | | +| | | +| | | +| LOCAL | REMOTE | +| | | +| | | +| | | +------------------------------------------</pre> </div> </div> </div> </div> </li> <li> <p><code>layout = "LOCAL,BASE,REMOTE / MERGED + BASE,LOCAL + BASE,REMOTE"</code></p> <div class="openblock"> <div class="content"> <p>Three tabs will open: the first one is a copy of the default layout, while the other two only show the differences between (<code>BASE</code> and <code>LOCAL</code>) and (<code>BASE</code> and <code>REMOTE</code>) respectively.</p> <div class="literalblock"> <div class="content"> <pre>------------------------------------------ +| <TAB #1> | TAB #2 | TAB #3 | | +------------------------------------------ +| | | | +| LOCAL | BASE | REMOTE | +| | | | +------------------------------------------ +| | +| MERGED | +| | +------------------------------------------</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>------------------------------------------ +| TAB #1 | <TAB #2> | TAB #3 | | +------------------------------------------ +| | | +| | | +| | | +| BASE | LOCAL | +| | | +| | | +| | | +------------------------------------------</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>------------------------------------------ +| TAB #1 | TAB #2 | <TAB #3> | | +------------------------------------------ +| | | +| | | +| | | +| BASE | REMOTE | +| | | +| | | +| | | +------------------------------------------</pre> </div> </div> </div> </div> </li> <li> <p><code>layout = "LOCAL,BASE,REMOTE / MERGED + BASE,LOCAL + BASE,REMOTE + (LOCAL/BASE/REMOTE),MERGED"</code></p> <div class="openblock"> <div class="content"> <p>Same as the previous example, but adds a fourth tab with the same information as the first tab, with a different layout.</p> <div class="literalblock"> <div class="content"> <pre>--------------------------------------------- +| TAB #1 | TAB #2 | TAB #3 | <TAB #4> | +--------------------------------------------- +| LOCAL | | +|---------------------| | +| BASE | MERGED | +|---------------------| | +| REMOTE | | +---------------------------------------------</pre> </div> </div> <p>Note how in the third tab definition we need to use parentheses to make <code>,</code> have precedence over <code>/</code>.</p> </div> </div> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_variants"> +Variants</h4> <p>Instead of <code>--tool=vimdiff</code>, you can also use one of these other variants:</p> <div class="ulist"> <ul> <li> <p><code>--tool=gvimdiff</code>, to open gVim instead of Vim.</p> </li> <li> <p><code>--tool=nvimdiff</code>, to open Neovim instead of Vim.</p> </li> </ul> </div> <p>When using these variants, in order to specify a custom layout you will have to set configuration variables <code>mergetool.gvimdiff.layout</code> and <code>mergetool.nvimdiff.layout</code> instead of <code>mergetool.vimdiff.layout</code></p> <p>In addition, for backwards compatibility with previous Git versions, you can also append <code>1</code>, <code>2</code> or <code>3</code> to either <code>vimdiff</code> or any of the variants (ex: <code>vimdiff3</code>, <code>nvimdiff1</code>, etc…) to use a predefined layout. In other words, using <code>--tool=[g,n,]vimdiffx</code> is the same as using <code>--tool=[g,n,]vimdiff</code> and setting configuration variable <code>mergetool.[g,n,]vimdiff.layout</code> to…</p> <div class="ulist"> <ul> <li> <p><code>x=1</code>: <code>"@LOCAL, REMOTE"</code></p> </li> <li> <p><code>x=2</code>: <code>"LOCAL, MERGED, REMOTE"</code></p> </li> <li> <p><code>x=3</code>: <code>"MERGED"</code></p> </li> </ul> </div> <p>Example: using <code>--tool=gvimdiff2</code> will open <code>gvim</code> with three columns (LOCAL, MERGED and REMOTE).</p> </div> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-mergetool" class="_attribution-link">https://git-scm.com/docs/git-mergetool</a> + </p> +</div> diff --git a/devdocs/git/git-mktag.html b/devdocs/git/git-mktag.html new file mode 100644 index 00000000..437b687d --- /dev/null +++ b/devdocs/git/git-mktag.html @@ -0,0 +1,10 @@ +<h1>git-mktag</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-mktag - Creates a tag object with extra validation</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git mktag</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Reads a tag’s contents on standard input and creates a tag object. The output is the new tag’s <object> identifier.</p> <p>This command is mostly equivalent to <a href="git-hash-object">git-hash-object[1]</a> invoked with <code>-t tag -w --stdin</code>. I.e. both of these will create and write a tag found in <code>my-tag</code>:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git mktag <my-tag +git hash-object -t tag -w --stdin <my-tag</pre> </div> </div> <p>The difference is that mktag will die before writing the tag if the tag doesn’t pass a <a href="git-fsck">git-fsck[1]</a> check.</p> <p>The "fsck" check done by mktag is stricter than what <a href="git-fsck">git-fsck[1]</a> would run by default in that all <code>fsck.<msg-id></code> messages are promoted from warnings to errors (so e.g. a missing "tagger" line is an error).</p> <p>Extra headers in the object are also an error under mktag, but ignored by <a href="git-fsck">git-fsck[1]</a>. This extra check can be turned off by setting the appropriate <code>fsck.<msg-id></code> variable:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git -c fsck.extraHeaderEntry=ignore mktag <my-tag-with-headers</pre> </div> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-mktag.txt---strict"> --strict </dt> <dd> <p>By default mktag turns on the equivalent of <a href="git-fsck">git-fsck[1]</a> <code>--strict</code> mode. Use <code>--no-strict</code> to disable it.</p> </dd> </dl> </div> </div> <h2 id="_tag_format">Tag format</h2> <div class="sectionbody"> <p>A tag signature file, to be fed to this command’s standard input, has a very simple fixed format: four lines of</p> <div class="literalblock"> <div class="content"> <pre>object <hash> +type <typename> +tag <tagname> +tagger <tagger></pre> </div> </div> <p>followed by some <code>optional</code> free-form message (some tags created by older Git may not have a <code>tagger</code> line). The message, when it exists, is separated by a blank line from the header. The message part may contain a signature that Git itself doesn’t care about, but that can be verified with gpg.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-mktag" class="_attribution-link">https://git-scm.com/docs/git-mktag</a> + </p> +</div> diff --git a/devdocs/git/git-mktree.html b/devdocs/git/git-mktree.html new file mode 100644 index 00000000..6fedd906 --- /dev/null +++ b/devdocs/git/git-mktree.html @@ -0,0 +1,6 @@ +<h1>git-mktree</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-mktree - Build a tree-object from ls-tree formatted text</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git mktree [-z] [--missing] [--batch]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Reads standard input in non-recursive <code>ls-tree</code> output format, and creates a tree object. The order of the tree entries is normalized by mktree so pre-sorting the input is not required. The object name of the tree object built is written to the standard output.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-mktree.txt--z"> -z </dt> <dd> <p>Read the NUL-terminated <code>ls-tree -z</code> output instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-mktree.txt---missing"> --missing </dt> <dd> <p>Allow missing objects. The default behaviour (without this option) is to verify that each tree entry’s hash identifies an existing object. This option has no effect on the treatment of gitlink entries (aka "submodules") which are always allowed to be missing.</p> </dd> <dt class="hdlist1" id="Documentation/git-mktree.txt---batch"> --batch </dt> <dd> <p>Allow building of more than one tree object before exiting. Each tree is separated by a single blank line. The final newline is optional. Note - if the <code>-z</code> option is used, lines are terminated with NUL.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-mktree" class="_attribution-link">https://git-scm.com/docs/git-mktree</a> + </p> +</div> diff --git a/devdocs/git/git-multi-pack-index.html b/devdocs/git/git-multi-pack-index.html new file mode 100644 index 00000000..95698245 --- /dev/null +++ b/devdocs/git/git-multi-pack-index.html @@ -0,0 +1,6 @@ +<h1>git-multi-pack-index</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-multi-pack-index - Write and verify multi-pack-indexes</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git multi-pack-index [--object-dir=<dir>] [--[no-]bitmap] <sub-command></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Write or verify a multi-pack-index (MIDX) file.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-multi-pack-index.txt---object-dirltdirgt"> --object-dir=<dir> </dt> <dd> <p>Use given directory for the location of Git objects. We check <code><dir>/packs/multi-pack-index</code> for the current MIDX file, and <code><dir>/packs</code> for the pack-files to index.</p> <p><code><dir></code> must be an alternate of the current repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-multi-pack-index.txt---no-progress"> --[no-]progress </dt> <dd> <p>Turn progress on/off explicitly. If neither is specified, progress is shown if standard error is connected to a terminal. Supported by sub-commands <code>write</code>, <code>verify</code>, <code>expire</code>, and `repack.</p> </dd> </dl> </div> <p>The following subcommands are available:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-multi-pack-index.txt-write"> write </dt> <dd> <p>Write a new MIDX file. The following options are available for the <code>write</code> sub-command:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-multi-pack-index.txt---preferred-packltpackgt"> --preferred-pack=<pack> </dt> <dd> <p>Optionally specify the tie-breaking pack used when multiple packs contain the same object. <code><pack></code> must contain at least one object. If not given, ties are broken in favor of the pack with the lowest mtime.</p> </dd> <dt class="hdlist1" id="Documentation/git-multi-pack-index.txt---no-bitmap"> --[no-]bitmap </dt> <dd> <p>Control whether or not a multi-pack bitmap is written.</p> </dd> <dt class="hdlist1" id="Documentation/git-multi-pack-index.txt---stdin-packs"> --stdin-packs </dt> <dd> <p>Write a multi-pack index containing only the set of line-delimited pack index basenames provided over stdin.</p> </dd> <dt class="hdlist1" id="Documentation/git-multi-pack-index.txt---refs-snapshotltpathgt"> --refs-snapshot=<path> </dt> <dd> <p>With <code>--bitmap</code>, optionally specify a file which contains a "refs snapshot" taken prior to repacking.</p> <p>A reference snapshot is composed of line-delimited OIDs corresponding to the reference tips, usually taken by <code>git repack</code> prior to generating a new pack. A line may optionally start with a <code>+</code> character to indicate that the reference which corresponds to that OID is "preferred" (see <a href="git-config">git-config[1]</a>'s <code>pack.preferBitmapTips</code>.)</p> <p>The file given at <code><path></code> is expected to be readable, and can contain duplicates. (If a given OID is given more than once, it is marked as preferred if at least one instance of it begins with the special <code>+</code> marker).</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-multi-pack-index.txt-verify"> verify </dt> <dd> <p>Verify the contents of the MIDX file.</p> </dd> <dt class="hdlist1" id="Documentation/git-multi-pack-index.txt-expire"> expire </dt> <dd> <p>Delete the pack-files that are tracked by the MIDX file, but have no objects referenced by the MIDX (with the exception of <code>.keep</code> packs and cruft packs). Rewrite the MIDX file afterward to remove all references to these pack-files.</p> </dd> <dt class="hdlist1" id="Documentation/git-multi-pack-index.txt-repack"> repack </dt> <dd> <p>Create a new pack-file containing objects in small pack-files referenced by the multi-pack-index. If the size given by the <code>--batch-size=<size></code> argument is zero, then create a pack containing all objects referenced by the multi-pack-index. For a non-zero batch size, Select the pack-files by examining packs from oldest-to-newest, computing the "expected size" by counting the number of objects in the pack referenced by the multi-pack-index, then divide by the total number of objects in the pack and multiply by the pack size. We select packs with expected size below the batch size until the set of packs have total expected size at least the batch size, or all pack-files are considered. If only one pack-file is selected, then do nothing. If a new pack-file is created, rewrite the multi-pack-index to reference the new pack-file. A later run of <code>git multi-pack-index expire</code> will delete the pack-files that were part of this batch.</p> <p>If <code>repack.packKeptObjects</code> is <code>false</code>, then any pack-files with an associated <code>.keep</code> file will not be selected for the batch to repack.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Write a MIDX file for the packfiles in the current <code>.git</code> directory.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git multi-pack-index write</pre> </div> </div> </li> <li> <p>Write a MIDX file for the packfiles in the current <code>.git</code> directory with a corresponding bitmap.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git multi-pack-index write --preferred-pack=<pack> --bitmap</pre> </div> </div> </li> <li> <p>Write a MIDX file for the packfiles in an alternate object store.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git multi-pack-index --object-dir <alt> write</pre> </div> </div> </li> <li> <p>Verify the MIDX file for the packfiles in the current <code>.git</code> directory.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git multi-pack-index verify</pre> </div> </div> </li> </ul> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p>See <a href="multi-pack-index">The Multi-Pack-Index Design Document</a> and <a href="gitformat-pack">gitformat-pack[5]</a> for more information on the multi-pack-index feature and its file format.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-multi-pack-index" class="_attribution-link">https://git-scm.com/docs/git-multi-pack-index</a> + </p> +</div> diff --git a/devdocs/git/git-mv.html b/devdocs/git/git-mv.html new file mode 100644 index 00000000..d21b324b --- /dev/null +++ b/devdocs/git/git-mv.html @@ -0,0 +1,7 @@ +<h1>git-mv</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-mv - Move or rename a file, a directory, or a symlink</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git mv [<options>] <source>… <destination></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Move or rename a file, directory, or symlink.</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git mv [-v] [-f] [-n] [-k] <source> <destination> +git mv [-v] [-f] [-n] [-k] <source> ... <destination directory></pre> </div> </div> <p>In the first form, it renames <source>, which must exist and be either a file, symlink or directory, to <destination>. In the second form, the last argument has to be an existing directory; the given sources will be moved into this directory.</p> <p>The index is updated after successful completion, but the change must still be committed.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-mv.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-mv.txt---force"> --force </dt> <dd> <p>Force renaming or moving of a file even if the <destination> exists.</p> </dd> <dt class="hdlist1" id="Documentation/git-mv.txt--k"> -k </dt> <dd> <p>Skip move or rename actions which would lead to an error condition. An error happens when a source is neither existing nor controlled by Git, or when it would overwrite an existing file unless <code>-f</code> is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-mv.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-mv.txt---dry-run"> --dry-run </dt> <dd> <p>Do nothing; only show what would happen</p> </dd> <dt class="hdlist1" id="Documentation/git-mv.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-mv.txt---verbose"> --verbose </dt> <dd> <p>Report the names of files as they are moved.</p> </dd> </dl> </div> </div> <h2 id="_submodules">Submodules</h2> <div class="sectionbody"> <p>Moving a submodule using a gitfile (which means they were cloned with a Git version 1.7.8 or newer) will update the gitfile and core.worktree setting to make the submodule work in the new location. It also will attempt to update the submodule.<name>.path setting in the <a href="gitmodules">gitmodules[5]</a> file and stage that file (unless -n is used).</p> </div> <h2 id="_bugs">Bugs</h2> <div class="sectionbody"> <p>Each time a superproject update moves a populated submodule (e.g. when switching between commits before and after the move) a stale submodule checkout will remain in the old location and an empty directory will appear in the new location. To populate the submodule again in the new location the user will have to run "git submodule update" afterwards. Removing the old directory is only safe when it uses a gitfile, as otherwise the history of the submodule will be deleted too. Both steps will be obsolete when recursive submodule update has been implemented.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-mv" class="_attribution-link">https://git-scm.com/docs/git-mv</a> + </p> +</div> diff --git a/devdocs/git/git-name-rev.html b/devdocs/git/git-name-rev.html new file mode 100644 index 00000000..3e8799c1 --- /dev/null +++ b/devdocs/git/git-name-rev.html @@ -0,0 +1,24 @@ +<h1>git-name-rev</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-name-rev - Find symbolic names for given revs</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git name-rev [--tags] [--refs=<pattern>] + ( --all | --annotate-stdin | <commit-ish>… )</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Finds symbolic names suitable for human digestion for revisions given in any format parsable by <code>git rev-parse</code>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-name-rev.txt---tags"> --tags </dt> <dd> <p>Do not use branch names, but only tags to name the commits</p> </dd> <dt class="hdlist1" id="Documentation/git-name-rev.txt---refsltpatterngt"> --refs=<pattern> </dt> <dd> <p>Only use refs whose names match a given shell pattern. The pattern can be a branch name, a tag name, or a fully qualified ref name. If given multiple times, use refs whose names match any of the given shell patterns. Use <code>--no-refs</code> to clear any previous ref patterns given.</p> </dd> <dt class="hdlist1" id="Documentation/git-name-rev.txt---excludeltpatterngt"> --exclude=<pattern> </dt> <dd> <p>Do not use any ref whose name matches a given shell pattern. The pattern can be one of branch name, tag name or fully qualified ref name. If given multiple times, a ref will be excluded when it matches any of the given patterns. When used together with --refs, a ref will be used as a match only when it matches at least one --refs pattern and does not match any --exclude patterns. Use <code>--no-exclude</code> to clear the list of exclude patterns.</p> </dd> <dt class="hdlist1" id="Documentation/git-name-rev.txt---all"> --all </dt> <dd> <p>List all commits reachable from all refs</p> </dd> <dt class="hdlist1" id="Documentation/git-name-rev.txt---annotate-stdin"> --annotate-stdin </dt> <dd> <p>Transform stdin by substituting all the 40-character SHA-1 hexes (say $hex) with "$hex ($rev_name)". When used with --name-only, substitute with "$rev_name", omitting $hex altogether. This option was called <code>--stdin</code> in older versions of Git.</p> <p>For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + +$ git name-rev --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master), +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + +$ git name-rev --name-only --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is master, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-name-rev.txt---name-only"> --name-only </dt> <dd> <p>Instead of printing both the SHA-1 and the name, print only the name. If given with --tags the usual tag prefix of "tags/" is also omitted from the name, matching the output of <code>git-describe</code> more closely.</p> </dd> <dt class="hdlist1" id="Documentation/git-name-rev.txt---no-undefined"> --no-undefined </dt> <dd> <p>Die with error code != 0 when a reference is undefined, instead of printing <code>undefined</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-name-rev.txt---always"> --always </dt> <dd> <p>Show uniquely abbreviated commit object as fallback.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>Given a commit, find out where it is relative to the local refs. Say somebody wrote you about that fantastic commit 33db5f4d9027a10e477ccf054b2c1ab94f74c85a. Of course, you look into the commit, but that only tells you what happened, but not the context.</p> <p>Enter <code>git name-rev</code>:</p> <div class="listingblock"> <div class="content"> <pre>% git name-rev 33db5f4d9027a10e477ccf054b2c1ab94f74c85a +33db5f4d9027a10e477ccf054b2c1ab94f74c85a tags/v0.99~940</pre> </div> </div> <p>Now you are wiser, because you know that it happened 940 revisions before v0.99.</p> <p>Another nice thing you can do is:</p> <div class="listingblock"> <div class="content"> <pre>% git log | git name-rev --annotate-stdin</pre> </div> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-name-rev" class="_attribution-link">https://git-scm.com/docs/git-name-rev</a> + </p> +</div> diff --git a/devdocs/git/git-notes.html b/devdocs/git/git-notes.html new file mode 100644 index 00000000..bba49883 --- /dev/null +++ b/devdocs/git/git-notes.html @@ -0,0 +1,25 @@ +<h1>git-notes</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-notes - Add or inspect object notes</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git notes [list [<object>]] +git notes add [-f] [--allow-empty] [--[no-]separator | --separator=<paragraph-break>] [--[no-]stripspace] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>] +git notes copy [-f] ( --stdin | <from-object> [<to-object>] ) +git notes append [--allow-empty] [--[no-]separator | --separator=<paragraph-break>] [--[no-]stripspace] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>] +git notes edit [--allow-empty] [<object>] [--[no-]stripspace] +git notes show [<object>] +git notes merge [-v | -q] [-s <strategy> ] <notes-ref> +git notes merge --commit [-v | -q] +git notes merge --abort [-v | -q] +git notes remove [--ignore-missing] [--stdin] [<object>…] +git notes prune [-n] [-v] +git notes get-ref</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Adds, removes, or reads notes attached to objects, without touching the objects themselves.</p> <p>By default, notes are saved to and read from <code>refs/notes/commits</code>, but this default can be overridden. See the OPTIONS, CONFIGURATION, and ENVIRONMENT sections below. If this ref does not exist, it will be quietly created when it is first needed to store a note.</p> <p>A typical use of notes is to supplement a commit message without changing the commit itself. Notes can be shown by <code>git log</code> along with the original commit message. To distinguish these notes from the message stored in the commit object, the notes are indented like the message, after an unindented line saying "Notes (<refname>):" (or "Notes:" for <code>refs/notes/commits</code>).</p> <p>Notes can also be added to patches prepared with <code>git format-patch</code> by using the <code>--notes</code> option. Such notes are added as a patch commentary after a three dash separator line.</p> <p>To change which notes are shown by <code>git log</code>, see the "notes.displayRef" discussion in <a href="#CONFIGURATION">CONFIGURATION</a>.</p> <p>See the "notes.rewrite.<command>" configuration for a way to carry notes across commands that rewrite commits.</p> </div> <h2 id="_subcommands">Subcommands</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-notes.txt-list"> list </dt> <dd> <p>List the notes object for a given object. If no object is given, show a list of all note objects and the objects they annotate (in the format "<note object> <annotated object>"). This is the default subcommand if no subcommand is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-add"> add </dt> <dd> <p>Add notes for a given object (defaults to HEAD). Abort if the object already has notes (use <code>-f</code> to overwrite existing notes). However, if you’re using <code>add</code> interactively (using an editor to supply the notes contents), then - instead of aborting - the existing notes will be opened in the editor (like the <code>edit</code> subcommand). If you specify multiple <code>-m</code> and <code>-F</code>, a blank line will be inserted between the messages. Use the <code>--separator</code> option to insert other delimiters.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-copy"> copy </dt> <dd> <p>Copy the notes for the first object onto the second object (defaults to HEAD). Abort if the second object already has notes, or if the first object has none (use -f to overwrite existing notes to the second object). This subcommand is equivalent to: <code>git notes add [-f] -C $(git notes list <from-object>) <to-object></code></p> <p>In <code>--stdin</code> mode, take lines in the format</p> <div class="listingblock"> <div class="content"> <pre><from-object> SP <to-object> [ SP <rest> ] LF</pre> </div> </div> <p>on standard input, and copy the notes from each <from-object> to its corresponding <to-object>. (The optional <code><rest></code> is ignored so that the command can read the input given to the <code>post-rewrite</code> hook.)</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-append"> append </dt> <dd> <p>Append new message(s) given by <code>-m</code> or <code>-F</code> options to an existing note, or add them as a new note if one does not exist, for the object (defaults to HEAD). When appending to an existing note, a blank line is added before each new message as an inter-paragraph separator. The separator can be customized with the <code>--separator</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-edit"> edit </dt> <dd> <p>Edit the notes for a given object (defaults to HEAD).</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-show"> show </dt> <dd> <p>Show the notes for a given object (defaults to HEAD).</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-merge"> merge </dt> <dd> <p>Merge the given notes ref into the current notes ref. This will try to merge the changes made by the given notes ref (called "remote") since the merge-base (if any) into the current notes ref (called "local").</p> <p>If conflicts arise and a strategy for automatically resolving conflicting notes (see the "NOTES MERGE STRATEGIES" section) is not given, the "manual" resolver is used. This resolver checks out the conflicting notes in a special worktree (<code>.git/NOTES_MERGE_WORKTREE</code>), and instructs the user to manually resolve the conflicts there. When done, the user can either finalize the merge with <code>git notes merge --commit</code>, or abort the merge with <code>git notes merge --abort</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-remove"> remove </dt> <dd> <p>Remove the notes for given objects (defaults to HEAD). When giving zero or one object from the command line, this is equivalent to specifying an empty note message to the <code>edit</code> subcommand.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-prune"> prune </dt> <dd> <p>Remove all notes for non-existing/unreachable objects.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-get-ref"> get-ref </dt> <dd> <p>Print the current notes ref. This provides an easy way to retrieve the current notes ref (e.g. from scripts).</p> </dd> </dl> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-notes.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-notes.txt---force"> --force </dt> <dd> <p>When adding notes to an object that already has notes, overwrite the existing notes (instead of aborting).</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt--mltmsggt"> -m <msg> </dt> <dt class="hdlist1" id="Documentation/git-notes.txt---messageltmsggt"> --message=<msg> </dt> <dd> <p>Use the given note message (instead of prompting). If multiple <code>-m</code> options are given, their values are concatenated as separate paragraphs. Lines starting with <code>#</code> and empty lines other than a single line between paragraphs will be stripped out. If you wish to keep them verbatim, use <code>--no-stripspace</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt--Fltfilegt"> -F <file> </dt> <dt class="hdlist1" id="Documentation/git-notes.txt---fileltfilegt"> --file=<file> </dt> <dd> <p>Take the note message from the given file. Use <code>-</code> to read the note message from the standard input. Lines starting with <code>#</code> and empty lines other than a single line between paragraphs will be stripped out. If you wish to keep them verbatim, use <code>--no-stripspace</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt--Cltobjectgt"> -C <object> </dt> <dt class="hdlist1" id="Documentation/git-notes.txt---reuse-messageltobjectgt"> --reuse-message=<object> </dt> <dd> <p>Take the given blob object (for example, another note) as the note message. (Use <code>git notes copy <object></code> instead to copy notes between objects.). By default, message will be copied verbatim, but if you wish to strip out the lines starting with <code>#</code> and empty lines other than a single line between paragraphs, use with`--stripspace` option.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt--cltobjectgt"> -c <object> </dt> <dt class="hdlist1" id="Documentation/git-notes.txt---reedit-messageltobjectgt"> --reedit-message=<object> </dt> <dd> <p>Like <code>-C</code>, but with <code>-c</code> the editor is invoked, so that the user can further edit the note message.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt---allow-empty"> --allow-empty </dt> <dd> <p>Allow an empty note object to be stored. The default behavior is to automatically remove empty notes.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt---no-separator--separatorltparagraph-breakgt"> --[no-]separator, --separator=<paragraph-break> </dt> <dd> <p>Specify a string used as a custom inter-paragraph separator (a newline is added at the end as needed). If <code>--no-separator</code>, no separators will be added between paragraphs. Defaults to a blank line.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt---no-stripspace"> --[no-]stripspace </dt> <dd> <p>Strip leading and trailing whitespace from the note message. Also strip out empty lines other than a single line between paragraphs. Lines starting with <code>#</code> will be stripped out in non-editor cases like <code>-m</code>, <code>-F</code> and <code>-C</code>, but not in editor case like <code>git notes edit</code>, <code>-c</code>, etc.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt---refltrefgt"> --ref <ref> </dt> <dd> <p>Manipulate the notes tree in <ref>. This overrides <code>GIT_NOTES_REF</code> and the "core.notesRef" configuration. The ref specifies the full refname when it begins with <code>refs/notes/</code>; when it begins with <code>notes/</code>, <code>refs/</code> and otherwise <code>refs/notes/</code> is prefixed to form a full name of the ref.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt---ignore-missing"> --ignore-missing </dt> <dd> <p>Do not consider it an error to request removing notes from an object that does not have notes attached to it.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt---stdin"> --stdin </dt> <dd> <p>Also read the object names to remove notes from the standard input (there is no reason you cannot combine this with object names from the command line).</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-notes.txt---dry-run"> --dry-run </dt> <dd> <p>Do not remove anything; just report the object names whose notes would be removed.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt--sltstrategygt"> -s <strategy> </dt> <dt class="hdlist1" id="Documentation/git-notes.txt---strategyltstrategygt"> --strategy=<strategy> </dt> <dd> <p>When merging notes, resolve notes conflicts using the given strategy. The following strategies are recognized: "manual" (default), "ours", "theirs", "union" and "cat_sort_uniq". This option overrides the "notes.mergeStrategy" configuration setting. See the "NOTES MERGE STRATEGIES" section below for more information on each notes merge strategy.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt---commit"> --commit </dt> <dd> <p>Finalize an in-progress <code>git notes merge</code>. Use this option when you have resolved the conflicts that <code>git notes merge</code> stored in .git/NOTES_MERGE_WORKTREE. This amends the partial merge commit created by <code>git notes merge</code> (stored in .git/NOTES_MERGE_PARTIAL) by adding the notes in .git/NOTES_MERGE_WORKTREE. The notes ref stored in the .git/NOTES_MERGE_REF symref is updated to the resulting commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt---abort"> --abort </dt> <dd> <p>Abort/reset an in-progress <code>git notes merge</code>, i.e. a notes merge with conflicts. This simply removes all files related to the notes merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-notes.txt---quiet"> --quiet </dt> <dd> <p>When merging notes, operate quietly.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-notes.txt---verbose"> --verbose </dt> <dd> <p>When merging notes, be more verbose. When pruning notes, report all object names whose notes are removed.</p> </dd> </dl> </div> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>Commit notes are blobs containing extra information about an object (usually information to supplement a commit’s message). These blobs are taken from notes refs. A notes ref is usually a branch which contains "files" whose paths are the object names for the objects they describe, with some directory separators included for performance reasons <sup class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnotedef_1" title="View footnote.">1</a>]</sup>.</p> <p>Every notes change creates a new commit at the specified notes ref. You can therefore inspect the history of the notes by invoking, e.g., <code>git log -p notes/commits</code>. Currently the commit message only records which operation triggered the update, and the commit authorship is determined according to the usual rules (see <a href="git-commit">git-commit[1]</a>). These details may change in the future.</p> <p>It is also permitted for a notes ref to point directly to a tree object, in which case the history of the notes can be read with <code>git log -p -g <refname></code>.</p> </div> <h2 id="_notes_merge_strategies">Notes merge strategies</h2> <div class="sectionbody"> <p>The default notes merge strategy is "manual", which checks out conflicting notes in a special work tree for resolving notes conflicts (<code>.git/NOTES_MERGE_WORKTREE</code>), and instructs the user to resolve the conflicts in that work tree. When done, the user can either finalize the merge with <code>git notes merge --commit</code>, or abort the merge with <code>git notes merge --abort</code>.</p> <p>Users may select an automated merge strategy from among the following using either -s/--strategy option or configuring notes.mergeStrategy accordingly:</p> <p>"ours" automatically resolves conflicting notes in favor of the local version (i.e. the current notes ref).</p> <p>"theirs" automatically resolves notes conflicts in favor of the remote version (i.e. the given notes ref being merged into the current notes ref).</p> <p>"union" automatically resolves notes conflicts by concatenating the local and remote versions.</p> <p>"cat_sort_uniq" is similar to "union", but in addition to concatenating the local and remote versions, this strategy also sorts the resulting lines, and removes duplicate lines from the result. This is equivalent to applying the "cat | sort | uniq" shell pipeline to the local and remote versions. This strategy is useful if the notes follow a line-based format where one wants to avoid duplicated lines in the merge result. Note that if either the local or remote version contain duplicate lines prior to the merge, these will also be removed by this notes merge strategy.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>You can use notes to add annotations with information that was not available at the time a commit was written.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git notes add -m 'Tested-by: Johannes Sixt <j6t@kdbg.org>' 72a144e2 +$ git show -s 72a144e +[...] + Signed-off-by: Junio C Hamano <gitster@pobox.com> + +Notes: + Tested-by: Johannes Sixt <j6t@kdbg.org></pre> </div> </div> <p>In principle, a note is a regular Git blob, and any kind of (non-)format is accepted. You can binary-safely create notes from arbitrary files using <code>git hash-object</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cc *.c +$ blob=$(git hash-object -w a.out) +$ git notes --ref=built add --allow-empty -C "$blob" HEAD</pre> </div> </div> <p>(You cannot simply use <code>git notes --ref=built add -F a.out HEAD</code> because that is not binary-safe.) Of course, it doesn’t make much sense to display non-text-format notes with <code>git log</code>, so if you use such notes, you’ll probably need to write some special-purpose tools to do something useful with them.</p> </div> <h2 id="CONFIGURATION">Configuration</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-notes.txt-corenotesRef"> core.notesRef </dt> <dd> <p>Notes ref to read and manipulate instead of <code>refs/notes/commits</code>. Must be an unabbreviated ref name. This setting can be overridden through the environment and command line.</p> </dd> </dl> </div> <p>Everything above this line in this section isn’t included from the <a href="git-config">git-config[1]</a> documentation. The content that follows is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-notes.txt-notesmergeStrategy"> notes.mergeStrategy </dt> <dd> <p>Which merge strategy to choose by default when resolving notes conflicts. Must be one of <code>manual</code>, <code>ours</code>, <code>theirs</code>, <code>union</code>, or <code>cat_sort_uniq</code>. Defaults to <code>manual</code>. See the "NOTES MERGE STRATEGIES" section of <a href="git-notes">git-notes[1]</a> for more information on each strategy.</p> <p>This setting can be overridden by passing the <code>--strategy</code> option to <a href="git-notes">git-notes[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-notesltnamegtmergeStrategy"> notes.<name>.mergeStrategy </dt> <dd> <p>Which merge strategy to choose when doing a notes merge into refs/notes/<name>. This overrides the more general "notes.mergeStrategy". See the "NOTES MERGE STRATEGIES" section in <a href="git-notes">git-notes[1]</a> for more information on the available strategies.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-notesdisplayRef"> notes.displayRef </dt> <dd> <p>Which ref (or refs, if a glob or specified more than once), in addition to the default set by <code>core.notesRef</code> or <code>GIT_NOTES_REF</code>, to read notes from when showing commit messages with the <code>git log</code> family of commands.</p> <p>This setting can be overridden with the <code>GIT_NOTES_DISPLAY_REF</code> environment variable, which must be a colon separated list of refs or globs.</p> <p>A warning will be issued for refs that do not exist, but a glob that does not match any refs is silently ignored.</p> <p>This setting can be disabled by the <code>--no-notes</code> option to the <code>git log</code> family of commands, or by the <code>--notes=<ref></code> option accepted by those commands.</p> <p>The effective value of "core.notesRef" (possibly overridden by GIT_NOTES_REF) is also implicitly added to the list of refs to be displayed.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-notesrewriteltcommandgt"> notes.rewrite.<command> </dt> <dd> <p>When rewriting commits with <command> (currently <code>amend</code> or <code>rebase</code>), if this variable is <code>false</code>, git will not copy notes from the original to the rewritten commit. Defaults to <code>true</code>. See also "<code>notes.rewriteRef</code>" below.</p> <p>This setting can be overridden with the <code>GIT_NOTES_REWRITE_REF</code> environment variable, which must be a colon separated list of refs or globs.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-notesrewriteMode"> notes.rewriteMode </dt> <dd> <p>When copying notes during a rewrite (see the "notes.rewrite.<command>" option), determines what to do if the target commit already has a note. Must be one of <code>overwrite</code>, <code>concatenate</code>, <code>cat_sort_uniq</code>, or <code>ignore</code>. Defaults to <code>concatenate</code>.</p> <p>This setting can be overridden with the <code>GIT_NOTES_REWRITE_MODE</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-notesrewriteRef"> notes.rewriteRef </dt> <dd> <p>When copying notes during a rewrite, specifies the (fully qualified) ref whose notes should be copied. May be a glob, in which case notes in all matching refs will be copied. You may also specify this configuration several times.</p> <p>Does not have a default value; you must configure this variable to enable note rewriting. Set it to <code>refs/notes/commits</code> to enable rewriting for the default commit notes.</p> <p>Can be overridden with the <code>GIT_NOTES_REWRITE_REF</code> environment variable. See <code>notes.rewrite.<command></code> above for a further description of its format.</p> </dd> </dl> </div> </div> <h2 id="_environment">Environment</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-notes.txt-codeGITNOTESREFcode"> <code>GIT_NOTES_REF</code> </dt> <dd> <p>Which ref to manipulate notes from, instead of <code>refs/notes/commits</code>. This overrides the <code>core.notesRef</code> setting.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-codeGITNOTESDISPLAYREFcode"> <code>GIT_NOTES_DISPLAY_REF</code> </dt> <dd> <p>Colon-delimited list of refs or globs indicating which refs, in addition to the default from <code>core.notesRef</code> or <code>GIT_NOTES_REF</code>, to read notes from when showing commit messages. This overrides the <code>notes.displayRef</code> setting.</p> <p>A warning will be issued for refs that do not exist, but a glob that does not match any refs is silently ignored.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-codeGITNOTESREWRITEMODEcode"> <code>GIT_NOTES_REWRITE_MODE</code> </dt> <dd> <p>When copying notes during a rewrite, what to do if the target commit already has a note. Must be one of <code>overwrite</code>, <code>concatenate</code>, <code>cat_sort_uniq</code>, or <code>ignore</code>. This overrides the <code>core.rewriteMode</code> setting.</p> </dd> <dt class="hdlist1" id="Documentation/git-notes.txt-codeGITNOTESREWRITEREFcode"> <code>GIT_NOTES_REWRITE_REF</code> </dt> <dd> <p>When rewriting commits, which notes to copy from the original to the rewritten commit. Must be a colon-delimited list of refs or globs.</p> <p>If not set in the environment, the list of notes to copy depends on the <code>notes.rewrite.<command></code> and <code>notes.rewriteRef</code> settings.</p> </dd> </dl> </div> </div> <hr> <div class="footnote" id="_footnotedef_1"> <a href="#_footnoteref_1">1</a>. Permitted pathnames have the form <em>bf</em><code>/</code><em>fe</em><code>/</code><em>30</em><code>/</code><em>…</em><code>/</code><em>680d5a…</em>: a sequence of directory names of two hexadecimal digits each followed by a filename with the rest of the object ID. </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-notes" class="_attribution-link">https://git-scm.com/docs/git-notes</a> + </p> +</div> diff --git a/devdocs/git/git-p4.html b/devdocs/git/git-p4.html new file mode 100644 index 00000000..ca75b9f9 --- /dev/null +++ b/devdocs/git/git-p4.html @@ -0,0 +1,45 @@ +<h1>git-p4</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-p4 - Import from and submit to Perforce repositories</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git p4 clone [<sync-options>] [<clone-options>] <p4-depot-path>… +git p4 sync [<sync-options>] [<p4-depot-path>…] +git p4 rebase +git p4 submit [<submit-options>] [<master-branch-name>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This command provides a way to interact with p4 repositories using Git.</p> <p>Create a new Git repository from an existing p4 repository using <code>git p4 clone</code>, giving it one or more p4 depot paths. Incorporate new commits from p4 changes with <code>git p4 sync</code>. The <code>sync</code> command is also used to include new branches from other p4 depot paths. Submit Git changes back to p4 using <code>git p4 submit</code>. The command <code>git p4 rebase</code> does a sync plus rebases the current branch onto the updated p4 remote branch.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Clone a repository:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git p4 clone //depot/path/project</pre> </div> </div> </li> <li> <p>Do some work in the newly created Git repository:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cd project +$ vi foo.h +$ git commit -a -m "edited foo.h"</pre> </div> </div> </li> <li> <p>Update the Git repository with recent changes from p4, rebasing your work on top:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git p4 rebase</pre> </div> </div> </li> <li> <p>Submit your commits back to p4:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git p4 submit</pre> </div> </div> </li> </ul> </div> </div> <h2 id="_commands">Commands</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_clone"> +Clone</h3> <p>Generally, <code>git p4 clone</code> is used to create a new Git directory from an existing p4 repository:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git p4 clone //depot/path/project</pre> </div> </div> <p>This:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Creates an empty Git repository in a subdirectory called <code>project</code>.</p> </li> <li> <p>Imports the full contents of the head revision from the given p4 depot path into a single commit in the Git branch <code>refs/remotes/p4/master</code>.</p> </li> <li> <p>Creates a local branch, <code>master</code> from this remote and checks it out.</p> </li> </ol> </div> <p>To reproduce the entire p4 history in Git, use the <code>@all</code> modifier on the depot path:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git p4 clone //depot/path/project@all</pre> </div> </div> </div> <div class="sect2"> <h3 id="_sync"> +Sync</h3> <p>As development continues in the p4 repository, those changes can be included in the Git repository using:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git p4 sync</pre> </div> </div> <p>This command finds new changes in p4 and imports them as Git commits.</p> <p>P4 repositories can be added to an existing Git repository using <code>git p4 sync</code> too:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ mkdir repo-git +$ cd repo-git +$ git init +$ git p4 sync //path/in/your/perforce/depot</pre> </div> </div> <p>This imports the specified depot into <code>refs/remotes/p4/master</code> in an existing Git repository. The <code>--branch</code> option can be used to specify a different branch to be used for the p4 content.</p> <p>If a Git repository includes branches <code>refs/remotes/origin/p4</code>, these will be fetched and consulted first during a <code>git p4 sync</code>. Since importing directly from p4 is considerably slower than pulling changes from a Git remote, this can be useful in a multi-developer environment.</p> <p>If there are multiple branches, doing <code>git p4 sync</code> will automatically use the "BRANCH DETECTION" algorithm to try to partition new changes into the right branch. This can be overridden with the <code>--branch</code> option to specify just a single branch to update.</p> </div> <div class="sect2"> <h3 id="_rebase"> +Rebase</h3> <p>A common working pattern is to fetch the latest changes from the p4 depot and merge them with local uncommitted changes. Often, the p4 repository is the ultimate location for all code, thus a rebase workflow makes sense. This command does <code>git p4 sync</code> followed by <code>git rebase</code> to move local commits on top of updated p4 changes.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git p4 rebase</pre> </div> </div> </div> <div class="sect2"> <h3 id="_submit"> +Submit</h3> <p>Submitting changes from a Git repository back to the p4 repository requires a separate p4 client workspace. This should be specified using the <code>P4CLIENT</code> environment variable or the Git configuration variable <code>git-p4.client</code>. The p4 client must exist, but the client root will be created and populated if it does not already exist.</p> <p>To submit all changes that are in the current Git branch but not in the <code>p4/master</code> branch, use:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git p4 submit</pre> </div> </div> <p>To specify a branch other than the current one, use:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git p4 submit topicbranch</pre> </div> </div> <p>To specify a single commit or a range of commits, use:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git p4 submit --commit <sha1> +$ git p4 submit --commit <sha1..sha1></pre> </div> </div> <p>The upstream reference is generally <code>refs/remotes/p4/master</code>, but can be overridden using the <code>--origin=</code> command-line option.</p> <p>The p4 changes will be created as the user invoking <code>git p4 submit</code>. The <code>--preserve-user</code> option will cause ownership to be modified according to the author of the Git commit. This option requires admin privileges in p4, which can be granted using <code>p4 protect</code>.</p> <p>To shelve changes instead of submitting, use <code>--shelve</code> and <code>--update-shelve</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git p4 submit --shelve +$ git p4 submit --update-shelve 1234 --update-shelve 2345</pre> </div> </div> </div> <div class="sect2"> <h3 id="_unshelve"> +Unshelve</h3> <p>Unshelving will take a shelved P4 changelist, and produce the equivalent git commit in the branch refs/remotes/p4-unshelved/<changelist>.</p> <p>The git commit is created relative to the current origin revision (HEAD by default). A parent commit is created based on the origin, and then the unshelve commit is created based on that.</p> <p>The origin revision can be changed with the "--origin" option.</p> <p>If the target branch in refs/remotes/p4-unshelved already exists, the old one will be renamed.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git p4 sync +$ git p4 unshelve 12345 +$ git show p4-unshelved/12345 +<submit more changes via p4 to the same files> +$ git p4 unshelve 12345 +<refuses to unshelve until git is in sync with p4 again></pre> </div> </div> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_general_options"> +General options</h3> <p>All commands except clone accept these options.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-p4.txt---git-dirltdirgt"> --git-dir <dir> </dt> <dd> <p>Set the <code>GIT_DIR</code> environment variable. See <a href="git">git[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-p4.txt---verbose"> --verbose </dt> <dd> <p>Provide more progress information.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_sync_options"> +Sync options</h3> <p>These options can be used in the initial <code>clone</code> as well as in subsequent <code>sync</code> operations.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-p4.txt---branchltrefgt"> --branch <ref> </dt> <dd> <p>Import changes into <ref> instead of refs/remotes/p4/master. If <ref> starts with refs/, it is used as is. Otherwise, if it does not start with p4/, that prefix is added.</p> <p>By default a <ref> not starting with refs/ is treated as the name of a remote-tracking branch (under refs/remotes/). This behavior can be modified using the --import-local option.</p> <p>The default <ref> is "master".</p> <p>This example imports a new remote "p4/proj2" into an existing Git repository:</p> <div class="listingblock"> <div class="content"> <pre> $ git init + $ git p4 sync --branch=refs/remotes/p4/proj2 //depot/proj2</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---detect-branches"> --detect-branches </dt> <dd> <p>Use the branch detection algorithm to find new paths in p4. It is documented below in "BRANCH DETECTION".</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---changesfileltfilegt"> --changesfile <file> </dt> <dd> <p>Import exactly the p4 change numbers listed in <code>file</code>, one per line. Normally, <code>git p4</code> inspects the current p4 repository state and detects the changes it should import.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---silent"> --silent </dt> <dd> <p>Do not print any progress information.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---detect-labels"> --detect-labels </dt> <dd> <p>Query p4 for labels associated with the depot paths, and add them as tags in Git. Limited usefulness as only imports labels associated with new changelists. Deprecated.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---import-labels"> --import-labels </dt> <dd> <p>Import labels from p4 into Git.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---import-local"> --import-local </dt> <dd> <p>By default, p4 branches are stored in <code>refs/remotes/p4/</code>, where they will be treated as remote-tracking branches by <a href="git-branch">git-branch[1]</a> and other commands. This option instead puts p4 branches in <code>refs/heads/p4/</code>. Note that future sync operations must specify <code>--import-local</code> as well so that they can find the p4 branches in refs/heads.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---max-changesltngt"> --max-changes <n> </dt> <dd> <p>Import at most <code>n</code> changes, rather than the entire range of changes included in the given revision specifier. A typical usage would be use <code>@all</code> as the revision specifier, but then to use <code>--max-changes 1000</code> to import only the last 1000 revisions rather than the entire revision history.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---changes-block-sizeltngt"> --changes-block-size <n> </dt> <dd> <p>The internal block size to use when converting a revision specifier such as <code>@all</code> into a list of specific change numbers. Instead of using a single call to <code>p4 changes</code> to find the full list of changes for the conversion, there are a sequence of calls to <code>p4 changes -m</code>, each of which requests one block of changes of the given size. The default block size is 500, which should usually be suitable.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---keep-path"> --keep-path </dt> <dd> <p>The mapping of file names from the p4 depot path to Git, by default, involves removing the entire depot path. With this option, the full p4 depot path is retained in Git. For example, path <code>//depot/main/foo/bar.c</code>, when imported from <code>//depot/main/</code>, becomes <code>foo/bar.c</code>. With <code>--keep-path</code>, the Git path is instead <code>depot/main/foo/bar.c</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---use-client-spec"> --use-client-spec </dt> <dd> <p>Use a client spec to find the list of interesting files in p4. See the "CLIENT SPEC" section below.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt--ltpathgt"> -/ <path> </dt> <dd> <p>Exclude selected depot paths when cloning or syncing.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_clone_options"> +Clone options</h3> <p>These options can be used in an initial <code>clone</code>, along with the <code>sync</code> options described above.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-p4.txt---destinationltdirectorygt"> --destination <directory> </dt> <dd> <p>Where to create the Git repository. If not provided, the last component in the p4 depot path is used to create a new directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---bare"> --bare </dt> <dd> <p>Perform a bare clone. See <a href="git-clone">git-clone[1]</a>.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_submit_options"> +Submit options</h3> <p>These options can be used to modify <code>git p4 submit</code> behavior.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-p4.txt---originltcommitgt"> --origin <commit> </dt> <dd> <p>Upstream location from which commits are identified to submit to p4. By default, this is the most recent p4 commit reachable from <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt--M"> -M </dt> <dd> <p>Detect renames. See <a href="git-diff">git-diff[1]</a>. Renames will be represented in p4 using explicit <code>move</code> operations. There is no corresponding option to detect copies, but there are variables for both moves and copies.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---preserve-user"> --preserve-user </dt> <dd> <p>Re-author p4 changes before submitting to p4. This option requires p4 admin privileges.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---export-labels"> --export-labels </dt> <dd> <p>Export tags from Git as p4 labels. Tags found in Git are applied to the perforce working directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-p4.txt---dry-run"> --dry-run </dt> <dd> <p>Show just what commits would be submitted to p4; do not change state in Git or p4.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---prepare-p4-only"> --prepare-p4-only </dt> <dd> <p>Apply a commit to the p4 workspace, opening, adding and deleting files in p4 as for a normal submit operation. Do not issue the final "p4 submit", but instead print a message about how to submit manually or revert. This option always stops after the first (oldest) commit. Git tags are not exported to p4.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---shelve"> --shelve </dt> <dd> <p>Instead of submitting create a series of shelved changelists. After creating each shelve, the relevant files are reverted/deleted. If you have multiple commits pending multiple shelves will be created.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---update-shelveCHANGELIST"> --update-shelve CHANGELIST </dt> <dd> <p>Update an existing shelved changelist with this commit. Implies --shelve. Repeat for multiple shelved changelists.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---conflictaskskipquit"> --conflict=(ask|skip|quit) </dt> <dd> <p>Conflicts can occur when applying a commit to p4. When this happens, the default behavior ("ask") is to prompt whether to skip this commit and continue, or quit. This option can be used to bypass the prompt, causing conflicting commits to be automatically skipped, or to quit trying to apply commits, without prompting.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---branchltbranchgt"> --branch <branch> </dt> <dd> <p>After submitting, sync this named branch instead of the default p4/master. See the "Sync options" section above for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---commitltsha1gtltsha1gtltsha1gt"> --commit (<sha1>|<sha1>..<sha1>) </dt> <dd> <p>Submit only the specified commit or range of commits, instead of the full list of changes that are in the current Git branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---disable-rebase"> --disable-rebase </dt> <dd> <p>Disable the automatic rebase after all commits have been successfully submitted. Can also be set with git-p4.disableRebase.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt---disable-p4sync"> --disable-p4sync </dt> <dd> <p>Disable the automatic sync of p4/master from Perforce after commits have been submitted. Implies --disable-rebase. Can also be set with git-p4.disableP4Sync. Sync with origin/master still goes ahead if possible.</p> </dd> </dl> </div> </div> </div> <h2 id="_hooks_for_submit">Hooks for submit</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_p4_pre_submit"> +p4-pre-submit</h3> <p>The <code>p4-pre-submit</code> hook is executed if it exists and is executable. The hook takes no parameters and nothing from standard input. Exiting with non-zero status from this script prevents <code>git-p4 submit</code> from launching. It can be bypassed with the <code>--no-verify</code> command line option.</p> <p>One usage scenario is to run unit tests in the hook.</p> </div> <div class="sect2"> <h3 id="_p4_prepare_changelist"> +p4-prepare-changelist</h3> <p>The <code>p4-prepare-changelist</code> hook is executed right after preparing the default changelist message and before the editor is started. It takes one parameter, the name of the file that contains the changelist text. Exiting with a non-zero status from the script will abort the process.</p> <p>The purpose of the hook is to edit the message file in place, and it is not suppressed by the <code>--no-verify</code> option. This hook is called even if <code>--prepare-p4-only</code> is set.</p> </div> <div class="sect2"> <h3 id="_p4_changelist"> +p4-changelist</h3> <p>The <code>p4-changelist</code> hook is executed after the changelist message has been edited by the user. It can be bypassed with the <code>--no-verify</code> option. It takes a single parameter, the name of the file that holds the proposed changelist text. Exiting with a non-zero status causes the command to abort.</p> <p>The hook is allowed to edit the changelist file and can be used to normalize the text into some project standard format. It can also be used to refuse the Submit after inspect the message file.</p> </div> <div class="sect2"> <h3 id="_p4_post_changelist"> +p4-post-changelist</h3> <p>The <code>p4-post-changelist</code> hook is invoked after the submit has successfully occurred in P4. It takes no parameters and is meant primarily for notification and cannot affect the outcome of the git p4 submit action.</p> </div> <div class="sect2"> <h3 id="_rebase_options"> +Rebase options</h3> <p>These options can be used to modify <code>git p4 rebase</code> behavior.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-p4.txt---import-labels-1"> --import-labels </dt> <dd> <p>Import p4 labels.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_unshelve_options"> +Unshelve options</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-p4.txt---origin"> --origin </dt> <dd> <p>Sets the git refspec against which the shelved P4 changelist is compared. Defaults to p4/master.</p> </dd> </dl> </div> </div> </div> <h2 id="_depot_path_syntax">Depot path syntax</h2> <div class="sectionbody"> <p>The p4 depot path argument to <code>git p4 sync</code> and <code>git p4 clone</code> can be one or more space-separated p4 depot paths, with an optional p4 revision specifier on the end:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-p4.txt-depotmyproject"> "//depot/my/project" </dt> <dd> <p>Import one commit with all files in the <code>#head</code> change under that tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-depotmyprojectall"> "//depot/my/project@all" </dt> <dd> <p>Import one commit for each change in the history of that depot path.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-depotmyproject16"> "//depot/my/project@1,6" </dt> <dd> <p>Import only changes 1 through 6.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-depotproj1alldepotproj2all"> "//depot/proj1@all //depot/proj2@all" </dt> <dd> <p>Import all changes from both named depot paths into a single repository. Only files below these directories are included. There is not a subdirectory in Git for each "proj1" and "proj2". You must use the <code>--destination</code> option when specifying more than one depot path. The revision specifier must be specified identically on each depot path. If there are files in the depot paths with the same name, the path with the most recently updated version of the file is the one that appears in Git.</p> </dd> </dl> </div> <p>See <code>p4 help revisions</code> for the full syntax of p4 revision specifiers.</p> </div> <h2 id="_client_spec">Client spec</h2> <div class="sectionbody"> <p>The p4 client specification is maintained with the <code>p4 client</code> command and contains among other fields, a View that specifies how the depot is mapped into the client repository. The <code>clone</code> and <code>sync</code> commands can consult the client spec when given the <code>--use-client-spec</code> option or when the useClientSpec variable is true. After <code>git p4 clone</code>, the useClientSpec variable is automatically set in the repository configuration file. This allows future <code>git p4 submit</code> commands to work properly; the submit command looks only at the variable and does not have a command-line option.</p> <p>The full syntax for a p4 view is documented in <code>p4 help views</code>. <code>git p4</code> knows only a subset of the view syntax. It understands multi-line mappings, overlays with <code>+</code>, exclusions with <code>-</code> and double-quotes around whitespace. Of the possible wildcards, <code>git p4</code> only handles <code>…</code>, and only when it is at the end of the path. <code>git p4</code> will complain if it encounters an unhandled wildcard.</p> <p>Bugs in the implementation of overlap mappings exist. If multiple depot paths map through overlays to the same location in the repository, <code>git p4</code> can choose the wrong one. This is hard to solve without dedicating a client spec just for <code>git p4</code>.</p> <p>The name of the client can be given to <code>git p4</code> in multiple ways. The variable <code>git-p4.client</code> takes precedence if it exists. Otherwise, normal p4 mechanisms of determining the client are used: environment variable <code>P4CLIENT</code>, a file referenced by <code>P4CONFIG</code>, or the local host name.</p> </div> <h2 id="_branch_detection">Branch detection</h2> <div class="sectionbody"> <p>P4 does not have the same concept of a branch as Git. Instead, p4 organizes its content as a directory tree, where by convention different logical branches are in different locations in the tree. The <code>p4 branch</code> command is used to maintain mappings between different areas in the tree, and indicate related content. <code>git p4</code> can use these mappings to determine branch relationships.</p> <p>If you have a repository where all the branches of interest exist as subdirectories of a single depot path, you can use <code>--detect-branches</code> when cloning or syncing to have <code>git p4</code> automatically find subdirectories in p4, and to generate these as branches in Git.</p> <p>For example, if the P4 repository structure is:</p> <div class="listingblock"> <div class="content"> <pre>//depot/main/... +//depot/branch1/...</pre> </div> </div> <p>And "p4 branch -o branch1" shows a View line that looks like:</p> <div class="listingblock"> <div class="content"> <pre>//depot/main/... //depot/branch1/...</pre> </div> </div> <p>Then this <code>git p4 clone</code> command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git p4 clone --detect-branches //depot@all</pre> </div> </div> <p>produces a separate branch in <code>refs/remotes/p4/</code> for //depot/main, called <code>master</code>, and one for //depot/branch1 called <code>depot/branch1</code>.</p> <p>However, it is not necessary to create branches in p4 to be able to use them like branches. Because it is difficult to infer branch relationships automatically, a Git configuration setting <code>git-p4.branchList</code> can be used to explicitly identify branch relationships. It is a list of "source:destination" pairs, like a simple p4 branch specification, where the "source" and "destination" are the path elements in the p4 repository. The example above relied on the presence of the p4 branch. Without p4 branches, the same result will occur with:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git init depot +cd depot +git config git-p4.branchList main:branch1 +git p4 clone --detect-branches //depot@all .</pre> </div> </div> </div> <h2 id="_performance">Performance</h2> <div class="sectionbody"> <p>The fast-import mechanism used by <code>git p4</code> creates one pack file for each invocation of <code>git p4 sync</code>. Normally, Git garbage compression (<a href="git-gc">git-gc[1]</a>) automatically compresses these to fewer pack files, but explicit invocation of <code>git repack -adf</code> may improve performance.</p> </div> <h2 id="_configuration_variables">Configuration variables</h2> <div class="sectionbody"> <p>The following config settings can be used to modify <code>git p4</code> behavior. They all are in the <code>git-p4</code> section.</p> <div class="sect2"> <h3 id="_general_variables"> +General variables</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4user"> git-p4.user </dt> <dd> <p>User specified as an option to all p4 commands, with <code>-u <user></code>. The environment variable <code>P4USER</code> can be used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4password"> git-p4.password </dt> <dd> <p>Password specified as an option to all p4 commands, with <code>-P <password></code>. The environment variable <code>P4PASS</code> can be used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4port"> git-p4.port </dt> <dd> <p>Port specified as an option to all p4 commands, with <code>-p <port></code>. The environment variable <code>P4PORT</code> can be used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4host"> git-p4.host </dt> <dd> <p>Host specified as an option to all p4 commands, with <code>-h <host></code>. The environment variable <code>P4HOST</code> can be used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4client"> git-p4.client </dt> <dd> <p>Client specified as an option to all p4 commands, with <code>-c <client></code>, including the client spec.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4retries"> git-p4.retries </dt> <dd> <p>Specifies the number of times to retry a p4 command (notably, <code>p4 sync</code>) if the network times out. The default value is 3. Set the value to 0 to disable retries or if your p4 version does not support retries (pre 2012.2).</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_clone_and_sync_variables"> +Clone and sync variables</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4syncFromOrigin"> git-p4.syncFromOrigin </dt> <dd> <p>Because importing commits from other Git repositories is much faster than importing them from p4, a mechanism exists to find p4 changes first in Git remotes. If branches exist under <code>refs/remote/origin/p4</code>, those will be fetched and used when syncing from p4. This variable can be set to <code>false</code> to disable this behavior.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4branchUser"> git-p4.branchUser </dt> <dd> <p>One phase in branch detection involves looking at p4 branches to find new ones to import. By default, all branches are inspected. This option limits the search to just those owned by the single user named in the variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4branchList"> git-p4.branchList </dt> <dd> <p>List of branches to be imported when branch detection is enabled. Each entry should be a pair of branch names separated by a colon (:). This example declares that both branchA and branchB were created from main:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git config git-p4.branchList main:branchA +git config --add git-p4.branchList main:branchB</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4ignoredP4Labels"> git-p4.ignoredP4Labels </dt> <dd> <p>List of p4 labels to ignore. This is built automatically as unimportable labels are discovered.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4importLabels"> git-p4.importLabels </dt> <dd> <p>Import p4 labels into git, as per --import-labels.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4labelImportRegexp"> git-p4.labelImportRegexp </dt> <dd> <p>Only p4 labels matching this regular expression will be imported. The default value is <code>[a-zA-Z0-9_\-.]+$</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4useClientSpec"> git-p4.useClientSpec </dt> <dd> <p>Specify that the p4 client spec should be used to identify p4 depot paths of interest. This is equivalent to specifying the option <code>--use-client-spec</code>. See the "CLIENT SPEC" section above. This variable is a boolean, not the name of a p4 client.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4pathEncoding"> git-p4.pathEncoding </dt> <dd> <p>Perforce keeps the encoding of a path as given by the originating OS. Git expects paths encoded as UTF-8. Use this config to tell git-p4 what encoding Perforce had used for the paths. This encoding is used to transcode the paths to UTF-8. As an example, Perforce on Windows often uses "cp1252" to encode path names. If this option is passed into a p4 clone request, it is persisted in the resulting new git repo.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4metadataDecodingStrategy"> git-p4.metadataDecodingStrategy </dt> <dd> <p>Perforce keeps the encoding of a changelist descriptions and user full names as stored by the client on a given OS. The p4v client uses the OS-local encoding, and so different users can end up storing different changelist descriptions or user full names in different encodings, in the same depot. Git tolerates inconsistent/incorrect encodings in commit messages and author names, but expects them to be specified in utf-8. git-p4 can use three different decoding strategies in handling the encoding uncertainty in Perforce: <code>passthrough</code> simply passes the original bytes through from Perforce to git, creating usable but incorrectly-encoded data when the Perforce data is encoded as anything other than utf-8. <code>strict</code> expects the Perforce data to be encoded as utf-8, and fails to import when this is not true. <code>fallback</code> attempts to interpret the data as utf-8, and otherwise falls back to using a secondary encoding - by default the common windows encoding <code>cp-1252</code> - with upper-range bytes escaped if decoding with the fallback encoding also fails. Under python2 the default strategy is <code>passthrough</code> for historical reasons, and under python3 the default is <code>fallback</code>. When <code>strict</code> is selected and decoding fails, the error message will propose changing this config parameter as a workaround. If this option is passed into a p4 clone request, it is persisted into the resulting new git repo.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4metadataFallbackEncoding"> git-p4.metadataFallbackEncoding </dt> <dd> <p>Specify the fallback encoding to use when decoding Perforce author names and changelists descriptions using the <code>fallback</code> strategy (see git-p4.metadataDecodingStrategy). The fallback encoding will only be used when decoding as utf-8 fails. This option defaults to cp1252, a common windows encoding. If this option is passed into a p4 clone request, it is persisted into the resulting new git repo.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4largeFileSystem"> git-p4.largeFileSystem </dt> <dd> <p>Specify the system that is used for large (binary) files. Please note that large file systems do not support the <code>git p4 submit</code> command. Only Git LFS is implemented right now (see <a href="https://git-lfs.github.com/" class="bare">https://git-lfs.github.com/</a> for more information). Download and install the Git LFS command line extension to use this option and configure it like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git config git-p4.largeFileSystem GitLFS</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4largeFileExtensions"> git-p4.largeFileExtensions </dt> <dd> <p>All files matching a file extension in the list will be processed by the large file system. Do not prefix the extensions with <code>.</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4largeFileThreshold"> git-p4.largeFileThreshold </dt> <dd> <p>All files with an uncompressed size exceeding the threshold will be processed by the large file system. By default the threshold is defined in bytes. Add the suffix k, m, or g to change the unit.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4largeFileCompressedThreshold"> git-p4.largeFileCompressedThreshold </dt> <dd> <p>All files with a compressed size exceeding the threshold will be processed by the large file system. This option might slow down your clone/sync process. By default the threshold is defined in bytes. Add the suffix k, m, or g to change the unit.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4largeFilePush"> git-p4.largeFilePush </dt> <dd> <p>Boolean variable which defines if large files are automatically pushed to a server.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4keepEmptyCommits"> git-p4.keepEmptyCommits </dt> <dd> <p>A changelist that contains only excluded files will be imported as an empty commit if this boolean option is set to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4mapUser"> git-p4.mapUser </dt> <dd> <p>Map a P4 user to a name and email address in Git. Use a string with the following format to create a mapping:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git config --add git-p4.mapUser "p4user = First Last <mail@address.com>"</pre> </div> </div> <p>A mapping will override any user information from P4. Mappings for multiple P4 user can be defined.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_submit_variables"> +Submit variables</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4detectRenames"> git-p4.detectRenames </dt> <dd> <p>Detect renames. See <a href="git-diff">git-diff[1]</a>. This can be true, false, or a score as expected by <code>git diff -M</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4detectCopies"> git-p4.detectCopies </dt> <dd> <p>Detect copies. See <a href="git-diff">git-diff[1]</a>. This can be true, false, or a score as expected by <code>git diff -C</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4detectCopiesHarder"> git-p4.detectCopiesHarder </dt> <dd> <p>Detect copies harder. See <a href="git-diff">git-diff[1]</a>. A boolean.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4preserveUser"> git-p4.preserveUser </dt> <dd> <p>On submit, re-author changes to reflect the Git author, regardless of who invokes <code>git p4 submit</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4allowMissingP4Users"> git-p4.allowMissingP4Users </dt> <dd> <p>When <code>preserveUser</code> is true, <code>git p4</code> normally dies if it cannot find an author in the p4 user map. This setting submits the change regardless.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4skipSubmitEdit"> git-p4.skipSubmitEdit </dt> <dd> <p>The submit process invokes the editor before each p4 change is submitted. If this setting is true, though, the editing step is skipped.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4skipSubmitEditCheck"> git-p4.skipSubmitEditCheck </dt> <dd> <p>After editing the p4 change message, <code>git p4</code> makes sure that the description really was changed by looking at the file modification time. This option disables that test.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4allowSubmit"> git-p4.allowSubmit </dt> <dd> <p>By default, any branch can be used as the source for a <code>git p4 submit</code> operation. This configuration variable, if set, permits only the named branches to be used as submit sources. Branch names must be the short names (no "refs/heads/"), and should be separated by commas (","), with no spaces.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4skipUserNameCheck"> git-p4.skipUserNameCheck </dt> <dd> <p>If the user running <code>git p4 submit</code> does not exist in the p4 user map, <code>git p4</code> exits. This option can be used to force submission regardless.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4attemptRCSCleanup"> git-p4.attemptRCSCleanup </dt> <dd> <p>If enabled, <code>git p4 submit</code> will attempt to cleanup RCS keywords ($Header$, etc). These would otherwise cause merge conflicts and prevent the submit going ahead. This option should be considered experimental at present.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4exportLabels"> git-p4.exportLabels </dt> <dd> <p>Export Git tags to p4 labels, as per --export-labels.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4labelExportRegexp"> git-p4.labelExportRegexp </dt> <dd> <p>Only p4 labels matching this regular expression will be exported. The default value is <code>[a-zA-Z0-9_\-.]+$</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4conflict"> git-p4.conflict </dt> <dd> <p>Specify submit behavior when a conflict with p4 is found, as per --conflict. The default behavior is <code>ask</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4disableRebase"> git-p4.disableRebase </dt> <dd> <p>Do not rebase the tree against p4/master following a submit.</p> </dd> <dt class="hdlist1" id="Documentation/git-p4.txt-git-p4disableP4Sync"> git-p4.disableP4Sync </dt> <dd> <p>Do not sync p4/master with Perforce following a submit. Implies git-p4.disableRebase.</p> </dd> </dl> </div> </div> </div> <h2 id="_implementation_details">Implementation details</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Changesets from p4 are imported using Git fast-import.</p> </li> <li> <p>Cloning or syncing does not require a p4 client; file contents are collected using <code>p4 print</code>.</p> </li> <li> <p>Submitting requires a p4 client, which is not in the same location as the Git repository. Patches are applied, one at a time, to this p4 client and submitted from there.</p> </li> <li> <p>Each commit imported by <code>git p4</code> has a line at the end of the log message indicating the p4 depot location and change number. This line is used by later <code>git p4 sync</code> operations to know which p4 changes are new.</p> </li> </ul> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-p4" class="_attribution-link">https://git-scm.com/docs/git-p4</a> + </p> +</div> diff --git a/devdocs/git/git-pack-objects.html b/devdocs/git/git-pack-objects.html new file mode 100644 index 00000000..3c6e769e --- /dev/null +++ b/devdocs/git/git-pack-objects.html @@ -0,0 +1,18 @@ +<h1>git-pack-objects</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-pack-objects - Create a packed archive of objects</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git pack-objects [-q | --progress | --all-progress] [--all-progress-implied] + [--no-reuse-delta] [--delta-base-offset] [--non-empty] + [--local] [--incremental] [--window=<n>] [--depth=<n>] + [--revs [--unpacked | --all]] [--keep-pack=<pack-name>] + [--cruft] [--cruft-expiration=<time>] + [--stdout [--filter=<filter-spec>] | <base-name>] + [--shallow] [--keep-true-parents] [--[no-]sparse] < <object-list></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Reads list of objects from the standard input, and writes either one or more packed archives with the specified base-name to disk, or a packed archive to the standard output.</p> <p>A packed archive is an efficient way to transfer a set of objects between two repositories as well as an access efficient archival format. In a packed archive, an object is either stored as a compressed whole or as a difference from some other object. The latter is often called a delta.</p> <p>The packed archive format (.pack) is designed to be self-contained so that it can be unpacked without any further information. Therefore, each object that a delta depends upon must be present within the pack.</p> <p>A pack index file (.idx) is generated for fast, random access to the objects in the pack. Placing both the index file (.idx) and the packed archive (.pack) in the pack/ subdirectory of $GIT_OBJECT_DIRECTORY (or any of the directories on $GIT_ALTERNATE_OBJECT_DIRECTORIES) enables Git to read from the pack archive.</p> <p>The <code>git unpack-objects</code> command can read the packed archive and expand the objects contained in the pack into "one-file one-object" format; this is typically done by the smart-pull commands when a pack is created on-the-fly for efficient network transport by their peers.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-pack-objects.txt-base-name"> base-name </dt> <dd> <p>Write into pairs of files (.pack and .idx), using <base-name> to determine the name of the created file. When this option is used, the two files in a pair are written in <base-name>-<SHA-1>.{pack,idx} files. <SHA-1> is a hash based on the pack content and is written to the standard output of the command.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---stdout"> --stdout </dt> <dd> <p>Write the pack contents (what would have been written to .pack file) out to the standard output.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---revs"> --revs </dt> <dd> <p>Read the revision arguments from the standard input, instead of individual object names. The revision arguments are processed the same way as <code>git rev-list</code> with the <code>--objects</code> flag uses its <code>commit</code> arguments to build the list of objects it outputs. The objects on the resulting list are packed. Besides revisions, <code>--not</code> or <code>--shallow <SHA-1></code> lines are also accepted.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---unpacked"> --unpacked </dt> <dd> <p>This implies <code>--revs</code>. When processing the list of revision arguments read from the standard input, limit the objects packed to those that are not already packed.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---all"> --all </dt> <dd> <p>This implies <code>--revs</code>. In addition to the list of revision arguments read from the standard input, pretend as if all refs under <code>refs/</code> are specified to be included.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---include-tag"> --include-tag </dt> <dd> <p>Include unasked-for annotated tags if the object they reference was included in the resulting packfile. This can be useful to send new tags to native Git clients.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---stdin-packs"> --stdin-packs </dt> <dd> <p>Read the basenames of packfiles (e.g., <code>pack-1234abcd.pack</code>) from the standard input, instead of object names or revision arguments. The resulting pack contains all objects listed in the included packs (those not beginning with <code>^</code>), excluding any objects listed in the excluded packs (beginning with <code>^</code>).</p> <p>Incompatible with <code>--revs</code>, or options that imply <code>--revs</code> (such as <code>--all</code>), with the exception of <code>--unpacked</code>, which is compatible.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---cruft"> --cruft </dt> <dd> <p>Packs unreachable objects into a separate "cruft" pack, denoted by the existence of a <code>.mtimes</code> file. Typically used by <code>git +repack --cruft</code>. Callers provide a list of pack names and indicate which packs will remain in the repository, along with which packs will be deleted (indicated by the <code>-</code> prefix). The contents of the cruft pack are all objects not contained in the surviving packs which have not exceeded the grace period (see <code>--cruft-expiration</code> below), or which have exceeded the grace period, but are reachable from an other object which hasn’t.</p> <p>When the input lists a pack containing all reachable objects (and lists all other packs as pending deletion), the corresponding cruft pack will contain all unreachable objects (with mtime newer than the <code>--cruft-expiration</code>) along with any unreachable objects whose mtime is older than the <code>--cruft-expiration</code>, but are reachable from an unreachable object whose mtime is newer than the <code>--cruft-expiration</code>).</p> <p>Incompatible with <code>--unpack-unreachable</code>, <code>--keep-unreachable</code>, <code>--pack-loose-unreachable</code>, <code>--stdin-packs</code>, as well as any other options which imply <code>--revs</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---cruft-expirationltapproxidategt"> --cruft-expiration=<approxidate> </dt> <dd> <p>If specified, objects are eliminated from the cruft pack if they have an mtime older than <code><approxidate></code>. If unspecified (and given <code>--cruft</code>), then no objects are eliminated.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---windowltngt"> --window=<n> </dt> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---depthltngt"> --depth=<n> </dt> <dd> <p>These two options affect how the objects contained in the pack are stored using delta compression. The objects are first internally sorted by type, size and optionally names and compared against the other objects within --window to see if using delta compression saves space. --depth limits the maximum delta depth; making it too deep affects the performance on the unpacker side, because delta data needs to be applied that many times to get to the necessary object.</p> <p>The default value for --window is 10 and --depth is 50. The maximum depth is 4095.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---window-memoryltngt"> --window-memory=<n> </dt> <dd> <p>This option provides an additional limit on top of <code>--window</code>; the window size will dynamically scale down so as to not take up more than <code><n></code> bytes in memory. This is useful in repositories with a mix of large and small objects to not run out of memory with a large window, but still be able to take advantage of the large window for the smaller objects. The size can be suffixed with "k", "m", or "g". <code>--window-memory=0</code> makes memory usage unlimited. The default is taken from the <code>pack.windowMemory</code> configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---max-pack-sizeltngt"> --max-pack-size=<n> </dt> <dd> <p>In unusual scenarios, you may not be able to create files larger than a certain size on your filesystem, and this option can be used to tell the command to split the output packfile into multiple independent packfiles, each not larger than the given size. The size can be suffixed with "k", "m", or "g". The minimum size allowed is limited to 1 MiB. The default is unlimited, unless the config variable <code>pack.packSizeLimit</code> is set. Note that this option may result in a larger and slower repository; see the discussion in <code>pack.packSizeLimit</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---honor-pack-keep"> --honor-pack-keep </dt> <dd> <p>This flag causes an object already in a local pack that has a .keep file to be ignored, even if it would have otherwise been packed.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---keep-packltpack-namegt"> --keep-pack=<pack-name> </dt> <dd> <p>This flag causes an object already in the given pack to be ignored, even if it would have otherwise been packed. <code><pack-name></code> is the pack file name without leading directory (e.g. <code>pack-123.pack</code>). The option could be specified multiple times to keep multiple packs.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---incremental"> --incremental </dt> <dd> <p>This flag causes an object already in a pack to be ignored even if it would have otherwise been packed.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---local"> --local </dt> <dd> <p>This flag causes an object that is borrowed from an alternate object store to be ignored even if it would have otherwise been packed.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---non-empty"> --non-empty </dt> <dd> <p>Only create a packed archive if it would contain at least one object.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---progress"> --progress </dt> <dd> <p>Progress status is reported on the standard error stream by default when it is attached to a terminal, unless -q is specified. This flag forces progress status even if the standard error stream is not directed to a terminal.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---all-progress"> --all-progress </dt> <dd> <p>When --stdout is specified then progress report is displayed during the object count and compression phases but inhibited during the write-out phase. The reason is that in some cases the output stream is directly linked to another command which may wish to display progress status of its own as it processes incoming pack data. This flag is like --progress except that it forces progress report for the write-out phase as well even if --stdout is used.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---all-progress-implied"> --all-progress-implied </dt> <dd> <p>This is used to imply --all-progress whenever progress display is activated. Unlike --all-progress this flag doesn’t actually force any progress display by itself.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt--q"> -q </dt> <dd> <p>This flag makes the command not to report its progress on the standard error stream.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---no-reuse-delta"> --no-reuse-delta </dt> <dd> <p>When creating a packed archive in a repository that has existing packs, the command reuses existing deltas. This sometimes results in a slightly suboptimal pack. This flag tells the command not to reuse existing deltas but compute them from scratch.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---no-reuse-object"> --no-reuse-object </dt> <dd> <p>This flag tells the command not to reuse existing object data at all, including non deltified object, forcing recompression of everything. This implies --no-reuse-delta. Useful only in the obscure case where wholesale enforcement of a different compression level on the packed data is desired.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---compressionltngt"> --compression=<n> </dt> <dd> <p>Specifies compression level for newly-compressed data in the generated pack. If not specified, pack compression level is determined first by pack.compression, then by core.compression, and defaults to -1, the zlib default, if neither is set. Add --no-reuse-object if you want to force a uniform compression level on all data no matter the source.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---no-sparse"> --[no-]sparse </dt> <dd> <p>Toggle the "sparse" algorithm to determine which objects to include in the pack, when combined with the "--revs" option. This algorithm only walks trees that appear in paths that introduce new objects. This can have significant performance benefits when computing a pack to send a small change. However, it is possible that extra objects are added to the pack-file if the included commits contain certain types of direct renames. If this option is not included, it defaults to the value of <code>pack.useSparse</code>, which is true unless otherwise specified.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---thin"> --thin </dt> <dd> <p>Create a "thin" pack by omitting the common objects between a sender and a receiver in order to reduce network transfer. This option only makes sense in conjunction with --stdout.</p> <p>Note: A thin pack violates the packed archive format by omitting required objects and is thus unusable by Git without making it self-contained. Use <code>git index-pack --fix-thin</code> (see <a href="git-index-pack">git-index-pack[1]</a>) to restore the self-contained property.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---shallow"> --shallow </dt> <dd> <p>Optimize a pack that will be provided to a client with a shallow repository. This option, combined with --thin, can result in a smaller pack at the cost of speed.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---delta-base-offset"> --delta-base-offset </dt> <dd> <p>A packed archive can express the base object of a delta as either a 20-byte object name or as an offset in the stream, but ancient versions of Git don’t understand the latter. By default, <code>git pack-objects</code> only uses the former format for better compatibility. This option allows the command to use the latter format for compactness. Depending on the average delta chain length, this option typically shrinks the resulting packfile by 3-5 per-cent.</p> <p>Note: Porcelain commands such as <code>git gc</code> (see <a href="git-gc">git-gc[1]</a>), <code>git repack</code> (see <a href="git-repack">git-repack[1]</a>) pass this option by default in modern Git when they put objects in your repository into pack files. So does <code>git bundle</code> (see <a href="git-bundle">git-bundle[1]</a>) when it creates a bundle.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---threadsltngt"> --threads=<n> </dt> <dd> <p>Specifies the number of threads to spawn when searching for best delta matches. This requires that pack-objects be compiled with pthreads otherwise this option is ignored with a warning. This is meant to reduce packing time on multiprocessor machines. The required amount of memory for the delta search window is however multiplied by the number of threads. Specifying 0 will cause Git to auto-detect the number of CPU’s and set the number of threads accordingly.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---index-versionltversiongtltoffsetgt"> --index-version=<version>[,<offset>] </dt> <dd> <p>This is intended to be used by the test suite only. It allows to force the version for the generated pack index, and to force 64-bit index entries on objects located above the given offset.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---keep-true-parents"> --keep-true-parents </dt> <dd> <p>With this option, parents that are hidden by grafts are packed nevertheless.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---filterltfilter-specgt"> --filter=<filter-spec> </dt> <dd> <p>Omits certain objects (usually blobs) from the resulting packfile. See <a href="git-rev-list">git-rev-list[1]</a> for valid <code><filter-spec></code> forms.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---no-filter"> --no-filter </dt> <dd> <p>Turns off any previous <code>--filter=</code> argument.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---missingltmissing-actiongt"> --missing=<missing-action> </dt> <dd> <p>A debug option to help with future "partial clone" development. This option specifies how missing objects are handled.</p> <p>The form <code>--missing=error</code> requests that pack-objects stop with an error if a missing object is encountered. If the repository is a partial clone, an attempt to fetch missing objects will be made before declaring them missing. This is the default action.</p> <p>The form <code>--missing=allow-any</code> will allow object traversal to continue if a missing object is encountered. No fetch of a missing object will occur. Missing objects will silently be omitted from the results.</p> <p>The form <code>--missing=allow-promisor</code> is like <code>allow-any</code>, but will only allow object traversal to continue for EXPECTED promisor missing objects. No fetch of a missing object will occur. An unexpected missing object will raise an error.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---exclude-promisor-objects"> --exclude-promisor-objects </dt> <dd> <p>Omit objects that are known to be in the promisor remote. (This option has the purpose of operating only on locally created objects, so that when we repack, we still maintain a distinction between locally created objects [without .promisor] and objects from the promisor remote [with .promisor].) This is used with partial clone.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---keep-unreachable"> --keep-unreachable </dt> <dd> <p>Objects unreachable from the refs in packs named with --unpacked= option are added to the resulting pack, in addition to the reachable objects that are not in packs marked with *.keep files. This implies <code>--revs</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---pack-loose-unreachable"> --pack-loose-unreachable </dt> <dd> <p>Pack unreachable loose objects (and their loose counterparts removed). This implies <code>--revs</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---unpack-unreachable"> --unpack-unreachable </dt> <dd> <p>Keep unreachable objects in loose form. This implies <code>--revs</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-objects.txt---delta-islands"> --delta-islands </dt> <dd> <p>Restrict delta matches based on "islands". See DELTA ISLANDS below.</p> </dd> </dl> </div> </div> <h2 id="_delta_islands">Delta islands</h2> <div class="sectionbody"> <p>When possible, <code>pack-objects</code> tries to reuse existing on-disk deltas to avoid having to search for new ones on the fly. This is an important optimization for serving fetches, because it means the server can avoid inflating most objects at all and just send the bytes directly from disk. This optimization can’t work when an object is stored as a delta against a base which the receiver does not have (and which we are not already sending). In that case the server "breaks" the delta and has to find a new one, which has a high CPU cost. Therefore it’s important for performance that the set of objects in on-disk delta relationships match what a client would fetch.</p> <p>In a normal repository, this tends to work automatically. The objects are mostly reachable from the branches and tags, and that’s what clients fetch. Any deltas we find on the server are likely to be between objects the client has or will have.</p> <p>But in some repository setups, you may have several related but separate groups of ref tips, with clients tending to fetch those groups independently. For example, imagine that you are hosting several "forks" of a repository in a single shared object store, and letting clients view them as separate repositories through <code>GIT_NAMESPACE</code> or separate repos using the alternates mechanism. A naive repack may find that the optimal delta for an object is against a base that is only found in another fork. But when a client fetches, they will not have the base object, and we’ll have to find a new delta on the fly.</p> <p>A similar situation may exist if you have many refs outside of <code>refs/heads/</code> and <code>refs/tags/</code> that point to related objects (e.g., <code>refs/pull</code> or <code>refs/changes</code> used by some hosting providers). By default, clients fetch only heads and tags, and deltas against objects found only in those other groups cannot be sent as-is.</p> <p>Delta islands solve this problem by allowing you to group your refs into distinct "islands". Pack-objects computes which objects are reachable from which islands, and refuses to make a delta from an object <code>A</code> against a base which is not present in all of <code>A</code>'s islands. This results in slightly larger packs (because we miss some delta opportunities), but guarantees that a fetch of one island will not have to recompute deltas on the fly due to crossing island boundaries.</p> <p>When repacking with delta islands the delta window tends to get clogged with candidates that are forbidden by the config. Repacking with a big --window helps (and doesn’t take as long as it otherwise might because we can reject some object pairs based on islands before doing any computation on the content).</p> <p>Islands are configured via the <code>pack.island</code> option, which can be specified multiple times. Each value is a left-anchored regular expressions matching refnames. For example:</p> <div class="listingblock"> <div class="content"> <pre>[pack] +island = refs/heads/ +island = refs/tags/</pre> </div> </div> <p>puts heads and tags into an island (whose name is the empty string; see below for more on naming). Any refs which do not match those regular expressions (e.g., <code>refs/pull/123</code>) is not in any island. Any object which is reachable only from <code>refs/pull/</code> (but not heads or tags) is therefore not a candidate to be used as a base for <code>refs/heads/</code>.</p> <p>Refs are grouped into islands based on their "names", and two regexes that produce the same name are considered to be in the same island. The names are computed from the regexes by concatenating any capture groups from the regex, with a <code>-</code> dash in between. (And if there are no capture groups, then the name is the empty string, as in the above example.) This allows you to create arbitrary numbers of islands. Only up to 14 such capture groups are supported though.</p> <p>For example, imagine you store the refs for each fork in <code>refs/virtual/ID</code>, where <code>ID</code> is a numeric identifier. You might then configure:</p> <div class="listingblock"> <div class="content"> <pre>[pack] +island = refs/virtual/([0-9]+)/heads/ +island = refs/virtual/([0-9]+)/tags/ +island = refs/virtual/([0-9]+)/(pull)/</pre> </div> </div> <p>That puts the heads and tags for each fork in their own island (named "1234" or similar), and the pull refs for each go into their own "1234-pull".</p> <p>Note that we pick a single island for each regex to go into, using "last one wins" ordering (which allows repo-specific config to take precedence over user-wide config, and so forth).</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Various configuration variables affect packing, see <a href="git-config">git-config[1]</a> (search for "pack" and "delta").</p> <p>Notably, delta compression is not used on objects larger than the <code>core.bigFileThreshold</code> configuration variable and on files with the attribute <code>delta</code> set to false.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-rev-list">git-rev-list[1]</a> <a href="git-repack">git-repack[1]</a> <a href="git-prune-packed">git-prune-packed[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-pack-objects" class="_attribution-link">https://git-scm.com/docs/git-pack-objects</a> + </p> +</div> diff --git a/devdocs/git/git-pack-redundant.html b/devdocs/git/git-pack-redundant.html new file mode 100644 index 00000000..c03cfedc --- /dev/null +++ b/devdocs/git/git-pack-redundant.html @@ -0,0 +1,6 @@ +<h1>git-pack-redundant</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-pack-redundant - Find redundant pack files</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git pack-redundant [--verbose] [--alt-odb] (--all | <pack-filename>…)</pre> </div> </div> <h2 id="_warning">Warning</h2> <div class="sectionbody"> <p><code>git pack-redundant</code> has been deprecated and is scheduled for removal in a future version of Git. Because it can only remove entire duplicate packs and not individual duplicate objects, it is generally not a useful tool for reducing repository size. You are better off using <code>git gc</code> to do so, which will put objects into a new pack, removing duplicates.</p> <p>Running <code>pack-redundant</code> without the <code>--i-still-use-this</code> flag will fail in this release. If you believe you have a use case for which <code>pack-redundant</code> is better suited and oppose this removal, please contact the Git mailing list at <a href="mailto:git@vger.kernel.org">git@vger.kernel.org</a>. More information about the list is available at <a href="https://git-scm.com/community" class="bare">https://git-scm.com/community</a>.</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This program computes which packs in your repository are redundant. The output is suitable for piping to <code>xargs rm</code> if you are in the root of the repository.</p> <p><code>git pack-redundant</code> accepts a list of objects on standard input. Any objects given will be ignored when checking which packs are required. This makes the following command useful when wanting to remove packs which contain unreachable objects.</p> <p>git fsck --full --unreachable | cut -d ' ' -f3 | \ git pack-redundant --all | xargs rm</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-pack-redundant.txt---all"> --all </dt> <dd> <p>Processes all packs. Any filenames on the command line are ignored.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-redundant.txt---alt-odb"> --alt-odb </dt> <dd> <p>Don’t require objects present in packs from alternate object database (odb) directories to be present in local packs.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-redundant.txt---verbose"> --verbose </dt> <dd> <p>Outputs some statistics to stderr. Has a small performance penalty.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-pack-objects">git-pack-objects[1]</a> <a href="git-repack">git-repack[1]</a> <a href="git-prune-packed">git-prune-packed[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-pack-redundant" class="_attribution-link">https://git-scm.com/docs/git-pack-redundant</a> + </p> +</div> diff --git a/devdocs/git/git-pack-refs.html b/devdocs/git/git-pack-refs.html new file mode 100644 index 00000000..80675347 --- /dev/null +++ b/devdocs/git/git-pack-refs.html @@ -0,0 +1,6 @@ +<h1>git-pack-refs</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-pack-refs - Pack heads and tags for efficient repository access</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git pack-refs [--all] [--no-prune] [--include <pattern>] [--exclude <pattern>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Traditionally, tips of branches and tags (collectively known as <code>refs</code>) were stored one file per ref in a (sub)directory under <code>$GIT_DIR/refs</code> directory. While many branch tips tend to be updated often, most tags and some branch tips are never updated. When a repository has hundreds or thousands of tags, this one-file-per-ref format both wastes storage and hurts performance.</p> <p>This command is used to solve the storage and performance problem by storing the refs in a single file, <code>$GIT_DIR/packed-refs</code>. When a ref is missing from the traditional <code>$GIT_DIR/refs</code> directory hierarchy, it is looked up in this file and used if found.</p> <p>Subsequent updates to branches always create new files under <code>$GIT_DIR/refs</code> directory hierarchy.</p> <p>A recommended practice to deal with a repository with too many refs is to pack its refs with <code>--all</code> once, and occasionally run <code>git pack-refs</code>. Tags are by definition stationary and are not expected to change. Branch heads will be packed with the initial <code>pack-refs --all</code>, but only the currently active branch heads will become unpacked, and the next <code>pack-refs</code> (without <code>--all</code>) will leave them unpacked.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-pack-refs.txt---all"> --all </dt> <dd> <p>The command by default packs all tags and refs that are already packed, and leaves other refs alone. This is because branches are expected to be actively developed and packing their tips does not help performance. This option causes all refs to be packed as well, with the exception of hidden refs, broken refs, and symbolic refs. Useful for a repository with many branches of historical interests.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-refs.txt---no-prune"> --no-prune </dt> <dd> <p>The command usually removes loose refs under <code>$GIT_DIR/refs</code> hierarchy after packing them. This option tells it not to.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-refs.txt---includeltpatterngt"> --include <pattern> </dt> <dd> <p>Pack refs based on a <code>glob(7)</code> pattern. Repetitions of this option accumulate inclusion patterns. If a ref is both included in <code>--include</code> and <code>--exclude</code>, <code>--exclude</code> takes precedence. Using <code>--include</code> will preclude all tags from being included by default. Symbolic refs and broken refs will never be packed. When used with <code>--all</code>, it will be a noop. Use <code>--no-include</code> to clear and reset the list of patterns.</p> </dd> <dt class="hdlist1" id="Documentation/git-pack-refs.txt---excludeltpatterngt"> --exclude <pattern> </dt> <dd> <p>Do not pack refs matching the given <code>glob(7)</code> pattern. Repetitions of this option accumulate exclusion patterns. Use <code>--no-exclude</code> to clear and reset the list of patterns. If a ref is already packed, including it with <code>--exclude</code> will not unpack it.</p> </dd> </dl> </div> <p>When used with <code>--all</code>, pack only loose refs which do not match any of the provided <code>--exclude</code> patterns.</p> <p>When used with <code>--include</code>, refs provided to <code>--include</code>, minus refs that are provided to <code>--exclude</code> will be packed.</p> </div> <h2 id="_bugs">Bugs</h2> <div class="sectionbody"> <p>Older documentation written before the packed-refs mechanism was introduced may still say things like ".git/refs/heads/<branch> file exists" when it means "branch <branch> exists".</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-pack-refs" class="_attribution-link">https://git-scm.com/docs/git-pack-refs</a> + </p> +</div> diff --git a/devdocs/git/git-patch-id.html b/devdocs/git/git-patch-id.html new file mode 100644 index 00000000..2e7ffa3d --- /dev/null +++ b/devdocs/git/git-patch-id.html @@ -0,0 +1,6 @@ +<h1>git-patch-id</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-patch-id - Compute unique ID for a patch</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git patch-id [--stable | --unstable | --verbatim]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Read a patch from the standard input and compute the patch ID for it.</p> <p>A "patch ID" is nothing but a sum of SHA-1 of the file diffs associated with a patch, with line numbers ignored. As such, it’s "reasonably stable", but at the same time also reasonably unique, i.e., two patches that have the same "patch ID" are almost guaranteed to be the same thing.</p> <p>The main usecase for this command is to look for likely duplicate commits.</p> <p>When dealing with <code>git diff-tree</code> output, it takes advantage of the fact that the patch is prefixed with the object name of the commit, and outputs two 40-byte hexadecimal strings. The first string is the patch ID, and the second string is the commit ID. This can be used to make a mapping from patch ID to commit ID.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-patch-id.txt---verbatim"> --verbatim </dt> <dd> <p>Calculate the patch-id of the input as it is given, do not strip any whitespace.</p> <div class="literalblock"> <div class="content"> <pre>This is the default if patchid.verbatim is true.</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-patch-id.txt---stable"> --stable </dt> <dd> <p>Use a "stable" sum of hashes as the patch ID. With this option:</p> <div class="ulist"> <ul> <li> <p>Reordering file diffs that make up a patch does not affect the ID. In particular, two patches produced by comparing the same two trees with two different settings for "-O<orderfile>" result in the same patch ID signature, thereby allowing the computed result to be used as a key to index some meta-information about the change between the two trees;</p> </li> <li> <p>Result is different from the value produced by git 1.9 and older or produced when an "unstable" hash (see --unstable below) is configured - even when used on a diff output taken without any use of "-O<orderfile>", thereby making existing databases storing such "unstable" or historical patch-ids unusable.</p> </li> <li> <p>All whitespace within the patch is ignored and does not affect the id.</p> <div class="literalblock"> <div class="content"> <pre>This is the default if patchid.stable is set to true.</pre> </div> </div> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-patch-id.txt---unstable"> --unstable </dt> <dd> <p>Use an "unstable" hash as the patch ID. With this option, the result produced is compatible with the patch-id value produced by git 1.9 and older and whitespace is ignored. Users with pre-existing databases storing patch-ids produced by git 1.9 and older (who do not deal with reordered patches) may want to use this option.</p> <div class="literalblock"> <div class="content"> <pre>This is the default.</pre> </div> </div> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-patch-id" class="_attribution-link">https://git-scm.com/docs/git-patch-id</a> + </p> +</div> diff --git a/devdocs/git/git-prune-packed.html b/devdocs/git/git-prune-packed.html new file mode 100644 index 00000000..be81d577 --- /dev/null +++ b/devdocs/git/git-prune-packed.html @@ -0,0 +1,6 @@ +<h1>git-prune-packed</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-prune-packed - Remove extra objects that are already in pack files</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git prune-packed [-n | --dry-run] [-q | --quiet]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This program searches the <code>$GIT_OBJECT_DIRECTORY</code> for all objects that currently exist in a pack file as well as in the independent object directories.</p> <p>All such extra objects are removed.</p> <p>A pack is a collection of objects, individually compressed, with delta compression applied, stored in a single file, with an associated index file.</p> <p>Packs are used to reduce the load on mirror systems, backup engines, disk storage, etc.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-prune-packed.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-prune-packed.txt---dry-run"> --dry-run </dt> <dd> <p>Don’t actually remove any objects, only show those that would have been removed.</p> </dd> <dt class="hdlist1" id="Documentation/git-prune-packed.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-prune-packed.txt---quiet"> --quiet </dt> <dd> <p>Squelch the progress indicator.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-pack-objects">git-pack-objects[1]</a> <a href="git-repack">git-repack[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-prune-packed" class="_attribution-link">https://git-scm.com/docs/git-prune-packed</a> + </p> +</div> diff --git a/devdocs/git/git-prune.html b/devdocs/git/git-prune.html new file mode 100644 index 00000000..80196dfa --- /dev/null +++ b/devdocs/git/git-prune.html @@ -0,0 +1,6 @@ +<h1>git-prune</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-prune - Prune all unreachable objects from the object database</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git prune [-n] [-v] [--progress] [--expire <time>] [--] [<head>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> In most cases, users should run <em>git gc</em>, which calls <em>git prune</em>. See the section "NOTES", below. </td> </tr> </table> </div> <p>This runs <code>git fsck --unreachable</code> using all the refs available in <code>refs/</code>, optionally with an additional set of objects specified on the command line, and prunes all unpacked objects unreachable from any of these head objects from the object database. In addition, it prunes the unpacked objects that are also found in packs by running <code>git prune-packed</code>. It also removes entries from .git/shallow that are not reachable by any ref.</p> <p>Note that unreachable, packed objects will remain. If this is not desired, see <a href="git-repack">git-repack[1]</a>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-prune.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-prune.txt---dry-run"> --dry-run </dt> <dd> <p>Do not remove anything; just report what it would remove.</p> </dd> <dt class="hdlist1" id="Documentation/git-prune.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-prune.txt---verbose"> --verbose </dt> <dd> <p>Report all removed objects.</p> </dd> <dt class="hdlist1" id="Documentation/git-prune.txt---progress"> --progress </dt> <dd> <p>Show progress.</p> </dd> <dt class="hdlist1" id="Documentation/git-prune.txt---expirelttimegt"> --expire <time> </dt> <dd> <p>Only expire loose objects older than <time>.</p> </dd> <dt class="hdlist1" id="Documentation/git-prune.txt---"> -- </dt> <dd> <p>Do not interpret any more arguments as options.</p> </dd> <dt class="hdlist1" id="Documentation/git-prune.txt-ltheadgt82308203"> <head>… </dt> <dd> <p>In addition to objects reachable from any of our references, keep objects reachable from listed <head>s.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>To prune objects not used by your repository or another that borrows from your repository via its <code>.git/objects/info/alternates</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git prune $(cd ../another && git rev-parse --all)</pre> </div> </div> </div> <h2 id="_notes">Notes</h2> <div class="sectionbody"> <p>In most cases, users will not need to call <code>git prune</code> directly, but should instead call <code>git gc</code>, which handles pruning along with many other housekeeping tasks.</p> <p>For a description of which objects are considered for pruning, see <code>git fsck</code>'s --unreachable option.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-fsck">git-fsck[1]</a>, <a href="git-gc">git-gc[1]</a>, <a href="git-reflog">git-reflog[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-prune" class="_attribution-link">https://git-scm.com/docs/git-prune</a> + </p> +</div> diff --git a/devdocs/git/git-pull.html b/devdocs/git/git-pull.html new file mode 100644 index 00000000..7912ad9b --- /dev/null +++ b/devdocs/git/git-pull.html @@ -0,0 +1,33 @@ +<h1>git-pull</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-pull - Fetch from and integrate with another repository or a local branch</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git pull [<options>] [<repository> [<refspec>…]]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Incorporates changes from a remote repository into the current branch. If the current branch is behind the remote, then by default it will fast-forward the current branch to match the remote. If the current branch and the remote have diverged, the user needs to specify how to reconcile the divergent branches with <code>--rebase</code> or <code>--no-rebase</code> (or the corresponding configuration option in <code>pull.rebase</code>).</p> <p>More precisely, <code>git pull</code> runs <code>git fetch</code> with the given parameters and then depending on configuration options or command line flags, will call either <code>git rebase</code> or <code>git merge</code> to reconcile diverging branches.</p> <p><repository> should be the name of a remote repository as passed to <a href="git-fetch">git-fetch[1]</a>. <refspec> can name an arbitrary remote ref (for example, the name of a tag) or even a collection of refs with corresponding remote-tracking branches (e.g., refs/heads/*:refs/remotes/origin/*), but usually it is the name of a branch in the remote repository.</p> <p>Default values for <repository> and <branch> are read from the "remote" and "merge" configuration for the current branch as set by <a href="git-branch">git-branch[1]</a> <code>--track</code>.</p> <p>Assume the following history exists and the current branch is "<code>master</code>":</p> <div class="listingblock"> <div class="content"> <pre> A---B---C master on origin + / + D---E---F---G master + ^ + origin/master in your repository</pre> </div> </div> <p>Then "<code>git pull</code>" will fetch and replay the changes from the remote <code>master</code> branch since it diverged from the local <code>master</code> (i.e., <code>E</code>) until its current commit (<code>C</code>) on top of <code>master</code> and record the result in a new commit along with the names of the two parent commits and a log message from the user describing the changes.</p> <div class="listingblock"> <div class="content"> <pre> A---B---C origin/master + / \ + D---E---F---G---H master</pre> </div> </div> <p>See <a href="git-merge">git-merge[1]</a> for details, including how conflicts are presented and handled.</p> <p>In Git 1.7.0 or later, to cancel a conflicting merge, use <code>git reset --merge</code>. <strong>Warning</strong>: In older versions of Git, running <code>git pull</code> with uncommitted changes is discouraged: while possible, it leaves you in a state that may be hard to back out of in the case of a conflict.</p> <p>If any of the remote changes overlap with local uncommitted changes, the merge will be automatically canceled and the work tree untouched. It is generally best to get any local changes in working order before pulling or stash them away with <a href="git-stash">git-stash[1]</a>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-pull.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---quiet"> --quiet </dt> <dd> <p>This is passed to both underlying git-fetch to squelch reporting of during transfer, and underlying git-merge to squelch output during merging.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---verbose"> --verbose </dt> <dd> <p>Pass --verbose to git-fetch and git-merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---no-recurse-submodulesyeson-demandno"> --[no-]recurse-submodules[=yes|on-demand|no] </dt> <dd> <p>This option controls if new commits of populated submodules should be fetched, and if the working trees of active submodules should be updated, too (see <a href="git-fetch">git-fetch[1]</a>, <a href="git-config">git-config[1]</a> and <a href="gitmodules">gitmodules[5]</a>).</p> <p>If the checkout is done via rebase, local submodule commits are rebased as well.</p> <p>If the update is done via merge, the submodule conflicts are resolved and checked out.</p> </dd> </dl> </div> <div class="sect2"> <h3 id="_options_related_to_merging"> +Options related to merging</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-pull.txt---commit"> --commit </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---no-commit"> --no-commit </dt> <dd> <p>Perform the merge and commit the result. This option can be used to override --no-commit. Only useful when merging.</p> <p>With --no-commit perform the merge and stop just before creating a merge commit, to give the user a chance to inspect and further tweak the merge result before committing.</p> <p>Note that fast-forward updates do not create a merge commit and therefore there is no way to stop those merges with --no-commit. Thus, if you want to ensure your branch is not changed or updated by the merge command, use --no-ff with --no-commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---edit"> --edit </dt> <dt class="hdlist1" id="Documentation/git-pull.txt--e"> -e </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---no-edit"> --no-edit </dt> <dd> <p>Invoke an editor before committing successful mechanical merge to further edit the auto-generated merge message, so that the user can explain and justify the merge. The <code>--no-edit</code> option can be used to accept the auto-generated message (this is generally discouraged).</p> <p>Older scripts may depend on the historical behaviour of not allowing the user to edit the merge log message. They will see an editor opened when they run <code>git merge</code>. To make it easier to adjust such scripts to the updated behaviour, the environment variable <code>GIT_MERGE_AUTOEDIT</code> can be set to <code>no</code> at the beginning of them.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---cleanupltmodegt"> --cleanup=<mode> </dt> <dd> <p>This option determines how the merge message will be cleaned up before committing. See <a href="git-commit">git-commit[1]</a> for more details. In addition, if the <code><mode></code> is given a value of <code>scissors</code>, scissors will be appended to <code>MERGE_MSG</code> before being passed on to the commit machinery in the case of a merge conflict.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---ff-only"> --ff-only </dt> <dd> <p>Only update to the new history if there is no divergent local history. This is the default when no method for reconciling divergent histories is provided (via the --rebase=* flags).</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---ff"> --ff </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---no-ff"> --no-ff </dt> <dd> <p>When merging rather than rebasing, specifies how a merge is handled when the merged-in history is already a descendant of the current history. If merging is requested, <code>--ff</code> is the default unless merging an annotated (and possibly signed) tag that is not stored in its natural place in the <code>refs/tags/</code> hierarchy, in which case <code>--no-ff</code> is assumed.</p> <p>With <code>--ff</code>, when possible resolve the merge as a fast-forward (only update the branch pointer to match the merged branch; do not create a merge commit). When not possible (when the merged-in history is not a descendant of the current history), create a merge commit.</p> <p>With <code>--no-ff</code>, create a merge commit in all cases, even when the merge could instead be resolved as a fast-forward.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt--Sltkeyidgt"> -S[<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---gpg-signltkeyidgt"> --gpg-sign[=<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---no-gpg-sign"> --no-gpg-sign </dt> <dd> <p>GPG-sign the resulting merge commit. The <code>keyid</code> argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space. <code>--no-gpg-sign</code> is useful to countermand both <code>commit.gpgSign</code> configuration variable, and earlier <code>--gpg-sign</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---logltngt"> --log[=<n>] </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---no-log"> --no-log </dt> <dd> <p>In addition to branch names, populate the log message with one-line descriptions from at most <n> actual commits that are being merged. See also <a href="git-fmt-merge-msg">git-fmt-merge-msg[1]</a>. Only useful when merging.</p> <p>With --no-log do not list one-line descriptions from the actual commits being merged.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---signoff"> --signoff </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---no-signoff"> --no-signoff </dt> <dd> <p>Add a <code>Signed-off-by</code> trailer by the committer at the end of the commit log message. The meaning of a signoff depends on the project to which you’re committing. For example, it may certify that the committer has the rights to submit the work under the project’s license or agrees to some contributor representation, such as a Developer Certificate of Origin. (See <a href="https://developercertificate.org" class="bare">https://developercertificate.org</a> for the one used by the Linux kernel and Git projects.) Consult the documentation or leadership of the project to which you’re contributing to understand how the signoffs are used in that project.</p> <p>The --no-signoff option can be used to countermand an earlier --signoff option on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---stat"> --stat </dt> <dt class="hdlist1" id="Documentation/git-pull.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---no-stat"> --no-stat </dt> <dd> <p>Show a diffstat at the end of the merge. The diffstat is also controlled by the configuration option merge.stat.</p> <p>With -n or --no-stat do not show a diffstat at the end of the merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---squash"> --squash </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---no-squash"> --no-squash </dt> <dd> <p>Produce the working tree and index state as if a real merge happened (except for the merge information), but do not actually make a commit, move the <code>HEAD</code>, or record <code>$GIT_DIR/MERGE_HEAD</code> (to cause the next <code>git commit</code> command to create a merge commit). This allows you to create a single commit on top of the current branch whose effect is the same as merging another branch (or more in case of an octopus).</p> <p>With --no-squash perform the merge and commit the result. This option can be used to override --squash.</p> <p>With --squash, --commit is not allowed, and will fail.</p> <p>Only useful when merging.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---no-verify"> --[no-]verify </dt> <dd> <p>By default, the pre-merge and commit-msg hooks are run. When <code>--no-verify</code> is given, these are bypassed. See also <a href="githooks">githooks[5]</a>. Only useful when merging.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt--sltstrategygt"> -s <strategy> </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---strategyltstrategygt"> --strategy=<strategy> </dt> <dd> <p>Use the given merge strategy; can be supplied more than once to specify them in the order they should be tried. If there is no <code>-s</code> option, a built-in list of strategies is used instead (<code>ort</code> when merging a single head, <code>octopus</code> otherwise).</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt--Xltoptiongt"> -X <option> </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---strategy-optionltoptiongt"> --strategy-option=<option> </dt> <dd> <p>Pass merge strategy specific option through to the merge strategy.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---verify-signatures"> --verify-signatures </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---no-verify-signatures"> --no-verify-signatures </dt> <dd> <p>Verify that the tip commit of the side branch being merged is signed with a valid key, i.e. a key that has a valid uid: in the default trust model, this means the signing key has been signed by a trusted key. If the tip commit of the side branch is not signed with a valid key, the merge is aborted.</p> <p>Only useful when merging.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---summary"> --summary </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---no-summary"> --no-summary </dt> <dd> <p>Synonyms to --stat and --no-stat; these are deprecated and will be removed in the future.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---autostash"> --autostash </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---no-autostash"> --no-autostash </dt> <dd> <p>Automatically create a temporary stash entry before the operation begins, record it in the ref <code>MERGE_AUTOSTASH</code> and apply it after the operation ends. This means that you can run the operation on a dirty worktree. However, use with care: the final stash application after a successful merge might result in non-trivial conflicts.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---allow-unrelated-histories"> --allow-unrelated-histories </dt> <dd> <p>By default, <code>git merge</code> command refuses to merge histories that do not share a common ancestor. This option can be used to override this safety when merging histories of two projects that started their lives independently. As that is a very rare occasion, no configuration variable to enable this by default exists and will not be added.</p> <p>Only useful when merging.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt--r"> -r </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---rebasefalsetruemergesinteractive"> --rebase[=false|true|merges|interactive] </dt> <dd> <p>When true, rebase the current branch on top of the upstream branch after fetching. If there is a remote-tracking branch corresponding to the upstream branch and the upstream branch was rebased since last fetched, the rebase uses that information to avoid rebasing non-local changes.</p> <p>When set to <code>merges</code>, rebase using <code>git rebase --rebase-merges</code> so that the local merge commits are included in the rebase (see <a href="git-rebase">git-rebase[1]</a> for details).</p> <p>When false, merge the upstream branch into the current branch.</p> <p>When <code>interactive</code>, enable the interactive mode of rebase.</p> <p>See <code>pull.rebase</code>, <code>branch.<name>.rebase</code> and <code>branch.autoSetupRebase</code> in <a href="git-config">git-config[1]</a> if you want to make <code>git pull</code> always use <code>--rebase</code> instead of merging.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> This is a potentially <em>dangerous</em> mode of operation. It rewrites history, which does not bode well when you published that history already. Do <strong>not</strong> use this option unless you have read <a href="git-rebase">git-rebase[1]</a> carefully. </td> </tr> </table> </div> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---no-rebase"> --no-rebase </dt> <dd> <p>This is shorthand for --rebase=false.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_options_related_to_fetching"> +Options related to fetching</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-pull.txt---all"> --all </dt> <dd> <p>Fetch all remotes.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---append"> --append </dt> <dd> <p>Append ref names and object names of fetched refs to the existing contents of <code>.git/FETCH_HEAD</code>. Without this option old data in <code>.git/FETCH_HEAD</code> will be overwritten.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---atomic"> --atomic </dt> <dd> <p>Use an atomic transaction to update local refs. Either all refs are updated, or on error, no refs are updated.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---depthltdepthgt"> --depth=<depth> </dt> <dd> <p>Limit fetching to the specified number of commits from the tip of each remote branch history. If fetching to a <code>shallow</code> repository created by <code>git clone</code> with <code>--depth=<depth></code> option (see <a href="git-clone">git-clone[1]</a>), deepen or shorten the history to the specified number of commits. Tags for the deepened commits are not fetched.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---deepenltdepthgt"> --deepen=<depth> </dt> <dd> <p>Similar to --depth, except it specifies the number of commits from the current shallow boundary instead of from the tip of each remote branch history.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---shallow-sinceltdategt"> --shallow-since=<date> </dt> <dd> <p>Deepen or shorten the history of a shallow repository to include all reachable commits after <date>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---shallow-excludeltrevisiongt"> --shallow-exclude=<revision> </dt> <dd> <p>Deepen or shorten the history of a shallow repository to exclude commits reachable from a specified remote branch or tag. This option can be specified multiple times.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---unshallow"> --unshallow </dt> <dd> <p>If the source repository is complete, convert a shallow repository to a complete one, removing all the limitations imposed by shallow repositories.</p> <p>If the source repository is shallow, fetch as much as possible so that the current repository has the same history as the source repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---update-shallow"> --update-shallow </dt> <dd> <p>By default when fetching from a shallow repository, <code>git fetch</code> refuses refs that require updating .git/shallow. This option updates .git/shallow and accepts such refs.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---negotiation-tipltcommitglobgt"> --negotiation-tip=<commit|glob> </dt> <dd> <p>By default, Git will report, to the server, commits reachable from all local refs to find common commits in an attempt to reduce the size of the to-be-received packfile. If specified, Git will only report commits reachable from the given tips. This is useful to speed up fetches when the user knows which local ref is likely to have commits in common with the upstream ref being fetched.</p> <p>This option may be specified more than once; if so, Git will report commits reachable from any of the given commits.</p> <p>The argument to this option may be a glob on ref names, a ref, or the (possibly abbreviated) SHA-1 of a commit. Specifying a glob is equivalent to specifying this option multiple times, one for each matching ref name.</p> <p>See also the <code>fetch.negotiationAlgorithm</code> and <code>push.negotiate</code> configuration variables documented in <a href="git-config">git-config[1]</a>, and the <code>--negotiate-only</code> option below.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---negotiate-only"> --negotiate-only </dt> <dd> <p>Do not fetch anything from the server, and instead print the ancestors of the provided <code>--negotiation-tip=*</code> arguments, which we have in common with the server.</p> <p>This is incompatible with <code>--recurse-submodules=[yes|on-demand]</code>. Internally this is used to implement the <code>push.negotiate</code> option, see <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---dry-run"> --dry-run </dt> <dd> <p>Show what would be done, without making any changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---porcelain"> --porcelain </dt> <dd> <p>Print the output to standard output in an easy-to-parse format for scripts. See section OUTPUT in <a href="git-fetch">git-fetch[1]</a> for details.</p> <p>This is incompatible with <code>--recurse-submodules=[yes|on-demand]</code> and takes precedence over the <code>fetch.output</code> config option.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---force"> --force </dt> <dd> <p>When <code>git fetch</code> is used with <code><src>:<dst></code> refspec, it may refuse to update the local branch as discussed in the <code><refspec></code> part of the <a href="git-fetch">git-fetch[1]</a> documentation. This option overrides that check.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt--k"> -k </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---keep"> --keep </dt> <dd> <p>Keep downloaded pack.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---prefetch"> --prefetch </dt> <dd> <p>Modify the configured refspec to place all refs into the <code>refs/prefetch/</code> namespace. See the <code>prefetch</code> task in <a href="git-maintenance">git-maintenance[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---prune"> --prune </dt> <dd> <p>Before fetching, remove any remote-tracking references that no longer exist on the remote. Tags are not subject to pruning if they are fetched only because of the default tag auto-following or due to a --tags option. However, if tags are fetched due to an explicit refspec (either on the command line or in the remote configuration, for example if the remote was cloned with the --mirror option), then they are also subject to pruning. Supplying <code>--prune-tags</code> is a shorthand for providing the tag refspec.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---no-tags"> --no-tags </dt> <dd> <p>By default, tags that point at objects that are downloaded from the remote repository are fetched and stored locally. This option disables this automatic tag following. The default behavior for a remote may be specified with the remote.<name>.tagOpt setting. See <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---refmapltrefspecgt"> --refmap=<refspec> </dt> <dd> <p>When fetching refs listed on the command line, use the specified refspec (can be given more than once) to map the refs to remote-tracking branches, instead of the values of <code>remote.*.fetch</code> configuration variables for the remote repository. Providing an empty <code><refspec></code> to the <code>--refmap</code> option causes Git to ignore the configured refspecs and rely entirely on the refspecs supplied as command-line arguments. See section on "Configured Remote-tracking Branches" for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt--t"> -t </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---tags"> --tags </dt> <dd> <p>Fetch all tags from the remote (i.e., fetch remote tags <code>refs/tags/*</code> into local tags with the same name), in addition to whatever else would otherwise be fetched. Using this option alone does not subject tags to pruning, even if --prune is used (though tags may be pruned anyway if they are also the destination of an explicit refspec; see <code>--prune</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt--j"> -j </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---jobsltngt"> --jobs=<n> </dt> <dd> <p>Number of parallel children to be used for all forms of fetching.</p> <p>If the <code>--multiple</code> option was specified, the different remotes will be fetched in parallel. If multiple submodules are fetched, they will be fetched in parallel. To control them independently, use the config settings <code>fetch.parallel</code> and <code>submodule.fetchJobs</code> (see <a href="git-config">git-config[1]</a>).</p> <p>Typically, parallel recursive and multi-remote fetches will be faster. By default fetches are performed sequentially, not in parallel.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---set-upstream"> --set-upstream </dt> <dd> <p>If the remote is fetched successfully, add upstream (tracking) reference, used by argument-less <a href="git-pull">git-pull[1]</a> and other commands. For more information, see <code>branch.<name>.merge</code> and <code>branch.<name>.remote</code> in <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---upload-packltupload-packgt"> --upload-pack <upload-pack> </dt> <dd> <p>When given, and the repository to fetch from is handled by <code>git fetch-pack</code>, <code>--exec=<upload-pack></code> is passed to the command to specify non-default path for the command run on the other end.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---progress"> --progress </dt> <dd> <p>Progress status is reported on the standard error stream by default when it is attached to a terminal, unless -q is specified. This flag forces progress status even if the standard error stream is not directed to a terminal.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt--oltoptiongt"> -o <option> </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---server-optionltoptiongt"> --server-option=<option> </dt> <dd> <p>Transmit the given string to the server when communicating using protocol version 2. The given string must not contain a NUL or LF character. The server’s handling of server options, including unknown ones, is server-specific. When multiple <code>--server-option=<option></code> are given, they are all sent to the other side in the order listed on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---show-forced-updates"> --show-forced-updates </dt> <dd> <p>By default, git checks if a branch is force-updated during fetch. This can be disabled through fetch.showForcedUpdates, but the --show-forced-updates option guarantees this check occurs. See <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt---no-show-forced-updates"> --no-show-forced-updates </dt> <dd> <p>By default, git checks if a branch is force-updated during fetch. Pass --no-show-forced-updates or set fetch.showForcedUpdates to false to skip this check for performance reasons. If used during <code>git-pull</code> the --ff-only option will still check for forced updates before attempting a fast-forward update. See <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt--4"> -4 </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---ipv4"> --ipv4 </dt> <dd> <p>Use IPv4 addresses only, ignoring IPv6 addresses.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt--6"> -6 </dt> <dt class="hdlist1" id="Documentation/git-pull.txt---ipv6"> --ipv6 </dt> <dd> <p>Use IPv6 addresses only, ignoring IPv4 addresses.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-ltrepositorygt"> <repository> </dt> <dd> <p>The "remote" repository that is the source of a fetch or pull operation. This parameter can be either a URL (see the section <a href="#URLS">GIT URLS</a> below) or the name of a remote (see the section <a href="#REMOTES">REMOTES</a> below).</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-ltrefspecgt"> <refspec> </dt> <dd> <p>Specifies which refs to fetch and which local refs to update. When no <refspec>s appear on the command line, the refs to fetch are read from <code>remote.<repository>.fetch</code> variables instead (see the section "CONFIGURED REMOTE-TRACKING BRANCHES" in <a href="git-fetch">git-fetch[1]</a>).</p> <p>The format of a <refspec> parameter is an optional plus <code>+</code>, followed by the source <src>, followed by a colon <code>:</code>, followed by the destination ref <dst>. The colon can be omitted when <dst> is empty. <src> is typically a ref, but it can also be a fully spelled hex object name.</p> <p>A <refspec> may contain a <code>*</code> in its <src> to indicate a simple pattern match. Such a refspec functions like a glob that matches any ref with the same prefix. A pattern <refspec> must have a <code>*</code> in both the <src> and <dst>. It will map refs to the destination by replacing the <code>*</code> with the contents matched from the source.</p> <p>If a refspec is prefixed by <code>^</code>, it will be interpreted as a negative refspec. Rather than specifying which refs to fetch or which local refs to update, such a refspec will instead specify refs to exclude. A ref will be considered to match if it matches at least one positive refspec, and does not match any negative refspec. Negative refspecs can be useful to restrict the scope of a pattern refspec so that it will not include specific refs. Negative refspecs can themselves be pattern refspecs. However, they may only contain a <src> and do not specify a <dst>. Fully spelled out hex object names are also not supported.</p> <p><code>tag <tag></code> means the same as <code>refs/tags/<tag>:refs/tags/<tag></code>; it requests fetching everything up to the given tag.</p> <p>The remote ref that matches <src> is fetched, and if <dst> is not an empty string, an attempt is made to update the local ref that matches it.</p> <p>Whether that update is allowed without <code>--force</code> depends on the ref namespace it’s being fetched to, the type of object being fetched, and whether the update is considered to be a fast-forward. Generally, the same rules apply for fetching as when pushing, see the <code><refspec>...</code> section of <a href="git-push">git-push[1]</a> for what those are. Exceptions to those rules particular to <code>git fetch</code> are noted below.</p> <p>Until Git version 2.20, and unlike when pushing with <a href="git-push">git-push[1]</a>, any updates to <code>refs/tags/*</code> would be accepted without <code>+</code> in the refspec (or <code>--force</code>). When fetching, we promiscuously considered all tag updates from a remote to be forced fetches. Since Git version 2.20, fetching to update <code>refs/tags/*</code> works the same way as when pushing. I.e. any updates will be rejected without <code>+</code> in the refspec (or <code>--force</code>).</p> <p>Unlike when pushing with <a href="git-push">git-push[1]</a>, any updates outside of <code>refs/{tags,heads}/*</code> will be accepted without <code>+</code> in the refspec (or <code>--force</code>), whether that’s swapping e.g. a tree object for a blob, or a commit for another commit that doesn’t have the previous commit as an ancestor etc.</p> <p>Unlike when pushing with <a href="git-push">git-push[1]</a>, there is no configuration which’ll amend these rules, and nothing like a <code>pre-fetch</code> hook analogous to the <code>pre-receive</code> hook.</p> <p>As with pushing with <a href="git-push">git-push[1]</a>, all of the rules described above about what’s not allowed as an update can be overridden by adding an optional leading <code>+</code> to a refspec (or using the <code>--force</code> command line option). The only exception to this is that no amount of forcing will make the <code>refs/heads/*</code> namespace accept a non-commit object.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> When the remote branch you want to fetch is known to be rewound and rebased regularly, it is expected that its new tip will not be a descendant of its previous tip (as stored in your remote-tracking branch the last time you fetched). You would want to use the <code>+</code> sign to indicate non-fast-forward updates will be needed for such branches. There is no way to determine or declare that a branch will be made available in a repository with this behavior; the pulling user simply must know this is the expected usage pattern for a branch. </td> </tr> </table> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> There is a difference between listing multiple <refspec> directly on <em>git pull</em> command line and having multiple <code>remote.<repository>.fetch</code> entries in your configuration for a <repository> and running a <em>git pull</em> command without any explicit <refspec> parameters. <refspec>s listed explicitly on the command line are always merged into the current branch after fetching. In other words, if you list more than one remote ref, <em>git pull</em> will create an Octopus merge. On the other hand, if you do not list any explicit <refspec> parameter on the command line, <em>git pull</em> will fetch all the <refspec>s it finds in the <code>remote.<repository>.fetch</code> configuration and merge only the first <refspec> found into the current branch. This is because making an Octopus from remote refs is rarely done, while keeping track of multiple remote heads in one-go by fetching more than one is often useful. </td> </tr> </table> </div> </dd> </dl> </div> </div> </div> <h2 id="_git_urls">Git urls</h2> <div class="sectionbody"> <p>In general, URLs contain information about the transport protocol, the address of the remote server, and the path to the repository. Depending on the transport protocol, some of this information may be absent.</p> <p>Git supports ssh, git, http, and https protocols (in addition, ftp and ftps can be used for fetching, but this is inefficient and deprecated; do not use them).</p> <p>The native transport (i.e. git:// URL) does no authentication and should be used with caution on unsecured networks.</p> <p>The following syntaxes may be used with them:</p> <div class="ulist"> <ul> <li> <p>ssh://[user@]host.xz[:port]/path/to/repo.git/</p> </li> <li> <p>git://host.xz[:port]/path/to/repo.git/</p> </li> <li> <p>http[s]://host.xz[:port]/path/to/repo.git/</p> </li> <li> <p>ftp[s]://host.xz[:port]/path/to/repo.git/</p> </li> </ul> </div> <p>An alternative scp-like syntax may also be used with the ssh protocol:</p> <div class="ulist"> <ul> <li> <p>[user@]host.xz:path/to/repo.git/</p> </li> </ul> </div> <p>This syntax is only recognized if there are no slashes before the first colon. This helps differentiate a local path that contains a colon. For example the local path <code>foo:bar</code> could be specified as an absolute path or <code>./foo:bar</code> to avoid being misinterpreted as an ssh url.</p> <p>The ssh and git protocols additionally support ~username expansion:</p> <div class="ulist"> <ul> <li> <p>ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/</p> </li> <li> <p>git://host.xz[:port]/~[user]/path/to/repo.git/</p> </li> <li> <p>[user@]host.xz:/~[user]/path/to/repo.git/</p> </li> </ul> </div> <p>For local repositories, also supported by Git natively, the following syntaxes may be used:</p> <div class="ulist"> <ul> <li> <p>/path/to/repo.git/</p> </li> <li> <p>file:///path/to/repo.git/</p> </li> </ul> </div> <p>These two syntaxes are mostly equivalent, except when cloning, when the former implies --local option. See <a href="git-clone">git-clone[1]</a> for details.</p> <p><code>git clone</code>, <code>git fetch</code> and <code>git pull</code>, but not <code>git push</code>, will also accept a suitable bundle file. See <a href="git-bundle">git-bundle[1]</a>.</p> <p>When Git doesn’t know how to handle a certain transport protocol, it attempts to use the <code>remote-<transport></code> remote helper, if one exists. To explicitly request a remote helper, the following syntax may be used:</p> <div class="ulist"> <ul> <li> <p><transport>::<address></p> </li> </ul> </div> <p>where <address> may be a path, a server and path, or an arbitrary URL-like string recognized by the specific remote helper being invoked. See <a href="gitremote-helpers">gitremote-helpers[7]</a> for details.</p> <p>If there are a large number of similarly-named remote repositories and you want to use a different format for them (such that the URLs you use will be rewritten into URLs that work), you can create a configuration section of the form:</p> <div class="listingblock"> <div class="content"> <pre> [url "<actual url base>"] + insteadOf = <other url base></pre> </div> </div> <p>For example, with this:</p> <div class="listingblock"> <div class="content"> <pre> [url "git://git.host.xz/"] + insteadOf = host.xz:/path/to/ + insteadOf = work:</pre> </div> </div> <p>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</p> <p>If you want to rewrite URLs for push only, you can create a configuration section of the form:</p> <div class="listingblock"> <div class="content"> <pre> [url "<actual url base>"] + pushInsteadOf = <other url base></pre> </div> </div> <p>For example, with this:</p> <div class="listingblock"> <div class="content"> <pre> [url "ssh://example.org/"] + pushInsteadOf = git://example.org/</pre> </div> </div> <p>a URL like "git://example.org/path/to/repo.git" will be rewritten to "ssh://example.org/path/to/repo.git" for pushes, but pulls will still use the original URL.</p> </div> <h2 id="_remotes">Remotes</h2> <div class="sectionbody"> <p>The name of one of the following can be used instead of a URL as <code><repository></code> argument:</p> <div class="ulist"> <ul> <li> <p>a remote in the Git configuration file: <code>$GIT_DIR/config</code>,</p> </li> <li> <p>a file in the <code>$GIT_DIR/remotes</code> directory, or</p> </li> <li> <p>a file in the <code>$GIT_DIR/branches</code> directory.</p> </li> </ul> </div> <p>All of these also allow you to omit the refspec from the command line because they each contain a refspec which git will use by default.</p> <div class="sect2"> <h3 id="_named_remote_in_configuration_file"> +Named remote in configuration file</h3> <p>You can choose to provide the name of a remote which you had previously configured using <a href="git-remote">git-remote[1]</a>, <a href="git-config">git-config[1]</a> or even by a manual edit to the <code>$GIT_DIR/config</code> file. The URL of this remote will be used to access the repository. The refspec of this remote will be used by default when you do not provide a refspec on the command line. The entry in the config file would appear like this:</p> <div class="listingblock"> <div class="content"> <pre> [remote "<name>"] + url = <URL> + pushurl = <pushurl> + push = <refspec> + fetch = <refspec></pre> </div> </div> <p>The <code><pushurl></code> is used for pushes only. It is optional and defaults to <code><URL></code>. Pushing to a remote affects all defined pushurls or all defined urls if no pushurls are defined. Fetch, however, will only fetch from the first defined url if multiple urls are defined.</p> </div> <div class="sect2"> <h3 id="_named_file_in_git_dirremotes"> +Named file in <code>$GIT_DIR/remotes</code> +</h3> <p>You can choose to provide the name of a file in <code>$GIT_DIR/remotes</code>. The URL in this file will be used to access the repository. The refspec in this file will be used as default when you do not provide a refspec on the command line. This file should have the following format:</p> <div class="listingblock"> <div class="content"> <pre> URL: one of the above URL formats + Push: <refspec> + Pull: <refspec></pre> </div> </div> <p><code>Push:</code> lines are used by <code>git push</code> and <code>Pull:</code> lines are used by <code>git pull</code> and <code>git fetch</code>. Multiple <code>Push:</code> and <code>Pull:</code> lines may be specified for additional branch mappings.</p> </div> <div class="sect2"> <h3 id="_named_file_in_git_dirbranches"> +Named file in <code>$GIT_DIR/branches</code> +</h3> <p>You can choose to provide the name of a file in <code>$GIT_DIR/branches</code>. The URL in this file will be used to access the repository. This file should have the following format:</p> <div class="listingblock"> <div class="content"> <pre> <URL>#<head></pre> </div> </div> <p><code><URL></code> is required; <code>#<head></code> is optional.</p> <p>Depending on the operation, git will use one of the following refspecs, if you don’t provide one on the command line. <code><branch></code> is the name of this file in <code>$GIT_DIR/branches</code> and <code><head></code> defaults to <code>master</code>.</p> <p>git fetch uses:</p> <div class="listingblock"> <div class="content"> <pre> refs/heads/<head>:refs/heads/<branch></pre> </div> </div> <p>git push uses:</p> <div class="listingblock"> <div class="content"> <pre> HEAD:refs/heads/<head></pre> </div> </div> </div> </div> <h2 id="_merge_strategies">Merge strategies</h2> <div class="sectionbody"> <p>The merge mechanism (<code>git merge</code> and <code>git pull</code> commands) allows the backend <code>merge strategies</code> to be chosen with <code>-s</code> option. Some strategies can also take their own options, which can be passed by giving <code>-X<option></code> arguments to <code>git merge</code> and/or <code>git pull</code>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-pull.txt-ort"> ort </dt> <dd> <p>This is the default merge strategy when pulling or merging one branch. This strategy can only resolve two heads using a 3-way merge algorithm. When there is more than one common ancestor that can be used for 3-way merge, it creates a merged tree of the common ancestors and uses that as the reference tree for the 3-way merge. This has been reported to result in fewer merge conflicts without causing mismerges by tests done on actual merge commits taken from Linux 2.6 kernel development history. Additionally this strategy can detect and handle merges involving renames. It does not make use of detected copies. The name for this algorithm is an acronym ("Ostensibly Recursive’s Twin") and came from the fact that it was written as a replacement for the previous default algorithm, <code>recursive</code>.</p> <p>The <code>ort</code> strategy can take the following options:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-pull.txt-ours"> ours </dt> <dd> <p>This option forces conflicting hunks to be auto-resolved cleanly by favoring <code>our</code> version. Changes from the other tree that do not conflict with our side are reflected in the merge result. For a binary file, the entire contents are taken from our side.</p> <p>This should not be confused with the <code>ours</code> merge strategy, which does not even look at what the other tree contains at all. It discards everything the other tree did, declaring <code>our</code> history contains all that happened in it.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-theirs"> theirs </dt> <dd> <p>This is the opposite of <code>ours</code>; note that, unlike <code>ours</code>, there is no <code>theirs</code> merge strategy to confuse this merge option with.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-ignore-space-change"> ignore-space-change </dt> <dt class="hdlist1" id="Documentation/git-pull.txt-ignore-all-space"> ignore-all-space </dt> <dt class="hdlist1" id="Documentation/git-pull.txt-ignore-space-at-eol"> ignore-space-at-eol </dt> <dt class="hdlist1" id="Documentation/git-pull.txt-ignore-cr-at-eol"> ignore-cr-at-eol </dt> <dd> <p>Treats lines with the indicated type of whitespace change as unchanged for the sake of a three-way merge. Whitespace changes mixed with other changes to a line are not ignored. See also <a href="git-diff">git-diff[1]</a> <code>-b</code>, <code>-w</code>, <code>--ignore-space-at-eol</code>, and <code>--ignore-cr-at-eol</code>.</p> <div class="ulist"> <ul> <li> <p>If <code>their</code> version only introduces whitespace changes to a line, <code>our</code> version is used;</p> </li> <li> <p>If <code>our</code> version introduces whitespace changes but <code>their</code> version includes a substantial change, <code>their</code> version is used;</p> </li> <li> <p>Otherwise, the merge proceeds in the usual way.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-renormalize"> renormalize </dt> <dd> <p>This runs a virtual check-out and check-in of all three stages of a file when resolving a three-way merge. This option is meant to be used when merging branches with different clean filters or end-of-line normalization rules. See "Merging branches with differing checkin/checkout attributes" in <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-no-renormalize"> no-renormalize </dt> <dd> <p>Disables the <code>renormalize</code> option. This overrides the <code>merge.renormalize</code> configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-find-renamesltngt"> find-renames[=<n>] </dt> <dd> <p>Turn on rename detection, optionally setting the similarity threshold. This is the default. This overrides the <code>merge.renames</code> configuration variable. See also <a href="git-diff">git-diff[1]</a> <code>--find-renames</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-rename-thresholdltngt"> rename-threshold=<n> </dt> <dd> <p>Deprecated synonym for <code>find-renames=<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-subtreeltpathgt"> subtree[=<path>] </dt> <dd> <p>This option is a more advanced form of <code>subtree</code> strategy, where the strategy makes a guess on how two trees must be shifted to match with each other when merging. Instead, the specified path is prefixed (or stripped from the beginning) to make the shape of two trees to match.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-recursive"> recursive </dt> <dd> <p>This can only resolve two heads using a 3-way merge algorithm. When there is more than one common ancestor that can be used for 3-way merge, it creates a merged tree of the common ancestors and uses that as the reference tree for the 3-way merge. This has been reported to result in fewer merge conflicts without causing mismerges by tests done on actual merge commits taken from Linux 2.6 kernel development history. Additionally this can detect and handle merges involving renames. It does not make use of detected copies. This was the default strategy for resolving two heads from Git v0.99.9k until v2.33.0.</p> <p>The <code>recursive</code> strategy takes the same options as <code>ort</code>. However, there are three additional options that <code>ort</code> ignores (not documented above) that are potentially useful with the <code>recursive</code> strategy:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-pull.txt-patience"> patience </dt> <dd> <p>Deprecated synonym for <code>diff-algorithm=patience</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-diff-algorithmpatienceminimalhistogrammyers"> diff-algorithm=[patience|minimal|histogram|myers] </dt> <dd> <p>Use a different diff algorithm while merging, which can help avoid mismerges that occur due to unimportant matching lines (such as braces from distinct functions). See also <a href="git-diff">git-diff[1]</a> <code>--diff-algorithm</code>. Note that <code>ort</code> specifically uses <code>diff-algorithm=histogram</code>, while <code>recursive</code> defaults to the <code>diff.algorithm</code> config setting.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-no-renames"> no-renames </dt> <dd> <p>Turn off rename detection. This overrides the <code>merge.renames</code> configuration variable. See also <a href="git-diff">git-diff[1]</a> <code>--no-renames</code>.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-resolve"> resolve </dt> <dd> <p>This can only resolve two heads (i.e. the current branch and another branch you pulled from) using a 3-way merge algorithm. It tries to carefully detect criss-cross merge ambiguities. It does not handle renames.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-octopus"> octopus </dt> <dd> <p>This resolves cases with more than two heads, but refuses to do a complex merge that needs manual resolution. It is primarily meant to be used for bundling topic branch heads together. This is the default merge strategy when pulling or merging more than one branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-ours-1"> ours </dt> <dd> <p>This resolves any number of heads, but the resulting tree of the merge is always that of the current branch head, effectively ignoring all changes from all other branches. It is meant to be used to supersede old development history of side branches. Note that this is different from the -Xours option to the <code>recursive</code> merge strategy.</p> </dd> <dt class="hdlist1" id="Documentation/git-pull.txt-subtree"> subtree </dt> <dd> <p>This is a modified <code>ort</code> strategy. When merging trees A and B, if B corresponds to a subtree of A, B is first adjusted to match the tree structure of A, instead of reading the trees at the same level. This adjustment is also done to the common ancestor tree.</p> </dd> </dl> </div> <p>With the strategies that use 3-way merge (including the default, <code>ort</code>), if a change is made on both branches, but later reverted on one of the branches, that change will be present in the merged result; some people find this behavior confusing. It occurs because only the heads and the merge base are considered when performing a merge, not the individual commits. The merge algorithm therefore considers the reverted change as no change at all, and substitutes the changed version instead.</p> </div> <h2 id="_default_behaviour">Default behaviour</h2> <div class="sectionbody"> <p>Often people use <code>git pull</code> without giving any parameter. Traditionally, this has been equivalent to saying <code>git pull +origin</code>. However, when configuration <code>branch.<name>.remote</code> is present while on branch <code><name></code>, that value is used instead of <code>origin</code>.</p> <p>In order to determine what URL to use to fetch from, the value of the configuration <code>remote.<origin>.url</code> is consulted and if there is not any such variable, the value on the <code>URL:</code> line in <code>$GIT_DIR/remotes/<origin></code> is used.</p> <p>In order to determine what remote branches to fetch (and optionally store in the remote-tracking branches) when the command is run without any refspec parameters on the command line, values of the configuration variable <code>remote.<origin>.fetch</code> are consulted, and if there aren’t any, <code>$GIT_DIR/remotes/<origin></code> is consulted and its <code>Pull:</code> lines are used. In addition to the refspec formats described in the OPTIONS section, you can have a globbing refspec that looks like this:</p> <div class="listingblock"> <div class="content"> <pre>refs/heads/*:refs/remotes/origin/*</pre> </div> </div> <p>A globbing refspec must have a non-empty RHS (i.e. must store what were fetched in remote-tracking branches), and its LHS and RHS must end with <code>/*</code>. The above specifies that all remote branches are tracked using remote-tracking branches in <code>refs/remotes/origin/</code> hierarchy under the same name.</p> <p>The rule to determine which remote branch to merge after fetching is a bit involved, in order not to break backward compatibility.</p> <p>If explicit refspecs were given on the command line of <code>git pull</code>, they are all merged.</p> <p>When no refspec was given on the command line, then <code>git pull</code> uses the refspec from the configuration or <code>$GIT_DIR/remotes/<origin></code>. In such cases, the following rules apply:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>If <code>branch.<name>.merge</code> configuration for the current branch <code><name></code> exists, that is the name of the branch at the remote site that is merged.</p> </li> <li> <p>If the refspec is a globbing one, nothing is merged.</p> </li> <li> <p>Otherwise the remote branch of the first refspec is merged.</p> </li> </ol> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Update the remote-tracking branches for the repository you cloned from, then merge one of them into your current branch:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git pull +$ git pull origin</pre> </div> </div> <p>Normally the branch merged in is the HEAD of the remote repository, but the choice is determined by the branch.<name>.remote and branch.<name>.merge options; see <a href="git-config">git-config[1]</a> for details.</p> </li> <li> <p>Merge into the current branch the remote branch <code>next</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git pull origin next</pre> </div> </div> <p>This leaves a copy of <code>next</code> temporarily in FETCH_HEAD, and updates the remote-tracking branch <code>origin/next</code>. The same can be done by invoking fetch and merge:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch origin +$ git merge origin/next</pre> </div> </div> </li> </ul> </div> <p>If you tried a pull which resulted in complex conflicts and would want to start over, you can recover with <code>git reset</code>.</p> </div> <h2 id="_security">Security</h2> <div class="sectionbody"> <p>The fetch and push protocols are not designed to prevent one side from stealing data from the other repository that was not intended to be shared. If you have private data that you need to protect from a malicious peer, your best option is to store it in another repository. This applies to both clients and servers. In particular, namespaces on a server are not effective for read access control; you should only grant read access to a namespace to clients that you would trust with read access to the entire repository.</p> <p>The known attack vectors are as follows:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>The victim sends "have" lines advertising the IDs of objects it has that are not explicitly intended to be shared but can be used to optimize the transfer if the peer also has them. The attacker chooses an object ID X to steal and sends a ref to X, but isn’t required to send the content of X because the victim already has it. Now the victim believes that the attacker has X, and it sends the content of X back to the attacker later. (This attack is most straightforward for a client to perform on a server, by creating a ref to X in the namespace the client has access to and then fetching it. The most likely way for a server to perform it on a client is to "merge" X into a public branch and hope that the user does additional work on this branch and pushes it back to the server without noticing the merge.)</p> </li> <li> <p>As in #1, the attacker chooses an object ID X to steal. The victim sends an object Y that the attacker already has, and the attacker falsely claims to have X and not Y, so the victim sends Y as a delta against X. The delta reveals regions of X that are similar to Y to the attacker.</p> </li> </ol> </div> </div> <h2 id="_bugs">Bugs</h2> <div class="sectionbody"> <p>Using --recurse-submodules can only fetch new commits in already checked out submodules right now. When e.g. upstream added a new submodule in the just fetched commits of the superproject the submodule itself cannot be fetched, making it impossible to check out that submodule later without having to do a fetch again. This is expected to be fixed in a future Git version.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-fetch">git-fetch[1]</a>, <a href="git-merge">git-merge[1]</a>, <a href="git-config">git-config[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-pull" class="_attribution-link">https://git-scm.com/docs/git-pull</a> + </p> +</div> diff --git a/devdocs/git/git-push.html b/devdocs/git/git-push.html new file mode 100644 index 00000000..e4f9fcb5 --- /dev/null +++ b/devdocs/git/git-push.html @@ -0,0 +1,57 @@ +<h1>git-push</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-push - Update remote refs along with associated objects</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git push [--all | --branches | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>] + [--repo=<repository>] [-f | --force] [-d | --delete] [--prune] [-q | --quiet] [-v | --verbose] + [-u | --set-upstream] [-o <string> | --push-option=<string>] + [--[no-]signed|--signed=(true|false|if-asked)] + [--force-with-lease[=<refname>[:<expect>]] [--force-if-includes]] + [--no-verify] [<repository> [<refspec>…]]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Updates remote refs using local refs, while sending objects necessary to complete the given refs.</p> <p>You can make interesting things happen to a repository every time you push into it, by setting up <code>hooks</code> there. See documentation for <a href="git-receive-pack">git-receive-pack[1]</a>.</p> <p>When the command line does not specify where to push with the <code><repository></code> argument, <code>branch.*.remote</code> configuration for the current branch is consulted to determine where to push. If the configuration is missing, it defaults to <code>origin</code>.</p> <p>When the command line does not specify what to push with <code><refspec>...</code> arguments or <code>--all</code>, <code>--mirror</code>, <code>--tags</code> options, the command finds the default <code><refspec></code> by consulting <code>remote.*.push</code> configuration, and if it is not found, honors <code>push.default</code> configuration to decide what to push (See <a href="git-config">git-config[1]</a> for the meaning of <code>push.default</code>).</p> <p>When neither the command-line nor the configuration specifies what to push, the default behavior is used, which corresponds to the <code>simple</code> value for <code>push.default</code>: the current branch is pushed to the corresponding upstream branch, but as a safety measure, the push is aborted if the upstream branch does not have the same name as the local one.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-push.txt-ltrepositorygt"> <repository> </dt> <dd> <p>The "remote" repository that is the destination of a push operation. This parameter can be either a URL (see the section <a href="#URLS">GIT URLS</a> below) or the name of a remote (see the section <a href="#REMOTES">REMOTES</a> below).</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-ltrefspecgt82308203"> <refspec>… </dt> <dd> <p>Specify what destination ref to update with what source object. The format of a <refspec> parameter is an optional plus <code>+</code>, followed by the source object <src>, followed by a colon <code>:</code>, followed by the destination ref <dst>.</p> <p>The <src> is often the name of the branch you would want to push, but it can be any arbitrary "SHA-1 expression", such as <code>master~4</code> or <code>HEAD</code> (see <a href="gitrevisions">gitrevisions[7]</a>).</p> <p>The <dst> tells which ref on the remote side is updated with this push. Arbitrary expressions cannot be used here, an actual ref must be named. If <code>git push [<repository>]</code> without any <code><refspec></code> argument is set to update some ref at the destination with <code><src></code> with <code>remote.<repository>.push</code> configuration variable, <code>:<dst></code> part can be omitted—such a push will update a ref that <code><src></code> normally updates without any <code><refspec></code> on the command line. Otherwise, missing <code>:<dst></code> means to update the same ref as the <code><src></code>.</p> <p>If <dst> doesn’t start with <code>refs/</code> (e.g. <code>refs/heads/master</code>) we will try to infer where in <code>refs/*</code> on the destination <repository> it belongs based on the type of <src> being pushed and whether <dst> is ambiguous.</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>If <dst> unambiguously refers to a ref on the <repository> remote, then push to that ref.</p> </li> <li> <p>If <src> resolves to a ref starting with refs/heads/ or refs/tags/, then prepend that to <dst>.</p> </li> <li> <p>Other ambiguity resolutions might be added in the future, but for now any other cases will error out with an error indicating what we tried, and depending on the <code>advice.pushUnqualifiedRefname</code> configuration (see <a href="git-config">git-config[1]</a>) suggest what refs/ namespace you may have wanted to push to.</p> </li> </ul> </div> </div> </div> <p>The object referenced by <src> is used to update the <dst> reference on the remote side. Whether this is allowed depends on where in <code>refs/*</code> the <dst> reference lives as described in detail below, in those sections "update" means any modifications except deletes, which as noted after the next few sections are treated differently.</p> <p>The <code>refs/heads/*</code> namespace will only accept commit objects, and updates only if they can be fast-forwarded.</p> <p>The <code>refs/tags/*</code> namespace will accept any kind of object (as commits, trees and blobs can be tagged), and any updates to them will be rejected.</p> <p>It’s possible to push any type of object to any namespace outside of <code>refs/{tags,heads}/*</code>. In the case of tags and commits, these will be treated as if they were the commits inside <code>refs/heads/*</code> for the purposes of whether the update is allowed.</p> <p>I.e. a fast-forward of commits and tags outside <code>refs/{tags,heads}/*</code> is allowed, even in cases where what’s being fast-forwarded is not a commit, but a tag object which happens to point to a new commit which is a fast-forward of the commit the last tag (or commit) it’s replacing. Replacing a tag with an entirely different tag is also allowed, if it points to the same commit, as well as pushing a peeled tag, i.e. pushing the commit that existing tag object points to, or a new tag object which an existing commit points to.</p> <p>Tree and blob objects outside of <code>refs/{tags,heads}/*</code> will be treated the same way as if they were inside <code>refs/tags/*</code>, any update of them will be rejected.</p> <p>All of the rules described above about what’s not allowed as an update can be overridden by adding an the optional leading <code>+</code> to a refspec (or using <code>--force</code> command line option). The only exception to this is that no amount of forcing will make the <code>refs/heads/*</code> namespace accept a non-commit object. Hooks and configuration can also override or amend these rules, see e.g. <code>receive.denyNonFastForwards</code> in <a href="git-config">git-config[1]</a> and <code>pre-receive</code> and <code>update</code> in <a href="githooks">githooks[5]</a>.</p> <p>Pushing an empty <src> allows you to delete the <dst> ref from the remote repository. Deletions are always accepted without a leading <code>+</code> in the refspec (or <code>--force</code>), except when forbidden by configuration or hooks. See <code>receive.denyDeletes</code> in <a href="git-config">git-config[1]</a> and <code>pre-receive</code> and <code>update</code> in <a href="githooks">githooks[5]</a>.</p> <p>The special refspec <code>:</code> (or <code>+:</code> to allow non-fast-forward updates) directs Git to push "matching" branches: for every branch that exists on the local side, the remote side is updated if a branch of the same name already exists on the remote side.</p> <p><code>tag <tag></code> means the same as <code>refs/tags/<tag>:refs/tags/<tag></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---all"> --all </dt> <dt class="hdlist1" id="Documentation/git-push.txt---branches"> --branches </dt> <dd> <p>Push all branches (i.e. refs under <code>refs/heads/</code>); cannot be used with other <refspec>.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---prune"> --prune </dt> <dd> <p>Remove remote branches that don’t have a local counterpart. For example a remote branch <code>tmp</code> will be removed if a local branch with the same name doesn’t exist any more. This also respects refspecs, e.g. <code>git push --prune remote refs/heads/*:refs/tmp/*</code> would make sure that remote <code>refs/tmp/foo</code> will be removed if <code>refs/heads/foo</code> doesn’t exist.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---mirror"> --mirror </dt> <dd> <p>Instead of naming each ref to push, specifies that all refs under <code>refs/</code> (which includes but is not limited to <code>refs/heads/</code>, <code>refs/remotes/</code>, and <code>refs/tags/</code>) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option <code>remote.<remote>.mirror</code> is set.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-push.txt---dry-run"> --dry-run </dt> <dd> <p>Do everything except actually send the updates.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---porcelain"> --porcelain </dt> <dd> <p>Produce machine-readable output. The output status line for each ref will be tab-separated and sent to stdout instead of stderr. The full symbolic names of the refs will be given.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt--d"> -d </dt> <dt class="hdlist1" id="Documentation/git-push.txt---delete"> --delete </dt> <dd> <p>All listed refs are deleted from the remote repository. This is the same as prefixing all refs with a colon.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---tags"> --tags </dt> <dd> <p>All refs under <code>refs/tags</code> are pushed, in addition to refspecs explicitly listed on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---follow-tags"> --follow-tags </dt> <dd> <p>Push all the refs that would be pushed without this option, and also push annotated tags in <code>refs/tags</code> that are missing from the remote but are pointing at commit-ish that are reachable from the refs being pushed. This can also be specified with configuration variable <code>push.followTags</code>. For more information, see <code>push.followTags</code> in <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---no-signed"> --[no-]signed </dt> <dt class="hdlist1" id="Documentation/git-push.txt---signedtruefalseif-asked"> --signed=(true|false|if-asked) </dt> <dd> <p>GPG-sign the push request to update refs on the receiving side, to allow it to be checked by the hooks and/or be logged. If <code>false</code> or <code>--no-signed</code>, no signing will be attempted. If <code>true</code> or <code>--signed</code>, the push will fail if the server does not support signed pushes. If set to <code>if-asked</code>, sign if and only if the server supports signed pushes. The push will also fail if the actual call to <code>gpg --sign</code> fails. See <a href="git-receive-pack">git-receive-pack[1]</a> for the details on the receiving end.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---no-atomic"> --[no-]atomic </dt> <dd> <p>Use an atomic transaction on the remote side if available. Either all refs are updated, or on error, no refs are updated. If the server does not support atomic pushes the push will fail.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt--oltoptiongt"> -o <option> </dt> <dt class="hdlist1" id="Documentation/git-push.txt---push-optionltoptiongt"> --push-option=<option> </dt> <dd> <p>Transmit the given string to the server, which passes them to the pre-receive as well as the post-receive hook. The given string must not contain a NUL or LF character. When multiple <code>--push-option=<option></code> are given, they are all sent to the other side in the order listed on the command line. When no <code>--push-option=<option></code> is given from the command line, the values of configuration variable <code>push.pushOption</code> are used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---receive-packltgit-receive-packgt"> --receive-pack=<git-receive-pack> </dt> <dt class="hdlist1" id="Documentation/git-push.txt---execltgit-receive-packgt"> --exec=<git-receive-pack> </dt> <dd> <p>Path to the <code>git-receive-pack</code> program on the remote end. Sometimes useful when pushing to a remote repository over ssh, and you do not have the program in a directory on the default $PATH.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---no-force-with-lease"> --[no-]force-with-lease </dt> <dt class="hdlist1" id="Documentation/git-push.txt---force-with-leaseltrefnamegt"> --force-with-lease=<refname> </dt> <dt class="hdlist1" id="Documentation/git-push.txt---force-with-leaseltrefnamegtltexpectgt"> --force-with-lease=<refname>:<expect> </dt> <dd> <p>Usually, "git push" refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it.</p> <p>This option overrides this restriction if the current value of the remote ref is the expected value. "git push" fails otherwise.</p> <p>Imagine that you have to rebase what you have already published. You will have to bypass the "must fast-forward" rule in order to replace the history you originally published with the rebased history. If somebody else built on top of your original history while you are rebasing, the tip of the branch at the remote may advance with their commit, and blindly pushing with <code>--force</code> will lose their work.</p> <p>This option allows you to say that you expect the history you are updating is what you rebased and want to replace. If the remote ref still points at the commit you specified, you can be sure that no other people did anything to the ref. It is like taking a "lease" on the ref without explicitly locking it, and the remote ref is updated only if the "lease" is still valid.</p> <p><code>--force-with-lease</code> alone, without specifying the details, will protect all remote refs that are going to be updated by requiring their current value to be the same as the remote-tracking branch we have for them.</p> <p><code>--force-with-lease=<refname></code>, without specifying the expected value, will protect the named ref (alone), if it is going to be updated, by requiring its current value to be the same as the remote-tracking branch we have for it.</p> <p><code>--force-with-lease=<refname>:<expect></code> will protect the named ref (alone), if it is going to be updated, by requiring its current value to be the same as the specified value <code><expect></code> (which is allowed to be different from the remote-tracking branch we have for the refname, or we do not even have to have such a remote-tracking branch when this form is used). If <code><expect></code> is the empty string, then the named ref must not already exist.</p> <p>Note that all forms other than <code>--force-with-lease=<refname>:<expect></code> that specifies the expected current value of the ref explicitly are still experimental and their semantics may change as we gain experience with this feature.</p> <p>"--no-force-with-lease" will cancel all the previous --force-with-lease on the command line.</p> <p>A general note on safety: supplying this option without an expected value, i.e. as <code>--force-with-lease</code> or <code>--force-with-lease=<refname></code> interacts very badly with anything that implicitly runs <code>git fetch</code> on the remote to be pushed to in the background, e.g. <code>git fetch origin</code> on your repository in a cronjob.</p> <p>The protection it offers over <code>--force</code> is ensuring that subsequent changes your work wasn’t based on aren’t clobbered, but this is trivially defeated if some background process is updating refs in the background. We don’t have anything except the remote tracking info to go by as a heuristic for refs you’re expected to have seen & are willing to clobber.</p> <p>If your editor or some other system is running <code>git fetch</code> in the background for you a way to mitigate this is to simply set up another remote:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git remote add origin-push $(git config remote.origin.url) +git fetch origin-push</pre> </div> </div> <p>Now when the background process runs <code>git fetch origin</code> the references on <code>origin-push</code> won’t be updated, and thus commands like:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git push --force-with-lease origin-push</pre> </div> </div> <p>Will fail unless you manually run <code>git fetch origin-push</code>. This method is of course entirely defeated by something that runs <code>git fetch +--all</code>, in that case you’d need to either disable it or do something more tedious like:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git fetch # update 'master' from remote +git tag base master # mark our base point +git rebase -i master # rewrite some commits +git push --force-with-lease=master:base master:master</pre> </div> </div> <p>I.e. create a <code>base</code> tag for versions of the upstream code that you’ve seen and are willing to overwrite, then rewrite history, and finally force push changes to <code>master</code> if the remote version is still at <code>base</code>, regardless of what your local <code>remotes/origin/master</code> has been updated to in the background.</p> <p>Alternatively, specifying <code>--force-if-includes</code> as an ancillary option along with <code>--force-with-lease[=<refname>]</code> (i.e., without saying what exact commit the ref on the remote side must be pointing at, or which refs on the remote side are being protected) at the time of "push" will verify if updates from the remote-tracking refs that may have been implicitly updated in the background are integrated locally before allowing a forced update.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-push.txt---force"> --force </dt> <dd> <p>Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. Also, when <code>--force-with-lease</code> option is used, the command refuses to update a remote ref whose current value does not match what is expected.</p> <p>This flag disables these checks, and can cause the remote repository to lose commits; use it with care.</p> <p>Note that <code>--force</code> applies to all the refs that are pushed, hence using it with <code>push.default</code> set to <code>matching</code> or with multiple push destinations configured with <code>remote.*.push</code> may overwrite refs other than the current branch (including local refs that are strictly behind their remote counterpart). To force a push to only one branch, use a <code>+</code> in front of the refspec to push (e.g <code>git push +origin +master</code> to force a push to the <code>master</code> branch). See the <code><refspec>...</code> section above for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---no-force-if-includes"> --[no-]force-if-includes </dt> <dd> <p>Force an update only if the tip of the remote-tracking ref has been integrated locally.</p> <p>This option enables a check that verifies if the tip of the remote-tracking ref is reachable from one of the "reflog" entries of the local branch based in it for a rewrite. The check ensures that any updates from the remote have been incorporated locally by rejecting the forced update if that is not the case.</p> <p>If the option is passed without specifying <code>--force-with-lease</code>, or specified along with <code>--force-with-lease=<refname>:<expect></code>, it is a "no-op".</p> <p>Specifying <code>--no-force-if-includes</code> disables this behavior.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---repoltrepositorygt"> --repo=<repository> </dt> <dd> <p>This option is equivalent to the <repository> argument. If both are specified, the command-line argument takes precedence.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt--u"> -u </dt> <dt class="hdlist1" id="Documentation/git-push.txt---set-upstream"> --set-upstream </dt> <dd> <p>For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-less <a href="git-pull">git-pull[1]</a> and other commands. For more information, see <code>branch.<name>.merge</code> in <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---no-thin"> --[no-]thin </dt> <dd> <p>These options are passed to <a href="git-send-pack">git-send-pack[1]</a>. A thin transfer significantly reduces the amount of sent data when the sender and receiver share many of the same objects in common. The default is <code>--thin</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-push.txt---quiet"> --quiet </dt> <dd> <p>Suppress all output, including the listing of updated refs, unless an error occurs. Progress is not reported to the standard error stream.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-push.txt---verbose"> --verbose </dt> <dd> <p>Run verbosely.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---progress"> --progress </dt> <dd> <p>Progress status is reported on the standard error stream by default when it is attached to a terminal, unless -q is specified. This flag forces progress status even if the standard error stream is not directed to a terminal.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---no-recurse-submodules"> --no-recurse-submodules </dt> <dt class="hdlist1" id="Documentation/git-push.txt---recurse-submodulescheckon-demandonlyno"> --recurse-submodules=check|on-demand|only|no </dt> <dd> <p>May be used to make sure all submodule commits used by the revisions to be pushed are available on a remote-tracking branch. If <code>check</code> is used Git will verify that all submodule commits that changed in the revisions to be pushed are available on at least one remote of the submodule. If any commits are missing the push will be aborted and exit with non-zero status. If <code>on-demand</code> is used all submodules that changed in the revisions to be pushed will be pushed. If on-demand was not able to push all necessary revisions it will also be aborted and exit with non-zero status. If <code>only</code> is used all submodules will be pushed while the superproject is left unpushed. A value of <code>no</code> or using <code>--no-recurse-submodules</code> can be used to override the push.recurseSubmodules configuration variable when no submodule recursion is required.</p> <p>When using <code>on-demand</code> or <code>only</code>, if a submodule has a "push.recurseSubmodules={on-demand,only}" or "submodule.recurse" configuration, further recursion will occur. In this case, "only" is treated as "on-demand".</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt---no-verify"> --[no-]verify </dt> <dd> <p>Toggle the pre-push hook (see <a href="githooks">githooks[5]</a>). The default is --verify, giving the hook a chance to prevent the push. With --no-verify, the hook is bypassed completely.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt--4"> -4 </dt> <dt class="hdlist1" id="Documentation/git-push.txt---ipv4"> --ipv4 </dt> <dd> <p>Use IPv4 addresses only, ignoring IPv6 addresses.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt--6"> -6 </dt> <dt class="hdlist1" id="Documentation/git-push.txt---ipv6"> --ipv6 </dt> <dd> <p>Use IPv6 addresses only, ignoring IPv4 addresses.</p> </dd> </dl> </div> </div> <h2 id="_git_urls">Git urls</h2> <div class="sectionbody"> <p>In general, URLs contain information about the transport protocol, the address of the remote server, and the path to the repository. Depending on the transport protocol, some of this information may be absent.</p> <p>Git supports ssh, git, http, and https protocols (in addition, ftp and ftps can be used for fetching, but this is inefficient and deprecated; do not use them).</p> <p>The native transport (i.e. git:// URL) does no authentication and should be used with caution on unsecured networks.</p> <p>The following syntaxes may be used with them:</p> <div class="ulist"> <ul> <li> <p>ssh://[user@]host.xz[:port]/path/to/repo.git/</p> </li> <li> <p>git://host.xz[:port]/path/to/repo.git/</p> </li> <li> <p>http[s]://host.xz[:port]/path/to/repo.git/</p> </li> <li> <p>ftp[s]://host.xz[:port]/path/to/repo.git/</p> </li> </ul> </div> <p>An alternative scp-like syntax may also be used with the ssh protocol:</p> <div class="ulist"> <ul> <li> <p>[user@]host.xz:path/to/repo.git/</p> </li> </ul> </div> <p>This syntax is only recognized if there are no slashes before the first colon. This helps differentiate a local path that contains a colon. For example the local path <code>foo:bar</code> could be specified as an absolute path or <code>./foo:bar</code> to avoid being misinterpreted as an ssh url.</p> <p>The ssh and git protocols additionally support ~username expansion:</p> <div class="ulist"> <ul> <li> <p>ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/</p> </li> <li> <p>git://host.xz[:port]/~[user]/path/to/repo.git/</p> </li> <li> <p>[user@]host.xz:/~[user]/path/to/repo.git/</p> </li> </ul> </div> <p>For local repositories, also supported by Git natively, the following syntaxes may be used:</p> <div class="ulist"> <ul> <li> <p>/path/to/repo.git/</p> </li> <li> <p>file:///path/to/repo.git/</p> </li> </ul> </div> <p>These two syntaxes are mostly equivalent, except when cloning, when the former implies --local option. See <a href="git-clone">git-clone[1]</a> for details.</p> <p><code>git clone</code>, <code>git fetch</code> and <code>git pull</code>, but not <code>git push</code>, will also accept a suitable bundle file. See <a href="git-bundle">git-bundle[1]</a>.</p> <p>When Git doesn’t know how to handle a certain transport protocol, it attempts to use the <code>remote-<transport></code> remote helper, if one exists. To explicitly request a remote helper, the following syntax may be used:</p> <div class="ulist"> <ul> <li> <p><transport>::<address></p> </li> </ul> </div> <p>where <address> may be a path, a server and path, or an arbitrary URL-like string recognized by the specific remote helper being invoked. See <a href="gitremote-helpers">gitremote-helpers[7]</a> for details.</p> <p>If there are a large number of similarly-named remote repositories and you want to use a different format for them (such that the URLs you use will be rewritten into URLs that work), you can create a configuration section of the form:</p> <div class="listingblock"> <div class="content"> <pre> [url "<actual url base>"] + insteadOf = <other url base></pre> </div> </div> <p>For example, with this:</p> <div class="listingblock"> <div class="content"> <pre> [url "git://git.host.xz/"] + insteadOf = host.xz:/path/to/ + insteadOf = work:</pre> </div> </div> <p>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</p> <p>If you want to rewrite URLs for push only, you can create a configuration section of the form:</p> <div class="listingblock"> <div class="content"> <pre> [url "<actual url base>"] + pushInsteadOf = <other url base></pre> </div> </div> <p>For example, with this:</p> <div class="listingblock"> <div class="content"> <pre> [url "ssh://example.org/"] + pushInsteadOf = git://example.org/</pre> </div> </div> <p>a URL like "git://example.org/path/to/repo.git" will be rewritten to "ssh://example.org/path/to/repo.git" for pushes, but pulls will still use the original URL.</p> </div> <h2 id="_remotes">Remotes</h2> <div class="sectionbody"> <p>The name of one of the following can be used instead of a URL as <code><repository></code> argument:</p> <div class="ulist"> <ul> <li> <p>a remote in the Git configuration file: <code>$GIT_DIR/config</code>,</p> </li> <li> <p>a file in the <code>$GIT_DIR/remotes</code> directory, or</p> </li> <li> <p>a file in the <code>$GIT_DIR/branches</code> directory.</p> </li> </ul> </div> <p>All of these also allow you to omit the refspec from the command line because they each contain a refspec which git will use by default.</p> <div class="sect2"> <h3 id="_named_remote_in_configuration_file"> +Named remote in configuration file</h3> <p>You can choose to provide the name of a remote which you had previously configured using <a href="git-remote">git-remote[1]</a>, <a href="git-config">git-config[1]</a> or even by a manual edit to the <code>$GIT_DIR/config</code> file. The URL of this remote will be used to access the repository. The refspec of this remote will be used by default when you do not provide a refspec on the command line. The entry in the config file would appear like this:</p> <div class="listingblock"> <div class="content"> <pre> [remote "<name>"] + url = <URL> + pushurl = <pushurl> + push = <refspec> + fetch = <refspec></pre> </div> </div> <p>The <code><pushurl></code> is used for pushes only. It is optional and defaults to <code><URL></code>. Pushing to a remote affects all defined pushurls or all defined urls if no pushurls are defined. Fetch, however, will only fetch from the first defined url if multiple urls are defined.</p> </div> <div class="sect2"> <h3 id="_named_file_in_git_dirremotes"> +Named file in <code>$GIT_DIR/remotes</code> +</h3> <p>You can choose to provide the name of a file in <code>$GIT_DIR/remotes</code>. The URL in this file will be used to access the repository. The refspec in this file will be used as default when you do not provide a refspec on the command line. This file should have the following format:</p> <div class="listingblock"> <div class="content"> <pre> URL: one of the above URL formats + Push: <refspec> + Pull: <refspec></pre> </div> </div> <p><code>Push:</code> lines are used by <code>git push</code> and <code>Pull:</code> lines are used by <code>git pull</code> and <code>git fetch</code>. Multiple <code>Push:</code> and <code>Pull:</code> lines may be specified for additional branch mappings.</p> </div> <div class="sect2"> <h3 id="_named_file_in_git_dirbranches"> +Named file in <code>$GIT_DIR/branches</code> +</h3> <p>You can choose to provide the name of a file in <code>$GIT_DIR/branches</code>. The URL in this file will be used to access the repository. This file should have the following format:</p> <div class="listingblock"> <div class="content"> <pre> <URL>#<head></pre> </div> </div> <p><code><URL></code> is required; <code>#<head></code> is optional.</p> <p>Depending on the operation, git will use one of the following refspecs, if you don’t provide one on the command line. <code><branch></code> is the name of this file in <code>$GIT_DIR/branches</code> and <code><head></code> defaults to <code>master</code>.</p> <p>git fetch uses:</p> <div class="listingblock"> <div class="content"> <pre> refs/heads/<head>:refs/heads/<branch></pre> </div> </div> <p>git push uses:</p> <div class="listingblock"> <div class="content"> <pre> HEAD:refs/heads/<head></pre> </div> </div> </div> </div> <h2 id="_output">Output</h2> <div class="sectionbody"> <p>The output of "git push" depends on the transport method used; this section describes the output when pushing over the Git protocol (either locally or via ssh).</p> <p>The status of the push is output in tabular form, with each line representing the status of a single ref. Each line is of the form:</p> <div class="listingblock"> <div class="content"> <pre> <flag> <summary> <from> -> <to> (<reason>)</pre> </div> </div> <p>If --porcelain is used, then each line of the output is of the form:</p> <div class="listingblock"> <div class="content"> <pre> <flag> \t <from>:<to> \t <summary> (<reason>)</pre> </div> </div> <p>The status of up-to-date refs is shown only if --porcelain or --verbose option is used.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-push.txt-flag"> flag </dt> <dd> <p>A single character indicating the status of the ref:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-push.txt-space"> (space) </dt> <dd> <p>for a successfully pushed fast-forward;</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-codecode"> <code>+</code> </dt> <dd> <p>for a successful forced update;</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-code-code"> <code>-</code> </dt> <dd> <p>for a successfully deleted ref;</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-codecode-1"> <code>*</code> </dt> <dd> <p>for a successfully pushed new ref;</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-codecode-1-1"> <code>!</code> </dt> <dd> <p>for a ref that was rejected or failed to push; and</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-codecode-1-1-1"> <code>=</code> </dt> <dd> <p>for a ref that was up to date and did not need pushing.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-summary"> summary </dt> <dd> <p>For a successfully pushed ref, the summary shows the old and new values of the ref in a form suitable for using as an argument to <code>git log</code> (this is <code><old>..<new></code> in most cases, and <code><old>...<new></code> for forced non-fast-forward updates).</p> <p>For a failed update, more details are given:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-push.txt-rejected"> rejected </dt> <dd> <p>Git did not try to send the ref at all, typically because it is not a fast-forward and you did not force the update.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-remoterejected"> remote rejected </dt> <dd> <p>The remote end refused the update. Usually caused by a hook on the remote side, or because the remote repository has one of the following safety options in effect: <code>receive.denyCurrentBranch</code> (for pushes to the checked out branch), <code>receive.denyNonFastForwards</code> (for forced non-fast-forward updates), <code>receive.denyDeletes</code> or <code>receive.denyDeleteCurrent</code>. See <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-remotefailure"> remote failure </dt> <dd> <p>The remote end did not report the successful update of the ref, perhaps because of a temporary error on the remote side, a break in the network connection, or other transient error.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-from"> from </dt> <dd> <p>The name of the local ref being pushed, minus its <code>refs/<type>/</code> prefix. In the case of deletion, the name of the local ref is omitted.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-to"> to </dt> <dd> <p>The name of the remote ref being updated, minus its <code>refs/<type>/</code> prefix.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-reason"> reason </dt> <dd> <p>A human-readable explanation. In the case of successfully pushed refs, no explanation is needed. For a failed ref, the reason for failure is described.</p> </dd> </dl> </div> </div> <h2 id="_note_about_fast_forwards">Note about fast-forwards</h2> <div class="sectionbody"> <p>When an update changes a branch (or more in general, a ref) that used to point at commit A to point at another commit B, it is called a fast-forward update if and only if B is a descendant of A.</p> <p>In a fast-forward update from A to B, the set of commits that the original commit A built on top of is a subset of the commits the new commit B builds on top of. Hence, it does not lose any history.</p> <p>In contrast, a non-fast-forward update will lose history. For example, suppose you and somebody else started at the same commit X, and you built a history leading to commit B while the other person built a history leading to commit A. The history looks like this:</p> <div class="listingblock"> <div class="content"> <pre> B + / + ---X---A</pre> </div> </div> <p>Further suppose that the other person already pushed changes leading to A back to the original repository from which you two obtained the original commit X.</p> <p>The push done by the other person updated the branch that used to point at commit X to point at commit A. It is a fast-forward.</p> <p>But if you try to push, you will attempt to update the branch (that now points at A) with commit B. This does <code>not</code> fast-forward. If you did so, the changes introduced by commit A will be lost, because everybody will now start building on top of B.</p> <p>The command by default does not allow an update that is not a fast-forward to prevent such loss of history.</p> <p>If you do not want to lose your work (history from X to B) or the work by the other person (history from X to A), you would need to first fetch the history from the repository, create a history that contains changes done by both parties, and push the result back.</p> <p>You can perform "git pull", resolve potential conflicts, and "git push" the result. A "git pull" will create a merge commit C between commits A and B.</p> <div class="listingblock"> <div class="content"> <pre> B---C + / / + ---X---A</pre> </div> </div> <p>Updating A with the resulting merge commit will fast-forward and your push will be accepted.</p> <p>Alternatively, you can rebase your change between X and B on top of A, with "git pull --rebase", and push the result back. The rebase will create a new commit D that builds the change between X and B on top of A.</p> <div class="listingblock"> <div class="content"> <pre> B D + / / + ---X---A</pre> </div> </div> <p>Again, updating A with this commit will fast-forward and your push will be accepted.</p> <p>There is another common situation where you may encounter non-fast-forward rejection when you try to push, and it is possible even when you are pushing into a repository nobody else pushes into. After you push commit A yourself (in the first picture in this section), replace it with "git commit --amend" to produce commit B, and you try to push it out, because forgot that you have pushed A out already. In such a case, and only if you are certain that nobody in the meantime fetched your earlier commit A (and started building on top of it), you can run "git push --force" to overwrite it. In other words, "git push --force" is a method reserved for a case where you do mean to lose history.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-push.txt-codegitpushcode"> <code>git push</code> </dt> <dd> <p>Works like <code>git push <remote></code>, where <remote> is the current branch’s remote (or <code>origin</code>, if no remote is configured for the current branch).</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-codegitpushorigincode"> <code>git push origin</code> </dt> <dd> <p>Without additional configuration, pushes the current branch to the configured upstream (<code>branch.<name>.merge</code> configuration variable) if it has the same name as the current branch, and errors out without pushing otherwise.</p> <p>The default behavior of this command when no <refspec> is given can be configured by setting the <code>push</code> option of the remote, or the <code>push.default</code> configuration variable.</p> <p>For example, to default to pushing only the current branch to <code>origin</code> use <code>git config remote.origin.push HEAD</code>. Any valid <refspec> (like the ones in the examples below) can be configured as the default for <code>git push origin</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-codegitpushorigincode-1"> <code>git push origin :</code> </dt> <dd> <p>Push "matching" branches to <code>origin</code>. See <refspec> in the <a href="#OPTIONS">OPTIONS</a> section above for a description of "matching" branches.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-codegitpushoriginmastercode"> <code>git push origin master</code> </dt> <dd> <p>Find a ref that matches <code>master</code> in the source repository (most likely, it would find <code>refs/heads/master</code>), and update the same ref (e.g. <code>refs/heads/master</code>) in <code>origin</code> repository with it. If <code>master</code> did not exist remotely, it would be created.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-codegitpushoriginHEADcode"> <code>git push origin HEAD</code> </dt> <dd> <p>A handy way to push the current branch to the same name on the remote.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-codegitpushmothershipmastersatellitemasterdevsatellitedevcode"> <code>git push mothership master:satellite/master dev:satellite/dev</code> </dt> <dd> <p>Use the source ref that matches <code>master</code> (e.g. <code>refs/heads/master</code>) to update the ref that matches <code>satellite/master</code> (most probably <code>refs/remotes/satellite/master</code>) in the <code>mothership</code> repository; do the same for <code>dev</code> and <code>satellite/dev</code>.</p> <p>See the section describing <code><refspec>...</code> above for a discussion of the matching semantics.</p> <p>This is to emulate <code>git fetch</code> run on the <code>mothership</code> using <code>git +push</code> that is run in the opposite direction in order to integrate the work done on <code>satellite</code>, and is often necessary when you can only make connection in one way (i.e. satellite can ssh into mothership but mothership cannot initiate connection to satellite because the latter is behind a firewall or does not run sshd).</p> <p>After running this <code>git push</code> on the <code>satellite</code> machine, you would ssh into the <code>mothership</code> and run <code>git merge</code> there to complete the emulation of <code>git pull</code> that were run on <code>mothership</code> to pull changes made on <code>satellite</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-codegitpushoriginHEADmastercode"> <code>git push origin HEAD:master</code> </dt> <dd> <p>Push the current branch to the remote ref matching <code>master</code> in the <code>origin</code> repository. This form is convenient to push the current branch without thinking about its local name.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-codegitpushoriginmasterrefsheadsexperimentalcode"> <code>git push origin master:refs/heads/experimental</code> </dt> <dd> <p>Create the branch <code>experimental</code> in the <code>origin</code> repository by copying the current <code>master</code> branch. This form is only needed to create a new branch or tag in the remote repository when the local name and the remote name are different; otherwise, the ref name on its own will work.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-codegitpushoriginexperimentalcode"> <code>git push origin :experimental</code> </dt> <dd> <p>Find a ref that matches <code>experimental</code> in the <code>origin</code> repository (e.g. <code>refs/heads/experimental</code>), and delete it.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-codegitpushorigindevmastercode"> <code>git push origin +dev:master</code> </dt> <dd> <p>Update the origin repository’s master branch with the dev branch, allowing non-fast-forward updates. <strong>This can leave unreferenced commits dangling in the origin repository.</strong> Consider the following situation, where a fast-forward is not possible:</p> <div class="listingblock"> <div class="content"> <pre> o---o---o---A---B origin/master + \ + X---Y---Z dev</pre> </div> </div> <p>The above command would change the origin repository to</p> <div class="listingblock"> <div class="content"> <pre> A---B (unnamed branch) + / + o---o---o---X---Y---Z master</pre> </div> </div> <p>Commits A and B would no longer belong to a branch with a symbolic name, and so would be unreachable. As such, these commits would be removed by a <code>git gc</code> command on the origin repository.</p> </dd> </dl> </div> </div> <h2 id="_security">Security</h2> <div class="sectionbody"> <p>The fetch and push protocols are not designed to prevent one side from stealing data from the other repository that was not intended to be shared. If you have private data that you need to protect from a malicious peer, your best option is to store it in another repository. This applies to both clients and servers. In particular, namespaces on a server are not effective for read access control; you should only grant read access to a namespace to clients that you would trust with read access to the entire repository.</p> <p>The known attack vectors are as follows:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>The victim sends "have" lines advertising the IDs of objects it has that are not explicitly intended to be shared but can be used to optimize the transfer if the peer also has them. The attacker chooses an object ID X to steal and sends a ref to X, but isn’t required to send the content of X because the victim already has it. Now the victim believes that the attacker has X, and it sends the content of X back to the attacker later. (This attack is most straightforward for a client to perform on a server, by creating a ref to X in the namespace the client has access to and then fetching it. The most likely way for a server to perform it on a client is to "merge" X into a public branch and hope that the user does additional work on this branch and pushes it back to the server without noticing the merge.)</p> </li> <li> <p>As in #1, the attacker chooses an object ID X to steal. The victim sends an object Y that the attacker already has, and the attacker falsely claims to have X and not Y, so the victim sends Y as a delta against X. The delta reveals regions of X that are similar to Y to the attacker.</p> </li> </ol> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-push.txt-pushautoSetupRemote"> push.autoSetupRemote </dt> <dd> <p>If set to "true" assume <code>--set-upstream</code> on default push when no upstream tracking exists for the current branch; this option takes effect with push.default options <code>simple</code>, <code>upstream</code>, and <code>current</code>. It is useful if by default you want new branches to be pushed to the default remote (like the behavior of <code>push.default=current</code>) and you also want the upstream tracking to be set. Workflows most likely to benefit from this option are <code>simple</code> central workflows where all branches are expected to have the same name on the remote.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-pushdefault"> push.default </dt> <dd> <p>Defines the action <code>git push</code> should take if no refspec is given (whether from the command-line, config, or elsewhere). Different values are well-suited for specific workflows; for instance, in a purely central workflow (i.e. the fetch source is equal to the push destination), <code>upstream</code> is probably what you want. Possible values are:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>nothing</code> - do not push anything (error out) unless a refspec is given. This is primarily meant for people who want to avoid mistakes by always being explicit.</p> </li> <li> <p><code>current</code> - push the current branch to update a branch with the same name on the receiving end. Works in both central and non-central workflows.</p> </li> <li> <p><code>upstream</code> - push the current branch back to the branch whose changes are usually integrated into the current branch (which is called <code>@{upstream}</code>). This mode only makes sense if you are pushing to the same repository you would normally pull from (i.e. central workflow).</p> </li> <li> <p><code>tracking</code> - This is a deprecated synonym for <code>upstream</code>.</p> </li> <li> <p><code>simple</code> - push the current branch with the same name on the remote.</p> <p>If you are working on a centralized workflow (pushing to the same repository you pull from, which is typically <code>origin</code>), then you need to configure an upstream branch with the same name.</p> <p>This mode is the default since Git 2.0, and is the safest option suited for beginners.</p> </li> <li> <p><code>matching</code> - push all branches having the same name on both ends. This makes the repository you are pushing to remember the set of branches that will be pushed out (e.g. if you always push <code>maint</code> and <code>master</code> there and no other branches, the repository you push to will have these two branches, and your local <code>maint</code> and <code>master</code> will be pushed there).</p> <p>To use this mode effectively, you have to make sure <code>all</code> the branches you would push out are ready to be pushed out before running <code>git push</code>, as the whole point of this mode is to allow you to push all of the branches in one go. If you usually finish work on only one branch and push out the result, while other branches are unfinished, this mode is not for you. Also this mode is not suitable for pushing into a shared central repository, as other people may add new branches there, or update the tip of existing branches outside your control.</p> <p>This used to be the default, but not since Git 2.0 (<code>simple</code> is the new default).</p> </li> </ul> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-pushfollowTags"> push.followTags </dt> <dd> <p>If set to true, enable <code>--follow-tags</code> option by default. You may override this configuration at time of push by specifying <code>--no-follow-tags</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-pushgpgSign"> push.gpgSign </dt> <dd> <p>May be set to a boolean value, or the string <code>if-asked</code>. A true value causes all pushes to be GPG signed, as if <code>--signed</code> is passed to <a href="git-push">git-push[1]</a>. The string <code>if-asked</code> causes pushes to be signed if the server supports it, as if <code>--signed=if-asked</code> is passed to <code>git push</code>. A false value may override a value from a lower-priority config file. An explicit command-line flag always overrides this config option.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-pushpushOption"> push.pushOption </dt> <dd> <p>When no <code>--push-option=<option></code> argument is given from the command line, <code>git push</code> behaves as if each <value> of this variable is given as <code>--push-option=<value></code>.</p> <p>This is a multi-valued variable, and an empty value can be used in a higher priority configuration file (e.g. <code>.git/config</code> in a repository) to clear the values inherited from a lower priority configuration files (e.g. <code>$HOME/.gitconfig</code>).</p> <div class="listingblock"> <div class="content"> <pre>Example: + +/etc/gitconfig + push.pushoption = a + push.pushoption = b + +~/.gitconfig + push.pushoption = c + +repo/.git/config + push.pushoption = + push.pushoption = b + +This will result in only b (a and c are cleared).</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-pushrecurseSubmodules"> push.recurseSubmodules </dt> <dd> <p>May be "check", "on-demand", "only", or "no", with the same behavior as that of "push --recurse-submodules". If not set, <code>no</code> is used by default, unless <code>submodule.recurse</code> is set (in which case a <code>true</code> value means <code>on-demand</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-pushuseForceIfIncludes"> push.useForceIfIncludes </dt> <dd> <p>If set to "true", it is equivalent to specifying <code>--force-if-includes</code> as an option to <a href="git-push">git-push[1]</a> in the command line. Adding <code>--no-force-if-includes</code> at the time of push overrides this configuration setting.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-pushnegotiate"> push.negotiate </dt> <dd> <p>If set to "true", attempt to reduce the size of the packfile sent by rounds of negotiation in which the client and the server attempt to find commits in common. If "false", Git will rely solely on the server’s ref advertisement to find commits in common.</p> </dd> <dt class="hdlist1" id="Documentation/git-push.txt-pushuseBitmaps"> push.useBitmaps </dt> <dd> <p>If set to "false", disable use of bitmaps for "git push" even if <code>pack.useBitmaps</code> is "true", without preventing other git operations from using bitmaps. Default is true.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-push" class="_attribution-link">https://git-scm.com/docs/git-push</a> + </p> +</div> diff --git a/devdocs/git/git-quiltimport.html b/devdocs/git/git-quiltimport.html new file mode 100644 index 00000000..4317f3f3 --- /dev/null +++ b/devdocs/git/git-quiltimport.html @@ -0,0 +1,7 @@ +<h1>git-quiltimport</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-quiltimport - Applies a quilt patchset onto the current branch</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git quiltimport [--dry-run | -n] [--author <author>] [--patches <dir>] + [--series <file>] [--keep-non-patch]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Applies a quilt patchset onto the current Git branch, preserving the patch boundaries, patch order, and patch descriptions present in the quilt patchset.</p> <p>For each patch the code attempts to extract the author from the patch description. If that fails it falls back to the author specified with --author. If the --author flag was not given the patch description is displayed and the user is asked to interactively enter the author of the patch.</p> <p>If a subject is not found in the patch description the patch name is preserved as the 1 line subject in the Git description.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-quiltimport.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-quiltimport.txt---dry-run"> --dry-run </dt> <dd> <p>Walk through the patches in the series and warn if we cannot find all of the necessary information to commit a patch. At the time of this writing only missing author information is warned about.</p> </dd> <dt class="hdlist1" id="Documentation/git-quiltimport.txt---authoremAuthorNameltAuthorEmailgtem"> --author <em>Author Name <Author Email></em> </dt> <dd> <p>The author name and email address to use when no author information can be found in the patch description.</p> </dd> <dt class="hdlist1" id="Documentation/git-quiltimport.txt---patchesltdirgt"> --patches <dir> </dt> <dd> <p>The directory to find the quilt patches.</p> <p>The default for the patch directory is <code>patches</code> or the value of the <code>$QUILT_PATCHES</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-quiltimport.txt---seriesltfilegt"> --series <file> </dt> <dd> <p>The quilt series file.</p> <p>The default for the series file is <patches>/series or the value of the <code>$QUILT_SERIES</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-quiltimport.txt---keep-non-patch"> --keep-non-patch </dt> <dd> <p>Pass <code>-b</code> flag to <code>git mailinfo</code> (see <a href="git-mailinfo">git-mailinfo[1]</a>).</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-quiltimport" class="_attribution-link">https://git-scm.com/docs/git-quiltimport</a> + </p> +</div> diff --git a/devdocs/git/git-range-diff.html b/devdocs/git/git-range-diff.html new file mode 100644 index 00000000..e2074384 --- /dev/null +++ b/devdocs/git/git-range-diff.html @@ -0,0 +1,57 @@ +<h1>git-range-diff</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-range-diff - Compare two commit ranges (e.g. two versions of a branch)</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git range-diff [--color=[<when>]] [--no-color] [<diff-options>] + [--no-dual-color] [--creation-factor=<factor>] + [--left-only | --right-only] + ( <range1> <range2> | <rev1>…<rev2> | <base> <rev1> <rev2> ) + [[--] <path>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This command shows the differences between two versions of a patch series, or more generally, two commit ranges (ignoring merge commits).</p> <p>In the presence of <code><path></code> arguments, these commit ranges are limited accordingly.</p> <p>To that end, it first finds pairs of commits from both commit ranges that correspond with each other. Two commits are said to correspond when the diff between their patches (i.e. the author information, the commit message and the commit diff) is reasonably small compared to the patches' size. See ``Algorithm`` below for details.</p> <p>Finally, the list of matching commits is shown in the order of the second commit range, with unmatched commits being inserted just after all of their ancestors have been shown.</p> <p>There are three ways to specify the commit ranges:</p> <div class="ulist"> <ul> <li> <p><code><range1> <range2></code>: Either commit range can be of the form <code><base>..<rev></code>, <code><rev>^!</code> or <code><rev>^-<n></code>. See <code>SPECIFYING RANGES</code> in <a href="gitrevisions">gitrevisions[7]</a> for more details.</p> </li> <li> <p><code><rev1>...<rev2></code>. This is equivalent to <code><rev2>..<rev1> <rev1>..<rev2></code>.</p> </li> <li> <p><code><base> <rev1> <rev2></code>: This is equivalent to <code><base>..<rev1> +<base>..<rev2></code>.</p> </li> </ul> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-range-diff.txt---no-dual-color"> --no-dual-color </dt> <dd> <p>When the commit diffs differ, <code>git range-diff</code> recreates the original diffs' coloring, and adds outer -/+ diff markers with the <strong>background</strong> being red/green to make it easier to see e.g. when there was a change in what exact lines were added.</p> <p>Additionally, the commit diff lines that are only present in the first commit range are shown "dimmed" (this can be overridden using the <code>color.diff.<slot></code> config setting where <code><slot></code> is one of <code>contextDimmed</code>, <code>oldDimmed</code> and <code>newDimmed</code>), and the commit diff lines that are only present in the second commit range are shown in bold (which can be overridden using the config settings <code>color.diff.<slot></code> with <code><slot></code> being one of <code>contextBold</code>, <code>oldBold</code> or <code>newBold</code>).</p> <p>This is known to <code>range-diff</code> as "dual coloring". Use <code>--no-dual-color</code> to revert to color all lines according to the outer diff markers (and completely ignore the inner diff when it comes to color).</p> </dd> <dt class="hdlist1" id="Documentation/git-range-diff.txt---creation-factorltpercentgt"> --creation-factor=<percent> </dt> <dd> <p>Set the creation/deletion cost fudge factor to <code><percent></code>. Defaults to 60. Try a larger value if <code>git range-diff</code> erroneously considers a large change a total rewrite (deletion of one commit and addition of another), and a smaller one in the reverse case. See the ``Algorithm`` section below for an explanation of why this is needed.</p> </dd> <dt class="hdlist1" id="Documentation/git-range-diff.txt---left-only"> --left-only </dt> <dd> <p>Suppress commits that are missing from the first specified range (or the "left range" when using the <code><rev1>...<rev2></code> format).</p> </dd> <dt class="hdlist1" id="Documentation/git-range-diff.txt---right-only"> --right-only </dt> <dd> <p>Suppress commits that are missing from the second specified range (or the "right range" when using the <code><rev1>...<rev2></code> format).</p> </dd> <dt class="hdlist1" id="Documentation/git-range-diff.txt---no-notesltrefgt"> --[no-]notes[=<ref>] </dt> <dd> <p>This flag is passed to the <code>git log</code> program (see <a href="git-log">git-log[1]</a>) that generates the patches.</p> </dd> <dt class="hdlist1" id="Documentation/git-range-diff.txt-ltrange1gtltrange2gt"> <range1> <range2> </dt> <dd> <p>Compare the commits specified by the two ranges, where <code><range1></code> is considered an older version of <code><range2></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-range-diff.txt-ltrev1gt82308203ltrev2gt"> <rev1>…<rev2> </dt> <dd> <p>Equivalent to passing <code><rev2>..<rev1></code> and <code><rev1>..<rev2></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-range-diff.txt-ltbasegtltrev1gtltrev2gt"> <base> <rev1> <rev2> </dt> <dd> <p>Equivalent to passing <code><base>..<rev1></code> and <code><base>..<rev2></code>. Note that <code><base></code> does not need to be the exact branch point of the branches. Example: after rebasing a branch <code>my-topic</code>, <code>git range-diff my-topic@{u} my-topic@{1} my-topic</code> would show the differences introduced by the rebase.</p> </dd> </dl> </div> <p><code>git range-diff</code> also accepts the regular diff options (see <a href="git-diff">git-diff[1]</a>), most notably the <code>--color=[<when>]</code> and <code>--no-color</code> options. These options are used when generating the "diff between patches", i.e. to compare the author, commit message and diff of corresponding old/new commits. There is currently no means to tweak most of the diff options passed to <code>git log</code> when generating those patches.</p> </div> <h2 id="_output_stability">Output stability</h2> <div class="sectionbody"> <p>The output of the <code>range-diff</code> command is subject to change. It is intended to be human-readable porcelain output, not something that can be used across versions of Git to get a textually stable <code>range-diff</code> (as opposed to something like the <code>--stable</code> option to <a href="git-patch-id">git-patch-id[1]</a>). There’s also no equivalent of <a href="git-apply">git-apply[1]</a> for <code>range-diff</code>, the output is not intended to be machine-readable.</p> <p>This is particularly true when passing in diff options. Currently some options like <code>--stat</code> can, as an emergent effect, produce output that’s quite useless in the context of <code>range-diff</code>. Future versions of <code>range-diff</code> may learn to interpret such options in a manner specific to <code>range-diff</code> (e.g. for <code>--stat</code> producing human-readable output which summarizes how the diffstat changed).</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>This command uses the <code>diff.color.*</code> and <code>pager.range-diff</code> settings (the latter is on by default). See <a href="git-config">git-config[1]</a>.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>When a rebase required merge conflicts to be resolved, compare the changes introduced by the rebase directly afterwards using:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git range-diff @{u} @{1} @</pre> </div> </div> <p>A typical output of <code>git range-diff</code> would look like this:</p> <div class="listingblock"> <div class="content"> <pre>-: ------- > 1: 0ddba11 Prepare for the inevitable! +1: c0debee = 2: cab005e Add a helpful message at the start +2: f00dbal ! 3: decafe1 Describe a bug + @@ -1,3 +1,3 @@ + Author: A U Thor <author@example.com> + + -TODO: Describe a bug + +Describe a bug + @@ -324,5 +324,6 + This is expected. + + -+What is unexpected is that it will also crash. + ++Unexpectedly, it also crashes. This is a bug, and the jury is + ++still out there how to fix it best. See ticket #314 for details. + + Contact +3: bedead < -: ------- TO-UNDO</pre> </div> </div> <p>In this example, there are 3 old and 3 new commits, where the developer removed the 3rd, added a new one before the first two, and modified the commit message of the 2nd commit as well as its diff.</p> <p>When the output goes to a terminal, it is color-coded by default, just like regular <code>git diff</code>'s output. In addition, the first line (adding a commit) is green, the last line (deleting a commit) is red, the second line (with a perfect match) is yellow like the commit header of <code>git +show</code>'s output, and the third line colors the old commit red, the new one green and the rest like <code>git show</code>'s commit header.</p> <p>A naive color-coded diff of diffs is actually a bit hard to read, though, as it colors the entire lines red or green. The line that added "What is unexpected" in the old commit, for example, is completely red, even if the intent of the old commit was to add something.</p> <p>To help with that, <code>range</code> uses the <code>--dual-color</code> mode by default. In this mode, the diff of diffs will retain the original diff colors, and prefix the lines with -/+ markers that have their <strong>background</strong> red or green, to make it more obvious that they describe how the diff itself changed.</p> </div> <h2 id="_algorithm">Algorithm</h2> <div class="sectionbody"> <p>The general idea is this: we generate a cost matrix between the commits in both commit ranges, then solve the least-cost assignment.</p> <p>The cost matrix is populated thusly: for each pair of commits, both diffs are generated and the "diff of diffs" is generated, with 3 context lines, then the number of lines in that diff is used as cost.</p> <p>To avoid false positives (e.g. when a patch has been removed, and an unrelated patch has been added between two iterations of the same patch series), the cost matrix is extended to allow for that, by adding fixed-cost entries for wholesale deletes/adds.</p> <p>Example: Let commits <code>1--2</code> be the first iteration of a patch series and <code>A--C</code> the second iteration. Let’s assume that <code>A</code> is a cherry-pick of <code>2,</code> and <code>C</code> is a cherry-pick of <code>1</code> but with a small modification (say, a fixed typo). Visualize the commits as a bipartite graph:</p> <div class="listingblock"> <div class="content"> <pre> 1 A + + 2 B + + C</pre> </div> </div> <p>We are looking for a "best" explanation of the new series in terms of the old one. We can represent an "explanation" as an edge in the graph:</p> <div class="listingblock"> <div class="content"> <pre> 1 A + / + 2 --------' B + + C</pre> </div> </div> <p>This explanation comes for "free" because there was no change. Similarly <code>C</code> could be explained using <code>1</code>, but that comes at some cost c>0 because of the modification:</p> <div class="listingblock"> <div class="content"> <pre> 1 ----. A + | / + 2 ----+---' B + | + `----- C + c>0</pre> </div> </div> <p>In mathematical terms, what we are looking for is some sort of a minimum cost bipartite matching; <code>1</code> is matched to <code>C</code> at some cost, etc. The underlying graph is in fact a complete bipartite graph; the cost we associate with every edge is the size of the diff between the two commits' patches. To explain also new commits, we introduce dummy nodes on both sides:</p> <div class="listingblock"> <div class="content"> <pre> 1 ----. A + | / + 2 ----+---' B + | + o `----- C + c>0 + o o + + o o</pre> </div> </div> <p>The cost of an edge <code>o--C</code> is the size of <code>C</code>'s diff, modified by a fudge factor that should be smaller than 100%. The cost of an edge <code>o--o</code> is free. The fudge factor is necessary because even if <code>1</code> and <code>C</code> have nothing in common, they may still share a few empty lines and such, possibly making the assignment <code>1--C</code>, <code>o--o</code> slightly cheaper than <code>1--o</code>, <code>o--C</code> even if <code>1</code> and <code>C</code> have nothing in common. With the fudge factor we require a much larger common part to consider patches as corresponding.</p> <p>The overall time needed to compute this algorithm is the time needed to compute n+m commit diffs and then n*m diffs of patches, plus the time needed to compute the least-cost assignment between n and m diffs. Git uses an implementation of the Jonker-Volgenant algorithm to solve the assignment problem, which has cubic runtime complexity. The matching found in this case will look like this:</p> <div class="listingblock"> <div class="content"> <pre> 1 ----. A + | / + 2 ----+---' B + .--+-----' + o -' `----- C + c>0 + o ---------- o + + o ---------- o</pre> </div> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-log">git-log[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-range-diff" class="_attribution-link">https://git-scm.com/docs/git-range-diff</a> + </p> +</div> diff --git a/devdocs/git/git-read-tree.html b/devdocs/git/git-read-tree.html new file mode 100644 index 00000000..7e6614c1 --- /dev/null +++ b/devdocs/git/git-read-tree.html @@ -0,0 +1,55 @@ +<h1>git-read-tree</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-read-tree - Reads tree information into the index</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git read-tree [(-m [--trivial] [--aggressive] | --reset | --prefix=<prefix>) + [-u | -i]] [--index-output=<file>] [--no-sparse-checkout] + (--empty | <tree-ish1> [<tree-ish2> [<tree-ish3>]])</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Reads the tree information given by <tree-ish> into the index, but does not actually <strong>update</strong> any of the files it "caches". (see: <a href="git-checkout-index">git-checkout-index[1]</a>)</p> <p>Optionally, it can merge a tree into the index, perform a fast-forward (i.e. 2-way) merge, or a 3-way merge, with the <code>-m</code> flag. When used with <code>-m</code>, the <code>-u</code> flag causes it to also update the files in the work tree with the result of the merge.</p> <p>Only trivial merges are done by <code>git read-tree</code> itself. Only conflicting paths will be in an unmerged state when <code>git read-tree</code> returns.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-read-tree.txt--m"> -m </dt> <dd> <p>Perform a merge, not just a read. The command will refuse to run if your index file has unmerged entries, indicating that you have not finished a previous merge you started.</p> </dd> <dt class="hdlist1" id="Documentation/git-read-tree.txt---reset"> --reset </dt> <dd> <p>Same as -m, except that unmerged entries are discarded instead of failing. When used with <code>-u</code>, updates leading to loss of working tree changes or untracked files or directories will not abort the operation.</p> </dd> <dt class="hdlist1" id="Documentation/git-read-tree.txt--u"> -u </dt> <dd> <p>After a successful merge, update the files in the work tree with the result of the merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-read-tree.txt--i"> -i </dt> <dd> <p>Usually a merge requires the index file as well as the files in the working tree to be up to date with the current head commit, in order not to lose local changes. This flag disables the check with the working tree and is meant to be used when creating a merge of trees that are not directly related to the current working tree status into a temporary index file.</p> </dd> <dt class="hdlist1" id="Documentation/git-read-tree.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-read-tree.txt---dry-run"> --dry-run </dt> <dd> <p>Check if the command would error out, without updating the index or the files in the working tree for real.</p> </dd> <dt class="hdlist1" id="Documentation/git-read-tree.txt--v"> -v </dt> <dd> <p>Show the progress of checking files out.</p> </dd> <dt class="hdlist1" id="Documentation/git-read-tree.txt---trivial"> --trivial </dt> <dd> <p>Restrict three-way merge by <code>git read-tree</code> to happen only if there is no file-level merging required, instead of resolving merge for trivial cases and leaving conflicting files unresolved in the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-read-tree.txt---aggressive"> --aggressive </dt> <dd> <p>Usually a three-way merge by <code>git read-tree</code> resolves the merge for really trivial cases and leaves other cases unresolved in the index, so that porcelains can implement different merge policies. This flag makes the command resolve a few more cases internally:</p> <div class="ulist"> <ul> <li> <p>when one side removes a path and the other side leaves the path unmodified. The resolution is to remove that path.</p> </li> <li> <p>when both sides remove a path. The resolution is to remove that path.</p> </li> <li> <p>when both sides add a path identically. The resolution is to add that path.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-read-tree.txt---prefixltprefixgt"> --prefix=<prefix> </dt> <dd> <p>Keep the current index contents, and read the contents of the named tree-ish under the directory at <code><prefix></code>. The command will refuse to overwrite entries that already existed in the original index file.</p> </dd> <dt class="hdlist1" id="Documentation/git-read-tree.txt---index-outputltfilegt"> --index-output=<file> </dt> <dd> <p>Instead of writing the results out to <code>$GIT_INDEX_FILE</code>, write the resulting index in the named file. While the command is operating, the original index file is locked with the same mechanism as usual. The file must allow to be rename(2)ed into from a temporary file that is created next to the usual index file; typically this means it needs to be on the same filesystem as the index file itself, and you need write permission to the directories the index file and index output file are located in.</p> </dd> <dt class="hdlist1" id="Documentation/git-read-tree.txt---no-recurse-submodules"> --[no-]recurse-submodules </dt> <dd> <p>Using --recurse-submodules will update the content of all active submodules according to the commit recorded in the superproject by calling read-tree recursively, also setting the submodules' HEAD to be detached at that commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-read-tree.txt---no-sparse-checkout"> --no-sparse-checkout </dt> <dd> <p>Disable sparse checkout support even if <code>core.sparseCheckout</code> is true.</p> </dd> <dt class="hdlist1" id="Documentation/git-read-tree.txt---empty"> --empty </dt> <dd> <p>Instead of reading tree object(s) into the index, just empty it.</p> </dd> <dt class="hdlist1" id="Documentation/git-read-tree.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-read-tree.txt---quiet"> --quiet </dt> <dd> <p>Quiet, suppress feedback messages.</p> </dd> <dt class="hdlist1" id="Documentation/git-read-tree.txt-lttree-ishgt"> <tree-ish#> </dt> <dd> <p>The id of the tree object(s) to be read/merged.</p> </dd> </dl> </div> </div> <h2 id="_merging">Merging</h2> <div class="sectionbody"> <p>If <code>-m</code> is specified, <code>git read-tree</code> can perform 3 kinds of merge, a single tree merge if only 1 tree is given, a fast-forward merge with 2 trees, or a 3-way merge if 3 or more trees are provided.</p> <div class="sect2"> <h3 id="_single_tree_merge"> +Single Tree Merge</h3> <p>If only 1 tree is specified, <code>git read-tree</code> operates as if the user did not specify <code>-m</code>, except that if the original index has an entry for a given pathname, and the contents of the path match with the tree being read, the stat info from the index is used. (In other words, the index’s stat()s take precedence over the merged tree’s).</p> <p>That means that if you do a <code>git read-tree -m <newtree></code> followed by a <code>git checkout-index -f -u -a</code>, the <code>git checkout-index</code> only checks out the stuff that really changed.</p> <p>This is used to avoid unnecessary false hits when <code>git diff-files</code> is run after <code>git read-tree</code>.</p> </div> <div class="sect2"> <h3 id="_two_tree_merge"> +Two Tree Merge</h3> <p>Typically, this is invoked as <code>git read-tree -m $H $M</code>, where $H is the head commit of the current repository, and $M is the head of a foreign tree, which is simply ahead of $H (i.e. we are in a fast-forward situation).</p> <p>When two trees are specified, the user is telling <code>git read-tree</code> the following:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>The current index and work tree is derived from $H, but the user may have local changes in them since $H.</p> </li> <li> <p>The user wants to fast-forward to $M.</p> </li> </ol> </div> <p>In this case, the <code>git read-tree -m $H $M</code> command makes sure that no local change is lost as the result of this "merge". Here are the "carry forward" rules, where "I" denotes the index, "clean" means that index and work tree coincide, and "exists"/"nothing" refer to the presence of a path in the specified commit:</p> <div class="literalblock"> <div class="content"> <pre> I H M Result + ------------------------------------------------------- + 0 nothing nothing nothing (does not happen) + 1 nothing nothing exists use M + 2 nothing exists nothing remove path from index + 3 nothing exists exists, use M if "initial checkout", + H == M keep index otherwise + exists, fail + H != M + + clean I==H I==M + ------------------ + 4 yes N/A N/A nothing nothing keep index + 5 no N/A N/A nothing nothing keep index + + 6 yes N/A yes nothing exists keep index + 7 no N/A yes nothing exists keep index + 8 yes N/A no nothing exists fail + 9 no N/A no nothing exists fail + + 10 yes yes N/A exists nothing remove path from index + 11 no yes N/A exists nothing fail + 12 yes no N/A exists nothing fail + 13 no no N/A exists nothing fail + + clean (H==M) + ------ + 14 yes exists exists keep index + 15 no exists exists keep index + + clean I==H I==M (H!=M) + ------------------ + 16 yes no no exists exists fail + 17 no no no exists exists fail + 18 yes no yes exists exists keep index + 19 no no yes exists exists keep index + 20 yes yes no exists exists use M + 21 no yes no exists exists fail</pre> </div> </div> <p>In all "keep index" cases, the index entry stays as in the original index file. If the entry is not up to date, <code>git read-tree</code> keeps the copy in the work tree intact when operating under the -u flag.</p> <p>When this form of <code>git read-tree</code> returns successfully, you can see which of the "local changes" that you made were carried forward by running <code>git diff-index --cached $M</code>. Note that this does not necessarily match what <code>git diff-index --cached $H</code> would have produced before such a two tree merge. This is because of cases 18 and 19 — if you already had the changes in $M (e.g. maybe you picked it up via e-mail in a patch form), <code>git diff-index +--cached $H</code> would have told you about the change before this merge, but it would not show in <code>git diff-index --cached $M</code> output after the two-tree merge.</p> <p>Case 3 is slightly tricky and needs explanation. The result from this rule logically should be to remove the path if the user staged the removal of the path and then switching to a new branch. That however will prevent the initial checkout from happening, so the rule is modified to use M (new tree) only when the content of the index is empty. Otherwise the removal of the path is kept as long as $H and $M are the same.</p> </div> <div class="sect2"> <h3 id="_3_way_merge"> +3-Way Merge</h3> <p>Each "index" entry has two bits worth of "stage" state. stage 0 is the normal one, and is the only one you’d see in any kind of normal use.</p> <p>However, when you do <code>git read-tree</code> with three trees, the "stage" starts out at 1.</p> <p>This means that you can do</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git read-tree -m <tree1> <tree2> <tree3></pre> </div> </div> <p>and you will end up with an index with all of the <tree1> entries in "stage1", all of the <tree2> entries in "stage2" and all of the <tree3> entries in "stage3". When performing a merge of another branch into the current branch, we use the common ancestor tree as <tree1>, the current branch head as <tree2>, and the other branch head as <tree3>.</p> <p>Furthermore, <code>git read-tree</code> has special-case logic that says: if you see a file that matches in all respects in the following states, it "collapses" back to "stage0":</p> <div class="ulist"> <ul> <li> <p>stage 2 and 3 are the same; take one or the other (it makes no difference - the same work has been done on our branch in stage 2 and their branch in stage 3)</p> </li> <li> <p>stage 1 and stage 2 are the same and stage 3 is different; take stage 3 (our branch in stage 2 did not do anything since the ancestor in stage 1 while their branch in stage 3 worked on it)</p> </li> <li> <p>stage 1 and stage 3 are the same and stage 2 is different take stage 2 (we did something while they did nothing)</p> </li> </ul> </div> <p>The <code>git write-tree</code> command refuses to write a nonsensical tree, and it will complain about unmerged entries if it sees a single entry that is not stage 0.</p> <p>OK, this all sounds like a collection of totally nonsensical rules, but it’s actually exactly what you want in order to do a fast merge. The different stages represent the "result tree" (stage 0, aka "merged"), the original tree (stage 1, aka "orig"), and the two trees you are trying to merge (stage 2 and 3 respectively).</p> <p>The order of stages 1, 2 and 3 (hence the order of three <tree-ish> command-line arguments) are significant when you start a 3-way merge with an index file that is already populated. Here is an outline of how the algorithm works:</p> <div class="ulist"> <ul> <li> <p>if a file exists in identical format in all three trees, it will automatically collapse to "merged" state by <code>git read-tree</code>.</p> </li> <li> <p>a file that has <code>any</code> difference what-so-ever in the three trees will stay as separate entries in the index. It’s up to "porcelain policy" to determine how to remove the non-0 stages, and insert a merged version.</p> </li> <li> <p>the index file saves and restores with all this information, so you can merge things incrementally, but as long as it has entries in stages 1/2/3 (i.e., "unmerged entries") you can’t write the result. So now the merge algorithm ends up being really simple:</p> <div class="ulist"> <ul> <li> <p>you walk the index in order, and ignore all entries of stage 0, since they’ve already been done.</p> </li> <li> <p>if you find a "stage1", but no matching "stage2" or "stage3", you know it’s been removed from both trees (it only existed in the original tree), and you remove that entry.</p> </li> <li> <p>if you find a matching "stage2" and "stage3" tree, you remove one of them, and turn the other into a "stage0" entry. Remove any matching "stage1" entry if it exists too. .. all the normal trivial rules ..</p> </li> </ul> </div> </li> </ul> </div> <p>You would normally use <code>git merge-index</code> with supplied <code>git merge-one-file</code> to do this last step. The script updates the files in the working tree as it merges each path and at the end of a successful merge.</p> <p>When you start a 3-way merge with an index file that is already populated, it is assumed that it represents the state of the files in your work tree, and you can even have files with changes unrecorded in the index file. It is further assumed that this state is "derived" from the stage 2 tree. The 3-way merge refuses to run if it finds an entry in the original index file that does not match stage 2.</p> <p>This is done to prevent you from losing your work-in-progress changes, and mixing your random changes in an unrelated merge commit. To illustrate, suppose you start from what has been committed last to your repository:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ JC=`git rev-parse --verify "HEAD^0"` +$ git checkout-index -f -u -a $JC</pre> </div> </div> <p>You do random edits, without running <code>git update-index</code>. And then you notice that the tip of your "upstream" tree has advanced since you pulled from him:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch git://.... linus +$ LT=`git rev-parse FETCH_HEAD`</pre> </div> </div> <p>Your work tree is still based on your HEAD ($JC), but you have some edits since. Three-way merge makes sure that you have not added or modified index entries since $JC, and if you haven’t, then does the right thing. So with the following sequence:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git read-tree -m -u `git merge-base $JC $LT` $JC $LT +$ git merge-index git-merge-one-file -a +$ echo "Merge with Linus" | \ + git commit-tree `git write-tree` -p $JC -p $LT</pre> </div> </div> <p>what you would commit is a pure merge between $JC and $LT without your work-in-progress changes, and your work tree would be updated to the result of the merge.</p> <p>However, if you have local changes in the working tree that would be overwritten by this merge, <code>git read-tree</code> will refuse to run to prevent your changes from being lost.</p> <p>In other words, there is no need to worry about what exists only in the working tree. When you have local changes in a part of the project that is not involved in the merge, your changes do not interfere with the merge, and are kept intact. When they <strong>do</strong> interfere, the merge does not even start (<code>git read-tree</code> complains loudly and fails without modifying anything). In such a case, you can simply continue doing what you were in the middle of doing, and when your working tree is ready (i.e. you have finished your work-in-progress), attempt the merge again.</p> </div> </div> <h2 id="_sparse_checkout">Sparse checkout</h2> <div class="sectionbody"> <p>Note: The skip-worktree capabilities in <a href="git-update-index">git-update-index[1]</a> and <code>read-tree</code> predated the introduction of <a href="git-sparse-checkout">git-sparse-checkout[1]</a>. Users are encouraged to use the <code>sparse-checkout</code> command in preference to these plumbing commands for sparse-checkout/skip-worktree related needs. However, the information below might be useful to users trying to understand the pattern style used in non-cone mode of the <code>sparse-checkout</code> command.</p> <p>"Sparse checkout" allows populating the working directory sparsely. It uses the skip-worktree bit (see <a href="git-update-index">git-update-index[1]</a>) to tell Git whether a file in the working directory is worth looking at.</p> <p><code>git read-tree</code> and other merge-based commands (<code>git merge</code>, <code>git checkout</code>…) can help maintaining the skip-worktree bitmap and working directory update. <code>$GIT_DIR/info/sparse-checkout</code> is used to define the skip-worktree reference bitmap. When <code>git read-tree</code> needs to update the working directory, it resets the skip-worktree bit in the index based on this file, which uses the same syntax as .gitignore files. If an entry matches a pattern in this file, or the entry corresponds to a file present in the working tree, then skip-worktree will not be set on that entry. Otherwise, skip-worktree will be set.</p> <p>Then it compares the new skip-worktree value with the previous one. If skip-worktree turns from set to unset, it will add the corresponding file back. If it turns from unset to set, that file will be removed.</p> <p>While <code>$GIT_DIR/info/sparse-checkout</code> is usually used to specify what files are in, you can also specify what files are <code>not</code> in, using negate patterns. For example, to remove the file <code>unwanted</code>:</p> <div class="listingblock"> <div class="content"> <pre>/* +!unwanted</pre> </div> </div> <p>Another tricky thing is fully repopulating the working directory when you no longer want sparse checkout. You cannot just disable "sparse checkout" because skip-worktree bits are still in the index and your working directory is still sparsely populated. You should re-populate the working directory with the <code>$GIT_DIR/info/sparse-checkout</code> file content as follows:</p> <div class="listingblock"> <div class="content"> <pre>/*</pre> </div> </div> <p>Then you can disable sparse checkout. Sparse checkout support in <code>git read-tree</code> and similar commands is disabled by default. You need to turn <code>core.sparseCheckout</code> on in order to have sparse checkout support.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-write-tree">git-write-tree[1]</a>, <a href="git-ls-files">git-ls-files[1]</a>, <a href="gitignore">gitignore[5]</a>, <a href="git-sparse-checkout">git-sparse-checkout[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-read-tree" class="_attribution-link">https://git-scm.com/docs/git-read-tree</a> + </p> +</div> diff --git a/devdocs/git/git-rebase.html b/devdocs/git/git-rebase.html new file mode 100644 index 00000000..f2278ec9 --- /dev/null +++ b/devdocs/git/git-rebase.html @@ -0,0 +1,129 @@ +<h1>git-rebase</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-rebase - Reapply commits on top of another base tip</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git rebase [-i | --interactive] [<options>] [--exec <cmd>] + [--onto <newbase> | --keep-base] [<upstream> [<branch>]] +git rebase [-i | --interactive] [<options>] [--exec <cmd>] [--onto <newbase>] + --root [<branch>] +git rebase (--continue | --skip | --abort | --quit | --edit-todo | --show-current-patch)</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>If <code><branch></code> is specified, <code>git rebase</code> will perform an automatic <code>git switch <branch></code> before doing anything else. Otherwise it remains on the current branch.</p> <p>If <code><upstream></code> is not specified, the upstream configured in <code>branch.<name>.remote</code> and <code>branch.<name>.merge</code> options will be used (see <a href="git-config">git-config[1]</a> for details) and the <code>--fork-point</code> option is assumed. If you are currently not on any branch or if the current branch does not have a configured upstream, the rebase will abort.</p> <p>All changes made by commits in the current branch but that are not in <code><upstream></code> are saved to a temporary area. This is the same set of commits that would be shown by <code>git log <upstream>..HEAD</code>; or by <code>git log 'fork_point'..HEAD</code>, if <code>--fork-point</code> is active (see the description on <code>--fork-point</code> below); or by <code>git log HEAD</code>, if the <code>--root</code> option is specified.</p> <p>The current branch is reset to <code><upstream></code> or <code><newbase></code> if the <code>--onto</code> option was supplied. This has the exact same effect as <code>git reset --hard <upstream></code> (or <code><newbase></code>). <code>ORIG_HEAD</code> is set to point at the tip of the branch before the reset.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> <code>ORIG_HEAD</code> is not guaranteed to still point to the previous branch tip at the end of the rebase if other commands that write that pseudo-ref (e.g. <code>git reset</code>) are used during the rebase. The previous branch tip, however, is accessible using the reflog of the current branch (i.e. <code>@{1}</code>, see <a href="gitrevisions">gitrevisions[7]</a>). </td> </tr> </table> </div> <p>The commits that were previously saved into the temporary area are then reapplied to the current branch, one by one, in order. Note that any commits in <code>HEAD</code> which introduce the same textual changes as a commit in <code>HEAD..<upstream></code> are omitted (i.e., a patch already accepted upstream with a different commit message or timestamp will be skipped).</p> <p>It is possible that a merge failure will prevent this process from being completely automatic. You will have to resolve any such merge failure and run <code>git rebase --continue</code>. Another option is to bypass the commit that caused the merge failure with <code>git rebase --skip</code>. To check out the original <code><branch></code> and remove the <code>.git/rebase-apply</code> working files, use the command <code>git rebase --abort</code> instead.</p> <p>Assume the following history exists and the current branch is "topic":</p> <div class="listingblock"> <div class="content"> <pre> A---B---C topic + / + D---E---F---G master</pre> </div> </div> <p>From this point, the result of either of the following commands:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git rebase master +git rebase master topic</pre> </div> </div> <p>would be:</p> <div class="listingblock"> <div class="content"> <pre> A'--B'--C' topic + / + D---E---F---G master</pre> </div> </div> <p><strong>NOTE:</strong> The latter form is just a short-hand of <code>git checkout topic</code> followed by <code>git rebase master</code>. When rebase exits <code>topic</code> will remain the checked-out branch.</p> <p>If the upstream branch already contains a change you have made (e.g., because you mailed a patch which was applied upstream), then that commit will be skipped and warnings will be issued (if the <code>merge</code> backend is used). For example, running <code>git rebase master</code> on the following history (in which <code>A'</code> and <code>A</code> introduce the same set of changes, but have different committer information):</p> <div class="listingblock"> <div class="content"> <pre> A---B---C topic + / + D---E---A'---F master</pre> </div> </div> <p>will result in:</p> <div class="listingblock"> <div class="content"> <pre> B'---C' topic + / + D---E---A'---F master</pre> </div> </div> <p>Here is how you would transplant a topic branch based on one branch to another, to pretend that you forked the topic branch from the latter branch, using <code>rebase --onto</code>.</p> <p>First let’s assume your <code>topic</code> is based on branch <code>next</code>. For example, a feature developed in <code>topic</code> depends on some functionality which is found in <code>next</code>.</p> <div class="listingblock"> <div class="content"> <pre> o---o---o---o---o master + \ + o---o---o---o---o next + \ + o---o---o topic</pre> </div> </div> <p>We want to make <code>topic</code> forked from branch <code>master</code>; for example, because the functionality on which <code>topic</code> depends was merged into the more stable <code>master</code> branch. We want our tree to look like this:</p> <div class="listingblock"> <div class="content"> <pre> o---o---o---o---o master + | \ + | o'--o'--o' topic + \ + o---o---o---o---o next</pre> </div> </div> <p>We can get this using the following command:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git rebase --onto master next topic</pre> </div> </div> <p>Another example of --onto option is to rebase part of a branch. If we have the following situation:</p> <div class="listingblock"> <div class="content"> <pre> H---I---J topicB + / + E---F---G topicA + / + A---B---C---D master</pre> </div> </div> <p>then the command</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git rebase --onto master topicA topicB</pre> </div> </div> <p>would result in:</p> <div class="listingblock"> <div class="content"> <pre> H'--I'--J' topicB + / + | E---F---G topicA + |/ + A---B---C---D master</pre> </div> </div> <p>This is useful when topicB does not depend on topicA.</p> <p>A range of commits could also be removed with rebase. If we have the following situation:</p> <div class="listingblock"> <div class="content"> <pre> E---F---G---H---I---J topicA</pre> </div> </div> <p>then the command</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git rebase --onto topicA~5 topicA~3 topicA</pre> </div> </div> <p>would result in the removal of commits F and G:</p> <div class="listingblock"> <div class="content"> <pre> E---H'---I'---J' topicA</pre> </div> </div> <p>This is useful if F and G were flawed in some way, or should not be part of topicA. Note that the argument to <code>--onto</code> and the <code><upstream></code> parameter can be any valid commit-ish.</p> <p>In case of conflict, <code>git rebase</code> will stop at the first problematic commit and leave conflict markers in the tree. You can use <code>git diff</code> to locate the markers (<<<<<<) and make edits to resolve the conflict. For each file you edit, you need to tell Git that the conflict has been resolved, typically this would be done with</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git add <filename></pre> </div> </div> <p>After resolving the conflict manually and updating the index with the desired resolution, you can continue the rebasing process with</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git rebase --continue</pre> </div> </div> <p>Alternatively, you can undo the <code>git rebase</code> with</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git rebase --abort</pre> </div> </div> </div> <h2 id="_mode_options">Mode options</h2> <div class="sectionbody"> <p>The options in this section cannot be used with any other option, including not with each other:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rebase.txt---continue"> --continue </dt> <dd> <p>Restart the rebasing process after having resolved a merge conflict.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---skip"> --skip </dt> <dd> <p>Restart the rebasing process by skipping the current patch.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---abort"> --abort </dt> <dd> <p>Abort the rebase operation and reset HEAD to the original branch. If <code><branch></code> was provided when the rebase operation was started, then <code>HEAD</code> will be reset to <code><branch></code>. Otherwise <code>HEAD</code> will be reset to where it was when the rebase operation was started.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---quit"> --quit </dt> <dd> <p>Abort the rebase operation but <code>HEAD</code> is not reset back to the original branch. The index and working tree are also left unchanged as a result. If a temporary stash entry was created using <code>--autostash</code>, it will be saved to the stash list.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---edit-todo"> --edit-todo </dt> <dd> <p>Edit the todo list during an interactive rebase.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---show-current-patch"> --show-current-patch </dt> <dd> <p>Show the current patch in an interactive rebase or when rebase is stopped because of conflicts. This is the equivalent of <code>git show REBASE_HEAD</code>.</p> </dd> </dl> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rebase.txt---ontoltnewbasegt"> --onto <newbase> </dt> <dd> <p>Starting point at which to create the new commits. If the <code>--onto</code> option is not specified, the starting point is <code><upstream></code>. May be any valid commit, and not just an existing branch name.</p> <p>As a special case, you may use "A...B" as a shortcut for the merge base of A and B if there is exactly one merge base. You can leave out at most one of A and B, in which case it defaults to HEAD.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---keep-base"> --keep-base </dt> <dd> <p>Set the starting point at which to create the new commits to the merge base of <code><upstream></code> and <code><branch></code>. Running <code>git rebase --keep-base <upstream> <branch></code> is equivalent to running <code>git rebase --reapply-cherry-picks --no-fork-point --onto <upstream>...<branch> <upstream> <branch></code>.</p> <p>This option is useful in the case where one is developing a feature on top of an upstream branch. While the feature is being worked on, the upstream branch may advance and it may not be the best idea to keep rebasing on top of the upstream but to keep the base commit as-is. As the base commit is unchanged this option implies <code>--reapply-cherry-picks</code> to avoid losing commits.</p> <p>Although both this option and <code>--fork-point</code> find the merge base between <code><upstream></code> and <code><branch></code>, this option uses the merge base as the <code>starting point</code> on which new commits will be created, whereas <code>--fork-point</code> uses the merge base to determine the <code>set of commits</code> which will be rebased.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-ltupstreamgt"> <upstream> </dt> <dd> <p>Upstream branch to compare against. May be any valid commit, not just an existing branch name. Defaults to the configured upstream for the current branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-ltbranchgt"> <branch> </dt> <dd> <p>Working branch; defaults to <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---apply"> --apply </dt> <dd> <p>Use applying strategies to rebase (calling <code>git-am</code> internally). This option may become a no-op in the future once the merge backend handles everything the apply one does.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---emptydropkeepask"> --empty=(drop|keep|ask) </dt> <dd> <p>How to handle commits that are not empty to start and are not clean cherry-picks of any upstream commit, but which become empty after rebasing (because they contain a subset of already upstream changes). With drop (the default), commits that become empty are dropped. With keep, such commits are kept. With ask (implied by <code>--interactive</code>), the rebase will halt when an empty commit is applied allowing you to choose whether to drop it, edit files more, or just commit the empty changes. Other options, like <code>--exec</code>, will use the default of drop unless <code>-i</code>/<code>--interactive</code> is explicitly specified.</p> <p>Note that commits which start empty are kept (unless <code>--no-keep-empty</code> is specified), and commits which are clean cherry-picks (as determined by <code>git log --cherry-mark ...</code>) are detected and dropped as a preliminary step (unless <code>--reapply-cherry-picks</code> or <code>--keep-base</code> is passed).</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---no-keep-empty"> --no-keep-empty </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---keep-empty"> --keep-empty </dt> <dd> <p>Do not keep commits that start empty before the rebase (i.e. that do not change anything from its parent) in the result. The default is to keep commits which start empty, since creating such commits requires passing the <code>--allow-empty</code> override flag to <code>git commit</code>, signifying that a user is very intentionally creating such a commit and thus wants to keep it.</p> <p>Usage of this flag will probably be rare, since you can get rid of commits that start empty by just firing up an interactive rebase and removing the lines corresponding to the commits you don’t want. This flag exists as a convenient shortcut, such as for cases where external tools generate many empty commits and you want them all removed.</p> <p>For commits which do not start empty but become empty after rebasing, see the <code>--empty</code> flag.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---reapply-cherry-picks"> --reapply-cherry-picks </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---no-reapply-cherry-picks"> --no-reapply-cherry-picks </dt> <dd> <p>Reapply all clean cherry-picks of any upstream commit instead of preemptively dropping them. (If these commits then become empty after rebasing, because they contain a subset of already upstream changes, the behavior towards them is controlled by the <code>--empty</code> flag.)</p> <p>In the absence of <code>--keep-base</code> (or if <code>--no-reapply-cherry-picks</code> is given), these commits will be automatically dropped. Because this necessitates reading all upstream commits, this can be expensive in repositories with a large number of upstream commits that need to be read. When using the <code>merge</code> backend, warnings will be issued for each dropped commit (unless <code>--quiet</code> is given). Advice will also be issued unless <code>advice.skippedCherryPicks</code> is set to false (see <a href="git-config">git-config[1]</a>).</p> <p><code>--reapply-cherry-picks</code> allows rebase to forgo reading all upstream commits, potentially improving performance.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---allow-empty-message"> --allow-empty-message </dt> <dd> <p>No-op. Rebasing commits with an empty message used to fail and this option would override that behavior, allowing commits with empty messages to be rebased. Now commits with an empty message do not cause rebasing to halt.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt--m"> -m </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---merge"> --merge </dt> <dd> <p>Using merging strategies to rebase (default).</p> <p>Note that a rebase merge works by replaying each commit from the working branch on top of the <code><upstream></code> branch. Because of this, when a merge conflict happens, the side reported as <code>ours</code> is the so-far rebased series, starting with <code><upstream></code>, and <code>theirs</code> is the working branch. In other words, the sides are swapped.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt--sltstrategygt"> -s <strategy> </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---strategyltstrategygt"> --strategy=<strategy> </dt> <dd> <p>Use the given merge strategy, instead of the default <code>ort</code>. This implies <code>--merge</code>.</p> <p>Because <code>git rebase</code> replays each commit from the working branch on top of the <code><upstream></code> branch using the given strategy, using the <code>ours</code> strategy simply empties all patches from the <code><branch></code>, which makes little sense.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt--Xltstrategy-optiongt"> -X <strategy-option> </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---strategy-optionltstrategy-optiongt"> --strategy-option=<strategy-option> </dt> <dd> <p>Pass the <strategy-option> through to the merge strategy. This implies <code>--merge</code> and, if no strategy has been specified, <code>-s ort</code>. Note the reversal of <code>ours</code> and <code>theirs</code> as noted above for the <code>-m</code> option.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---rerere-autoupdate"> --rerere-autoupdate </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---no-rerere-autoupdate"> --no-rerere-autoupdate </dt> <dd> <p>After the rerere mechanism reuses a recorded resolution on the current conflict to update the files in the working tree, allow it to also update the index with the result of resolution. <code>--no-rerere-autoupdate</code> is a good way to double-check what <code>rerere</code> did and catch potential mismerges, before committing the result to the index with a separate <code>git add</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt--Sltkeyidgt"> -S[<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---gpg-signltkeyidgt"> --gpg-sign[=<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---no-gpg-sign"> --no-gpg-sign </dt> <dd> <p>GPG-sign commits. The <code>keyid</code> argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space. <code>--no-gpg-sign</code> is useful to countermand both <code>commit.gpgSign</code> configuration variable, and earlier <code>--gpg-sign</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---quiet"> --quiet </dt> <dd> <p>Be quiet. Implies <code>--no-stat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---verbose"> --verbose </dt> <dd> <p>Be verbose. Implies <code>--stat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---stat"> --stat </dt> <dd> <p>Show a diffstat of what changed upstream since the last rebase. The diffstat is also controlled by the configuration option rebase.stat.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---no-stat"> --no-stat </dt> <dd> <p>Do not show a diffstat as part of the rebase process.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---no-verify"> --no-verify </dt> <dd> <p>This option bypasses the pre-rebase hook. See also <a href="githooks">githooks[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---verify"> --verify </dt> <dd> <p>Allows the pre-rebase hook to run, which is the default. This option can be used to override <code>--no-verify</code>. See also <a href="githooks">githooks[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt--Cltngt"> -C<n> </dt> <dd> <p>Ensure at least <code><n></code> lines of surrounding context match before and after each change. When fewer lines of surrounding context exist they all must match. By default no context is ever ignored. Implies <code>--apply</code>.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---no-ff"> --no-ff </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---force-rebase"> --force-rebase </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt--f"> -f </dt> <dd> <p>Individually replay all rebased commits instead of fast-forwarding over the unchanged ones. This ensures that the entire history of the rebased branch is composed of new commits.</p> <p>You may find this helpful after reverting a topic branch merge, as this option recreates the topic branch with fresh commits so it can be remerged successfully without needing to "revert the reversion" (see the <a href="https://git-scm.com/docs/howto/revert-a-faulty-merge">revert-a-faulty-merge How-To</a> for details).</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---fork-point"> --fork-point </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---no-fork-point"> --no-fork-point </dt> <dd> <p>Use reflog to find a better common ancestor between <code><upstream></code> and <code><branch></code> when calculating which commits have been introduced by <code><branch></code>.</p> <p>When <code>--fork-point</code> is active, <code>fork_point</code> will be used instead of <code><upstream></code> to calculate the set of commits to rebase, where <code>fork_point</code> is the result of <code>git merge-base --fork-point <upstream> +<branch></code> command (see <a href="git-merge-base">git-merge-base[1]</a>). If <code>fork_point</code> ends up being empty, the <code><upstream></code> will be used as a fallback.</p> <p>If <code><upstream></code> or <code>--keep-base</code> is given on the command line, then the default is <code>--no-fork-point</code>, otherwise the default is <code>--fork-point</code>. See also <code>rebase.forkpoint</code> in <a href="git-config">git-config[1]</a>.</p> <p>If your branch was based on <code><upstream></code> but <code><upstream></code> was rewound and your branch contains commits which were dropped, this option can be used with <code>--keep-base</code> in order to drop those commits from your branch.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---ignore-whitespace"> --ignore-whitespace </dt> <dd> <p>Ignore whitespace differences when trying to reconcile differences. Currently, each backend implements an approximation of this behavior:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rebase.txt-applybackend"> apply backend </dt> <dd> <p>When applying a patch, ignore changes in whitespace in context lines. Unfortunately, this means that if the "old" lines being replaced by the patch differ only in whitespace from the existing file, you will get a merge conflict instead of a successful patch application.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-mergebackend"> merge backend </dt> <dd> <p>Treat lines with only whitespace changes as unchanged when merging. Unfortunately, this means that any patch hunks that were intended to modify whitespace and nothing else will be dropped, even if the other side had no changes that conflicted.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---whitespaceltoptiongt"> --whitespace=<option> </dt> <dd> <p>This flag is passed to the <code>git apply</code> program (see <a href="git-apply">git-apply[1]</a>) that applies the patch. Implies <code>--apply</code>.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---committer-date-is-author-date"> --committer-date-is-author-date </dt> <dd> <p>Instead of using the current time as the committer date, use the author date of the commit being rebased as the committer date. This option implies <code>--force-rebase</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---ignore-date"> --ignore-date </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---reset-author-date"> --reset-author-date </dt> <dd> <p>Instead of using the author date of the original commit, use the current time as the author date of the rebased commit. This option implies <code>--force-rebase</code>.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---signoff"> --signoff </dt> <dd> <p>Add a <code>Signed-off-by</code> trailer to all the rebased commits. Note that if <code>--interactive</code> is given then only commits marked to be picked, edited or reworded will have the trailer added.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt--i"> -i </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---interactive"> --interactive </dt> <dd> <p>Make a list of the commits which are about to be rebased. Let the user edit that list before rebasing. This mode can also be used to split commits (see SPLITTING COMMITS below).</p> <p>The commit list format can be changed by setting the configuration option rebase.instructionFormat. A customized instruction format will automatically have the commit hash prepended to the format.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt--r"> -r </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---rebase-mergesrebase-cousinsno-rebase-cousins"> --rebase-merges[=(rebase-cousins|no-rebase-cousins)] </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---no-rebase-merges"> --no-rebase-merges </dt> <dd> <p>By default, a rebase will simply drop merge commits from the todo list, and put the rebased commits into a single, linear branch. With <code>--rebase-merges</code>, the rebase will instead try to preserve the branching structure within the commits that are to be rebased, by recreating the merge commits. Any resolved merge conflicts or manual amendments in these merge commits will have to be resolved/re-applied manually. <code>--no-rebase-merges</code> can be used to countermand both the <code>rebase.rebaseMerges</code> config option and a previous <code>--rebase-merges</code>.</p> <p>When rebasing merges, there are two modes: <code>rebase-cousins</code> and <code>no-rebase-cousins</code>. If the mode is not specified, it defaults to <code>no-rebase-cousins</code>. In <code>no-rebase-cousins</code> mode, commits which do not have <code><upstream></code> as direct ancestor will keep their original branch point, i.e. commits that would be excluded by <a href="git-log">git-log[1]</a>'s <code>--ancestry-path</code> option will keep their original ancestry by default. In <code>rebase-cousins</code> mode, such commits are instead rebased onto <code><upstream></code> (or <code><onto></code>, if specified).</p> <p>It is currently only possible to recreate the merge commits using the <code>ort</code> merge strategy; different merge strategies can be used only via explicit <code>exec git merge -s <strategy> [...]</code> commands.</p> <p>See also REBASING MERGES and INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt--xltcmdgt"> -x <cmd> </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---execltcmdgt"> --exec <cmd> </dt> <dd> <p>Append "exec <cmd>" after each line creating a commit in the final history. <code><cmd></code> will be interpreted as one or more shell commands. Any command that fails will interrupt the rebase, with exit code 1.</p> <p>You may execute several commands by either using one instance of <code>--exec</code> with several commands:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git rebase -i --exec "cmd1 && cmd2 && ..."</pre> </div> </div> <p>or by giving more than one <code>--exec</code>:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git rebase -i --exec "cmd1" --exec "cmd2" --exec ...</pre> </div> </div> <p>If <code>--autosquash</code> is used, <code>exec</code> lines will not be appended for the intermediate commits, and will only appear at the end of each squash/fixup series.</p> <p>This uses the <code>--interactive</code> machinery internally, but it can be run without an explicit <code>--interactive</code>.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---root"> --root </dt> <dd> <p>Rebase all commits reachable from <code><branch></code>, instead of limiting them with an <code><upstream></code>. This allows you to rebase the root commit(s) on a branch.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---autosquash"> --autosquash </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---no-autosquash"> --no-autosquash </dt> <dd> <p>When the commit log message begins with "squash! …" or "fixup! …" or "amend! …", and there is already a commit in the todo list that matches the same <code>...</code>, automatically modify the todo list of <code>rebase -i</code>, so that the commit marked for squashing comes right after the commit to be modified, and change the action of the moved commit from <code>pick</code> to <code>squash</code> or <code>fixup</code> or <code>fixup -C</code> respectively. A commit matches the <code>...</code> if the commit subject matches, or if the <code>...</code> refers to the commit’s hash. As a fall-back, partial matches of the commit subject work, too. The recommended way to create fixup/amend/squash commits is by using the <code>--fixup</code>, <code>--fixup=amend:</code> or <code>--fixup=reword:</code> and <code>--squash</code> options respectively of <a href="git-commit">git-commit[1]</a>.</p> <p>If the <code>--autosquash</code> option is enabled by default using the configuration variable <code>rebase.autoSquash</code>, this option can be used to override and disable this setting.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---autostash"> --autostash </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---no-autostash"> --no-autostash </dt> <dd> <p>Automatically create a temporary stash entry before the operation begins, and apply it after the operation ends. This means that you can run rebase on a dirty worktree. However, use with care: the final stash application after a successful rebase might result in non-trivial conflicts.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---reschedule-failed-exec"> --reschedule-failed-exec </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---no-reschedule-failed-exec"> --no-reschedule-failed-exec </dt> <dd> <p>Automatically reschedule <code>exec</code> commands that failed. This only makes sense in interactive mode (or when an <code>--exec</code> option was provided).</p> <p>This option applies once a rebase is started. It is preserved for the whole rebase based on, in order, the command line option provided to the initial <code>git +rebase</code>, the <code>rebase.rescheduleFailedExec</code> configuration (see <a href="git-config">git-config[1]</a> or "CONFIGURATION" below), or it defaults to false.</p> <p>Recording this option for the whole rebase is a convenience feature. Otherwise an explicit <code>--no-reschedule-failed-exec</code> at the start would be overridden by the presence of a <code>rebase.rescheduleFailedExec=true</code> configuration when <code>git +rebase --continue</code> is invoked. Currently, you cannot pass <code>--[no-]reschedule-failed-exec</code> to <code>git rebase --continue</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt---update-refs"> --update-refs </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt---no-update-refs"> --no-update-refs </dt> <dd> <p>Automatically force-update any branches that point to commits that are being rebased. Any branches that are checked out in a worktree are not updated in this way.</p> <p>If the configuration variable <code>rebase.updateRefs</code> is set, then this option can be used to override and disable this setting.</p> <p>See also INCOMPATIBLE OPTIONS below.</p> </dd> </dl> </div> </div> <h2 id="_incompatible_options">Incompatible options</h2> <div class="sectionbody"> <p>The following options:</p> <div class="ulist"> <ul> <li> <p>--apply</p> </li> <li> <p>--whitespace</p> </li> <li> <p>-C</p> </li> </ul> </div> <p>are incompatible with the following options:</p> <div class="ulist"> <ul> <li> <p>--merge</p> </li> <li> <p>--strategy</p> </li> <li> <p>--strategy-option</p> </li> <li> <p>--autosquash</p> </li> <li> <p>--rebase-merges</p> </li> <li> <p>--interactive</p> </li> <li> <p>--exec</p> </li> <li> <p>--no-keep-empty</p> </li> <li> <p>--empty=</p> </li> <li> <p>--[no-]reapply-cherry-picks when used without --keep-base</p> </li> <li> <p>--update-refs</p> </li> <li> <p>--root when used without --onto</p> </li> </ul> </div> <p>In addition, the following pairs of options are incompatible:</p> <div class="ulist"> <ul> <li> <p>--keep-base and --onto</p> </li> <li> <p>--keep-base and --root</p> </li> <li> <p>--fork-point and --root</p> </li> </ul> </div> </div> <h2 id="_behavioral_differences">Behavioral differences</h2> <div class="sectionbody"> <p><code>git rebase</code> has two primary backends: <code>apply</code> and <code>merge</code>. (The <code>apply</code> backend used to be known as the <code>am</code> backend, but the name led to confusion as it looks like a verb instead of a noun. Also, the <code>merge</code> backend used to be known as the interactive backend, but it is now used for non-interactive cases as well. Both were renamed based on lower-level functionality that underpinned each.) There are some subtle differences in how these two backends behave:</p> <div class="sect2"> <h3 id="_empty_commits"> +Empty commits</h3> <p>The <code>apply</code> backend unfortunately drops intentionally empty commits, i.e. commits that started empty, though these are rare in practice. It also drops commits that become empty and has no option for controlling this behavior.</p> <p>The <code>merge</code> backend keeps intentionally empty commits by default (though with <code>-i</code> they are marked as empty in the todo list editor, or they can be dropped automatically with <code>--no-keep-empty</code>).</p> <p>Similar to the apply backend, by default the merge backend drops commits that become empty unless <code>-i</code>/<code>--interactive</code> is specified (in which case it stops and asks the user what to do). The merge backend also has an <code>--empty=(drop|keep|ask)</code> option for changing the behavior of handling commits that become empty.</p> </div> <div class="sect2"> <h3 id="_directory_rename_detection"> +Directory rename detection</h3> <p>Due to the lack of accurate tree information (arising from constructing fake ancestors with the limited information available in patches), directory rename detection is disabled in the <code>apply</code> backend. Disabled directory rename detection means that if one side of history renames a directory and the other adds new files to the old directory, then the new files will be left behind in the old directory without any warning at the time of rebasing that you may want to move these files into the new directory.</p> <p>Directory rename detection works with the <code>merge</code> backend to provide you warnings in such cases.</p> </div> <div class="sect2"> <h3 id="_context"> +Context</h3> <p>The <code>apply</code> backend works by creating a sequence of patches (by calling <code>format-patch</code> internally), and then applying the patches in sequence (calling <code>am</code> internally). Patches are composed of multiple hunks, each with line numbers, a context region, and the actual changes. The line numbers have to be taken with some fuzz, since the other side will likely have inserted or deleted lines earlier in the file. The context region is meant to help find how to adjust the line numbers in order to apply the changes to the right lines. However, if multiple areas of the code have the same surrounding lines of context, the wrong one can be picked. There are real-world cases where this has caused commits to be reapplied incorrectly with no conflicts reported. Setting <code>diff.context</code> to a larger value may prevent such types of problems, but increases the chance of spurious conflicts (since it will require more lines of matching context to apply).</p> <p>The <code>merge</code> backend works with a full copy of each relevant file, insulating it from these types of problems.</p> </div> <div class="sect2"> <h3 id="_labelling_of_conflicts_markers"> +Labelling of conflicts markers</h3> <p>When there are content conflicts, the merge machinery tries to annotate each side’s conflict markers with the commits where the content came from. Since the <code>apply</code> backend drops the original information about the rebased commits and their parents (and instead generates new fake commits based off limited information in the generated patches), those commits cannot be identified; instead it has to fall back to a commit summary. Also, when <code>merge.conflictStyle</code> is set to <code>diff3</code> or <code>zdiff3</code>, the <code>apply</code> backend will use "constructed merge base" to label the content from the merge base, and thus provide no information about the merge base commit whatsoever.</p> <p>The <code>merge</code> backend works with the full commits on both sides of history and thus has no such limitations.</p> </div> <div class="sect2"> <h3 id="_hooks"> +Hooks</h3> <p>The <code>apply</code> backend has not traditionally called the post-commit hook, while the <code>merge</code> backend has. Both have called the post-checkout hook, though the <code>merge</code> backend has squelched its output. Further, both backends only call the post-checkout hook with the starting point commit of the rebase, not the intermediate commits nor the final commit. In each case, the calling of these hooks was by accident of implementation rather than by design (both backends were originally implemented as shell scripts and happened to invoke other commands like <code>git checkout</code> or <code>git commit</code> that would call the hooks). Both backends should have the same behavior, though it is not entirely clear which, if any, is correct. We will likely make rebase stop calling either of these hooks in the future.</p> </div> <div class="sect2"> <h3 id="_interruptability"> +Interruptability</h3> <p>The <code>apply</code> backend has safety problems with an ill-timed interrupt; if the user presses Ctrl-C at the wrong time to try to abort the rebase, the rebase can enter a state where it cannot be aborted with a subsequent <code>git rebase --abort</code>. The <code>merge</code> backend does not appear to suffer from the same shortcoming. (See <a href="https://lore.kernel.org/git/20200207132152.GC2868@szeder.dev/" class="bare">https://lore.kernel.org/git/20200207132152.GC2868@szeder.dev/</a> for details.)</p> </div> <div class="sect2"> <h3 id="_commit_rewording"> +Commit Rewording</h3> <p>When a conflict occurs while rebasing, rebase stops and asks the user to resolve. Since the user may need to make notable changes while resolving conflicts, after conflicts are resolved and the user has run <code>git rebase --continue</code>, the rebase should open an editor and ask the user to update the commit message. The <code>merge</code> backend does this, while the <code>apply</code> backend blindly applies the original commit message.</p> </div> <div class="sect2"> <h3 id="_miscellaneous_differences"> +Miscellaneous differences</h3> <p>There are a few more behavioral differences that most folks would probably consider inconsequential but which are mentioned for completeness:</p> <div class="ulist"> <ul> <li> <p>Reflog: The two backends will use different wording when describing the changes made in the reflog, though both will make use of the word "rebase".</p> </li> <li> <p>Progress, informational, and error messages: The two backends provide slightly different progress and informational messages. Also, the apply backend writes error messages (such as "Your files would be overwritten…") to stdout, while the merge backend writes them to stderr.</p> </li> <li> <p>State directories: The two backends keep their state in different directories under <code>.git/</code></p> </li> </ul> </div> </div> </div> <h2 id="_merge_strategies">Merge strategies</h2> <div class="sectionbody"> <p>The merge mechanism (<code>git merge</code> and <code>git pull</code> commands) allows the backend <code>merge strategies</code> to be chosen with <code>-s</code> option. Some strategies can also take their own options, which can be passed by giving <code>-X<option></code> arguments to <code>git merge</code> and/or <code>git pull</code>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rebase.txt-ort"> ort </dt> <dd> <p>This is the default merge strategy when pulling or merging one branch. This strategy can only resolve two heads using a 3-way merge algorithm. When there is more than one common ancestor that can be used for 3-way merge, it creates a merged tree of the common ancestors and uses that as the reference tree for the 3-way merge. This has been reported to result in fewer merge conflicts without causing mismerges by tests done on actual merge commits taken from Linux 2.6 kernel development history. Additionally this strategy can detect and handle merges involving renames. It does not make use of detected copies. The name for this algorithm is an acronym ("Ostensibly Recursive’s Twin") and came from the fact that it was written as a replacement for the previous default algorithm, <code>recursive</code>.</p> <p>The <code>ort</code> strategy can take the following options:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rebase.txt-ours"> ours </dt> <dd> <p>This option forces conflicting hunks to be auto-resolved cleanly by favoring <code>our</code> version. Changes from the other tree that do not conflict with our side are reflected in the merge result. For a binary file, the entire contents are taken from our side.</p> <p>This should not be confused with the <code>ours</code> merge strategy, which does not even look at what the other tree contains at all. It discards everything the other tree did, declaring <code>our</code> history contains all that happened in it.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-theirs"> theirs </dt> <dd> <p>This is the opposite of <code>ours</code>; note that, unlike <code>ours</code>, there is no <code>theirs</code> merge strategy to confuse this merge option with.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-ignore-space-change"> ignore-space-change </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt-ignore-all-space"> ignore-all-space </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt-ignore-space-at-eol"> ignore-space-at-eol </dt> <dt class="hdlist1" id="Documentation/git-rebase.txt-ignore-cr-at-eol"> ignore-cr-at-eol </dt> <dd> <p>Treats lines with the indicated type of whitespace change as unchanged for the sake of a three-way merge. Whitespace changes mixed with other changes to a line are not ignored. See also <a href="git-diff">git-diff[1]</a> <code>-b</code>, <code>-w</code>, <code>--ignore-space-at-eol</code>, and <code>--ignore-cr-at-eol</code>.</p> <div class="ulist"> <ul> <li> <p>If <code>their</code> version only introduces whitespace changes to a line, <code>our</code> version is used;</p> </li> <li> <p>If <code>our</code> version introduces whitespace changes but <code>their</code> version includes a substantial change, <code>their</code> version is used;</p> </li> <li> <p>Otherwise, the merge proceeds in the usual way.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-renormalize"> renormalize </dt> <dd> <p>This runs a virtual check-out and check-in of all three stages of a file when resolving a three-way merge. This option is meant to be used when merging branches with different clean filters or end-of-line normalization rules. See "Merging branches with differing checkin/checkout attributes" in <a href="gitattributes">gitattributes[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-no-renormalize"> no-renormalize </dt> <dd> <p>Disables the <code>renormalize</code> option. This overrides the <code>merge.renormalize</code> configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-find-renamesltngt"> find-renames[=<n>] </dt> <dd> <p>Turn on rename detection, optionally setting the similarity threshold. This is the default. This overrides the <code>merge.renames</code> configuration variable. See also <a href="git-diff">git-diff[1]</a> <code>--find-renames</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-rename-thresholdltngt"> rename-threshold=<n> </dt> <dd> <p>Deprecated synonym for <code>find-renames=<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-subtreeltpathgt"> subtree[=<path>] </dt> <dd> <p>This option is a more advanced form of <code>subtree</code> strategy, where the strategy makes a guess on how two trees must be shifted to match with each other when merging. Instead, the specified path is prefixed (or stripped from the beginning) to make the shape of two trees to match.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-recursive"> recursive </dt> <dd> <p>This can only resolve two heads using a 3-way merge algorithm. When there is more than one common ancestor that can be used for 3-way merge, it creates a merged tree of the common ancestors and uses that as the reference tree for the 3-way merge. This has been reported to result in fewer merge conflicts without causing mismerges by tests done on actual merge commits taken from Linux 2.6 kernel development history. Additionally this can detect and handle merges involving renames. It does not make use of detected copies. This was the default strategy for resolving two heads from Git v0.99.9k until v2.33.0.</p> <p>The <code>recursive</code> strategy takes the same options as <code>ort</code>. However, there are three additional options that <code>ort</code> ignores (not documented above) that are potentially useful with the <code>recursive</code> strategy:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rebase.txt-patience"> patience </dt> <dd> <p>Deprecated synonym for <code>diff-algorithm=patience</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-diff-algorithmpatienceminimalhistogrammyers"> diff-algorithm=[patience|minimal|histogram|myers] </dt> <dd> <p>Use a different diff algorithm while merging, which can help avoid mismerges that occur due to unimportant matching lines (such as braces from distinct functions). See also <a href="git-diff">git-diff[1]</a> <code>--diff-algorithm</code>. Note that <code>ort</code> specifically uses <code>diff-algorithm=histogram</code>, while <code>recursive</code> defaults to the <code>diff.algorithm</code> config setting.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-no-renames"> no-renames </dt> <dd> <p>Turn off rename detection. This overrides the <code>merge.renames</code> configuration variable. See also <a href="git-diff">git-diff[1]</a> <code>--no-renames</code>.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-resolve"> resolve </dt> <dd> <p>This can only resolve two heads (i.e. the current branch and another branch you pulled from) using a 3-way merge algorithm. It tries to carefully detect criss-cross merge ambiguities. It does not handle renames.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-octopus"> octopus </dt> <dd> <p>This resolves cases with more than two heads, but refuses to do a complex merge that needs manual resolution. It is primarily meant to be used for bundling topic branch heads together. This is the default merge strategy when pulling or merging more than one branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-ours-1"> ours </dt> <dd> <p>This resolves any number of heads, but the resulting tree of the merge is always that of the current branch head, effectively ignoring all changes from all other branches. It is meant to be used to supersede old development history of side branches. Note that this is different from the -Xours option to the <code>recursive</code> merge strategy.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-subtree"> subtree </dt> <dd> <p>This is a modified <code>ort</code> strategy. When merging trees A and B, if B corresponds to a subtree of A, B is first adjusted to match the tree structure of A, instead of reading the trees at the same level. This adjustment is also done to the common ancestor tree.</p> </dd> </dl> </div> <p>With the strategies that use 3-way merge (including the default, <code>ort</code>), if a change is made on both branches, but later reverted on one of the branches, that change will be present in the merged result; some people find this behavior confusing. It occurs because only the heads and the merge base are considered when performing a merge, not the individual commits. The merge algorithm therefore considers the reverted change as no change at all, and substitutes the changed version instead.</p> </div> <h2 id="_notes">Notes</h2> <div class="sectionbody"> <p>You should understand the implications of using <code>git rebase</code> on a repository that you share. See also RECOVERING FROM UPSTREAM REBASE below.</p> <p>When the rebase is run, it will first execute a <code>pre-rebase</code> hook if one exists. You can use this hook to do sanity checks and reject the rebase if it isn’t appropriate. Please see the template <code>pre-rebase</code> hook script for an example.</p> <p>Upon completion, <code><branch></code> will be the current branch.</p> </div> <h2 id="_interactive_mode">Interactive mode</h2> <div class="sectionbody"> <p>Rebasing interactively means that you have a chance to edit the commits which are rebased. You can reorder the commits, and you can remove them (weeding out bad or otherwise unwanted patches).</p> <p>The interactive mode is meant for this type of workflow:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>have a wonderful idea</p> </li> <li> <p>hack on the code</p> </li> <li> <p>prepare a series for submission</p> </li> <li> <p>submit</p> </li> </ol> </div> <p>where point 2. consists of several instances of</p> <p>a) regular use</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>finish something worthy of a commit</p> </li> <li> <p>commit</p> </li> </ol> </div> <p>b) independent fixup</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>realize that something does not work</p> </li> <li> <p>fix that</p> </li> <li> <p>commit it</p> </li> </ol> </div> <p>Sometimes the thing fixed in b.2. cannot be amended to the not-quite perfect commit it fixes, because that commit is buried deeply in a patch series. That is exactly what interactive rebase is for: use it after plenty of "a"s and "b"s, by rearranging and editing commits, and squashing multiple commits into one.</p> <p>Start it with the last commit you want to retain as-is:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git rebase -i <after-this-commit></pre> </div> </div> <p>An editor will be fired up with all the commits in your current branch (ignoring merge commits), which come after the given commit. You can reorder the commits in this list to your heart’s content, and you can remove them. The list looks more or less like this:</p> <div class="listingblock"> <div class="content"> <pre>pick deadbee The oneline of this commit +pick fa1afe1 The oneline of the next commit +...</pre> </div> </div> <p>The oneline descriptions are purely for your pleasure; <code>git rebase</code> will not look at them but at the commit names ("deadbee" and "fa1afe1" in this example), so do not delete or edit the names.</p> <p>By replacing the command "pick" with the command "edit", you can tell <code>git rebase</code> to stop after applying that commit, so that you can edit the files and/or the commit message, amend the commit, and continue rebasing.</p> <p>To interrupt the rebase (just like an "edit" command would do, but without cherry-picking any commit first), use the "break" command.</p> <p>If you just want to edit the commit message for a commit, replace the command "pick" with the command "reword".</p> <p>To drop a commit, replace the command "pick" with "drop", or just delete the matching line.</p> <p>If you want to fold two or more commits into one, replace the command "pick" for the second and subsequent commits with "squash" or "fixup". If the commits had different authors, the folded commit will be attributed to the author of the first commit. The suggested commit message for the folded commit is the concatenation of the first commit’s message with those identified by "squash" commands, omitting the messages of commits identified by "fixup" commands, unless "fixup -c" is used. In that case the suggested commit message is only the message of the "fixup -c" commit, and an editor is opened allowing you to edit the message. The contents (patch) of the "fixup -c" commit are still incorporated into the folded commit. If there is more than one "fixup -c" commit, the message from the final one is used. You can also use "fixup -C" to get the same behavior as "fixup -c" except without opening an editor.</p> <p><code>git rebase</code> will stop when "pick" has been replaced with "edit" or when a command fails due to merge errors. When you are done editing and/or resolving conflicts you can continue with <code>git rebase --continue</code>.</p> <p>For example, if you want to reorder the last 5 commits, such that what was <code>HEAD~4</code> becomes the new <code>HEAD</code>. To achieve that, you would call <code>git rebase</code> like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rebase -i HEAD~5</pre> </div> </div> <p>And move the first patch to the end of the list.</p> <p>You might want to recreate merge commits, e.g. if you have a history like this:</p> <div class="listingblock"> <div class="content"> <pre> X + \ + A---M---B + / +---o---O---P---Q</pre> </div> </div> <p>Suppose you want to rebase the side branch starting at "A" to "Q". Make sure that the current <code>HEAD</code> is "B", and call</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rebase -i -r --onto Q O</pre> </div> </div> <p>Reordering and editing commits usually creates untested intermediate steps. You may want to check that your history editing did not break anything by running a test, or at least recompiling at intermediate points in history by using the "exec" command (shortcut "x"). You may do so by creating a todo list like this one:</p> <div class="listingblock"> <div class="content"> <pre>pick deadbee Implement feature XXX +fixup f1a5c00 Fix to feature XXX +exec make +pick c0ffeee The oneline of the next commit +edit deadbab The oneline of the commit after +exec cd subdir; make test +...</pre> </div> </div> <p>The interactive rebase will stop when a command fails (i.e. exits with non-0 status) to give you an opportunity to fix the problem. You can continue with <code>git rebase --continue</code>.</p> <p>The "exec" command launches the command in a shell (the one specified in <code>$SHELL</code>, or the default shell if <code>$SHELL</code> is not set), so you can use shell features (like "cd", ">", ";" …). The command is run from the root of the working tree.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rebase -i --exec "make test"</pre> </div> </div> <p>This command lets you check that intermediate commits are compilable. The todo list becomes like that:</p> <div class="listingblock"> <div class="content"> <pre>pick 5928aea one +exec make test +pick 04d0fda two +exec make test +pick ba46169 three +exec make test +pick f4593f9 four +exec make test</pre> </div> </div> </div> <h2 id="_splitting_commits">Splitting commits</h2> <div class="sectionbody"> <p>In interactive mode, you can mark commits with the action "edit". However, this does not necessarily mean that <code>git rebase</code> expects the result of this edit to be exactly one commit. Indeed, you can undo the commit, or you can add other commits. This can be used to split a commit into two:</p> <div class="ulist"> <ul> <li> <p>Start an interactive rebase with <code>git rebase -i <commit>^</code>, where <code><commit></code> is the commit you want to split. In fact, any commit range will do, as long as it contains that commit.</p> </li> <li> <p>Mark the commit you want to split with the action "edit".</p> </li> <li> <p>When it comes to editing that commit, execute <code>git reset HEAD^</code>. The effect is that the <code>HEAD</code> is rewound by one, and the index follows suit. However, the working tree stays the same.</p> </li> <li> <p>Now add the changes to the index that you want to have in the first commit. You can use <code>git add</code> (possibly interactively) or <code>git gui</code> (or both) to do that.</p> </li> <li> <p>Commit the now-current index with whatever commit message is appropriate now.</p> </li> <li> <p>Repeat the last two steps until your working tree is clean.</p> </li> <li> <p>Continue the rebase with <code>git rebase --continue</code>.</p> </li> </ul> </div> <p>If you are not absolutely sure that the intermediate revisions are consistent (they compile, pass the testsuite, etc.) you should use <code>git stash</code> to stash away the not-yet-committed changes after each commit, test, and amend the commit if fixes are necessary.</p> </div> <h2 id="_recovering_from_upstream_rebase">Recovering from upstream rebase</h2> <div class="sectionbody"> <p>Rebasing (or any other form of rewriting) a branch that others have based work on is a bad idea: anyone downstream of it is forced to manually fix their history. This section explains how to do the fix from the downstream’s point of view. The real fix, however, would be to avoid rebasing the upstream in the first place.</p> <p>To illustrate, suppose you are in a situation where someone develops a <code>subsystem</code> branch, and you are working on a <code>topic</code> that is dependent on this <code>subsystem</code>. You might end up with a history like the following:</p> <div class="listingblock"> <div class="content"> <pre> o---o---o---o---o---o---o---o master + \ + o---o---o---o---o subsystem + \ + *---*---* topic</pre> </div> </div> <p>If <code>subsystem</code> is rebased against <code>master</code>, the following happens:</p> <div class="listingblock"> <div class="content"> <pre> o---o---o---o---o---o---o---o master + \ \ + o---o---o---o---o o'--o'--o'--o'--o' subsystem + \ + *---*---* topic</pre> </div> </div> <p>If you now continue development as usual, and eventually merge <code>topic</code> to <code>subsystem</code>, the commits from <code>subsystem</code> will remain duplicated forever:</p> <div class="listingblock"> <div class="content"> <pre> o---o---o---o---o---o---o---o master + \ \ + o---o---o---o---o o'--o'--o'--o'--o'--M subsystem + \ / + *---*---*-..........-*--* topic</pre> </div> </div> <p>Such duplicates are generally frowned upon because they clutter up history, making it harder to follow. To clean things up, you need to transplant the commits on <code>topic</code> to the new <code>subsystem</code> tip, i.e., rebase <code>topic</code>. This becomes a ripple effect: anyone downstream from <code>topic</code> is forced to rebase too, and so on!</p> <p>There are two kinds of fixes, discussed in the following subsections:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rebase.txt-EasycaseThechangesareliterallythesame"> Easy case: The changes are literally the same. </dt> <dd> <p>This happens if the <code>subsystem</code> rebase was a simple rebase and had no conflicts.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-HardcaseThechangesarenotthesame"> Hard case: The changes are not the same. </dt> <dd> <p>This happens if the <code>subsystem</code> rebase had conflicts, or used <code>--interactive</code> to omit, edit, squash, or fixup commits; or if the upstream used one of <code>commit --amend</code>, <code>reset</code>, or a full history rewriting command like <a href="https://github.com/newren/git-filter-repo"><code>filter-repo</code></a>.</p> </dd> </dl> </div> <div class="sect2"> <h3 id="_the_easy_case"> +The easy case</h3> <p>Only works if the changes (patch IDs based on the diff contents) on <code>subsystem</code> are literally the same before and after the rebase <code>subsystem</code> did.</p> <p>In that case, the fix is easy because <code>git rebase</code> knows to skip changes that are already present in the new upstream (unless <code>--reapply-cherry-picks</code> is given). So if you say (assuming you’re on <code>topic</code>)</p> <div class="listingblock"> <div class="content"> <pre> $ git rebase subsystem</pre> </div> </div> <p>you will end up with the fixed history</p> <div class="listingblock"> <div class="content"> <pre> o---o---o---o---o---o---o---o master + \ + o'--o'--o'--o'--o' subsystem + \ + *---*---* topic</pre> </div> </div> </div> <div class="sect2"> <h3 id="_the_hard_case"> +The hard case</h3> <p>Things get more complicated if the <code>subsystem</code> changes do not exactly correspond to the ones before the rebase.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> While an "easy case recovery" sometimes appears to be successful even in the hard case, it may have unintended consequences. For example, a commit that was removed via <code>git rebase + --interactive</code> will be <strong>resurrected</strong>! </td> </tr> </table> </div> <p>The idea is to manually tell <code>git rebase</code> "where the old <code>subsystem</code> ended and your <code>topic</code> began", that is, what the old merge base between them was. You will have to find a way to name the last commit of the old <code>subsystem</code>, for example:</p> <div class="ulist"> <ul> <li> <p>With the <code>subsystem</code> reflog: after <code>git fetch</code>, the old tip of <code>subsystem</code> is at <code>subsystem@{1}</code>. Subsequent fetches will increase the number. (See <a href="git-reflog">git-reflog[1]</a>.)</p> </li> <li> <p>Relative to the tip of <code>topic</code>: knowing that your <code>topic</code> has three commits, the old tip of <code>subsystem</code> must be <code>topic~3</code>.</p> </li> </ul> </div> <p>You can then transplant the old <code>subsystem..topic</code> to the new tip by saying (for the reflog case, and assuming you are on <code>topic</code> already):</p> <div class="listingblock"> <div class="content"> <pre> $ git rebase --onto subsystem subsystem@{1}</pre> </div> </div> <p>The ripple effect of a "hard case" recovery is especially bad: <code>everyone</code> downstream from <code>topic</code> will now have to perform a "hard case" recovery too!</p> </div> </div> <h2 id="_rebasing_merges">Rebasing merges</h2> <div class="sectionbody"> <p>The interactive rebase command was originally designed to handle individual patch series. As such, it makes sense to exclude merge commits from the todo list, as the developer may have merged the then-current <code>master</code> while working on the branch, only to rebase all the commits onto <code>master</code> eventually (skipping the merge commits).</p> <p>However, there are legitimate reasons why a developer may want to recreate merge commits: to keep the branch structure (or "commit topology") when working on multiple, inter-related branches.</p> <p>In the following example, the developer works on a topic branch that refactors the way buttons are defined, and on another topic branch that uses that refactoring to implement a "Report a bug" button. The output of <code>git log --graph --format=%s -5</code> may look like this:</p> <div class="listingblock"> <div class="content"> <pre>* Merge branch 'report-a-bug' +|\ +| * Add the feedback button +* | Merge branch 'refactor-button' +|\ \ +| |/ +| * Use the Button class for all buttons +| * Extract a generic Button class from the DownloadButton one</pre> </div> </div> <p>The developer might want to rebase those commits to a newer <code>master</code> while keeping the branch topology, for example when the first topic branch is expected to be integrated into <code>master</code> much earlier than the second one, say, to resolve merge conflicts with changes to the DownloadButton class that made it into <code>master</code>.</p> <p>This rebase can be performed using the <code>--rebase-merges</code> option. It will generate a todo list looking like this:</p> <div class="listingblock"> <div class="content"> <pre>label onto + +# Branch: refactor-button +reset onto +pick 123456 Extract a generic Button class from the DownloadButton one +pick 654321 Use the Button class for all buttons +label refactor-button + +# Branch: report-a-bug +reset refactor-button # Use the Button class for all buttons +pick abcdef Add the feedback button +label report-a-bug + +reset onto +merge -C a1b2c3 refactor-button # Merge 'refactor-button' +merge -C 6f5e4d report-a-bug # Merge 'report-a-bug'</pre> </div> </div> <p>In contrast to a regular interactive rebase, there are <code>label</code>, <code>reset</code> and <code>merge</code> commands in addition to <code>pick</code> ones.</p> <p>The <code>label</code> command associates a label with the current HEAD when that command is executed. These labels are created as worktree-local refs (<code>refs/rewritten/<label></code>) that will be deleted when the rebase finishes. That way, rebase operations in multiple worktrees linked to the same repository do not interfere with one another. If the <code>label</code> command fails, it is rescheduled immediately, with a helpful message how to proceed.</p> <p>The <code>reset</code> command resets the HEAD, index and worktree to the specified revision. It is similar to an <code>exec git reset --hard <label></code>, but refuses to overwrite untracked files. If the <code>reset</code> command fails, it is rescheduled immediately, with a helpful message how to edit the todo list (this typically happens when a <code>reset</code> command was inserted into the todo list manually and contains a typo).</p> <p>The <code>merge</code> command will merge the specified revision(s) into whatever is HEAD at that time. With <code>-C <original-commit></code>, the commit message of the specified merge commit will be used. When the <code>-C</code> is changed to a lower-case <code>-c</code>, the message will be opened in an editor after a successful merge so that the user can edit the message.</p> <p>If a <code>merge</code> command fails for any reason other than merge conflicts (i.e. when the merge operation did not even start), it is rescheduled immediately.</p> <p>By default, the <code>merge</code> command will use the <code>ort</code> merge strategy for regular merges, and <code>octopus</code> for octopus merges. One can specify a default strategy for all merges using the <code>--strategy</code> argument when invoking rebase, or can override specific merges in the interactive list of commands by using an <code>exec</code> command to call <code>git merge</code> explicitly with a <code>--strategy</code> argument. Note that when calling <code>git +merge</code> explicitly like this, you can make use of the fact that the labels are worktree-local refs (the ref <code>refs/rewritten/onto</code> would correspond to the label <code>onto</code>, for example) in order to refer to the branches you want to merge.</p> <p>Note: the first command (<code>label onto</code>) labels the revision onto which the commits are rebased; The name <code>onto</code> is just a convention, as a nod to the <code>--onto</code> option.</p> <p>It is also possible to introduce completely new merge commits from scratch by adding a command of the form <code>merge <merge-head></code>. This form will generate a tentative commit message and always open an editor to let the user edit it. This can be useful e.g. when a topic branch turns out to address more than a single concern and wants to be split into two or even more topic branches. Consider this todo list:</p> <div class="listingblock"> <div class="content"> <pre>pick 192837 Switch from GNU Makefiles to CMake +pick 5a6c7e Document the switch to CMake +pick 918273 Fix detection of OpenSSL in CMake +pick afbecd http: add support for TLS v1.3 +pick fdbaec Fix detection of cURL in CMake on Windows</pre> </div> </div> <p>The one commit in this list that is not related to CMake may very well have been motivated by working on fixing all those bugs introduced by switching to CMake, but it addresses a different concern. To split this branch into two topic branches, the todo list could be edited like this:</p> <div class="listingblock"> <div class="content"> <pre>label onto + +pick afbecd http: add support for TLS v1.3 +label tlsv1.3 + +reset onto +pick 192837 Switch from GNU Makefiles to CMake +pick 918273 Fix detection of OpenSSL in CMake +pick fdbaec Fix detection of cURL in CMake on Windows +pick 5a6c7e Document the switch to CMake +label cmake + +reset onto +merge tlsv1.3 +merge cmake</pre> </div> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rebase.txt-rebasebackend"> rebase.backend </dt> <dd> <p>Default backend to use for rebasing. Possible choices are <code>apply</code> or <code>merge</code>. In the future, if the merge backend gains all remaining capabilities of the apply backend, this setting may become unused.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-rebasestat"> rebase.stat </dt> <dd> <p>Whether to show a diffstat of what changed upstream since the last rebase. False by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-rebaseautoSquash"> rebase.autoSquash </dt> <dd> <p>If set to true enable <code>--autosquash</code> option by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-rebaseautoStash"> rebase.autoStash </dt> <dd> <p>When set to true, automatically create a temporary stash entry before the operation begins, and apply it after the operation ends. This means that you can run rebase on a dirty worktree. However, use with care: the final stash application after a successful rebase might result in non-trivial conflicts. This option can be overridden by the <code>--no-autostash</code> and <code>--autostash</code> options of <a href="git-rebase">git-rebase[1]</a>. Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-rebaseupdateRefs"> rebase.updateRefs </dt> <dd> <p>If set to true enable <code>--update-refs</code> option by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-rebasemissingCommitsCheck"> rebase.missingCommitsCheck </dt> <dd> <p>If set to "warn", git rebase -i will print a warning if some commits are removed (e.g. a line was deleted), however the rebase will still proceed. If set to "error", it will print the previous warning and stop the rebase, <code>git rebase --edit-todo</code> can then be used to correct the error. If set to "ignore", no checking is done. To drop a commit without warning or error, use the <code>drop</code> command in the todo list. Defaults to "ignore".</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-rebaseinstructionFormat"> rebase.instructionFormat </dt> <dd> <p>A format string, as specified in <a href="git-log">git-log[1]</a>, to be used for the todo list during an interactive rebase. The format will automatically have the commit hash prepended to the format.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-rebaseabbreviateCommands"> rebase.abbreviateCommands </dt> <dd> <p>If set to true, <code>git rebase</code> will use abbreviated command names in the todo list resulting in something like this:</p> <div class="listingblock"> <div class="content"> <pre> p deadbee The oneline of the commit + p fa1afe1 The oneline of the next commit + ...</pre> </div> </div> <p>instead of:</p> <div class="listingblock"> <div class="content"> <pre> pick deadbee The oneline of the commit + pick fa1afe1 The oneline of the next commit + ...</pre> </div> </div> <p>Defaults to false.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-rebaserescheduleFailedExec"> rebase.rescheduleFailedExec </dt> <dd> <p>Automatically reschedule <code>exec</code> commands that failed. This only makes sense in interactive mode (or when an <code>--exec</code> option was provided). This is the same as specifying the <code>--reschedule-failed-exec</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-rebaseforkPoint"> rebase.forkPoint </dt> <dd> <p>If set to false set <code>--no-fork-point</code> option by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-rebaserebaseMerges"> rebase.rebaseMerges </dt> <dd> <p>Whether and how to set the <code>--rebase-merges</code> option by default. Can be <code>rebase-cousins</code>, <code>no-rebase-cousins</code>, or a boolean. Setting to true or to <code>no-rebase-cousins</code> is equivalent to <code>--rebase-merges=no-rebase-cousins</code>, setting to <code>rebase-cousins</code> is equivalent to <code>--rebase-merges=rebase-cousins</code>, and setting to false is equivalent to <code>--no-rebase-merges</code>. Passing <code>--rebase-merges</code> on the command line, with or without an argument, overrides any <code>rebase.rebaseMerges</code> configuration.</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-rebasemaxLabelLength"> rebase.maxLabelLength </dt> <dd> <p>When generating label names from commit subjects, truncate the names to this length. By default, the names are truncated to a little less than <code>NAME_MAX</code> (to allow e.g. <code>.lock</code> files to be written for the corresponding loose refs).</p> </dd> <dt class="hdlist1" id="Documentation/git-rebase.txt-sequenceeditor"> sequence.editor </dt> <dd> <p>Text editor used by <code>git rebase -i</code> for editing the rebase instruction file. The value is meant to be interpreted by the shell when it is used. It can be overridden by the <code>GIT_SEQUENCE_EDITOR</code> environment variable. When not configured, the default commit message editor is used instead.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-rebase" class="_attribution-link">https://git-scm.com/docs/git-rebase</a> + </p> +</div> diff --git a/devdocs/git/git-receive-pack.html b/devdocs/git/git-receive-pack.html new file mode 100644 index 00000000..9e11742d --- /dev/null +++ b/devdocs/git/git-receive-pack.html @@ -0,0 +1,29 @@ +<h1>git-receive-pack</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-receive-pack - Receive what is pushed into the repository</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git receive-pack <git-dir></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Invoked by <code>git send-pack</code> and updates the repository with the information fed from the remote end.</p> <p>This command is usually not invoked directly by the end user. The UI for the protocol is on the <code>git send-pack</code> side, and the program pair is meant to be used to push updates to a remote repository. For pull operations, see <a href="git-fetch-pack">git-fetch-pack[1]</a>.</p> <p>The command allows for the creation and fast-forwarding of sha1 refs (heads/tags) on the remote end (strictly speaking, it is the local end <code>git-receive-pack</code> runs, but to the user who is sitting at the send-pack end, it is updating the remote. Confused?)</p> <p>There are other real-world examples of using update and post-update hooks found in the Documentation/howto directory.</p> <p><code>git-receive-pack</code> honours the receive.denyNonFastForwards config option, which tells it if updates to a ref should be denied if they are not fast-forwards.</p> <p>A number of other receive.* config options are available to tweak its behavior, see <a href="git-config">git-config[1]</a>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-receive-pack.txt-ltgit-dirgt"> <git-dir> </dt> <dd> <p>The repository to sync into.</p> </dd> <dt class="hdlist1" id="Documentation/git-receive-pack.txt---http-backend-info-refs"> --http-backend-info-refs </dt> <dd> <p>Used by <a href="git-http-backend">git-http-backend[1]</a> to serve up <code>$GIT_URL/info/refs?service=git-receive-pack</code> requests. See <code>--http-backend-info-refs</code> in <a href="git-upload-pack">git-upload-pack[1]</a>.</p> </dd> </dl> </div> </div> <h2 id="_pre_receive_hook">Pre-receive hook</h2> <div class="sectionbody"> <p>Before any ref is updated, if $GIT_DIR/hooks/pre-receive file exists and is executable, it will be invoked once with no parameters. The standard input of the hook will be one line per ref to be updated:</p> <div class="literalblock"> <div class="content"> <pre>sha1-old SP sha1-new SP refname LF</pre> </div> </div> <p>The refname value is relative to $GIT_DIR; e.g. for the master head this is "refs/heads/master". The two sha1 values before each refname are the object names for the refname before and after the update. Refs to be created will have sha1-old equal to 0{40}, while refs to be deleted will have sha1-new equal to 0{40}, otherwise sha1-old and sha1-new should be valid objects in the repository.</p> <p>When accepting a signed push (see <a href="git-push">git-push[1]</a>), the signed push certificate is stored in a blob and an environment variable <code>GIT_PUSH_CERT</code> can be consulted for its object name. See the description of <code>post-receive</code> hook for an example. In addition, the certificate is verified using GPG and the result is exported with the following environment variables:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-receive-pack.txt-codeGITPUSHCERTSIGNERcode"> <code>GIT_PUSH_CERT_SIGNER</code> </dt> <dd> <p>The name and the e-mail address of the owner of the key that signed the push certificate.</p> </dd> <dt class="hdlist1" id="Documentation/git-receive-pack.txt-codeGITPUSHCERTKEYcode"> <code>GIT_PUSH_CERT_KEY</code> </dt> <dd> <p>The GPG key ID of the key that signed the push certificate.</p> </dd> <dt class="hdlist1" id="Documentation/git-receive-pack.txt-codeGITPUSHCERTSTATUScode"> <code>GIT_PUSH_CERT_STATUS</code> </dt> <dd> <p>The status of GPG verification of the push certificate, using the same mnemonic as used in <code>%G?</code> format of <code>git log</code> family of commands (see <a href="git-log">git-log[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-receive-pack.txt-codeGITPUSHCERTNONCEcode"> <code>GIT_PUSH_CERT_NONCE</code> </dt> <dd> <p>The nonce string the process asked the signer to include in the push certificate. If this does not match the value recorded on the "nonce" header in the push certificate, it may indicate that the certificate is a valid one that is being replayed from a separate "git push" session.</p> </dd> <dt class="hdlist1" id="Documentation/git-receive-pack.txt-codeGITPUSHCERTNONCESTATUScode"> <code>GIT_PUSH_CERT_NONCE_STATUS</code> </dt> <dd> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-receive-pack.txt-codeUNSOLICITEDcode"> <code>UNSOLICITED</code> </dt> <dd> <p>"git push --signed" sent a nonce when we did not ask it to send one.</p> </dd> <dt class="hdlist1" id="Documentation/git-receive-pack.txt-codeMISSINGcode"> <code>MISSING</code> </dt> <dd> <p>"git push --signed" did not send any nonce header.</p> </dd> <dt class="hdlist1" id="Documentation/git-receive-pack.txt-codeBADcode"> <code>BAD</code> </dt> <dd> <p>"git push --signed" sent a bogus nonce.</p> </dd> <dt class="hdlist1" id="Documentation/git-receive-pack.txt-codeOKcode"> <code>OK</code> </dt> <dd> <p>"git push --signed" sent the nonce we asked it to send.</p> </dd> <dt class="hdlist1" id="Documentation/git-receive-pack.txt-codeSLOPcode"> <code>SLOP</code> </dt> <dd> <p>"git push --signed" sent a nonce different from what we asked it to send now, but in a previous session. See <code>GIT_PUSH_CERT_NONCE_SLOP</code> environment variable.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-receive-pack.txt-codeGITPUSHCERTNONCESLOPcode"> <code>GIT_PUSH_CERT_NONCE_SLOP</code> </dt> <dd> <p>"git push --signed" sent a nonce different from what we asked it to send now, but in a different session whose starting time is different by this many seconds from the current session. Only meaningful when <code>GIT_PUSH_CERT_NONCE_STATUS</code> says <code>SLOP</code>. Also read about <code>receive.certNonceSlop</code> variable in <a href="git-config">git-config[1]</a>.</p> </dd> </dl> </div> <p>This hook is called before any refname is updated and before any fast-forward checks are performed.</p> <p>If the pre-receive hook exits with a non-zero exit status no updates will be performed, and the update, post-receive and post-update hooks will not be invoked either. This can be useful to quickly bail out if the update is not to be supported.</p> <p>See the notes on the quarantine environment below.</p> </div> <h2 id="_update_hook">Update hook</h2> <div class="sectionbody"> <p>Before each ref is updated, if $GIT_DIR/hooks/update file exists and is executable, it is invoked once per ref, with three parameters:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$GIT_DIR/hooks/update refname sha1-old sha1-new</pre> </div> </div> <p>The refname parameter is relative to $GIT_DIR; e.g. for the master head this is "refs/heads/master". The two sha1 arguments are the object names for the refname before and after the update. Note that the hook is called before the refname is updated, so either sha1-old is 0{40} (meaning there is no such ref yet), or it should match what is recorded in refname.</p> <p>The hook should exit with non-zero status if it wants to disallow updating the named ref. Otherwise it should exit with zero.</p> <p>Successful execution (a zero exit status) of this hook does not ensure the ref will actually be updated, it is only a prerequisite. As such it is not a good idea to send notices (e.g. email) from this hook. Consider using the post-receive hook instead.</p> </div> <h2 id="_post_receive_hook">Post-receive hook</h2> <div class="sectionbody"> <p>After all refs were updated (or attempted to be updated), if any ref update was successful, and if $GIT_DIR/hooks/post-receive file exists and is executable, it will be invoked once with no parameters. The standard input of the hook will be one line for each successfully updated ref:</p> <div class="literalblock"> <div class="content"> <pre>sha1-old SP sha1-new SP refname LF</pre> </div> </div> <p>The refname value is relative to $GIT_DIR; e.g. for the master head this is "refs/heads/master". The two sha1 values before each refname are the object names for the refname before and after the update. Refs that were created will have sha1-old equal to 0{40}, while refs that were deleted will have sha1-new equal to 0{40}, otherwise sha1-old and sha1-new should be valid objects in the repository.</p> <p>The <code>GIT_PUSH_CERT*</code> environment variables can be inspected, just as in <code>pre-receive</code> hook, after accepting a signed push.</p> <p>Using this hook, it is easy to generate mails describing the updates to the repository. This example script sends one mail message per ref listing the commits pushed to the repository, and logs the push certificates of signed pushes with good signatures to a logger service:</p> <div class="listingblock"> <div class="content"> <pre>#!/bin/sh +# mail out commit update information. +while read oval nval ref +do + if expr "$oval" : '0*$' >/dev/null + then + echo "Created a new ref, with the following commits:" + git rev-list --pretty "$nval" + else + echo "New commits:" + git rev-list --pretty "$nval" "^$oval" + fi | + mail -s "Changes to ref $ref" commit-list@mydomain +done +# log signed push certificate, if any +if test -n "${GIT_PUSH_CERT-}" && test ${GIT_PUSH_CERT_STATUS} = G +then + ( + echo expected nonce is ${GIT_PUSH_NONCE} + git cat-file blob ${GIT_PUSH_CERT} + ) | mail -s "push certificate from $GIT_PUSH_CERT_SIGNER" push-log@mydomain +fi +exit 0</pre> </div> </div> <p>The exit code from this hook invocation is ignored, however a non-zero exit code will generate an error message.</p> <p>Note that it is possible for refname to not have sha1-new when this hook runs. This can easily occur if another user modifies the ref after it was updated by <code>git-receive-pack</code>, but before the hook was able to evaluate it. It is recommended that hooks rely on sha1-new rather than the current value of refname.</p> </div> <h2 id="_post_update_hook">Post-update hook</h2> <div class="sectionbody"> <p>After all other processing, if at least one ref was updated, and if $GIT_DIR/hooks/post-update file exists and is executable, then post-update will be called with the list of refs that have been updated. This can be used to implement any repository wide cleanup tasks.</p> <p>The exit code from this hook invocation is ignored; the only thing left for <code>git-receive-pack</code> to do at that point is to exit itself anyway.</p> <p>This hook can be used, for example, to run <code>git update-server-info</code> if the repository is packed and is served via a dumb transport.</p> <div class="listingblock"> <div class="content"> <pre>#!/bin/sh +exec git update-server-info</pre> </div> </div> </div> <h2 id="_quarantine_environment">Quarantine environment</h2> <div class="sectionbody"> <p>When <code>receive-pack</code> takes in objects, they are placed into a temporary "quarantine" directory within the <code>$GIT_DIR/objects</code> directory and migrated into the main object store only after the <code>pre-receive</code> hook has completed. If the push fails before then, the temporary directory is removed entirely.</p> <p>This has a few user-visible effects and caveats:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Pushes which fail due to problems with the incoming pack, missing objects, or due to the <code>pre-receive</code> hook will not leave any on-disk data. This is usually helpful to prevent repeated failed pushes from filling up your disk, but can make debugging more challenging.</p> </li> <li> <p>Any objects created by the <code>pre-receive</code> hook will be created in the quarantine directory (and migrated only if it succeeds).</p> </li> <li> <p>The <code>pre-receive</code> hook MUST NOT update any refs to point to quarantined objects. Other programs accessing the repository will not be able to see the objects (and if the pre-receive hook fails, those refs would become corrupted). For safety, any ref updates from within <code>pre-receive</code> are automatically rejected.</p> </li> </ol> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-send-pack">git-send-pack[1]</a>, <a href="gitnamespaces">gitnamespaces[7]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-receive-pack" class="_attribution-link">https://git-scm.com/docs/git-receive-pack</a> + </p> +</div> diff --git a/devdocs/git/git-reflog.html b/devdocs/git/git-reflog.html new file mode 100644 index 00000000..59f08ef0 --- /dev/null +++ b/devdocs/git/git-reflog.html @@ -0,0 +1,20 @@ +<h1>git-reflog</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-reflog - Manage reflog information</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git reflog [show] [<log-options>] [<ref>] +git reflog expire [--expire=<time>] [--expire-unreachable=<time>] + [--rewrite] [--updateref] [--stale-fix] + [--dry-run | -n] [--verbose] [--all [--single-worktree] | <refs>…] +git reflog delete [--rewrite] [--updateref] + [--dry-run | -n] [--verbose] <ref>@{<specifier>}… +git reflog exists <ref></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This command manages the information recorded in the reflogs.</p> <p>Reference logs, or "reflogs", record when the tips of branches and other references were updated in the local repository. Reflogs are useful in various Git commands, to specify the old value of a reference. For example, <code>HEAD@{2}</code> means "where HEAD used to be two moves ago", <code>master@{one.week.ago}</code> means "where master used to point to one week ago in this local repository", and so on. See <a href="gitrevisions">gitrevisions[7]</a> for more details.</p> <p>The command takes various subcommands, and different options depending on the subcommand:</p> <p>The "show" subcommand (which is also the default, in the absence of any subcommands) shows the log of the reference provided in the command-line (or <code>HEAD</code>, by default). The reflog covers all recent actions, and in addition the <code>HEAD</code> reflog records branch switching. <code>git reflog show</code> is an alias for <code>git log -g --abbrev-commit +--pretty=oneline</code>; see <a href="git-log">git-log[1]</a> for more information.</p> <p>The "expire" subcommand prunes older reflog entries. Entries older than <code>expire</code> time, or entries older than <code>expire-unreachable</code> time and not reachable from the current tip, are removed from the reflog. This is typically not used directly by end users — instead, see <a href="git-gc">git-gc[1]</a>.</p> <p>The "delete" subcommand deletes single entries from the reflog. Its argument must be an <code>exact</code> entry (e.g. "<code>git reflog delete +master@{2}</code>"). This subcommand is also typically not used directly by end users.</p> <p>The "exists" subcommand checks whether a ref has a reflog. It exits with zero status if the reflog exists, and non-zero status if it does not.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_options_for_show"> +Options for <code>show</code> +</h3> <p><code>git reflog show</code> accepts any of the options accepted by <code>git log</code>.</p> </div> <div class="sect2"> <h3 id="_options_for_expire"> +Options for <code>expire</code> +</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-reflog.txt---all"> --all </dt> <dd> <p>Process the reflogs of all references.</p> </dd> <dt class="hdlist1" id="Documentation/git-reflog.txt---single-worktree"> --single-worktree </dt> <dd> <p>By default when <code>--all</code> is specified, reflogs from all working trees are processed. This option limits the processing to reflogs from the current working tree only.</p> </dd> <dt class="hdlist1" id="Documentation/git-reflog.txt---expirelttimegt"> --expire=<time> </dt> <dd> <p>Prune entries older than the specified time. If this option is not specified, the expiration time is taken from the configuration setting <code>gc.reflogExpire</code>, which in turn defaults to 90 days. <code>--expire=all</code> prunes entries regardless of their age; <code>--expire=never</code> turns off pruning of reachable entries (but see <code>--expire-unreachable</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-reflog.txt---expire-unreachablelttimegt"> --expire-unreachable=<time> </dt> <dd> <p>Prune entries older than <code><time></code> that are not reachable from the current tip of the branch. If this option is not specified, the expiration time is taken from the configuration setting <code>gc.reflogExpireUnreachable</code>, which in turn defaults to 30 days. <code>--expire-unreachable=all</code> prunes unreachable entries regardless of their age; <code>--expire-unreachable=never</code> turns off early pruning of unreachable entries (but see <code>--expire</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-reflog.txt---updateref"> --updateref </dt> <dd> <p>Update the reference to the value of the top reflog entry (i.e. <ref>@{0}) if the previous top entry was pruned. (This option is ignored for symbolic references.)</p> </dd> <dt class="hdlist1" id="Documentation/git-reflog.txt---rewrite"> --rewrite </dt> <dd> <p>If a reflog entry’s predecessor is pruned, adjust its "old" SHA-1 to be equal to the "new" SHA-1 field of the entry that now precedes it.</p> </dd> <dt class="hdlist1" id="Documentation/git-reflog.txt---stale-fix"> --stale-fix </dt> <dd> <p>Prune any reflog entries that point to "broken commits". A broken commit is a commit that is not reachable from any of the reference tips and that refers, directly or indirectly, to a missing commit, tree, or blob object.</p> <p>This computation involves traversing all the reachable objects, i.e. it has the same cost as <code>git prune</code>. It is primarily intended to fix corruption caused by garbage collecting using older versions of Git, which didn’t protect objects referred to by reflogs.</p> </dd> <dt class="hdlist1" id="Documentation/git-reflog.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-reflog.txt---dry-run"> --dry-run </dt> <dd> <p>Do not actually prune any entries; just show what would have been pruned.</p> </dd> <dt class="hdlist1" id="Documentation/git-reflog.txt---verbose"> --verbose </dt> <dd> <p>Print extra information on screen.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_options_for_delete"> +Options for <code>delete</code> +</h3> <p><code>git reflog delete</code> accepts options <code>--updateref</code>, <code>--rewrite</code>, <code>-n</code>, <code>--dry-run</code>, and <code>--verbose</code>, with the same meanings as when they are used with <code>expire</code>.</p> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-reflog" class="_attribution-link">https://git-scm.com/docs/git-reflog</a> + </p> +</div> diff --git a/devdocs/git/git-remote-ext.html b/devdocs/git/git-remote-ext.html new file mode 100644 index 00000000..4a59e311 --- /dev/null +++ b/devdocs/git/git-remote-ext.html @@ -0,0 +1,6 @@ +<h1>git-remote-ext</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-remote-ext - Bridge smart transport to external command.</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git remote add <nick> "ext::<command>[ <arguments>…]"</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This remote helper uses the specified <code><command></code> to connect to a remote Git server.</p> <p>Data written to stdin of the specified <code><command></code> is assumed to be sent to a git:// server, git-upload-pack, git-receive-pack or git-upload-archive (depending on situation), and data read from stdout of <command> is assumed to be received from the same service.</p> <p>Command and arguments are separated by an unescaped space.</p> <p>The following sequences have a special meaning:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-remote-ext.txt-"> '% ' </dt> <dd> <p>Literal space in command or argument.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote-ext.txt-emem"> <em>%%</em> </dt> <dd> <p>Literal percent sign.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote-ext.txt-emsem"> <em>%s</em> </dt> <dd> <p>Replaced with name (receive-pack, upload-pack, or upload-archive) of the service Git wants to invoke.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote-ext.txt-emSem"> <em>%S</em> </dt> <dd> <p>Replaced with long name (git-receive-pack, git-upload-pack, or git-upload-archive) of the service Git wants to invoke.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote-ext.txt-emGemmustbethefirstcharactersinanargument"> <em>%G</em> (must be the first characters in an argument) </dt> <dd> <p>This argument will not be passed to <code><command></code>. Instead, it will cause the helper to start by sending git:// service requests to the remote side with the service field set to an appropriate value and the repository field set to the rest of the argument. Default is not to send such a request.</p> <p>This is useful if the remote side is git:// server accessed over some tunnel.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote-ext.txt-emVemmustbefirstcharactersinargument"> <em>%V</em> (must be first characters in argument) </dt> <dd> <p>This argument will not be passed to <code><command></code>. Instead it sets the vhost field in the git:// service request (to the rest of the argument). Default is not to send vhost in such request (if sent).</p> </dd> </dl> </div> </div> <h2 id="_environment_variables">Environment variables</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-remote-ext.txt-GITTRANSLOOPDEBUG"> GIT_TRANSLOOP_DEBUG </dt> <dd> <p>If set, prints debugging information about various reads/writes.</p> </dd> </dl> </div> </div> <h2 id="_environment_variables_passed_to_command">Environment variables passed to command</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-remote-ext.txt-GITEXTSERVICE"> GIT_EXT_SERVICE </dt> <dd> <p>Set to long name (git-upload-pack, etc…) of service helper needs to invoke.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote-ext.txt-GITEXTSERVICENOPREFIX"> GIT_EXT_SERVICE_NOPREFIX </dt> <dd> <p>Set to long name (upload-pack, etc…) of service helper needs to invoke.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>This remote helper is transparently used by Git when you use commands such as "git fetch <URL>", "git clone <URL>", , "git push <URL>" or "git remote add <nick> <URL>", where <URL> begins with <code>ext::</code>. Examples:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-remote-ext.txt-extssh-ihomefoosshsomekeyuser64hostexampleSemfoorepoem"> "ext::ssh -i /home/foo/.ssh/somekey user@host.example %S <em>foo/repo</em>" </dt> <dd> <p>Like host.example:foo/repo, but use /home/foo/.ssh/somekey as keypair and user as the user on the remote side. This avoids the need to edit .ssh/config.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote-ext.txt-extsocat-t3600-ABSTRACT-CONNECTgit-serverGsomerepo"> "ext::socat -t3600 - ABSTRACT-CONNECT:/git-server %G/somerepo" </dt> <dd> <p>Represents repository with path /somerepo accessible over git protocol at the abstract namespace address /git-server.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote-ext.txt-extgit-server-aliasfooGrepo"> "ext::git-server-alias foo %G/repo" </dt> <dd> <p>Represents a repository with path /repo accessed using the helper program "git-server-alias foo". The path to the repository and type of request are not passed on the command line but as part of the protocol stream, as usual with git:// protocol.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote-ext.txt-extgit-server-aliasfooGrepoVfoo"> "ext::git-server-alias foo %G/repo %Vfoo" </dt> <dd> <p>Represents a repository with path /repo accessed using the helper program "git-server-alias foo". The hostname for the remote server passed in the protocol stream will be "foo" (this allows multiple virtual Git servers to share a link-level address).</p> </dd> <dt class="hdlist1" id="Documentation/git-remote-ext.txt-extgit-server-aliasfooGrepowithspacesVfoo"> "ext::git-server-alias foo %G/repo% with% spaces %Vfoo" </dt> <dd> <p>Represents a repository with path <code>/repo with spaces</code> accessed using the helper program "git-server-alias foo". The hostname for the remote server passed in the protocol stream will be "foo" (this allows multiple virtual Git servers to share a link-level address).</p> </dd> <dt class="hdlist1" id="Documentation/git-remote-ext.txt-extgit-sslfooexamplebar"> "ext::git-ssl foo.example /bar" </dt> <dd> <p>Represents a repository accessed using the helper program "git-ssl foo.example /bar". The type of request can be determined by the helper using environment variables (see above).</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gitremote-helpers">gitremote-helpers[7]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-remote-ext" class="_attribution-link">https://git-scm.com/docs/git-remote-ext</a> + </p> +</div> diff --git a/devdocs/git/git-remote-fd.html b/devdocs/git/git-remote-fd.html new file mode 100644 index 00000000..2458eb98 --- /dev/null +++ b/devdocs/git/git-remote-fd.html @@ -0,0 +1,6 @@ +<h1>git-remote-fd</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-remote-fd - Reflect smart transport stream back to caller</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>"fd::<infd>[,<outfd>][/<anything>]" (as URL)</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This helper uses specified file descriptors to connect to a remote Git server. This is not meant for end users but for programs and scripts calling git fetch, push, or archive.</p> <p>If only <infd> is given, it is assumed to be a bidirectional socket connected to a remote Git server (git-upload-pack, git-receive-pack, or git-upload-archive). If both <infd> and <outfd> are given, they are assumed to be pipes connected to a remote Git server (<infd> being the inbound pipe and <outfd> being the outbound pipe).</p> <p>It is assumed that any handshaking procedures have already been completed (such as sending service request for git://) before this helper is started.</p> <p><anything> can be any string. It is ignored. It is meant for providing information to the user in the URL in case that URL is displayed in some context.</p> </div> <h2 id="_environment_variables">Environment variables</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-remote-fd.txt-GITTRANSLOOPDEBUG"> GIT_TRANSLOOP_DEBUG </dt> <dd> <p>If set, prints debugging information about various reads/writes.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-remote-fd.txt-codegitfetchfd17mastercode"> <code>git fetch fd::17 master</code> </dt> <dd> <p>Fetch master, using file descriptor #17 to communicate with git-upload-pack.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote-fd.txt-codegitfetchfd17foomastercode"> <code>git fetch fd::17/foo master</code> </dt> <dd> <p>Same as above.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote-fd.txt-codegitpushfd78masterasURLcode"> <code>git push fd::7,8 master (as URL)</code> </dt> <dd> <p>Push master, using file descriptor #7 to read data from git-receive-pack and file descriptor #8 to write data to the same service.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote-fd.txt-codegitpushfd78barmastercode"> <code>git push fd::7,8/bar master</code> </dt> <dd> <p>Same as above.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gitremote-helpers">gitremote-helpers[7]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-remote-fd" class="_attribution-link">https://git-scm.com/docs/git-remote-fd</a> + </p> +</div> diff --git a/devdocs/git/git-remote.html b/devdocs/git/git-remote.html new file mode 100644 index 00000000..8e9b8753 --- /dev/null +++ b/devdocs/git/git-remote.html @@ -0,0 +1,46 @@ +<h1>git-remote</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-remote - Manage set of tracked repositories</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git remote [-v | --verbose] +git remote add [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=(fetch|push)] <name> <URL> +git remote rename [--[no-]progress] <old> <new> +git remote remove <name> +git remote set-head <name> (-a | --auto | -d | --delete | <branch>) +git remote set-branches [--add] <name> <branch>… +git remote get-url [--push] [--all] <name> +git remote set-url [--push] <name> <newurl> [<oldurl>] +git remote set-url --add [--push] <name> <newurl> +git remote set-url --delete [--push] <name> <URL> +git remote [-v | --verbose] show [-n] <name>… +git remote prune [-n | --dry-run] <name>… +git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Manage the set of repositories ("remotes") whose branches you track.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-remote.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-remote.txt---verbose"> --verbose </dt> <dd> <p>Be a little more verbose and show remote url after name. For promisor remotes, also show which filter (<code>blob:none</code> etc.) are configured. NOTE: This must be placed between <code>remote</code> and subcommand.</p> </dd> </dl> </div> </div> <h2 id="_commands">Commands</h2> <div class="sectionbody"> <p>With no arguments, shows a list of existing remotes. Several subcommands are available to perform operations on the remotes.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-remote.txt-emaddem"> <em>add</em> </dt> <dd> <p>Add a remote named <name> for the repository at <URL>. The command <code>git fetch <name></code> can then be used to create and update remote-tracking branches <name>/<branch>.</p> <p>With <code>-f</code> option, <code>git fetch <name></code> is run immediately after the remote information is set up.</p> <p>With <code>--tags</code> option, <code>git fetch <name></code> imports every tag from the remote repository.</p> <p>With <code>--no-tags</code> option, <code>git fetch <name></code> does not import tags from the remote repository.</p> <p>By default, only tags on fetched branches are imported (see <a href="git-fetch">git-fetch[1]</a>).</p> <p>With <code>-t <branch></code> option, instead of the default glob refspec for the remote to track all branches under the <code>refs/remotes/<name>/</code> namespace, a refspec to track only <code><branch></code> is created. You can give more than one <code>-t <branch></code> to track multiple branches without grabbing all branches.</p> <p>With <code>-m <master></code> option, a symbolic-ref <code>refs/remotes/<name>/HEAD</code> is set up to point at remote’s <code><master></code> branch. See also the set-head command.</p> <p>When a fetch mirror is created with <code>--mirror=fetch</code>, the refs will not be stored in the <code>refs/remotes/</code> namespace, but rather everything in <code>refs/</code> on the remote will be directly mirrored into <code>refs/</code> in the local repository. This option only makes sense in bare repositories, because a fetch would overwrite any local commits.</p> <p>When a push mirror is created with <code>--mirror=push</code>, then <code>git push</code> will always behave as if <code>--mirror</code> was passed.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote.txt-emrenameem"> <em>rename</em> </dt> <dd> <p>Rename the remote named <old> to <new>. All remote-tracking branches and configuration settings for the remote are updated.</p> <p>In case <old> and <new> are the same, and <old> is a file under <code>$GIT_DIR/remotes</code> or <code>$GIT_DIR/branches</code>, the remote is converted to the configuration file format.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote.txt-emremoveem"> <em>remove</em> </dt> <dt class="hdlist1" id="Documentation/git-remote.txt-emrmem"> <em>rm</em> </dt> <dd> <p>Remove the remote named <name>. All remote-tracking branches and configuration settings for the remote are removed.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote.txt-emset-headem"> <em>set-head</em> </dt> <dd> <p>Sets or deletes the default branch (i.e. the target of the symbolic-ref <code>refs/remotes/<name>/HEAD</code>) for the named remote. Having a default branch for a remote is not required, but allows the name of the remote to be specified in lieu of a specific branch. For example, if the default branch for <code>origin</code> is set to <code>master</code>, then <code>origin</code> may be specified wherever you would normally specify <code>origin/master</code>.</p> <p>With <code>-d</code> or <code>--delete</code>, the symbolic ref <code>refs/remotes/<name>/HEAD</code> is deleted.</p> <p>With <code>-a</code> or <code>--auto</code>, the remote is queried to determine its <code>HEAD</code>, then the symbolic-ref <code>refs/remotes/<name>/HEAD</code> is set to the same branch. e.g., if the remote <code>HEAD</code> is pointed at <code>next</code>, <code>git remote set-head origin -a</code> will set the symbolic-ref <code>refs/remotes/origin/HEAD</code> to <code>refs/remotes/origin/next</code>. This will only work if <code>refs/remotes/origin/next</code> already exists; if not it must be fetched first.</p> <p>Use <code><branch></code> to set the symbolic-ref <code>refs/remotes/<name>/HEAD</code> explicitly. e.g., <code>git +remote set-head origin master</code> will set the symbolic-ref <code>refs/remotes/origin/HEAD</code> to <code>refs/remotes/origin/master</code>. This will only work if <code>refs/remotes/origin/master</code> already exists; if not it must be fetched first.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote.txt-emset-branchesem"> <em>set-branches</em> </dt> <dd> <p>Changes the list of branches tracked by the named remote. This can be used to track a subset of the available remote branches after the initial setup for a remote.</p> <p>The named branches will be interpreted as if specified with the <code>-t</code> option on the <code>git remote add</code> command line.</p> <p>With <code>--add</code>, instead of replacing the list of currently tracked branches, adds to that list.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote.txt-emget-urlem"> <em>get-url</em> </dt> <dd> <p>Retrieves the URLs for a remote. Configurations for <code>insteadOf</code> and <code>pushInsteadOf</code> are expanded here. By default, only the first URL is listed.</p> <p>With <code>--push</code>, push URLs are queried rather than fetch URLs.</p> <p>With <code>--all</code>, all URLs for the remote will be listed.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote.txt-emset-urlem"> <em>set-url</em> </dt> <dd> <p>Changes URLs for the remote. Sets first URL for remote <name> that matches regex <oldurl> (first URL if no <oldurl> is given) to <newurl>. If <oldurl> doesn’t match any URL, an error occurs and nothing is changed.</p> <p>With <code>--push</code>, push URLs are manipulated instead of fetch URLs.</p> <p>With <code>--add</code>, instead of changing existing URLs, new URL is added.</p> <p>With <code>--delete</code>, instead of changing existing URLs, all URLs matching regex <URL> are deleted for remote <name>. Trying to delete all non-push URLs is an error.</p> <p>Note that the push URL and the fetch URL, even though they can be set differently, must still refer to the same place. What you pushed to the push URL should be what you would see if you immediately fetched from the fetch URL. If you are trying to fetch from one place (e.g. your upstream) and push to another (e.g. your publishing repository), use two separate remotes.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote.txt-emshowem"> <em>show</em> </dt> <dd> <p>Gives some information about the remote <name>.</p> <p>With <code>-n</code> option, the remote heads are not queried first with <code>git ls-remote <name></code>; cached information is used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote.txt-empruneem"> <em>prune</em> </dt> <dd> <p>Deletes stale references associated with <name>. By default, stale remote-tracking branches under <name> are deleted, but depending on global configuration and the configuration of the remote we might even prune local tags that haven’t been pushed there. Equivalent to <code>git +fetch --prune <name></code>, except that no new references will be fetched.</p> <p>See the PRUNING section of <a href="git-fetch">git-fetch[1]</a> for what it’ll prune depending on various configuration.</p> <p>With <code>--dry-run</code> option, report what branches would be pruned, but do not actually prune them.</p> </dd> <dt class="hdlist1" id="Documentation/git-remote.txt-emupdateem"> <em>update</em> </dt> <dd> <p>Fetch updates for remotes or remote groups in the repository as defined by <code>remotes.<group></code>. If neither group nor remote is specified on the command line, the configuration parameter remotes.default will be used; if remotes.default is not defined, all remotes which do not have the configuration parameter <code>remote.<name>.skipDefaultUpdate</code> set to true will be updated. (See <a href="git-config">git-config[1]</a>).</p> <p>With <code>--prune</code> option, run pruning against all the remotes that are updated.</p> </dd> </dl> </div> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>The remote configuration is achieved using the <code>remote.origin.url</code> and <code>remote.origin.fetch</code> configuration variables. (See <a href="git-config">git-config[1]</a>).</p> </div> <h2 id="_exit_status">Exit status</h2> <div class="sectionbody"> <p>On success, the exit status is <code>0</code>.</p> <p>When subcommands such as <code>add</code>, <code>rename</code>, and <code>remove</code> can’t find the remote in question, the exit status is <code>2</code>. When the remote already exists, the exit status is <code>3</code>.</p> <p>On any other error, the exit status may be any other non-zero value.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Add a new remote, fetch, and check out a branch from it</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git remote +origin +$ git branch -r + origin/HEAD -> origin/master + origin/master +$ git remote add staging git://git.kernel.org/.../gregkh/staging.git +$ git remote +origin +staging +$ git fetch staging +... +From git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging + * [new branch] master -> staging/master + * [new branch] staging-linus -> staging/staging-linus + * [new branch] staging-next -> staging/staging-next +$ git branch -r + origin/HEAD -> origin/master + origin/master + staging/master + staging/staging-linus + staging/staging-next +$ git switch -c staging staging/master +...</pre> </div> </div> </li> <li> <p>Imitate <code>git clone</code> but track only selected branches</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ mkdir project.git +$ cd project.git +$ git init +$ git remote add -f -t master -m master origin git://example.com/git.git/ +$ git merge origin</pre> </div> </div> </li> </ul> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-fetch">git-fetch[1]</a> <a href="git-branch">git-branch[1]</a> <a href="git-config">git-config[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-remote" class="_attribution-link">https://git-scm.com/docs/git-remote</a> + </p> +</div> diff --git a/devdocs/git/git-repack.html b/devdocs/git/git-repack.html new file mode 100644 index 00000000..7169dfa9 --- /dev/null +++ b/devdocs/git/git-repack.html @@ -0,0 +1,6 @@ +<h1>git-repack</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-repack - Pack unpacked objects in a repository</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git repack [-a] [-A] [-d] [-f] [-F] [-l] [-n] [-q] [-b] [-m] [--window=<n>] [--depth=<n>] [--threads=<n>] [--keep-pack=<pack-name>] [--write-midx]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This command is used to combine all objects that do not currently reside in a "pack", into a pack. It can also be used to re-organize existing packs into a single, more efficient pack.</p> <p>A pack is a collection of objects, individually compressed, with delta compression applied, stored in a single file, with an associated index file.</p> <p>Packs are used to reduce the load on mirror systems, backup engines, disk storage, etc.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-repack.txt--a"> -a </dt> <dd> <p>Instead of incrementally packing the unpacked objects, pack everything referenced into a single pack. Especially useful when packing a repository that is used for private development. Use with <code>-d</code>. This will clean up the objects that <code>git prune</code> leaves behind, but <code>git fsck --full --dangling</code> shows as dangling.</p> <p>Note that users fetching over dumb protocols will have to fetch the whole new pack in order to get any contained object, no matter how many other objects in that pack they already have locally.</p> <p>Promisor packfiles are repacked separately: if there are packfiles that have an associated ".promisor" file, these packfiles will be repacked into another separate pack, and an empty ".promisor" file corresponding to the new separate pack will be written.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt--A"> -A </dt> <dd> <p>Same as <code>-a</code>, unless <code>-d</code> is used. Then any unreachable objects in a previous pack become loose, unpacked objects, instead of being left in the old pack. Unreachable objects are never intentionally added to a pack, even when repacking. This option prevents unreachable objects from being immediately deleted by way of being left in the old pack and then removed. Instead, the loose unreachable objects will be pruned according to normal expiry rules with the next <code>git gc</code> invocation. See <a href="git-gc">git-gc[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt--d"> -d </dt> <dd> <p>After packing, if the newly created packs make some existing packs redundant, remove the redundant packs. Also run <code>git prune-packed</code> to remove redundant loose object files.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt---cruft"> --cruft </dt> <dd> <p>Same as <code>-a</code>, unless <code>-d</code> is used. Then any unreachable objects are packed into a separate cruft pack. Unreachable objects can be pruned using the normal expiry rules with the next <code>git gc</code> invocation (see <a href="git-gc">git-gc[1]</a>). Incompatible with <code>-k</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt---cruft-expirationltapproxidategt"> --cruft-expiration=<approxidate> </dt> <dd> <p>Expire unreachable objects older than <code><approxidate></code> immediately instead of waiting for the next <code>git gc</code> invocation. Only useful with <code>--cruft -d</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt---max-cruft-sizeltngt"> --max-cruft-size=<n> </dt> <dd> <p>Repack cruft objects into packs as large as <code><n></code> bytes before creating new packs. As long as there are enough cruft packs smaller than <code><n></code>, repacking will cause a new cruft pack to be created containing objects from any combined cruft packs, along with any new unreachable objects. Cruft packs larger than <code><n></code> will not be modified. When the new cruft pack is larger than <code><n></code> bytes, it will be split into multiple packs, all of which are guaranteed to be at most <code><n></code> bytes in size. Only useful with <code>--cruft -d</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt---expire-toltdirgt"> --expire-to=<dir> </dt> <dd> <p>Write a cruft pack containing pruned objects (if any) to the directory <code><dir></code>. This option is useful for keeping a copy of any pruned objects in a separate directory as a backup. Only useful with <code>--cruft -d</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt--l"> -l </dt> <dd> <p>Pass the <code>--local</code> option to <code>git pack-objects</code>. See <a href="git-pack-objects">git-pack-objects[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt--f"> -f </dt> <dd> <p>Pass the <code>--no-reuse-delta</code> option to <code>git-pack-objects</code>, see <a href="git-pack-objects">git-pack-objects[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt--F"> -F </dt> <dd> <p>Pass the <code>--no-reuse-object</code> option to <code>git-pack-objects</code>, see <a href="git-pack-objects">git-pack-objects[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-repack.txt---quiet"> --quiet </dt> <dd> <p>Show no progress over the standard error stream and pass the <code>-q</code> option to <code>git pack-objects</code>. See <a href="git-pack-objects">git-pack-objects[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt--n"> -n </dt> <dd> <p>Do not update the server information with <code>git update-server-info</code>. This option skips updating local catalog files needed to publish this repository (or a direct copy of it) over HTTP or FTP. See <a href="git-update-server-info">git-update-server-info[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt---windowltngt"> --window=<n> </dt> <dt class="hdlist1" id="Documentation/git-repack.txt---depthltngt"> --depth=<n> </dt> <dd> <p>These two options affect how the objects contained in the pack are stored using delta compression. The objects are first internally sorted by type, size and optionally names and compared against the other objects within <code>--window</code> to see if using delta compression saves space. <code>--depth</code> limits the maximum delta depth; making it too deep affects the performance on the unpacker side, because delta data needs to be applied that many times to get to the necessary object.</p> <p>The default value for --window is 10 and --depth is 50. The maximum depth is 4095.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt---threadsltngt"> --threads=<n> </dt> <dd> <p>This option is passed through to <code>git pack-objects</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt---window-memoryltngt"> --window-memory=<n> </dt> <dd> <p>This option provides an additional limit on top of <code>--window</code>; the window size will dynamically scale down so as to not take up more than <code><n></code> bytes in memory. This is useful in repositories with a mix of large and small objects to not run out of memory with a large window, but still be able to take advantage of the large window for the smaller objects. The size can be suffixed with "k", "m", or "g". <code>--window-memory=0</code> makes memory usage unlimited. The default is taken from the <code>pack.windowMemory</code> configuration variable. Note that the actual memory usage will be the limit multiplied by the number of threads used by <a href="git-pack-objects">git-pack-objects[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt---max-pack-sizeltngt"> --max-pack-size=<n> </dt> <dd> <p>Maximum size of each output pack file. The size can be suffixed with "k", "m", or "g". The minimum size allowed is limited to 1 MiB. If specified, multiple packfiles may be created, which also prevents the creation of a bitmap index. The default is unlimited, unless the config variable <code>pack.packSizeLimit</code> is set. Note that this option may result in a larger and slower repository; see the discussion in <code>pack.packSizeLimit</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt---filterltfilter-specgt"> --filter=<filter-spec> </dt> <dd> <p>Remove objects matching the filter specification from the resulting packfile and put them into a separate packfile. Note that objects used in the working directory are not filtered out. So for the split to fully work, it’s best to perform it in a bare repo and to use the <code>-a</code> and <code>-d</code> options along with this option. Also <code>--no-write-bitmap-index</code> (or the <code>repack.writebitmaps</code> config option set to <code>false</code>) should be used otherwise writing bitmap index will fail, as it supposes a single packfile containing all the objects. See <a href="git-rev-list">git-rev-list[1]</a> for valid <code><filter-spec></code> forms.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt---filter-toltdirgt"> --filter-to=<dir> </dt> <dd> <p>Write the pack containing filtered out objects to the directory <code><dir></code>. Only useful with <code>--filter</code>. This can be used for putting the pack on a separate object directory that is accessed through the Git alternates mechanism. <strong>WARNING:</strong> If the packfile containing the filtered out objects is not accessible, the repo can become corrupt as it might not be possible to access the objects in that packfile. See the <code>objects</code> and <code>objects/info/alternates</code> sections of <a href="gitrepository-layout">gitrepository-layout[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt--b"> -b </dt> <dt class="hdlist1" id="Documentation/git-repack.txt---write-bitmap-index"> --write-bitmap-index </dt> <dd> <p>Write a reachability bitmap index as part of the repack. This only makes sense when used with <code>-a</code>, <code>-A</code> or <code>-m</code>, as the bitmaps must be able to refer to all reachable objects. This option overrides the setting of <code>repack.writeBitmaps</code>. This option has no effect if multiple packfiles are created, unless writing a MIDX (in which case a multi-pack bitmap is created).</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt---pack-kept-objects"> --pack-kept-objects </dt> <dd> <p>Include objects in <code>.keep</code> files when repacking. Note that we still do not delete <code>.keep</code> packs after <code>pack-objects</code> finishes. This means that we may duplicate objects, but this makes the option safe to use when there are concurrent pushes or fetches. This option is generally only useful if you are writing bitmaps with <code>-b</code> or <code>repack.writeBitmaps</code>, as it ensures that the bitmapped packfile has the necessary objects.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt---keep-packltpack-namegt"> --keep-pack=<pack-name> </dt> <dd> <p>Exclude the given pack from repacking. This is the equivalent of having <code>.keep</code> file on the pack. <code><pack-name></code> is the pack file name without leading directory (e.g. <code>pack-123.pack</code>). The option can be specified multiple times to keep multiple packs.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt---unpack-unreachableltwhengt"> --unpack-unreachable=<when> </dt> <dd> <p>When loosening unreachable objects, do not bother loosening any objects older than <code><when></code>. This can be used to optimize out the write of any objects that would be immediately pruned by a follow-up <code>git prune</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt--k"> -k </dt> <dt class="hdlist1" id="Documentation/git-repack.txt---keep-unreachable"> --keep-unreachable </dt> <dd> <p>When used with <code>-ad</code>, any unreachable objects from existing packs will be appended to the end of the packfile instead of being removed. In addition, any unreachable loose objects will be packed (and their loose counterparts removed).</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt--i"> -i </dt> <dt class="hdlist1" id="Documentation/git-repack.txt---delta-islands"> --delta-islands </dt> <dd> <p>Pass the <code>--delta-islands</code> option to <code>git-pack-objects</code>, see <a href="git-pack-objects">git-pack-objects[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt--gltfactorgt"> -g<factor> </dt> <dt class="hdlist1" id="Documentation/git-repack.txt---geometricltfactorgt"> --geometric=<factor> </dt> <dd> <p>Arrange resulting pack structure so that each successive pack contains at least <code><factor></code> times the number of objects as the next-largest pack.</p> <p><code>git repack</code> ensures this by determining a "cut" of packfiles that need to be repacked into one in order to ensure a geometric progression. It picks the smallest set of packfiles such that as many of the larger packfiles (by count of objects contained in that pack) may be left intact.</p> <p>Unlike other repack modes, the set of objects to pack is determined uniquely by the set of packs being "rolled-up"; in other words, the packs determined to need to be combined in order to restore a geometric progression.</p> <p>Loose objects are implicitly included in this "roll-up", without respect to their reachability. This is subject to change in the future.</p> <p>When writing a multi-pack bitmap, <code>git repack</code> selects the largest resulting pack as the preferred pack for object selection by the MIDX (see <a href="git-multi-pack-index">git-multi-pack-index[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-repack.txt--m"> -m </dt> <dt class="hdlist1" id="Documentation/git-repack.txt---write-midx"> --write-midx </dt> <dd> <p>Write a multi-pack index (see <a href="git-multi-pack-index">git-multi-pack-index[1]</a>) containing the non-redundant packs.</p> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Various configuration variables affect packing, see <a href="git-config">git-config[1]</a> (search for "pack" and "delta").</p> <p>By default, the command passes <code>--delta-base-offset</code> option to <code>git pack-objects</code>; this typically results in slightly smaller packs, but the generated packs are incompatible with versions of Git older than version 1.4.4. If you need to share your repository with such ancient Git versions, either directly or via the dumb http protocol, then you need to set the configuration variable <code>repack.UseDeltaBaseOffset</code> to "false" and repack. Access from old Git versions over the native protocol is unaffected by this option as the conversion is performed on the fly as needed in that case.</p> <p>Delta compression is not used on objects larger than the <code>core.bigFileThreshold</code> configuration variable and on files with the attribute <code>delta</code> set to false.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-pack-objects">git-pack-objects[1]</a> <a href="git-prune-packed">git-prune-packed[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-repack" class="_attribution-link">https://git-scm.com/docs/git-repack</a> + </p> +</div> diff --git a/devdocs/git/git-replace.html b/devdocs/git/git-replace.html new file mode 100644 index 00000000..8d1d3581 --- /dev/null +++ b/devdocs/git/git-replace.html @@ -0,0 +1,11 @@ +<h1>git-replace</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-replace - Create, list, delete refs to replace objects</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git replace [-f] <object> <replacement> +git replace [-f] --edit <object> +git replace [-f] --graft <commit> [<parent>…] +git replace [-f] --convert-graft-file +git replace -d <object>… +git replace [--format=<format>] [-l [<pattern>]]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Adds a <code>replace</code> reference in <code>refs/replace/</code> namespace.</p> <p>The name of the <code>replace</code> reference is the SHA-1 of the object that is replaced. The content of the <code>replace</code> reference is the SHA-1 of the replacement object.</p> <p>The replaced object and the replacement object must be of the same type. This restriction can be bypassed using <code>-f</code>.</p> <p>Unless <code>-f</code> is given, the <code>replace</code> reference must not yet exist.</p> <p>There is no other restriction on the replaced and replacement objects. Merge commits can be replaced by non-merge commits and vice versa.</p> <p>Replacement references will be used by default by all Git commands except those doing reachability traversal (prune, pack transfer and fsck).</p> <p>It is possible to disable the use of replacement references for any command using the <code>--no-replace-objects</code> option just after <code>git</code>.</p> <p>For example if commit <code>foo</code> has been replaced by commit <code>bar</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git --no-replace-objects cat-file commit foo</pre> </div> </div> <p>shows information about commit <code>foo</code>, while:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cat-file commit foo</pre> </div> </div> <p>shows information about commit <code>bar</code>.</p> <p>The <code>GIT_NO_REPLACE_OBJECTS</code> environment variable can be set to achieve the same effect as the <code>--no-replace-objects</code> option.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-replace.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-replace.txt---force"> --force </dt> <dd> <p>If an existing replace ref for the same object exists, it will be overwritten (instead of failing).</p> </dd> <dt class="hdlist1" id="Documentation/git-replace.txt--d"> -d </dt> <dt class="hdlist1" id="Documentation/git-replace.txt---delete"> --delete </dt> <dd> <p>Delete existing replace refs for the given objects.</p> </dd> <dt class="hdlist1" id="Documentation/git-replace.txt---editltobjectgt"> --edit <object> </dt> <dd> <p>Edit an object’s content interactively. The existing content for <object> is pretty-printed into a temporary file, an editor is launched on the file, and the result is parsed to create a new object of the same type as <object>. A replacement ref is then created to replace <object> with the newly created object. See <a href="git-var">git-var[1]</a> for details about how the editor will be chosen.</p> </dd> <dt class="hdlist1" id="Documentation/git-replace.txt---raw"> --raw </dt> <dd> <p>When editing, provide the raw object contents rather than pretty-printed ones. Currently this only affects trees, which will be shown in their binary form. This is harder to work with, but can help when repairing a tree that is so corrupted it cannot be pretty-printed. Note that you may need to configure your editor to cleanly read and write binary data.</p> </dd> <dt class="hdlist1" id="Documentation/git-replace.txt---graftltcommitgtltparentgt82308203"> --graft <commit> [<parent>…] </dt> <dd> <p>Create a graft commit. A new commit is created with the same content as <commit> except that its parents will be [<parent>…] instead of <commit>'s parents. A replacement ref is then created to replace <commit> with the newly created commit. Use <code>--convert-graft-file</code> to convert a <code>$GIT_DIR/info/grafts</code> file and use replace refs instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-replace.txt---convert-graft-file"> --convert-graft-file </dt> <dd> <p>Creates graft commits for all entries in <code>$GIT_DIR/info/grafts</code> and deletes that file upon success. The purpose is to help users with transitioning off of the now-deprecated graft file.</p> </dd> <dt class="hdlist1" id="Documentation/git-replace.txt--lltpatterngt"> -l <pattern> </dt> <dt class="hdlist1" id="Documentation/git-replace.txt---listltpatterngt"> --list <pattern> </dt> <dd> <p>List replace refs for objects that match the given pattern (or all if no pattern is given). Typing "git replace" without arguments, also lists all replace refs.</p> </dd> <dt class="hdlist1" id="Documentation/git-replace.txt---formatltformatgt"> --format=<format> </dt> <dd> <p>When listing, use the specified <format>, which can be one of <code>short</code>, <code>medium</code> and <code>long</code>. When omitted, the format defaults to <code>short</code>.</p> </dd> </dl> </div> </div> <h2 id="_formats">Formats</h2> <div class="sectionbody"> <p>The following formats are available:</p> <div class="ulist"> <ul> <li> <p><code>short</code>: <replaced sha1></p> </li> <li> <p><code>medium</code>: <replaced sha1> → <replacement sha1></p> </li> <li> <p><code>long</code>: <replaced sha1> (<replaced type>) → <replacement sha1> (<replacement type>)</p> </li> </ul> </div> </div> <h2 id="_creating_replacement_objects">Creating replacement objects</h2> <div class="sectionbody"> <p><a href="git-hash-object">git-hash-object[1]</a>, <a href="git-rebase">git-rebase[1]</a>, and <a href="https://github.com/newren/git-filter-repo">git-filter-repo</a>, among other git commands, can be used to create replacement objects from existing objects. The <code>--edit</code> option can also be used with <code>git replace</code> to create a replacement object by editing an existing object.</p> <p>If you want to replace many blobs, trees or commits that are part of a string of commits, you may just want to create a replacement string of commits and then only replace the commit at the tip of the target string of commits with the commit at the tip of the replacement string of commits.</p> </div> <h2 id="_bugs">Bugs</h2> <div class="sectionbody"> <p>Comparing blobs or trees that have been replaced with those that replace them will not work properly. And using <code>git reset --hard</code> to go back to a replaced commit will move the branch to the replacement commit instead of the replaced commit.</p> <p>There may be other problems when using <code>git rev-list</code> related to pending objects.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-hash-object">git-hash-object[1]</a> <a href="git-rebase">git-rebase[1]</a> <a href="git-tag">git-tag[1]</a> <a href="git-branch">git-branch[1]</a> <a href="git-commit">git-commit[1]</a> <a href="git-var">git-var[1]</a> <a href="git">git[1]</a> <a href="https://github.com/newren/git-filter-repo">git-filter-repo</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-replace" class="_attribution-link">https://git-scm.com/docs/git-replace</a> + </p> +</div> diff --git a/devdocs/git/git-request-pull.html b/devdocs/git/git-request-pull.html new file mode 100644 index 00000000..af85a37c --- /dev/null +++ b/devdocs/git/git-request-pull.html @@ -0,0 +1,6 @@ +<h1>git-request-pull</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-request-pull - Generates a summary of pending changes</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git request-pull [-p] <start> <URL> [<end>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Generate a request asking your upstream project to pull changes into their tree. The request, printed to the standard output, begins with the branch description, summarizes the changes, and indicates from where they can be pulled.</p> <p>The upstream project is expected to have the commit named by <code><start></code> and the output asks it to integrate the changes you made since that commit, up to the commit named by <code><end></code>, by visiting the repository named by <code><URL></code>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-request-pull.txt--p"> -p </dt> <dd> <p>Include patch text in the output.</p> </dd> <dt class="hdlist1" id="Documentation/git-request-pull.txt-ltstartgt"> <start> </dt> <dd> <p>Commit to start at. This names a commit that is already in the upstream history.</p> </dd> <dt class="hdlist1" id="Documentation/git-request-pull.txt-ltURLgt"> <URL> </dt> <dd> <p>The repository URL to be pulled from.</p> </dd> <dt class="hdlist1" id="Documentation/git-request-pull.txt-ltendgt"> <end> </dt> <dd> <p>Commit to end at (defaults to HEAD). This names the commit at the tip of the history you are asking to be pulled.</p> <p>When the repository named by <code><URL></code> has the commit at a tip of a ref that is different from the ref you have locally, you can use the <code><local>:<remote></code> syntax, to have its local name, a colon <code>:</code>, and its remote name.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>Imagine that you built your work on your <code>master</code> branch on top of the <code>v1.0</code> release, and want it to be integrated into the project. First you push that change to your public repository for others to see:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git push https://git.ko.xz/project master</pre> </div> </div> <p>Then, you run this command:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git request-pull v1.0 https://git.ko.xz/project master</pre> </div> </div> <p>which will produce a request to the upstream, summarizing the changes between the <code>v1.0</code> release and your <code>master</code>, to pull it from your public repository.</p> <p>If you pushed your change to a branch whose name is different from the one you have locally, e.g.</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git push https://git.ko.xz/project master:for-linus</pre> </div> </div> <p>then you can ask that to be pulled with</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git request-pull v1.0 https://git.ko.xz/project master:for-linus</pre> </div> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-request-pull" class="_attribution-link">https://git-scm.com/docs/git-request-pull</a> + </p> +</div> diff --git a/devdocs/git/git-rerere.html b/devdocs/git/git-rerere.html new file mode 100644 index 00000000..721cea77 --- /dev/null +++ b/devdocs/git/git-rerere.html @@ -0,0 +1,38 @@ +<h1>git-rerere</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-rerere - Reuse recorded resolution of conflicted merges</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git rerere [clear | forget <pathspec>… | diff | status | remaining | gc]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>In a workflow employing relatively long lived topic branches, the developer sometimes needs to resolve the same conflicts over and over again until the topic branches are done (either merged to the "release" branch, or sent out and accepted upstream).</p> <p>This command assists the developer in this process by recording conflicted automerge results and corresponding hand resolve results on the initial manual merge, and applying previously recorded hand resolutions to their corresponding automerge results.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> You need to set the configuration variable <code>rerere.enabled</code> in order to enable this command. </td> </tr> </table> </div> </div> <h2 id="_commands">Commands</h2> <div class="sectionbody"> <p>Normally, <code>git rerere</code> is run without arguments or user-intervention. However, it has several commands that allow it to interact with its working state.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rerere.txt-emclearem"> <em>clear</em> </dt> <dd> <p>Reset the metadata used by rerere if a merge resolution is to be aborted. Calling <code>git am [--skip|--abort]</code> or <code>git rebase [--skip|--abort]</code> will automatically invoke this command.</p> </dd> <dt class="hdlist1" id="Documentation/git-rerere.txt-emforgetemltpathspecgt"> <em>forget</em> <pathspec> </dt> <dd> <p>Reset the conflict resolutions which rerere has recorded for the current conflict in <pathspec>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rerere.txt-emdiffem"> <em>diff</em> </dt> <dd> <p>Display diffs for the current state of the resolution. It is useful for tracking what has changed while the user is resolving conflicts. Additional arguments are passed directly to the system <code>diff</code> command installed in PATH.</p> </dd> <dt class="hdlist1" id="Documentation/git-rerere.txt-emstatusem"> <em>status</em> </dt> <dd> <p>Print paths with conflicts whose merge resolution rerere will record.</p> </dd> <dt class="hdlist1" id="Documentation/git-rerere.txt-emremainingem"> <em>remaining</em> </dt> <dd> <p>Print paths with conflicts that have not been autoresolved by rerere. This includes paths whose resolutions cannot be tracked by rerere, such as conflicting submodules.</p> </dd> <dt class="hdlist1" id="Documentation/git-rerere.txt-emgcem"> <em>gc</em> </dt> <dd> <p>Prune records of conflicted merges that occurred a long time ago. By default, unresolved conflicts older than 15 days and resolved conflicts older than 60 days are pruned. These defaults are controlled via the <code>gc.rerereUnresolved</code> and <code>gc.rerereResolved</code> configuration variables respectively.</p> </dd> </dl> </div> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>When your topic branch modifies an overlapping area that your master branch (or upstream) touched since your topic branch forked from it, you may want to test it with the latest master, even before your topic branch is ready to be pushed upstream:</p> <div class="listingblock"> <div class="content"> <pre> o---*---o topic + / + o---o---o---*---o---o master</pre> </div> </div> <p>For such a test, you need to merge master and topic somehow. One way to do it is to pull master into the topic branch:</p> <div class="listingblock"> <div class="content"> <pre> $ git switch topic + $ git merge master + + o---*---o---+ topic + / / + o---o---o---*---o---o master</pre> </div> </div> <p>The commits marked with <code>*</code> touch the same area in the same file; you need to resolve the conflicts when creating the commit marked with <code>+</code>. Then you can test the result to make sure your work-in-progress still works with what is in the latest master.</p> <p>After this test merge, there are two ways to continue your work on the topic. The easiest is to build on top of the test merge commit <code>+</code>, and when your work in the topic branch is finally ready, pull the topic branch into master, and/or ask the upstream to pull from you. By that time, however, the master or the upstream might have been advanced since the test merge <code>+</code>, in which case the final commit graph would look like this:</p> <div class="listingblock"> <div class="content"> <pre> $ git switch topic + $ git merge master + $ ... work on both topic and master branches + $ git switch master + $ git merge topic + + o---*---o---+---o---o topic + / / \ + o---o---o---*---o---o---o---o---+ master</pre> </div> </div> <p>When your topic branch is long-lived, however, your topic branch would end up having many such "Merge from master" commits on it, which would unnecessarily clutter the development history. Readers of the Linux kernel mailing list may remember that Linus complained about such too frequent test merges when a subsystem maintainer asked to pull from a branch full of "useless merges".</p> <p>As an alternative, to keep the topic branch clean of test merges, you could blow away the test merge, and keep building on top of the tip before the test merge:</p> <div class="listingblock"> <div class="content"> <pre> $ git switch topic + $ git merge master + $ git reset --hard HEAD^ ;# rewind the test merge + $ ... work on both topic and master branches + $ git switch master + $ git merge topic + + o---*---o-------o---o topic + / \ + o---o---o---*---o---o---o---o---+ master</pre> </div> </div> <p>This would leave only one merge commit when your topic branch is finally ready and merged into the master branch. This merge would require you to resolve the conflict, introduced by the commits marked with <code>*</code>. However, this conflict is often the same conflict you resolved when you created the test merge you blew away. <code>git rerere</code> helps you resolve this final conflicted merge using the information from your earlier hand resolve.</p> <p>Running the <code>git rerere</code> command immediately after a conflicted automerge records the conflicted working tree files, with the usual conflict markers <code><<<<<<<</code>, <code>=======</code>, and <code>>>>>>>></code> in them. Later, after you are done resolving the conflicts, running <code>git rerere</code> again will record the resolved state of these files. Suppose you did this when you created the test merge of master into the topic branch.</p> <p>Next time, after seeing the same conflicted automerge, running <code>git rerere</code> will perform a three-way merge between the earlier conflicted automerge, the earlier manual resolution, and the current conflicted automerge. If this three-way merge resolves cleanly, the result is written out to your working tree file, so you do not have to manually resolve it. Note that <code>git rerere</code> leaves the index file alone, so you still need to do the final sanity checks with <code>git diff</code> (or <code>git diff -c</code>) and <code>git add</code> when you are satisfied.</p> <p>As a convenience measure, <code>git merge</code> automatically invokes <code>git rerere</code> upon exiting with a failed automerge and <code>git rerere</code> records the hand resolve when it is a new conflict, or reuses the earlier hand resolve when it is not. <code>git commit</code> also invokes <code>git rerere</code> when committing a merge result. What this means is that you do not have to do anything special yourself (besides enabling the rerere.enabled config variable).</p> <p>In our example, when you do the test merge, the manual resolution is recorded, and it will be reused when you do the actual merge later with the updated master and topic branch, as long as the recorded resolution is still applicable.</p> <p>The information <code>git rerere</code> records is also used when running <code>git rebase</code>. After blowing away the test merge and continuing development on the topic branch:</p> <div class="listingblock"> <div class="content"> <pre> o---*---o-------o---o topic + / + o---o---o---*---o---o---o---o master + + $ git rebase master topic + + o---*---o-------o---o topic + / + o---o---o---*---o---o---o---o master</pre> </div> </div> <p>you could run <code>git rebase master topic</code>, to bring yourself up to date before your topic is ready to be sent upstream. This would result in falling back to a three-way merge, and it would conflict the same way as the test merge you resolved earlier. <code>git rerere</code> will be run by <code>git rebase</code> to help you resolve this conflict.</p> <p>[NOTE] <code>git rerere</code> relies on the conflict markers in the file to detect the conflict. If the file already contains lines that look the same as lines with conflict markers, <code>git rerere</code> may fail to record a conflict resolution. To work around this, the <code>conflict-marker-size</code> setting in <a href="gitattributes">gitattributes[5]</a> can be used.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-rerere" class="_attribution-link">https://git-scm.com/docs/git-rerere</a> + </p> +</div> diff --git a/devdocs/git/git-reset.html b/devdocs/git/git-reset.html new file mode 100644 index 00000000..2d2f2090 --- /dev/null +++ b/devdocs/git/git-reset.html @@ -0,0 +1,105 @@ +<h1>git-reset</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-reset - Reset current HEAD to the specified state</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git reset [-q] [<tree-ish>] [--] <pathspec>… +git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>] +git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>…] +git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>In the first three forms, copy entries from <code><tree-ish></code> to the index. In the last form, set the current branch head (<code>HEAD</code>) to <code><commit></code>, optionally modifying index and working tree to match. The <code><tree-ish></code>/<code><commit></code> defaults to <code>HEAD</code> in all forms.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-reset.txt-emgitresetem-qlttree-ishgt--ltpathspecgt82308203"> <em>git reset</em> [-q] [<tree-ish>] [--] <pathspec>… </dt> <dt class="hdlist1" id="Documentation/git-reset.txt-emgitresetem-q--pathspec-from-fileltfilegt--pathspec-file-nullttree-ishgt"> <em>git reset</em> [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>] </dt> <dd> <p>These forms reset the index entries for all paths that match the <code><pathspec></code> to their state at <code><tree-ish></code>. (It does not affect the working tree or the current branch.)</p> <p>This means that <code>git reset <pathspec></code> is the opposite of <code>git add +<pathspec></code>. This command is equivalent to <code>git restore [--source=<tree-ish>] --staged <pathspec>...</code>.</p> <p>After running <code>git reset <pathspec></code> to update the index entry, you can use <a href="git-restore">git-restore[1]</a> to check the contents out of the index to the working tree. Alternatively, using <a href="git-restore">git-restore[1]</a> and specifying a commit with <code>--source</code>, you can copy the contents of a path out of a commit to the index and to the working tree in one go.</p> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt-emgitresetem--patch-plttree-ishgt--ltpathspecgt82308203"> <em>git reset</em> (--patch | -p) [<tree-ish>] [--] [<pathspec>…] </dt> <dd> <p>Interactively select hunks in the difference between the index and <code><tree-ish></code> (defaults to <code>HEAD</code>). The chosen hunks are applied in reverse to the index.</p> <p>This means that <code>git reset -p</code> is the opposite of <code>git add -p</code>, i.e. you can use it to selectively reset hunks. See the “Interactive Mode” section of <a href="git-add">git-add[1]</a> to learn how to operate the <code>--patch</code> mode.</p> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt-emgitresetemltmodegtltcommitgt"> <em>git reset</em> [<mode>] [<commit>] </dt> <dd> <p>This form resets the current branch head to <code><commit></code> and possibly updates the index (resetting it to the tree of <code><commit></code>) and the working tree depending on <code><mode></code>. Before the operation, <code>ORIG_HEAD</code> is set to the tip of the current branch. If <code><mode></code> is omitted, defaults to <code>--mixed</code>. The <code><mode></code> must be one of the following:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-reset.txt---soft"> --soft </dt> <dd> <p>Does not touch the index file or the working tree at all (but resets the head to <code><commit></code>, just like all modes do). This leaves all your changed files "Changes to be committed", as <code>git status</code> would put it.</p> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt---mixed"> --mixed </dt> <dd> <p>Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action.</p> <p>If <code>-N</code> is specified, removed paths are marked as intent-to-add (see <a href="git-add">git-add[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt---hard"> --hard </dt> <dd> <p>Resets the index and working tree. Any changes to tracked files in the working tree since <code><commit></code> are discarded. Any untracked files or directories in the way of writing any tracked files are simply deleted.</p> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt---merge"> --merge </dt> <dd> <p>Resets the index and updates the files in the working tree that are different between <code><commit></code> and <code>HEAD</code>, but keeps those which are different between the index and working tree (i.e. which have changes which have not been added). If a file that is different between <code><commit></code> and the index has unstaged changes, reset is aborted.</p> <p>In other words, <code>--merge</code> does something like a <code>git read-tree -u -m <commit></code>, but carries forward unmerged index entries.</p> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt---keep"> --keep </dt> <dd> <p>Resets index entries and updates files in the working tree that are different between <code><commit></code> and <code>HEAD</code>. If a file that is different between <code><commit></code> and <code>HEAD</code> has local changes, reset is aborted.</p> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt---no-recurse-submodules"> --[no-]recurse-submodules </dt> <dd> <p>When the working tree is updated, using --recurse-submodules will also recursively reset the working tree of all active submodules according to the commit recorded in the superproject, also setting the submodules' HEAD to be detached at that commit.</p> </dd> </dl> </div> </div> </div> </dd> </dl> </div> <p>See "Reset, restore and revert" in <a href="git">git[1]</a> for the differences between the three commands.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-reset.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-reset.txt---quiet"> --quiet </dt> <dd> <p>Be quiet, only report errors.</p> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt---refresh"> --refresh </dt> <dt class="hdlist1" id="Documentation/git-reset.txt---no-refresh"> --no-refresh </dt> <dd> <p>Refresh the index after a mixed reset. Enabled by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt---pathspec-from-fileltfilegt"> --pathspec-from-file=<file> </dt> <dd> <p>Pathspec is passed in <code><file></code> instead of commandline args. If <code><file></code> is exactly <code>-</code> then standard input is used. Pathspec elements are separated by LF or CR/LF. Pathspec elements can be quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>). See also <code>--pathspec-file-nul</code> and global <code>--literal-pathspecs</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt---pathspec-file-nul"> --pathspec-file-nul </dt> <dd> <p>Only meaningful with <code>--pathspec-from-file</code>. Pathspec elements are separated with NUL character and all other characters are taken literally (including newlines and quotes).</p> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt---"> -- </dt> <dd> <p>Do not interpret any more arguments as options.</p> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt-ltpathspecgt82308203"> <pathspec>… </dt> <dd> <p>Limits the paths affected by the operation.</p> <p>For more details, see the <code>pathspec</code> entry in <a href="gitglossary">gitglossary[7]</a>.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-reset.txt-Undoadd"> Undo add </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ edit (1) +$ git add frotz.c filfre.c +$ mailx (2) +$ git reset (3) +$ git pull git://info.example.com/ nitfol (4)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>You are happily working on something, and find the changes in these files are in good order. You do not want to see them when you run <code>git diff</code>, because you plan to work on other files and changes with these files are distracting.</p> </li> <li> <p>Somebody asks you to pull, and the changes sound worthy of merging.</p> </li> <li> <p>However, you already dirtied the index (i.e. your index does not match the <code>HEAD</code> commit). But you know the pull you are going to make does not affect <code>frotz.c</code> or <code>filfre.c</code>, so you revert the index changes for these two files. Your changes in working tree remain there.</p> </li> <li> <p>Then you can pull and merge, leaving <code>frotz.c</code> and <code>filfre.c</code> changes still in the working tree.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt-Undoacommitandredo"> Undo a commit and redo </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit ... +$ git reset --soft HEAD^ (1) +$ edit (2) +$ git commit -a -c ORIG_HEAD (3)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>This is most often done when you remembered what you just committed is incomplete, or you misspelled your commit message, or both. Leaves working tree as it was before "reset".</p> </li> <li> <p>Make corrections to working tree files.</p> </li> <li> <p>"reset" copies the old head to <code>.git/ORIG_HEAD</code>; redo the commit by starting with its log message. If you do not need to edit the message further, you can give <code>-C</code> option instead.</p> </li> </ol> </div> <p>See also the <code>--amend</code> option to <a href="git-commit">git-commit[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt-Undoacommitmakingitatopicbranch"> Undo a commit, making it a topic branch </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch topic/wip (1) +$ git reset --hard HEAD~3 (2) +$ git switch topic/wip (3)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>You have made some commits, but realize they were premature to be in the <code>master</code> branch. You want to continue polishing them in a topic branch, so create <code>topic/wip</code> branch off of the current <code>HEAD</code>.</p> </li> <li> <p>Rewind the master branch to get rid of those three commits.</p> </li> <li> <p>Switch to <code>topic/wip</code> branch and keep working.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt-Undocommitspermanently"> Undo commits permanently </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit ... +$ git reset --hard HEAD~3 (1)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>The last three commits (<code>HEAD</code>, <code>HEAD^</code>, and <code>HEAD~2</code>) were bad and you do not want to ever see them again. Do <strong>not</strong> do this if you have already given these commits to somebody else. (See the "RECOVERING FROM UPSTREAM REBASE" section in <a href="git-rebase">git-rebase[1]</a> for the implications of doing so.)</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt-Undoamergeorpull"> Undo a merge or pull </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git pull (1) +Auto-merging nitfol +CONFLICT (content): Merge conflict in nitfol +Automatic merge failed; fix conflicts and then commit the result. +$ git reset --hard (2) +$ git pull . topic/branch (3) +Updating from 41223... to 13134... +Fast-forward +$ git reset --hard ORIG_HEAD (4)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>Try to update from the upstream resulted in a lot of conflicts; you were not ready to spend a lot of time merging right now, so you decide to do that later.</p> </li> <li> <p>"pull" has not made merge commit, so <code>git reset --hard</code> which is a synonym for <code>git reset --hard HEAD</code> clears the mess from the index file and the working tree.</p> </li> <li> <p>Merge a topic branch into the current branch, which resulted in a fast-forward.</p> </li> <li> <p>But you decided that the topic branch is not ready for public consumption yet. "pull" or "merge" always leaves the original tip of the current branch in <code>ORIG_HEAD</code>, so resetting hard to it brings your index file and the working tree back to that state, and resets the tip of the branch to that commit.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt-Undoamergeorpullinsideadirtyworkingtree"> Undo a merge or pull inside a dirty working tree </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git pull (1) +Auto-merging nitfol +Merge made by recursive. + nitfol | 20 +++++---- + ... +$ git reset --merge ORIG_HEAD (2)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>Even if you may have local modifications in your working tree, you can safely say <code>git pull</code> when you know that the change in the other branch does not overlap with them.</p> </li> <li> <p>After inspecting the result of the merge, you may find that the change in the other branch is unsatisfactory. Running <code>git reset --hard ORIG_HEAD</code> will let you go back to where you were, but it will discard your local changes, which you do not want. <code>git reset --merge</code> keeps your local changes.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt-Interruptedworkflow"> Interrupted workflow </dt> <dd> <p>Suppose you are interrupted by an urgent fix request while you are in the middle of a large change. The files in your working tree are not in any shape to be committed yet, but you need to get to the other branch for a quick bugfix.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch feature ;# you were working in "feature" branch and +$ work work work ;# got interrupted +$ git commit -a -m "snapshot WIP" (1) +$ git switch master +$ fix fix fix +$ git commit ;# commit with real log +$ git switch feature +$ git reset --soft HEAD^ ;# go back to WIP state (2) +$ git reset (3)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>This commit will get blown away so a throw-away log message is OK.</p> </li> <li> <p>This removes the <code>WIP</code> commit from the commit history, and sets your working tree to the state just before you made that snapshot.</p> </li> <li> <p>At this point the index file still has all the WIP changes you committed as <code>snapshot WIP</code>. This updates the index to show your WIP files as uncommitted.</p> </li> </ol> </div> <p>See also <a href="git-stash">git-stash[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt-Resetasinglefileintheindex"> Reset a single file in the index </dt> <dd> <p>Suppose you have added a file to your index, but later decide you do not want to add it to your commit. You can remove the file from the index while keeping your changes with git reset.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git reset -- frotz.c (1) +$ git commit -m "Commit files in index" (2) +$ git add frotz.c (3)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>This removes the file from the index while keeping it in the working directory.</p> </li> <li> <p>This commits all other changes in the index.</p> </li> <li> <p>Adds the file to the index again.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt-Keepchangesinworkingtreewhilediscardingsomepreviouscommits"> Keep changes in working tree while discarding some previous commits </dt> <dd> <p>Suppose you are working on something and you commit it, and then you continue working a bit more, but now you think that what you have in your working tree should be in another branch that has nothing to do with what you committed previously. You can start a new branch and reset it while keeping the changes in your working tree.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git tag start +$ git switch -c branch1 +$ edit +$ git commit ... (1) +$ edit +$ git switch -c branch2 (2) +$ git reset --keep start (3)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>This commits your first edits in <code>branch1</code>.</p> </li> <li> <p>In the ideal world, you could have realized that the earlier commit did not belong to the new topic when you created and switched to <code>branch2</code> (i.e. <code>git switch -c branch2 start</code>), but nobody is perfect.</p> </li> <li> <p>But you can use <code>reset --keep</code> to remove the unwanted commit after you switched to <code>branch2</code>.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/git-reset.txt-Splitacommitapartintoasequenceofcommits"> Split a commit apart into a sequence of commits </dt> <dd> <p>Suppose that you have created lots of logically separate changes and committed them together. Then, later you decide that it might be better to have each logical chunk associated with its own commit. You can use git reset to rewind history without changing the contents of your local files, and then successively use <code>git add -p</code> to interactively select which hunks to include into each commit, using <code>git commit -c</code> to pre-populate the commit message.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git reset -N HEAD^ (1) +$ git add -p (2) +$ git diff --cached (3) +$ git commit -c HEAD@{1} (4) +... (5) +$ git add ... (6) +$ git diff --cached (7) +$ git commit ... (8)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>First, reset the history back one commit so that we remove the original commit, but leave the working tree with all the changes. The -N ensures that any new files added with <code>HEAD</code> are still marked so that <code>git add -p</code> will find them.</p> </li> <li> <p>Next, we interactively select diff hunks to add using the <code>git add -p</code> facility. This will ask you about each diff hunk in sequence and you can use simple commands such as "yes, include this", "No don’t include this" or even the very powerful "edit" facility.</p> </li> <li> <p>Once satisfied with the hunks you want to include, you should verify what has been prepared for the first commit by using <code>git diff --cached</code>. This shows all the changes that have been moved into the index and are about to be committed.</p> </li> <li> <p>Next, commit the changes stored in the index. The <code>-c</code> option specifies to pre-populate the commit message from the original message that you started with in the first commit. This is helpful to avoid retyping it. The <code>HEAD@{1}</code> is a special notation for the commit that <code>HEAD</code> used to be at prior to the original reset commit (1 change ago). See <a href="git-reflog">git-reflog[1]</a> for more details. You may also use any other valid commit reference.</p> </li> <li> <p>You can repeat steps 2-4 multiple times to break the original code into any number of commits.</p> </li> <li> <p>Now you’ve split out many of the changes into their own commits, and might no longer use the patch mode of <code>git add</code>, in order to select all remaining uncommitted changes.</p> </li> <li> <p>Once again, check to verify that you’ve included what you want to. You may also wish to verify that git diff doesn’t show any remaining changes to be committed later.</p> </li> <li> <p>And finally create the final commit.</p> </li> </ol> </div> </dd> </dl> </div> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>The tables below show what happens when running:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git reset --option target</pre> </div> </div> <p>to reset the <code>HEAD</code> to another commit (<code>target</code>) with the different reset options depending on the state of the files.</p> <p>In these tables, <code>A</code>, <code>B</code>, <code>C</code> and <code>D</code> are some different states of a file. For example, the first line of the first table means that if a file is in state <code>A</code> in the working tree, in state <code>B</code> in the index, in state <code>C</code> in <code>HEAD</code> and in state <code>D</code> in the target, then <code>git reset --soft +target</code> will leave the file in the working tree in state <code>A</code> and in the index in state <code>B</code>. It resets (i.e. moves) the <code>HEAD</code> (i.e. the tip of the current branch, if you are on one) to <code>target</code> (which has the file in state <code>D</code>).</p> <div class="literalblock"> <div class="content"> <pre>working index HEAD target working index HEAD +---------------------------------------------------- + A B C D --soft A B D + --mixed A D D + --hard D D D + --merge (disallowed) + --keep (disallowed)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>working index HEAD target working index HEAD +---------------------------------------------------- + A B C C --soft A B C + --mixed A C C + --hard C C C + --merge (disallowed) + --keep A C C</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>working index HEAD target working index HEAD +---------------------------------------------------- + B B C D --soft B B D + --mixed B D D + --hard D D D + --merge D D D + --keep (disallowed)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>working index HEAD target working index HEAD +---------------------------------------------------- + B B C C --soft B B C + --mixed B C C + --hard C C C + --merge C C C + --keep B C C</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>working index HEAD target working index HEAD +---------------------------------------------------- + B C C D --soft B C D + --mixed B D D + --hard D D D + --merge (disallowed) + --keep (disallowed)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>working index HEAD target working index HEAD +---------------------------------------------------- + B C C C --soft B C C + --mixed B C C + --hard C C C + --merge B C C + --keep B C C</pre> </div> </div> <p><code>reset --merge</code> is meant to be used when resetting out of a conflicted merge. Any mergy operation guarantees that the working tree file that is involved in the merge does not have a local change with respect to the index before it starts, and that it writes the result out to the working tree. So if we see some difference between the index and the target and also between the index and the working tree, then it means that we are not resetting out from a state that a mergy operation left after failing with a conflict. That is why we disallow <code>--merge</code> option in this case.</p> <p><code>reset --keep</code> is meant to be used when removing some of the last commits in the current branch while keeping changes in the working tree. If there could be conflicts between the changes in the commit we want to remove and the changes in the working tree we want to keep, the reset is disallowed. That’s why it is disallowed if there are both changes between the working tree and <code>HEAD</code>, and between <code>HEAD</code> and the target. To be safe, it is also disallowed when there are unmerged entries.</p> <p>The following tables show what happens when there are unmerged entries:</p> <div class="literalblock"> <div class="content"> <pre>working index HEAD target working index HEAD +---------------------------------------------------- + X U A B --soft (disallowed) + --mixed X B B + --hard B B B + --merge B B B + --keep (disallowed)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>working index HEAD target working index HEAD +---------------------------------------------------- + X U A A --soft (disallowed) + --mixed X A A + --hard A A A + --merge A A A + --keep (disallowed)</pre> </div> </div> <p><code>X</code> means any state and <code>U</code> means an unmerged index.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-reset" class="_attribution-link">https://git-scm.com/docs/git-reset</a> + </p> +</div> diff --git a/devdocs/git/git-restore.html b/devdocs/git/git-restore.html new file mode 100644 index 00000000..edb95688 --- /dev/null +++ b/devdocs/git/git-restore.html @@ -0,0 +1,11 @@ +<h1>git-restore</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-restore - Restore working tree files</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git restore [<options>] [--source=<tree>] [--staged] [--worktree] [--] <pathspec>… +git restore [<options>] [--source=<tree>] [--staged] [--worktree] --pathspec-from-file=<file> [--pathspec-file-nul] +git restore (-p|--patch) [<options>] [--source=<tree>] [--staged] [--worktree] [--] [<pathspec>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Restore specified paths in the working tree with some contents from a restore source. If a path is tracked but does not exist in the restore source, it will be removed to match the source.</p> <p>The command can also be used to restore the content in the index with <code>--staged</code>, or restore both the working tree and the index with <code>--staged --worktree</code>.</p> <p>By default, if <code>--staged</code> is given, the contents are restored from <code>HEAD</code>, otherwise from the index. Use <code>--source</code> to restore from a different commit.</p> <p>See "Reset, restore and revert" in <a href="git">git[1]</a> for the differences between the three commands.</p> <p>THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-restore.txt--slttreegt"> -s <tree> </dt> <dt class="hdlist1" id="Documentation/git-restore.txt---sourcelttreegt"> --source=<tree> </dt> <dd> <p>Restore the working tree files with the content from the given tree. It is common to specify the source tree by naming a commit, branch or tag associated with it.</p> <p>If not specified, the contents are restored from <code>HEAD</code> if <code>--staged</code> is given, otherwise from the index.</p> <p>As a special case, you may use <code>"A...B"</code> as a shortcut for the merge base of <code>A</code> and <code>B</code> if there is exactly one merge base. You can leave out at most one of <code>A</code> and <code>B</code>, in which case it defaults to <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-restore.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-restore.txt---patch"> --patch </dt> <dd> <p>Interactively select hunks in the difference between the restore source and the restore location. See the “Interactive Mode” section of <a href="git-add">git-add[1]</a> to learn how to operate the <code>--patch</code> mode.</p> <p>Note that <code>--patch</code> can accept no pathspec and will prompt to restore all modified paths.</p> </dd> <dt class="hdlist1" id="Documentation/git-restore.txt--W"> -W </dt> <dt class="hdlist1" id="Documentation/git-restore.txt---worktree"> --worktree </dt> <dt class="hdlist1" id="Documentation/git-restore.txt--S"> -S </dt> <dt class="hdlist1" id="Documentation/git-restore.txt---staged"> --staged </dt> <dd> <p>Specify the restore location. If neither option is specified, by default the working tree is restored. Specifying <code>--staged</code> will only restore the index. Specifying both restores both.</p> </dd> <dt class="hdlist1" id="Documentation/git-restore.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-restore.txt---quiet"> --quiet </dt> <dd> <p>Quiet, suppress feedback messages. Implies <code>--no-progress</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-restore.txt---progress"> --progress </dt> <dt class="hdlist1" id="Documentation/git-restore.txt---no-progress"> --no-progress </dt> <dd> <p>Progress status is reported on the standard error stream by default when it is attached to a terminal, unless <code>--quiet</code> is specified. This flag enables progress reporting even if not attached to a terminal, regardless of <code>--quiet</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-restore.txt---ours"> --ours </dt> <dt class="hdlist1" id="Documentation/git-restore.txt---theirs"> --theirs </dt> <dd> <p>When restoring files in the working tree from the index, use stage #2 (<code>ours</code>) or #3 (<code>theirs</code>) for unmerged paths. This option cannot be used when checking out paths from a tree-ish (i.e. with the <code>--source</code> option).</p> <p>Note that during <code>git rebase</code> and <code>git pull --rebase</code>, <code>ours</code> and <code>theirs</code> may appear swapped. See the explanation of the same options in <a href="git-checkout">git-checkout[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-restore.txt--m"> -m </dt> <dt class="hdlist1" id="Documentation/git-restore.txt---merge"> --merge </dt> <dd> <p>When restoring files on the working tree from the index, recreate the conflicted merge in the unmerged paths. This option cannot be used when checking out paths from a tree-ish (i.e. with the <code>--source</code> option).</p> </dd> <dt class="hdlist1" id="Documentation/git-restore.txt---conflictltstylegt"> --conflict=<style> </dt> <dd> <p>The same as <code>--merge</code> option above, but changes the way the conflicting hunks are presented, overriding the <code>merge.conflictStyle</code> configuration variable. Possible values are "merge" (default), "diff3", and "zdiff3".</p> </dd> <dt class="hdlist1" id="Documentation/git-restore.txt---ignore-unmerged"> --ignore-unmerged </dt> <dd> <p>When restoring files on the working tree from the index, do not abort the operation if there are unmerged entries and neither <code>--ours</code>, <code>--theirs</code>, <code>--merge</code> or <code>--conflict</code> is specified. Unmerged paths on the working tree are left alone.</p> </dd> <dt class="hdlist1" id="Documentation/git-restore.txt---ignore-skip-worktree-bits"> --ignore-skip-worktree-bits </dt> <dd> <p>In sparse checkout mode, the default is to only update entries matched by <code><pathspec></code> and sparse patterns in $GIT_DIR/info/sparse-checkout. This option ignores the sparse patterns and unconditionally restores any files in <code><pathspec></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-restore.txt---recurse-submodules"> --recurse-submodules </dt> <dt class="hdlist1" id="Documentation/git-restore.txt---no-recurse-submodules"> --no-recurse-submodules </dt> <dd> <p>If <code><pathspec></code> names an active submodule and the restore location includes the working tree, the submodule will only be updated if this option is given, in which case its working tree will be restored to the commit recorded in the superproject, and any local modifications overwritten. If nothing (or <code>--no-recurse-submodules</code>) is used, submodules working trees will not be updated. Just like <a href="git-checkout">git-checkout[1]</a>, this will detach <code>HEAD</code> of the submodule.</p> </dd> <dt class="hdlist1" id="Documentation/git-restore.txt---overlay"> --overlay </dt> <dt class="hdlist1" id="Documentation/git-restore.txt---no-overlay"> --no-overlay </dt> <dd> <p>In overlay mode, the command never removes files when restoring. In no-overlay mode, tracked files that do not appear in the <code>--source</code> tree are removed, to make them match <code><tree></code> exactly. The default is no-overlay mode.</p> </dd> <dt class="hdlist1" id="Documentation/git-restore.txt---pathspec-from-fileltfilegt"> --pathspec-from-file=<file> </dt> <dd> <p>Pathspec is passed in <code><file></code> instead of commandline args. If <code><file></code> is exactly <code>-</code> then standard input is used. Pathspec elements are separated by LF or CR/LF. Pathspec elements can be quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>). See also <code>--pathspec-file-nul</code> and global <code>--literal-pathspecs</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-restore.txt---pathspec-file-nul"> --pathspec-file-nul </dt> <dd> <p>Only meaningful with <code>--pathspec-from-file</code>. Pathspec elements are separated with NUL character and all other characters are taken literally (including newlines and quotes).</p> </dd> <dt class="hdlist1" id="Documentation/git-restore.txt---"> -- </dt> <dd> <p>Do not interpret any more arguments as options.</p> </dd> <dt class="hdlist1" id="Documentation/git-restore.txt-ltpathspecgt82308203"> <pathspec>… </dt> <dd> <p>Limits the paths affected by the operation.</p> <p>For more details, see the <code>pathspec</code> entry in <a href="gitglossary">gitglossary[7]</a>.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>The following sequence switches to the <code>master</code> branch, reverts the <code>Makefile</code> to two revisions back, deletes hello.c by mistake, and gets it back from the index.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch master +$ git restore --source master~2 Makefile (1) +$ rm -f hello.c +$ git restore hello.c (2)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>take a file out of another commit</p> </li> <li> <p>restore hello.c from the index</p> </li> </ol> </div> <p>If you want to restore <code>all</code> C source files to match the version in the index, you can say</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git restore '*.c'</pre> </div> </div> <p>Note the quotes around <code>*.c</code>. The file <code>hello.c</code> will also be restored, even though it is no longer in the working tree, because the file globbing is used to match entries in the index (not in the working tree by the shell).</p> <p>To restore all files in the current directory</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git restore .</pre> </div> </div> <p>or to restore all working tree files with <code>top</code> pathspec magic (see <a href="gitglossary">gitglossary[7]</a>)</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git restore :/</pre> </div> </div> <p>To restore a file in the index to match the version in <code>HEAD</code> (this is the same as using <a href="git-reset">git-reset[1]</a>)</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git restore --staged hello.c</pre> </div> </div> <p>or you can restore both the index and the working tree (this is the same as using <a href="git-checkout">git-checkout[1]</a>)</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git restore --source=HEAD --staged --worktree hello.c</pre> </div> </div> <p>or the short form which is more practical but less readable:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git restore -s@ -SW hello.c</pre> </div> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-checkout">git-checkout[1]</a>, <a href="git-reset">git-reset[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-restore" class="_attribution-link">https://git-scm.com/docs/git-restore</a> + </p> +</div> diff --git a/devdocs/git/git-rev-list.html b/devdocs/git/git-rev-list.html new file mode 100644 index 00000000..f480d1e0 --- /dev/null +++ b/devdocs/git/git-rev-list.html @@ -0,0 +1,113 @@ +<h1>git-rev-list</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-rev-list - Lists commit objects in reverse chronological order</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git rev-list [<options>] <commit>… [--] [<path>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>List commits that are reachable by following the <code>parent</code> links from the given commit(s), but exclude commits that are reachable from the one(s) given with a <code>^</code> in front of them. The output is given in reverse chronological order by default.</p> <p>You can think of this as a set operation. Commits reachable from any of the commits given on the command line form a set, and then commits reachable from any of the ones given with <code>^</code> in front are subtracted from that set. The remaining commits are what comes out in the command’s output. Various other options and paths parameters can be used to further limit the result.</p> <p>Thus, the following command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rev-list foo bar ^baz</pre> </div> </div> <p>means "list all the commits which are reachable from <code>foo</code> or <code>bar</code>, but not from <code>baz</code>".</p> <p>A special notation "<code><commit1></code>..<code><commit2></code>" can be used as a short-hand for "^<code><commit1></code> <code><commit2></code>". For example, either of the following may be used interchangeably:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rev-list origin..HEAD +$ git rev-list HEAD ^origin</pre> </div> </div> <p>Another special notation is "<code><commit1></code>…<code><commit2></code>" which is useful for merges. The resulting set of commits is the symmetric difference between the two operands. The following two commands are equivalent:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rev-list A B --not $(git merge-base --all A B) +$ git rev-list A...B</pre> </div> </div> <p><code>rev-list</code> is an essential Git command, since it provides the ability to build and traverse commit ancestry graphs. For this reason, it has a lot of different options that enable it to be used by commands as different as <code>git bisect</code> and <code>git repack</code>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_commit_limiting"> +Commit Limiting</h3> <p>Besides specifying a range of commits that should be listed using the special notations explained in the description, additional commit limiting may be applied.</p> <p>Using more options generally further limits the output (e.g. <code>--since=<date1></code> limits to commits newer than <code><date1></code>, and using it with <code>--grep=<pattern></code> further limits to commits whose log message has a line that matches <code><pattern></code>), unless otherwise noted.</p> <p>Note that these are applied before commit ordering and formatting options, such as <code>--reverse</code>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-list.txt--ltnumbergt"> -<number> </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt--nltnumbergt"> -n <number> </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---max-countltnumbergt"> --max-count=<number> </dt> <dd> <p>Limit the number of commits to output.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---skipltnumbergt"> --skip=<number> </dt> <dd> <p>Skip <code>number</code> commits before starting to show the commit output.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---sinceltdategt"> --since=<date> </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---afterltdategt"> --after=<date> </dt> <dd> <p>Show commits more recent than a specific date.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---since-as-filterltdategt"> --since-as-filter=<date> </dt> <dd> <p>Show all commits more recent than a specific date. This visits all commits in the range, rather than stopping at the first commit which is older than a specific date.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---untilltdategt"> --until=<date> </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---beforeltdategt"> --before=<date> </dt> <dd> <p>Show commits older than a specific date.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---max-agelttimestampgt"> --max-age=<timestamp> </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---min-agelttimestampgt"> --min-age=<timestamp> </dt> <dd> <p>Limit the commits output to specified time range.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---authorltpatterngt"> --author=<pattern> </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---committerltpatterngt"> --committer=<pattern> </dt> <dd> <p>Limit the commits output to ones with author/committer header lines that match the specified pattern (regular expression). With more than one <code>--author=<pattern></code>, commits whose author matches any of the given patterns are chosen (similarly for multiple <code>--committer=<pattern></code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---grep-reflogltpatterngt"> --grep-reflog=<pattern> </dt> <dd> <p>Limit the commits output to ones with reflog entries that match the specified pattern (regular expression). With more than one <code>--grep-reflog</code>, commits whose reflog message matches any of the given patterns are chosen. It is an error to use this option unless <code>--walk-reflogs</code> is in use.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---grepltpatterngt"> --grep=<pattern> </dt> <dd> <p>Limit the commits output to ones with a log message that matches the specified pattern (regular expression). With more than one <code>--grep=<pattern></code>, commits whose message matches any of the given patterns are chosen (but see <code>--all-match</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---all-match"> --all-match </dt> <dd> <p>Limit the commits output to ones that match all given <code>--grep</code>, instead of ones that match at least one.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---invert-grep"> --invert-grep </dt> <dd> <p>Limit the commits output to ones with a log message that do not match the pattern specified with <code>--grep=<pattern></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt--i"> -i </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---regexp-ignore-case"> --regexp-ignore-case </dt> <dd> <p>Match the regular expression limiting patterns without regard to letter case.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---basic-regexp"> --basic-regexp </dt> <dd> <p>Consider the limiting patterns to be basic regular expressions; this is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt--E"> -E </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---extended-regexp"> --extended-regexp </dt> <dd> <p>Consider the limiting patterns to be extended regular expressions instead of the default basic regular expressions.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt--F"> -F </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---fixed-strings"> --fixed-strings </dt> <dd> <p>Consider the limiting patterns to be fixed strings (don’t interpret pattern as a regular expression).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt--P"> -P </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---perl-regexp"> --perl-regexp </dt> <dd> <p>Consider the limiting patterns to be Perl-compatible regular expressions.</p> <p>Support for these types of regular expressions is an optional compile-time dependency. If Git wasn’t compiled with support for them providing this option will cause it to die.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---remove-empty"> --remove-empty </dt> <dd> <p>Stop when a given path disappears from the tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---merges"> --merges </dt> <dd> <p>Print only merge commits. This is exactly the same as <code>--min-parents=2</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---no-merges"> --no-merges </dt> <dd> <p>Do not print commits with more than one parent. This is exactly the same as <code>--max-parents=1</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---min-parentsltnumbergt"> --min-parents=<number> </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---max-parentsltnumbergt"> --max-parents=<number> </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---no-min-parents"> --no-min-parents </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---no-max-parents"> --no-max-parents </dt> <dd> <p>Show only commits which have at least (or at most) that many parent commits. In particular, <code>--max-parents=1</code> is the same as <code>--no-merges</code>, <code>--min-parents=2</code> is the same as <code>--merges</code>. <code>--max-parents=0</code> gives all root commits and <code>--min-parents=3</code> all octopus merges.</p> <p><code>--no-min-parents</code> and <code>--no-max-parents</code> reset these limits (to no limit) again. Equivalent forms are <code>--min-parents=0</code> (any commit has 0 or more parents) and <code>--max-parents=-1</code> (negative numbers denote no upper limit).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---first-parent"> --first-parent </dt> <dd> <p>When finding commits to include, follow only the first parent commit upon seeing a merge commit. This option can give a better overview when viewing the evolution of a particular topic branch, because merges into a topic branch tend to be only about adjusting to updated upstream from time to time, and this option allows you to ignore the individual commits brought in to your history by such a merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---exclude-first-parent-only"> --exclude-first-parent-only </dt> <dd> <p>When finding commits to exclude (with a <code>^</code>), follow only the first parent commit upon seeing a merge commit. This can be used to find the set of changes in a topic branch from the point where it diverged from the remote branch, given that arbitrary merges can be valid topic branch changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---not"> --not </dt> <dd> <p>Reverses the meaning of the <code>^</code> prefix (or lack thereof) for all following revision specifiers, up to the next <code>--not</code>. When used on the command line before --stdin, the revisions passed through stdin will not be affected by it. Conversely, when passed via standard input, the revisions passed on the command line will not be affected by it.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---all"> --all </dt> <dd> <p>Pretend as if all the refs in <code>refs/</code>, along with <code>HEAD</code>, are listed on the command line as <code><commit></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---branchesltpatterngt"> --branches[=<pattern>] </dt> <dd> <p>Pretend as if all the refs in <code>refs/heads</code> are listed on the command line as <code><commit></code>. If <code><pattern></code> is given, limit branches to ones matching given shell glob. If pattern lacks <code>?</code>, <code>*</code>, or <code>[</code>, <code>/*</code> at the end is implied.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---tagsltpatterngt"> --tags[=<pattern>] </dt> <dd> <p>Pretend as if all the refs in <code>refs/tags</code> are listed on the command line as <code><commit></code>. If <code><pattern></code> is given, limit tags to ones matching given shell glob. If pattern lacks <code>?</code>, <code>*</code>, or <code>[</code>, <code>/*</code> at the end is implied.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---remotesltpatterngt"> --remotes[=<pattern>] </dt> <dd> <p>Pretend as if all the refs in <code>refs/remotes</code> are listed on the command line as <code><commit></code>. If <code><pattern></code> is given, limit remote-tracking branches to ones matching given shell glob. If pattern lacks <code>?</code>, <code>*</code>, or <code>[</code>, <code>/*</code> at the end is implied.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---globltglob-patterngt"> --glob=<glob-pattern> </dt> <dd> <p>Pretend as if all the refs matching shell glob <code><glob-pattern></code> are listed on the command line as <code><commit></code>. Leading <code>refs/</code>, is automatically prepended if missing. If pattern lacks <code>?</code>, <code>*</code>, or <code>[</code>, <code>/*</code> at the end is implied.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---excludeltglob-patterngt"> --exclude=<glob-pattern> </dt> <dd> <p>Do not include refs matching <code><glob-pattern></code> that the next <code>--all</code>, <code>--branches</code>, <code>--tags</code>, <code>--remotes</code>, or <code>--glob</code> would otherwise consider. Repetitions of this option accumulate exclusion patterns up to the next <code>--all</code>, <code>--branches</code>, <code>--tags</code>, <code>--remotes</code>, or <code>--glob</code> option (other options or arguments do not clear accumulated patterns).</p> <p>The patterns given should not begin with <code>refs/heads</code>, <code>refs/tags</code>, or <code>refs/remotes</code> when applied to <code>--branches</code>, <code>--tags</code>, or <code>--remotes</code>, respectively, and they must begin with <code>refs/</code> when applied to <code>--glob</code> or <code>--all</code>. If a trailing <code>/*</code> is intended, it must be given explicitly.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---exclude-hiddenfetchreceiveuploadpack"> --exclude-hidden=[fetch|receive|uploadpack] </dt> <dd> <p>Do not include refs that would be hidden by <code>git-fetch</code>, <code>git-receive-pack</code> or <code>git-upload-pack</code> by consulting the appropriate <code>fetch.hideRefs</code>, <code>receive.hideRefs</code> or <code>uploadpack.hideRefs</code> configuration along with <code>transfer.hideRefs</code> (see <a href="git-config">git-config[1]</a>). This option affects the next pseudo-ref option <code>--all</code> or <code>--glob</code> and is cleared after processing them.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---reflog"> --reflog </dt> <dd> <p>Pretend as if all objects mentioned by reflogs are listed on the command line as <code><commit></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---alternate-refs"> --alternate-refs </dt> <dd> <p>Pretend as if all objects mentioned as ref tips of alternate repositories were listed on the command line. An alternate repository is any repository whose object directory is specified in <code>objects/info/alternates</code>. The set of included objects may be modified by <code>core.alternateRefsCommand</code>, etc. See <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---single-worktree"> --single-worktree </dt> <dd> <p>By default, all working trees will be examined by the following options when there are more than one (see <a href="git-worktree">git-worktree[1]</a>): <code>--all</code>, <code>--reflog</code> and <code>--indexed-objects</code>. This option forces them to examine the current working tree only.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---ignore-missing"> --ignore-missing </dt> <dd> <p>Upon seeing an invalid object name in the input, pretend as if the bad input was not given.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---stdin"> --stdin </dt> <dd> <p>In addition to getting arguments from the command line, read them from standard input as well. This accepts commits and pseudo-options like <code>--all</code> and <code>--glob=</code>. When a <code>--</code> separator is seen, the following input is treated as paths and used to limit the result. Flags like <code>--not</code> which are read via standard input are only respected for arguments passed in the same way and will not influence any subsequent command line arguments.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---quiet"> --quiet </dt> <dd> <p>Don’t print anything to standard output. This form is primarily meant to allow the caller to test the exit status to see if a range of objects is fully connected (or not). It is faster than redirecting stdout to <code>/dev/null</code> as the output does not have to be formatted.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---disk-usage"> --disk-usage </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---disk-usagehuman"> --disk-usage=human </dt> <dd> <p>Suppress normal output; instead, print the sum of the bytes used for on-disk storage by the selected commits or objects. This is equivalent to piping the output into <code>git cat-file +--batch-check='%(objectsize:disk)'</code>, except that it runs much faster (especially with <code>--use-bitmap-index</code>). See the <code>CAVEATS</code> section in <a href="git-cat-file">git-cat-file[1]</a> for the limitations of what "on-disk storage" means. With the optional value <code>human</code>, on-disk storage size is shown in human-readable string(e.g. 12.24 Kib, 3.50 Mib).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---cherry-mark"> --cherry-mark </dt> <dd> <p>Like <code>--cherry-pick</code> (see below) but mark equivalent commits with <code>=</code> rather than omitting them, and inequivalent ones with <code>+</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---cherry-pick"> --cherry-pick </dt> <dd> <p>Omit any commit that introduces the same change as another commit on the “other side” when the set of commits are limited with symmetric difference.</p> <p>For example, if you have two branches, <code>A</code> and <code>B</code>, a usual way to list all commits on only one side of them is with <code>--left-right</code> (see the example below in the description of the <code>--left-right</code> option). However, it shows the commits that were cherry-picked from the other branch (for example, “3rd on b” may be cherry-picked from branch A). With this option, such pairs of commits are excluded from the output.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---left-only"> --left-only </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---right-only"> --right-only </dt> <dd> <p>List only commits on the respective side of a symmetric difference, i.e. only those which would be marked <code><</code> resp. <code>></code> by <code>--left-right</code>.</p> <p>For example, <code>--cherry-pick --right-only A...B</code> omits those commits from <code>B</code> which are in <code>A</code> or are patch-equivalent to a commit in <code>A</code>. In other words, this lists the <code>+</code> commits from <code>git cherry A B</code>. More precisely, <code>--cherry-pick --right-only --no-merges</code> gives the exact list.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---cherry"> --cherry </dt> <dd> <p>A synonym for <code>--right-only --cherry-mark --no-merges</code>; useful to limit the output to the commits on our side and mark those that have been applied to the other side of a forked history with <code>git log --cherry upstream...mybranch</code>, similar to <code>git cherry upstream mybranch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt--g"> -g </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---walk-reflogs"> --walk-reflogs </dt> <dd> <p>Instead of walking the commit ancestry chain, walk reflog entries from the most recent one to older ones. When this option is used you cannot specify commits to exclude (that is, <code>^commit</code>, <code>commit1..commit2</code>, and <code>commit1...commit2</code> notations cannot be used).</p> <p>With <code>--pretty</code> format other than <code>oneline</code> and <code>reference</code> (for obvious reasons), this causes the output to have two extra lines of information taken from the reflog. The reflog designator in the output may be shown as <code>ref@{Nth}</code> (where <code>Nth</code> is the reverse-chronological index in the reflog) or as <code>ref@{timestamp}</code> (with the timestamp for that entry), depending on a few rules:</p> <div class="openblock"> <div class="content"> <div class="olist arabic"> <ol class="arabic"> <li> <p>If the starting point is specified as <code>ref@{Nth}</code>, show the index format.</p> </li> <li> <p>If the starting point was specified as <code>ref@{now}</code>, show the timestamp format.</p> </li> <li> <p>If neither was used, but <code>--date</code> was given on the command line, show the timestamp in the format requested by <code>--date</code>.</p> </li> <li> <p>Otherwise, show the index format.</p> </li> </ol> </div> </div> </div> <p>Under <code>--pretty=oneline</code>, the commit message is prefixed with this information on the same line. This option cannot be combined with <code>--reverse</code>. See also <a href="git-reflog">git-reflog[1]</a>.</p> <p>Under <code>--pretty=reference</code>, this information will not be shown at all.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---merge"> --merge </dt> <dd> <p>After a failed merge, show refs that touch files having a conflict and don’t exist on all heads to merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---boundary"> --boundary </dt> <dd> <p>Output excluded boundary commits. Boundary commits are prefixed with <code>-</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---use-bitmap-index"> --use-bitmap-index </dt> <dd> <p>Try to speed up the traversal using the pack bitmap index (if one is available). Note that when traversing with <code>--objects</code>, trees and blobs will not have their associated path printed.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---progressltheadergt"> --progress=<header> </dt> <dd> <p>Show progress reports on stderr as objects are considered. The <code><header></code> text will be printed with each progress update.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_history_simplification"> +History Simplification</h3> <p>Sometimes you are only interested in parts of the history, for example the commits modifying a particular <path>. But there are two parts of <code>History Simplification</code>, one part is selecting the commits and the other is how to do it, as there are various strategies to simplify the history.</p> <p>The following options select the commits to be shown:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-list.txt-ltpathsgt"> <paths> </dt> <dd> <p>Commits modifying the given <paths> are selected.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---simplify-by-decoration"> --simplify-by-decoration </dt> <dd> <p>Commits that are referred by some branch or tag are selected.</p> </dd> </dl> </div> <p>Note that extra commits can be shown to give a meaningful history.</p> <p>The following options affect the way the simplification is performed:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-list.txt-Defaultmode"> Default mode </dt> <dd> <p>Simplifies the history to the simplest history explaining the final state of the tree. Simplest because it prunes some side branches if the end result is the same (i.e. merging branches with the same content)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---show-pulls"> --show-pulls </dt> <dd> <p>Include all commits from the default mode, but also any merge commits that are not TREESAME to the first parent but are TREESAME to a later parent. This mode is helpful for showing the merge commits that "first introduced" a change to a branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---full-history"> --full-history </dt> <dd> <p>Same as the default mode, but does not prune some history.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---dense"> --dense </dt> <dd> <p>Only the selected commits are shown, plus some to have a meaningful history.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---sparse"> --sparse </dt> <dd> <p>All commits in the simplified history are shown.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---simplify-merges"> --simplify-merges </dt> <dd> <p>Additional option to <code>--full-history</code> to remove some needless merges from the resulting history, as there are no selected commits contributing to this merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---ancestry-pathltcommitgt"> --ancestry-path[=<commit>] </dt> <dd> <p>When given a range of commits to display (e.g. <code>commit1..commit2</code> or <code>commit2 ^commit1</code>), only display commits in that range that are ancestors of <commit>, descendants of <commit>, or <commit> itself. If no commit is specified, use <code>commit1</code> (the excluded part of the range) as <commit>. Can be passed multiple times; if so, a commit is included if it is any of the commits given or if it is an ancestor or descendant of one of them.</p> </dd> </dl> </div> <p>A more detailed explanation follows.</p> <p>Suppose you specified <code>foo</code> as the <paths>. We shall call commits that modify <code>foo</code> !TREESAME, and the rest TREESAME. (In a diff filtered for <code>foo</code>, they look different and equal, respectively.)</p> <p>In the following, we will always refer to the same example history to illustrate the differences between simplification settings. We assume that you are filtering for a file <code>foo</code> in this commit graph:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M---N---O---P---Q + / / / / / / + I B C D E Y + \ / / / / / + `-------------' X</pre> </div> </div> <p>The horizontal line of history A---Q is taken to be the first parent of each merge. The commits are:</p> <div class="ulist"> <ul> <li> <p><code>I</code> is the initial commit, in which <code>foo</code> exists with contents “asdf”, and a file <code>quux</code> exists with contents “quux”. Initial commits are compared to an empty tree, so <code>I</code> is !TREESAME.</p> </li> <li> <p>In <code>A</code>, <code>foo</code> contains just “foo”.</p> </li> <li> <p><code>B</code> contains the same change as <code>A</code>. Its merge <code>M</code> is trivial and hence TREESAME to all parents.</p> </li> <li> <p><code>C</code> does not change <code>foo</code>, but its merge <code>N</code> changes it to “foobar”, so it is not TREESAME to any parent.</p> </li> <li> <p><code>D</code> sets <code>foo</code> to “baz”. Its merge <code>O</code> combines the strings from <code>N</code> and <code>D</code> to “foobarbaz”; i.e., it is not TREESAME to any parent.</p> </li> <li> <p><code>E</code> changes <code>quux</code> to “xyzzy”, and its merge <code>P</code> combines the strings to “quux xyzzy”. <code>P</code> is TREESAME to <code>O</code>, but not to <code>E</code>.</p> </li> <li> <p><code>X</code> is an independent root commit that added a new file <code>side</code>, and <code>Y</code> modified it. <code>Y</code> is TREESAME to <code>X</code>. Its merge <code>Q</code> added <code>side</code> to <code>P</code>, and <code>Q</code> is TREESAME to <code>P</code>, but not to <code>Y</code>.</p> </li> </ul> </div> <p><code>rev-list</code> walks backwards through history, including or excluding commits based on whether <code>--full-history</code> and/or parent rewriting (via <code>--parents</code> or <code>--children</code>) are used. The following settings are available.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-list.txt-Defaultmode-1"> Default mode </dt> <dd> <p>Commits are included if they are not TREESAME to any parent (though this can be changed, see <code>--sparse</code> below). If the commit was a merge, and it was TREESAME to one parent, follow only that parent. (Even if there are several TREESAME parents, follow only one of them.) Otherwise, follow all parents.</p> <p>This results in:</p> <div class="listingblock"> <div class="content"> <pre> .-A---N---O + / / / + I---------D</pre> </div> </div> <p>Note how the rule to only follow the TREESAME parent, if one is available, removed <code>B</code> from consideration entirely. <code>C</code> was considered via <code>N</code>, but is TREESAME. Root commits are compared to an empty tree, so <code>I</code> is !TREESAME.</p> <p>Parent/child relations are only visible with <code>--parents</code>, but that does not affect the commits selected in default mode, so we have shown the parent lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---full-historywithoutparentrewriting"> --full-history without parent rewriting </dt> <dd> <p>This mode differs from the default in one point: always follow all parents of a merge, even if it is TREESAME to one of them. Even if more than one side of the merge has commits that are included, this does not imply that the merge itself is! In the example, we get</p> <div class="listingblock"> <div class="content"> <pre> I A B N D O P Q</pre> </div> </div> <p><code>M</code> was excluded because it is TREESAME to both parents. <code>E</code>, <code>C</code> and <code>B</code> were all walked, but only <code>B</code> was !TREESAME, so the others do not appear.</p> <p>Note that without parent rewriting, it is not really possible to talk about the parent/child relationships between the commits, so we show them disconnected.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---full-historywithparentrewriting"> --full-history with parent rewriting </dt> <dd> <p>Ordinary commits are only included if they are !TREESAME (though this can be changed, see <code>--sparse</code> below).</p> <p>Merges are always included. However, their parent list is rewritten: Along each parent, prune away commits that are not included themselves. This results in</p> <div class="listingblock"> <div class="content"> <pre> .-A---M---N---O---P---Q + / / / / / + I B / D / + \ / / / / + `-------------'</pre> </div> </div> <p>Compare to <code>--full-history</code> without rewriting above. Note that <code>E</code> was pruned away because it is TREESAME, but the parent list of P was rewritten to contain <code>E</code>'s parent <code>I</code>. The same happened for <code>C</code> and <code>N</code>, and <code>X</code>, <code>Y</code> and <code>Q</code>.</p> </dd> </dl> </div> <p>In addition to the above settings, you can change whether TREESAME affects inclusion:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-list.txt---dense-1"> --dense </dt> <dd> <p>Commits that are walked are included if they are not TREESAME to any parent.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---sparse-1"> --sparse </dt> <dd> <p>All commits that are walked are included.</p> <p>Note that without <code>--full-history</code>, this still simplifies merges: if one of the parents is TREESAME, we follow only that one, so the other sides of the merge are never walked.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---simplify-merges-1"> --simplify-merges </dt> <dd> <p>First, build a history graph in the same way that <code>--full-history</code> with parent rewriting does (see above).</p> <p>Then simplify each commit <code>C</code> to its replacement <code>C'</code> in the final history according to the following rules:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>Set <code>C'</code> to <code>C</code>.</p> </li> <li> <p>Replace each parent <code>P</code> of <code>C'</code> with its simplification <code>P'</code>. In the process, drop parents that are ancestors of other parents or that are root commits TREESAME to an empty tree, and remove duplicates, but take care to never drop all parents that we are TREESAME to.</p> </li> <li> <p>If after this parent rewriting, <code>C'</code> is a root or merge commit (has zero or >1 parents), a boundary commit, or !TREESAME, it remains. Otherwise, it is replaced with its only parent.</p> </li> </ul> </div> </div> </div> <p>The effect of this is best shown by way of comparing to <code>--full-history</code> with parent rewriting. The example turns into:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M---N---O + / / / + I B D + \ / / + `---------'</pre> </div> </div> <p>Note the major differences in <code>N</code>, <code>P</code>, and <code>Q</code> over <code>--full-history</code>:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>N</code>'s parent list had <code>I</code> removed, because it is an ancestor of the other parent <code>M</code>. Still, <code>N</code> remained because it is !TREESAME.</p> </li> <li> <p><code>P</code>'s parent list similarly had <code>I</code> removed. <code>P</code> was then removed completely, because it had one parent and is TREESAME.</p> </li> <li> <p><code>Q</code>'s parent list had <code>Y</code> simplified to <code>X</code>. <code>X</code> was then removed, because it was a TREESAME root. <code>Q</code> was then removed completely, because it had one parent and is TREESAME.</p> </li> </ul> </div> </div> </div> </dd> </dl> </div> <p>There is another simplification mode available:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-list.txt---ancestry-pathltcommitgt-1"> --ancestry-path[=<commit>] </dt> <dd> <p>Limit the displayed commits to those which are an ancestor of <commit>, or which are a descendant of <commit>, or are <commit> itself.</p> <p>As an example use case, consider the following commit history:</p> <div class="listingblock"> <div class="content"> <pre> D---E-------F + / \ \ + B---C---G---H---I---J + / \ + A-------K---------------L--M</pre> </div> </div> <p>A regular <code>D..M</code> computes the set of commits that are ancestors of <code>M</code>, but excludes the ones that are ancestors of <code>D</code>. This is useful to see what happened to the history leading to <code>M</code> since <code>D</code>, in the sense that “what does <code>M</code> have that did not exist in <code>D</code>”. The result in this example would be all the commits, except <code>A</code> and <code>B</code> (and <code>D</code> itself, of course).</p> <p>When we want to find out what commits in <code>M</code> are contaminated with the bug introduced by <code>D</code> and need fixing, however, we might want to view only the subset of <code>D..M</code> that are actually descendants of <code>D</code>, i.e. excluding <code>C</code> and <code>K</code>. This is exactly what the <code>--ancestry-path</code> option does. Applied to the <code>D..M</code> range, it results in:</p> <div class="listingblock"> <div class="content"> <pre> E-------F + \ \ + G---H---I---J + \ + L--M</pre> </div> </div> <p>We can also use <code>--ancestry-path=D</code> instead of <code>--ancestry-path</code> which means the same thing when applied to the <code>D..M</code> range but is just more explicit.</p> <p>If we instead are interested in a given topic within this range, and all commits affected by that topic, we may only want to view the subset of <code>D..M</code> which contain that topic in their ancestry path. So, using <code>--ancestry-path=H D..M</code> for example would result in:</p> <div class="listingblock"> <div class="content"> <pre> E + \ + G---H---I---J + \ + L--M</pre> </div> </div> <p>Whereas <code>--ancestry-path=K D..M</code> would result in</p> <div class="listingblock"> <div class="content"> <pre> K---------------L--M</pre> </div> </div> </dd> </dl> </div> <p>Before discussing another option, <code>--show-pulls</code>, we need to create a new example history.</p> <p>A common problem users face when looking at simplified history is that a commit they know changed a file somehow does not appear in the file’s simplified history. Let’s demonstrate a new example and show how options such as <code>--full-history</code> and <code>--simplify-merges</code> works in that case:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M-----C--N---O---P + / / \ \ \/ / / + I B \ R-'`-Z' / + \ / \/ / + \ / /\ / + `---X--' `---Y--'</pre> </div> </div> <p>For this example, suppose <code>I</code> created <code>file.txt</code> which was modified by <code>A</code>, <code>B</code>, and <code>X</code> in different ways. The single-parent commits <code>C</code>, <code>Z</code>, and <code>Y</code> do not change <code>file.txt</code>. The merge commit <code>M</code> was created by resolving the merge conflict to include both changes from <code>A</code> and <code>B</code> and hence is not TREESAME to either. The merge commit <code>R</code>, however, was created by ignoring the contents of <code>file.txt</code> at <code>M</code> and taking only the contents of <code>file.txt</code> at <code>X</code>. Hence, <code>R</code> is TREESAME to <code>X</code> but not <code>M</code>. Finally, the natural merge resolution to create <code>N</code> is to take the contents of <code>file.txt</code> at <code>R</code>, so <code>N</code> is TREESAME to <code>R</code> but not <code>C</code>. The merge commits <code>O</code> and <code>P</code> are TREESAME to their first parents, but not to their second parents, <code>Z</code> and <code>Y</code> respectively.</p> <p>When using the default mode, <code>N</code> and <code>R</code> both have a TREESAME parent, so those edges are walked and the others are ignored. The resulting history graph is:</p> <div class="listingblock"> <div class="content"> <pre> I---X</pre> </div> </div> <p>When using <code>--full-history</code>, Git walks every edge. This will discover the commits <code>A</code> and <code>B</code> and the merge <code>M</code>, but also will reveal the merge commits <code>O</code> and <code>P</code>. With parent rewriting, the resulting graph is:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M--------N---O---P + / / \ \ \/ / / + I B \ R-'`--' / + \ / \/ / + \ / /\ / + `---X--' `------'</pre> </div> </div> <p>Here, the merge commits <code>O</code> and <code>P</code> contribute extra noise, as they did not actually contribute a change to <code>file.txt</code>. They only merged a topic that was based on an older version of <code>file.txt</code>. This is a common issue in repositories using a workflow where many contributors work in parallel and merge their topic branches along a single trunk: many unrelated merges appear in the <code>--full-history</code> results.</p> <p>When using the <code>--simplify-merges</code> option, the commits <code>O</code> and <code>P</code> disappear from the results. This is because the rewritten second parents of <code>O</code> and <code>P</code> are reachable from their first parents. Those edges are removed and then the commits look like single-parent commits that are TREESAME to their parent. This also happens to the commit <code>N</code>, resulting in a history view as follows:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M--. + / / \ + I B R + \ / / + \ / / + `---X--'</pre> </div> </div> <p>In this view, we see all of the important single-parent changes from <code>A</code>, <code>B</code>, and <code>X</code>. We also see the carefully-resolved merge <code>M</code> and the not-so-carefully-resolved merge <code>R</code>. This is usually enough information to determine why the commits <code>A</code> and <code>B</code> "disappeared" from history in the default view. However, there are a few issues with this approach.</p> <p>The first issue is performance. Unlike any previous option, the <code>--simplify-merges</code> option requires walking the entire commit history before returning a single result. This can make the option difficult to use for very large repositories.</p> <p>The second issue is one of auditing. When many contributors are working on the same repository, it is important which merge commits introduced a change into an important branch. The problematic merge <code>R</code> above is not likely to be the merge commit that was used to merge into an important branch. Instead, the merge <code>N</code> was used to merge <code>R</code> and <code>X</code> into the important branch. This commit may have information about why the change <code>X</code> came to override the changes from <code>A</code> and <code>B</code> in its commit message.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-list.txt---show-pulls-1"> --show-pulls </dt> <dd> <p>In addition to the commits shown in the default history, show each merge commit that is not TREESAME to its first parent but is TREESAME to a later parent.</p> <p>When a merge commit is included by <code>--show-pulls</code>, the merge is treated as if it "pulled" the change from another branch. When using <code>--show-pulls</code> on this example (and no other options) the resulting graph is:</p> <div class="listingblock"> <div class="content"> <pre> I---X---R---N</pre> </div> </div> <p>Here, the merge commits <code>R</code> and <code>N</code> are included because they pulled the commits <code>X</code> and <code>R</code> into the base branch, respectively. These merges are the reason the commits <code>A</code> and <code>B</code> do not appear in the default history.</p> <p>When <code>--show-pulls</code> is paired with <code>--simplify-merges</code>, the graph includes all of the necessary information:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M--. N + / / \ / + I B R + \ / / + \ / / + `---X--'</pre> </div> </div> <p>Notice that since <code>M</code> is reachable from <code>R</code>, the edge from <code>N</code> to <code>M</code> was simplified away. However, <code>N</code> still appears in the history as an important commit because it "pulled" the change <code>R</code> into the main branch.</p> </dd> </dl> </div> <p>The <code>--simplify-by-decoration</code> option allows you to view only the big picture of the topology of the history, by omitting commits that are not referenced by tags. Commits are marked as !TREESAME (in other words, kept after history simplification rules described above) if (1) they are referenced by tags, or (2) they change the contents of the paths given on the command line. All other commits are marked as TREESAME (subject to be simplified away).</p> </div> <div class="sect2"> <h3 id="_bisection_helpers"> +Bisection Helpers</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-list.txt---bisect"> --bisect </dt> <dd> <p>Limit output to the one commit object which is roughly halfway between included and excluded commits. Note that the bad bisection ref <code>refs/bisect/bad</code> is added to the included commits (if it exists) and the good bisection refs <code>refs/bisect/good-*</code> are added to the excluded commits (if they exist). Thus, supposing there are no refs in <code>refs/bisect/</code>, if</p> <div class="listingblock"> <div class="content"> <pre> $ git rev-list --bisect foo ^bar ^baz</pre> </div> </div> <p>outputs <code>midpoint</code>, the output of the two commands</p> <div class="listingblock"> <div class="content"> <pre> $ git rev-list foo ^midpoint + $ git rev-list midpoint ^bar ^baz</pre> </div> </div> <p>would be of roughly the same length. Finding the change which introduces a regression is thus reduced to a binary search: repeatedly generate and test new 'midpoint’s until the commit chain is of length one.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---bisect-vars"> --bisect-vars </dt> <dd> <p>This calculates the same as <code>--bisect</code>, except that refs in <code>refs/bisect/</code> are not used, and except that this outputs text ready to be eval’ed by the shell. These lines will assign the name of the midpoint revision to the variable <code>bisect_rev</code>, and the expected number of commits to be tested after <code>bisect_rev</code> is tested to <code>bisect_nr</code>, the expected number of commits to be tested if <code>bisect_rev</code> turns out to be good to <code>bisect_good</code>, the expected number of commits to be tested if <code>bisect_rev</code> turns out to be bad to <code>bisect_bad</code>, and the number of commits we are bisecting right now to <code>bisect_all</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---bisect-all"> --bisect-all </dt> <dd> <p>This outputs all the commit objects between the included and excluded commits, ordered by their distance to the included and excluded commits. Refs in <code>refs/bisect/</code> are not used. The farthest from them is displayed first. (This is the only one displayed by <code>--bisect</code>.)</p> <p>This is useful because it makes it easy to choose a good commit to test when you want to avoid to test some of them for some reason (they may not compile for example).</p> <p>This option can be used along with <code>--bisect-vars</code>, in this case, after all the sorted commit objects, there will be the same text as if <code>--bisect-vars</code> had been used alone.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_commit_ordering"> +Commit Ordering</h3> <p>By default, the commits are shown in reverse chronological order.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-list.txt---date-order"> --date-order </dt> <dd> <p>Show no parents before all of its children are shown, but otherwise show commits in the commit timestamp order.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---author-date-order"> --author-date-order </dt> <dd> <p>Show no parents before all of its children are shown, but otherwise show commits in the author timestamp order.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---topo-order"> --topo-order </dt> <dd> <p>Show no parents before all of its children are shown, and avoid showing commits on multiple lines of history intermixed.</p> <p>For example, in a commit history like this:</p> <div class="listingblock"> <div class="content"> <pre> ---1----2----4----7 + \ \ + 3----5----6----8---</pre> </div> </div> <p>where the numbers denote the order of commit timestamps, <code>git +rev-list</code> and friends with <code>--date-order</code> show the commits in the timestamp order: 8 7 6 5 4 3 2 1.</p> <p>With <code>--topo-order</code>, they would show 8 6 5 3 7 4 2 1 (or 8 7 4 2 6 5 3 1); some older commits are shown before newer ones in order to avoid showing the commits from two parallel development track mixed together.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---reverse"> --reverse </dt> <dd> <p>Output the commits chosen to be shown (see Commit Limiting section above) in reverse order. Cannot be combined with <code>--walk-reflogs</code>.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_object_traversal"> +Object Traversal</h3> <p>These options are mostly targeted for packing of Git repositories.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-list.txt---objects"> --objects </dt> <dd> <p>Print the object IDs of any object referenced by the listed commits. <code>--objects foo ^bar</code> thus means “send me all object IDs which I need to download if I have the commit object <code>bar</code> but not <code>foo</code>”. See also <code>--object-names</code> below.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---in-commit-order"> --in-commit-order </dt> <dd> <p>Print tree and blob ids in order of the commits. The tree and blob ids are printed after they are first referenced by a commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---objects-edge"> --objects-edge </dt> <dd> <p>Similar to <code>--objects</code>, but also print the IDs of excluded commits prefixed with a “-” character. This is used by <a href="git-pack-objects">git-pack-objects[1]</a> to build a “thin” pack, which records objects in deltified form based on objects contained in these excluded commits to reduce network traffic.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---objects-edge-aggressive"> --objects-edge-aggressive </dt> <dd> <p>Similar to <code>--objects-edge</code>, but it tries harder to find excluded commits at the cost of increased time. This is used instead of <code>--objects-edge</code> to build “thin” packs for shallow repositories.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---indexed-objects"> --indexed-objects </dt> <dd> <p>Pretend as if all trees and blobs used by the index are listed on the command line. Note that you probably want to use <code>--objects</code>, too.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---unpacked"> --unpacked </dt> <dd> <p>Only useful with <code>--objects</code>; print the object IDs that are not in packs.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---object-names"> --object-names </dt> <dd> <p>Only useful with <code>--objects</code>; print the names of the object IDs that are found. This is the default behavior. Note that the "name" of each object is ambiguous, and mostly intended as a hint for packing objects. In particular: no distinction is made between the names of tags, trees, and blobs; path names may be modified to remove newlines; and if an object would appear multiple times with different names, only one name is shown.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---no-object-names"> --no-object-names </dt> <dd> <p>Only useful with <code>--objects</code>; does not print the names of the object IDs that are found. This inverts <code>--object-names</code>. This flag allows the output to be more easily parsed by commands such as <a href="git-cat-file">git-cat-file[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---filterltfilter-specgt"> --filter=<filter-spec> </dt> <dd> <p>Only useful with one of the <code>--objects*</code>; omits objects (usually blobs) from the list of printed objects. The <code><filter-spec></code> may be one of the following:</p> <p>The form <code>--filter=blob:none</code> omits all blobs.</p> <p>The form <code>--filter=blob:limit=<n>[kmg]</code> omits blobs larger than n bytes or units. n may be zero. The suffixes k, m, and g can be used to name units in KiB, MiB, or GiB. For example, <code>blob:limit=1k</code> is the same as <code>blob:limit=1024</code>.</p> <p>The form <code>--filter=object:type=(tag|commit|tree|blob)</code> omits all objects which are not of the requested type.</p> <p>The form <code>--filter=sparse:oid=<blob-ish></code> uses a sparse-checkout specification contained in the blob (or blob-expression) <code><blob-ish></code> to omit blobs that would not be required for a sparse checkout on the requested refs.</p> <p>The form <code>--filter=tree:<depth></code> omits all blobs and trees whose depth from the root tree is >= <depth> (minimum depth if an object is located at multiple depths in the commits traversed). <depth>=0 will not include any trees or blobs unless included explicitly in the command-line (or standard input when --stdin is used). <depth>=1 will include only the tree and blobs which are referenced directly by a commit reachable from <commit> or an explicitly-given object. <depth>=2 is like <depth>=1 while also including trees and blobs one more level removed from an explicitly-given commit or tree.</p> <p>Note that the form <code>--filter=sparse:path=<path></code> that wants to read from an arbitrary path on the filesystem has been dropped for security reasons.</p> <p>Multiple <code>--filter=</code> flags can be specified to combine filters. Only objects which are accepted by every filter are included.</p> <p>The form <code>--filter=combine:<filter1>+<filter2>+…<filterN></code> can also be used to combined several filters, but this is harder than just repeating the <code>--filter</code> flag and is usually not necessary. Filters are joined by <code>+</code> and individual filters are %-encoded (i.e. URL-encoded). Besides the <code>+</code> and <code>%</code> characters, the following characters are reserved and also must be encoded: <code>~!@#$^&*()[]{}\;",<>?</code><code>'`</code> as well as all characters with ASCII code <= <code>0x20</code>, which includes space and newline.</p> <p>Other arbitrary characters can also be encoded. For instance, <code>combine:tree:3+blob:none</code> and <code>combine:tree%3A3+blob%3Anone</code> are equivalent.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---no-filter"> --no-filter </dt> <dd> <p>Turn off any previous <code>--filter=</code> argument.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---filter-provided-objects"> --filter-provided-objects </dt> <dd> <p>Filter the list of explicitly provided objects, which would otherwise always be printed even if they did not match any of the filters. Only useful with <code>--filter=</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---filter-print-omitted"> --filter-print-omitted </dt> <dd> <p>Only useful with <code>--filter=</code>; prints a list of the objects omitted by the filter. Object IDs are prefixed with a “~” character.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---missingltmissing-actiongt"> --missing=<missing-action> </dt> <dd> <p>A debug option to help with future "partial clone" development. This option specifies how missing objects are handled.</p> <p>The form <code>--missing=error</code> requests that rev-list stop with an error if a missing object is encountered. This is the default action.</p> <p>The form <code>--missing=allow-any</code> will allow object traversal to continue if a missing object is encountered. Missing objects will silently be omitted from the results.</p> <p>The form <code>--missing=allow-promisor</code> is like <code>allow-any</code>, but will only allow object traversal to continue for EXPECTED promisor missing objects. Unexpected missing objects will raise an error.</p> <p>The form <code>--missing=print</code> is like <code>allow-any</code>, but will also print a list of the missing objects. Object IDs are prefixed with a “?” character.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---exclude-promisor-objects"> --exclude-promisor-objects </dt> <dd> <p>(For internal use only.) Prefilter object traversal at promisor boundary. This is used with partial clone. This is stronger than <code>--missing=allow-promisor</code> because it limits the traversal, rather than just silencing errors about missing objects.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---no-walksortedunsorted"> --no-walk[=(sorted|unsorted)] </dt> <dd> <p>Only show the given commits, but do not traverse their ancestors. This has no effect if a range is specified. If the argument <code>unsorted</code> is given, the commits are shown in the order they were given on the command line. Otherwise (if <code>sorted</code> or no argument was given), the commits are shown in reverse chronological order by commit time. Cannot be combined with <code>--graph</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---do-walk"> --do-walk </dt> <dd> <p>Overrides a previous <code>--no-walk</code>.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_commit_formatting"> +Commit Formatting</h3> <p>Using these options, <a href="git-rev-list">git-rev-list[1]</a> will act similar to the more specialized family of commit log tools: <a href="git-log">git-log[1]</a>, <a href="git-show">git-show[1]</a>, and <a href="git-whatchanged">git-whatchanged[1]</a></p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-list.txt---prettyltformatgt"> --pretty[=<format>] </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---formatltformatgt"> --format=<format> </dt> <dd> <p>Pretty-print the contents of the commit logs in a given format, where <code><format></code> can be one of <code>oneline</code>, <code>short</code>, <code>medium</code>, <code>full</code>, <code>fuller</code>, <code>reference</code>, <code>email</code>, <code>raw</code>, <code>format:<string></code> and <code>tformat:<string></code>. When <code><format></code> is none of the above, and has <code>%placeholder</code> in it, it acts as if <code>--pretty=tformat:<format></code> were given.</p> <p>See the "PRETTY FORMATS" section for some additional details for each format. When <code>=<format></code> part is omitted, it defaults to <code>medium</code>.</p> <p>Note: you can specify the default pretty format in the repository configuration (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---abbrev-commit"> --abbrev-commit </dt> <dd> <p>Instead of showing the full 40-byte hexadecimal commit object name, show a prefix that names the object uniquely. "--abbrev=<n>" (which also modifies diff output, if it is displayed) option can be used to specify the minimum length of the prefix.</p> <p>This should make "--pretty=oneline" a whole lot more readable for people using 80-column terminals.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---no-abbrev-commit"> --no-abbrev-commit </dt> <dd> <p>Show the full 40-byte hexadecimal commit object name. This negates <code>--abbrev-commit</code>, either explicit or implied by other options such as "--oneline". It also overrides the <code>log.abbrevCommit</code> variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---oneline"> --oneline </dt> <dd> <p>This is a shorthand for "--pretty=oneline --abbrev-commit" used together.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---encodingltencodinggt"> --encoding=<encoding> </dt> <dd> <p>Commit objects record the character encoding used for the log message in their encoding header; this option can be used to tell the command to re-code the commit log message in the encoding preferred by the user. For non plumbing commands this defaults to UTF-8. Note that if an object claims to be encoded in <code>X</code> and we are outputting in <code>X</code>, we will output the object verbatim; this means that invalid sequences in the original commit may be copied to the output. Likewise, if iconv(3) fails to convert the commit, we will quietly output the original object verbatim.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---expand-tabsltngt"> --expand-tabs=<n> </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---expand-tabs"> --expand-tabs </dt> <dt class="hdlist1" id="Documentation/git-rev-list.txt---no-expand-tabs"> --no-expand-tabs </dt> <dd> <p>Perform a tab expansion (replace each tab with enough spaces to fill to the next display column that is a multiple of <code><n></code>) in the log message before showing it in the output. <code>--expand-tabs</code> is a short-hand for <code>--expand-tabs=8</code>, and <code>--no-expand-tabs</code> is a short-hand for <code>--expand-tabs=0</code>, which disables tab expansion.</p> <p>By default, tabs are expanded in pretty formats that indent the log message by 4 spaces (i.e. <code>medium</code>, which is the default, <code>full</code>, and <code>fuller</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---show-signature"> --show-signature </dt> <dd> <p>Check the validity of a signed commit object by passing the signature to <code>gpg --verify</code> and show the output.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---relative-date"> --relative-date </dt> <dd> <p>Synonym for <code>--date=relative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---dateltformatgt"> --date=<format> </dt> <dd> <p>Only takes effect for dates shown in human-readable format, such as when using <code>--pretty</code>. <code>log.date</code> config variable sets a default value for the log command’s <code>--date</code> option. By default, dates are shown in the original time zone (either committer’s or author’s). If <code>-local</code> is appended to the format (e.g., <code>iso-local</code>), the user’s local time zone is used instead.</p> <div class="openblock"> <div class="content"> <p><code>--date=relative</code> shows dates relative to the current time, e.g. “2 hours ago”. The <code>-local</code> option has no effect for <code>--date=relative</code>.</p> <p><code>--date=local</code> is an alias for <code>--date=default-local</code>.</p> <p><code>--date=iso</code> (or <code>--date=iso8601</code>) shows timestamps in a ISO 8601-like format. The differences to the strict ISO 8601 format are:</p> <div class="ulist"> <ul> <li> <p>a space instead of the <code>T</code> date/time delimiter</p> </li> <li> <p>a space between time and time zone</p> </li> <li> <p>no colon between hours and minutes of the time zone</p> </li> </ul> </div> <p><code>--date=iso-strict</code> (or <code>--date=iso8601-strict</code>) shows timestamps in strict ISO 8601 format.</p> <p><code>--date=rfc</code> (or <code>--date=rfc2822</code>) shows timestamps in RFC 2822 format, often found in email messages.</p> <p><code>--date=short</code> shows only the date, but not the time, in <code>YYYY-MM-DD</code> format.</p> <p><code>--date=raw</code> shows the date as seconds since the epoch (1970-01-01 00:00:00 UTC), followed by a space, and then the timezone as an offset from UTC (a <code>+</code> or <code>-</code> with four digits; the first two are hours, and the second two are minutes). I.e., as if the timestamp were formatted with <code>strftime("%s %z")</code>). Note that the <code>-local</code> option does not affect the seconds-since-epoch value (which is always measured in UTC), but does switch the accompanying timezone value.</p> <p><code>--date=human</code> shows the timezone if the timezone does not match the current time-zone, and doesn’t print the whole date if that matches (ie skip printing year for dates that are "this year", but also skip the whole date itself if it’s in the last few days and we can just say what weekday it was). For older dates the hour and minute is also omitted.</p> <p><code>--date=unix</code> shows the date as a Unix epoch timestamp (seconds since 1970). As with <code>--raw</code>, this is always in UTC and therefore <code>-local</code> has no effect.</p> <p><code>--date=format:...</code> feeds the format <code>...</code> to your system <code>strftime</code>, except for %s, %z, and %Z, which are handled internally. Use <code>--date=format:%c</code> to show the date in your system locale’s preferred format. See the <code>strftime</code> manual for a complete list of format placeholders. When using <code>-local</code>, the correct syntax is <code>--date=format-local:...</code>.</p> <p><code>--date=default</code> is the default format, and is based on ctime(3) output. It shows a single line with three-letter day of the week, three-letter month, day-of-month, hour-minute-seconds in "HH:MM:SS" format, followed by 4-digit year, plus timezone information, unless the local time zone is used, e.g. <code>Thu Jan 1 00:00:00 1970 +0000</code>.</p> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---header"> --header </dt> <dd> <p>Print the contents of the commit in raw-format; each record is separated with a NUL character.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---no-commit-header"> --no-commit-header </dt> <dd> <p>Suppress the header line containing "commit" and the object ID printed before the specified format. This has no effect on the built-in formats; only custom formats are affected.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---commit-header"> --commit-header </dt> <dd> <p>Overrides a previous <code>--no-commit-header</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---parents"> --parents </dt> <dd> <p>Print also the parents of the commit (in the form "commit parent…"). Also enables parent rewriting, see <code>History Simplification</code> above.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---children"> --children </dt> <dd> <p>Print also the children of the commit (in the form "commit child…"). Also enables parent rewriting, see <code>History Simplification</code> above.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---timestamp"> --timestamp </dt> <dd> <p>Print the raw commit timestamp.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---left-right"> --left-right </dt> <dd> <p>Mark which side of a symmetric difference a commit is reachable from. Commits from the left side are prefixed with <code><</code> and those from the right with <code>></code>. If combined with <code>--boundary</code>, those commits are prefixed with <code>-</code>.</p> <p>For example, if you have this topology:</p> <div class="listingblock"> <div class="content"> <pre> y---b---b branch B + / \ / + / . + / / \ + o---x---a---a branch A</pre> </div> </div> <p>you would get an output like this:</p> <div class="listingblock"> <div class="content"> <pre> $ git rev-list --left-right --boundary --pretty=oneline A...B + + >bbbbbbb... 3rd on b + >bbbbbbb... 2nd on b + <aaaaaaa... 3rd on a + <aaaaaaa... 2nd on a + -yyyyyyy... 1st on b + -xxxxxxx... 1st on a</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---graph"> --graph </dt> <dd> <p>Draw a text-based graphical representation of the commit history on the left hand side of the output. This may cause extra lines to be printed in between commits, in order for the graph history to be drawn properly. Cannot be combined with <code>--no-walk</code>.</p> <p>This enables parent rewriting, see <code>History Simplification</code> above.</p> <p>This implies the <code>--topo-order</code> option by default, but the <code>--date-order</code> option may also be specified.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---show-linear-breakltbarriergt"> --show-linear-break[=<barrier>] </dt> <dd> <p>When --graph is not used, all history branches are flattened which can make it hard to see that the two consecutive commits do not belong to a linear branch. This option puts a barrier in between them in that case. If <code><barrier></code> is specified, it is the string that will be shown instead of the default one.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt---count"> --count </dt> <dd> <p>Print a number stating how many commits would have been listed, and suppress all other output. When used together with <code>--left-right</code>, instead print the counts for left and right commits, separated by a tab. When used together with <code>--cherry-mark</code>, omit patch equivalent commits from these counts and print the count for equivalent commits separated by a tab.</p> </dd> </dl> </div> </div> </div> <h2 id="_pretty_formats">Pretty formats</h2> <div class="sectionbody"> <p>If the commit is a merge, and if the pretty-format is not <code>oneline</code>, <code>email</code> or <code>raw</code>, an additional line is inserted before the <code>Author:</code> line. This line begins with "Merge: " and the hashes of ancestral commits are printed, separated by spaces. Note that the listed commits may not necessarily be the list of the <strong>direct</strong> parent commits if you have limited your view of history: for example, if you are only interested in changes related to a certain directory or file.</p> <p>There are several built-in formats, and you can define additional formats by setting a pretty.<name> config option to either another format name, or a <code>format:</code> string, as described below (see <a href="git-config">git-config[1]</a>). Here are the details of the built-in formats:</p> <div class="ulist"> <ul> <li> <p><code>oneline</code></p> <div class="literalblock"> <div class="content"> <pre><hash> <title-line></pre> </div> </div> <p>This is designed to be as compact as possible.</p> </li> <li> <p><code>short</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> </li> <li> <p><code>medium</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author> +Date: <author-date></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>full</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author> +Commit: <committer></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>fuller</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author> +AuthorDate: <author-date> +Commit: <committer> +CommitDate: <committer-date></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>reference</code></p> <div class="literalblock"> <div class="content"> <pre><abbrev-hash> (<title-line>, <short-author-date>)</pre> </div> </div> <p>This format is used to refer to another commit in a commit message and is the same as <code>--pretty='format:%C(auto)%h (%s, %ad)'</code>. By default, the date is formatted with <code>--date=short</code> unless another <code>--date</code> option is explicitly specified. As with any <code>format:</code> with format placeholders, its output is not affected by other options like <code>--decorate</code> and <code>--walk-reflogs</code>.</p> </li> <li> <p><code>email</code></p> <div class="literalblock"> <div class="content"> <pre>From <hash> <date> +From: <author> +Date: <author-date> +Subject: [PATCH] <title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>mboxrd</code></p> <p>Like <code>email</code>, but lines in the commit message starting with "From " (preceded by zero or more ">") are quoted with ">" so they aren’t confused as starting a new commit.</p> </li> <li> <p><code>raw</code></p> <p>The <code>raw</code> format shows the entire commit exactly as stored in the commit object. Notably, the hashes are displayed in full, regardless of whether --abbrev or --no-abbrev are used, and <code>parents</code> information show the true parent commits, without taking grafts or history simplification into account. Note that this format affects the way commits are displayed, but not the way the diff is shown e.g. with <code>git log --raw</code>. To get full object names in a raw diff format, use <code>--no-abbrev</code>.</p> </li> <li> <p><code>format:<format-string></code></p> <p>The <code>format:<format-string></code> format allows you to specify which information you want to show. It works a little bit like printf format, with the notable exception that you get a newline with <code>%n</code> instead of <code>\n</code>.</p> <p>E.g, <code>format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"</code> would show something like this:</p> <div class="listingblock"> <div class="content"> <pre>The author of fe6e0ee was Junio C Hamano, 23 hours ago +The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<</pre> </div> </div> <p>The placeholders are:</p> <div class="ulist"> <ul> <li> <p>Placeholders that expand to a single literal character:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emnem"> <em>%n</em> </dt> <dd> <p>newline</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emem"> <em>%%</em> </dt> <dd> <p>a raw <code>%</code></p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emx00em"> <em>%x00</em> </dt> <dd> <p><code>%x</code> followed by two hexadecimal digits is replaced with a byte with the hexadecimal digits' value (we will call this "literal formatting code" in the rest of this document).</p> </dd> </dl> </div> </li> <li> <p>Placeholders that affect formatting of later placeholders:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emCredem"> <em>%Cred</em> </dt> <dd> <p>switch color to red</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emCgreenem"> <em>%Cgreen</em> </dt> <dd> <p>switch color to green</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emCblueem"> <em>%Cblue</em> </dt> <dd> <p>switch color to blue</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emCresetem"> <em>%Creset</em> </dt> <dd> <p>reset color</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emC82308203em"> <em>%C(…)</em> </dt> <dd> <p>color specification, as described under Values in the "CONFIGURATION FILE" section of <a href="git-config">git-config[1]</a>. By default, colors are shown only when enabled for log output (by <code>color.diff</code>, <code>color.ui</code>, or <code>--color</code>, and respecting the <code>auto</code> settings of the former if we are going to a terminal). <code>%C(auto,...)</code> is accepted as a historical synonym for the default (e.g., <code>%C(auto,red)</code>). Specifying <code>%C(always,...)</code> will show the colors even when color is not otherwise enabled (though consider just using <code>--color=always</code> to enable color for the whole output, including this format and anything else git might color). <code>auto</code> alone (i.e. <code>%C(auto)</code>) will turn on auto coloring on the next placeholders until the color is switched again.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emmem"> <em>%m</em> </dt> <dd> <p>left (<code><</code>), right (<code>></code>) or boundary (<code>-</code>) mark</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emwltwgtlti1gtlti2gtem"> <em>%w([<w>[,<i1>[,<i2>]]])</em> </dt> <dd> <p>switch line wrapping, like the -w option of <a href="git-shortlog">git-shortlog[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emltltNgttruncltruncmtruncem"> <em>%<( <N> [,trunc|ltrunc|mtrunc])</em> </dt> <dd> <p>make the next placeholder take at least N column widths, padding spaces on the right if necessary. Optionally truncate (with ellipsis <code>..</code>) at the left (ltrunc) <code>..ft</code>, the middle (mtrunc) <code>mi..le</code>, or the end (trunc) <code>rig..</code>, if the output is longer than N columns. Note 1: that truncating only works correctly with N >= 2. Note 2: spaces around the N and M (see below) values are optional. Note 3: Emojis and other wide characters will take two display columns, which may over-run column boundaries. Note 4: decomposed character combining marks may be misplaced at padding boundaries.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emltltMgtem"> <em>%<|( <M> )</em> </dt> <dd> <p>make the next placeholder take at least until Mth display column, padding spaces on the right if necessary. Use negative M values for column positions measured from the right hand edge of the terminal window.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emgtltNgtememgtltMgtem"> <em>%>( <N> )</em>, <em>%>|( <M> )</em> </dt> <dd> <p>similar to <code>%<( <N> )</code>, <code>%<|( <M> )</code> respectively, but padding spaces on the left</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emgtgtltNgtememgtgtltMgtem"> <em>%>>( <N> )</em>, <em>%>>|( <M> )</em> </dt> <dd> <p>similar to <code>%>( <N> )</code>, <code>%>|( <M> )</code> respectively, except that if the next placeholder takes more spaces than given and there are spaces on its left, use those spaces</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emgtltltNgtememgtltltMgtem"> <em>%><( <N> )</em>, <em>%><|( <M> )</em> </dt> <dd> <p>similar to <code>%<( <N> )</code>, <code>%<|( <M> )</code> respectively, but padding both sides (i.e. the text is centered)</p> </dd> </dl> </div> </li> <li> <p>Placeholders that expand to information extracted from the commit:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emHem"> <em>%H</em> </dt> <dd> <p>commit hash</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emhem"> <em>%h</em> </dt> <dd> <p>abbreviated commit hash</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emTem"> <em>%T</em> </dt> <dd> <p>tree hash</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emtem"> <em>%t</em> </dt> <dd> <p>abbreviated tree hash</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emPem"> <em>%P</em> </dt> <dd> <p>parent hashes</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-empem"> <em>%p</em> </dt> <dd> <p>abbreviated parent hashes</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emanem"> <em>%an</em> </dt> <dd> <p>author name</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emaNem"> <em>%aN</em> </dt> <dd> <p>author name (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emaeem"> <em>%ae</em> </dt> <dd> <p>author email</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emaEem"> <em>%aE</em> </dt> <dd> <p>author email (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emalem"> <em>%al</em> </dt> <dd> <p>author email local-part (the part before the <code>@</code> sign)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emaLem"> <em>%aL</em> </dt> <dd> <p>author local-part (see <code>%al</code>) respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emadem"> <em>%ad</em> </dt> <dd> <p>author date (format respects --date= option)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emaDem"> <em>%aD</em> </dt> <dd> <p>author date, RFC2822 style</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emarem"> <em>%ar</em> </dt> <dd> <p>author date, relative</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-ematem"> <em>%at</em> </dt> <dd> <p>author date, UNIX timestamp</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emaiem"> <em>%ai</em> </dt> <dd> <p>author date, ISO 8601-like format</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emaIem"> <em>%aI</em> </dt> <dd> <p>author date, strict ISO 8601 format</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emasem"> <em>%as</em> </dt> <dd> <p>author date, short format (<code>YYYY-MM-DD</code>)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emahem"> <em>%ah</em> </dt> <dd> <p>author date, human style (like the <code>--date=human</code> option of <a href="git-rev-list">git-rev-list[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emcnem"> <em>%cn</em> </dt> <dd> <p>committer name</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emcNem"> <em>%cN</em> </dt> <dd> <p>committer name (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emceem"> <em>%ce</em> </dt> <dd> <p>committer email</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emcEem"> <em>%cE</em> </dt> <dd> <p>committer email (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emclem"> <em>%cl</em> </dt> <dd> <p>committer email local-part (the part before the <code>@</code> sign)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emcLem"> <em>%cL</em> </dt> <dd> <p>committer local-part (see <code>%cl</code>) respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emcdem"> <em>%cd</em> </dt> <dd> <p>committer date (format respects --date= option)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emcDem"> <em>%cD</em> </dt> <dd> <p>committer date, RFC2822 style</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emcrem"> <em>%cr</em> </dt> <dd> <p>committer date, relative</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emctem"> <em>%ct</em> </dt> <dd> <p>committer date, UNIX timestamp</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emciem"> <em>%ci</em> </dt> <dd> <p>committer date, ISO 8601-like format</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emcIem"> <em>%cI</em> </dt> <dd> <p>committer date, strict ISO 8601 format</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emcsem"> <em>%cs</em> </dt> <dd> <p>committer date, short format (<code>YYYY-MM-DD</code>)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emchem"> <em>%ch</em> </dt> <dd> <p>committer date, human style (like the <code>--date=human</code> option of <a href="git-rev-list">git-rev-list[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emdem"> <em>%d</em> </dt> <dd> <p>ref names, like the --decorate option of <a href="git-log">git-log[1]</a></p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emDem"> <em>%D</em> </dt> <dd> <p>ref names without the " (", ")" wrapping.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emdecorateltoptionsgtem"> <em>%(decorate[:<options>])</em> </dt> <dd> <p>ref names with custom decorations. The <code>decorate</code> string may be followed by a colon and zero or more comma-separated options. Option values may contain literal formatting codes. These must be used for commas (<code>%x2C</code>) and closing parentheses (<code>%x29</code>), due to their role in the option syntax.</p> <div class="ulist"> <ul> <li> <p><code>prefix=<value></code>: Shown before the list of ref names. Defaults to " <code>(</code>".</p> </li> <li> <p><code>suffix=<value></code>: Shown after the list of ref names. Defaults to "<code>)</code>".</p> </li> <li> <p><code>separator=<value></code>: Shown between ref names. Defaults to "<code>,</code> ".</p> </li> <li> <p><code>pointer=<value></code>: Shown between HEAD and the branch it points to, if any. Defaults to " <code>-></code> ".</p> </li> <li> <p><code>tag=<value></code>: Shown before tag names. Defaults to "<code>tag:</code> ".</p> </li> </ul> </div> </dd> </dl> </div> </li> </ul> </div> <p>For example, to produce decorations with no wrapping or tag annotations, and spaces as separators:</p> <p>+ <code>%(decorate:prefix=,suffix=,tag=,separator= )</code></p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emdescribeltoptionsgtem"> <em>%(describe[:<options>])</em> </dt> <dd> <p>human-readable name, like <a href="git-describe">git-describe[1]</a>; empty string for undescribable commits. The <code>describe</code> string may be followed by a colon and zero or more comma-separated options. Descriptions can be inconsistent when tags are added or removed at the same time.</p> <div class="ulist"> <ul> <li> <p><code>tags[=<bool-value>]</code>: Instead of only considering annotated tags, consider lightweight tags as well.</p> </li> <li> <p><code>abbrev=<number></code>: Instead of using the default number of hexadecimal digits (which will vary according to the number of objects in the repository with a default of 7) of the abbreviated object name, use <number> digits, or as many digits as needed to form a unique object name.</p> </li> <li> <p><code>match=<pattern></code>: Only consider tags matching the given <code>glob(7)</code> pattern, excluding the "refs/tags/" prefix.</p> </li> <li> <p><code>exclude=<pattern></code>: Do not consider tags matching the given <code>glob(7)</code> pattern, excluding the "refs/tags/" prefix.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emSem"> <em>%S</em> </dt> <dd> <p>ref name given on the command line by which the commit was reached (like <code>git log --source</code>), only works with <code>git log</code></p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emeem"> <em>%e</em> </dt> <dd> <p>encoding</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emsem"> <em>%s</em> </dt> <dd> <p>subject</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emfem"> <em>%f</em> </dt> <dd> <p>sanitized subject line, suitable for a filename</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-embem"> <em>%b</em> </dt> <dd> <p>body</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emBem"> <em>%B</em> </dt> <dd> <p>raw body (unwrapped subject and body)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emGGem"> <em>%GG</em> </dt> <dd> <p>raw verification message from GPG for a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emGem"> <em>%G?</em> </dt> <dd> <p>show "G" for a good (valid) signature, "B" for a bad signature, "U" for a good signature with unknown validity, "X" for a good signature that has expired, "Y" for a good signature made by an expired key, "R" for a good signature made by a revoked key, "E" if the signature cannot be checked (e.g. missing key) and "N" for no signature</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emGSem"> <em>%GS</em> </dt> <dd> <p>show the name of the signer for a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emGKem"> <em>%GK</em> </dt> <dd> <p>show the key used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emGFem"> <em>%GF</em> </dt> <dd> <p>show the fingerprint of the key used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emGPem"> <em>%GP</em> </dt> <dd> <p>show the fingerprint of the primary key whose subkey was used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emGTem"> <em>%GT</em> </dt> <dd> <p>show the trust level for the key used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emgDem"> <em>%gD</em> </dt> <dd> <p>reflog selector, e.g., <code>refs/stash@{1}</code> or <code>refs/stash@{2 +minutes ago}</code>; the format follows the rules described for the <code>-g</code> option. The portion before the <code>@</code> is the refname as given on the command line (so <code>git log -g refs/heads/master</code> would yield <code>refs/heads/master@{0}</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emgdem"> <em>%gd</em> </dt> <dd> <p>shortened reflog selector; same as <code>%gD</code>, but the refname portion is shortened for human readability (so <code>refs/heads/master</code> becomes just <code>master</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emgnem"> <em>%gn</em> </dt> <dd> <p>reflog identity name</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emgNem"> <em>%gN</em> </dt> <dd> <p>reflog identity name (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emgeem"> <em>%ge</em> </dt> <dd> <p>reflog identity email</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emgEem"> <em>%gE</em> </dt> <dd> <p>reflog identity email (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emgsem"> <em>%gs</em> </dt> <dd> <p>reflog subject</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-list.txt-emtrailersltoptionsgtem"> <em>%(trailers[:<options>])</em> </dt> <dd> <p>display the trailers of the body as interpreted by <a href="git-interpret-trailers">git-interpret-trailers[1]</a>. The <code>trailers</code> string may be followed by a colon and zero or more comma-separated options. If any option is provided multiple times, the last occurrence wins.</p> <div class="ulist"> <ul> <li> <p><code>key=<key></code>: only show trailers with specified <key>. Matching is done case-insensitively and trailing colon is optional. If option is given multiple times trailer lines matching any of the keys are shown. This option automatically enables the <code>only</code> option so that non-trailer lines in the trailer block are hidden. If that is not desired it can be disabled with <code>only=false</code>. E.g., <code>%(trailers:key=Reviewed-by)</code> shows trailer lines with key <code>Reviewed-by</code>.</p> </li> <li> <p><code>only[=<bool>]</code>: select whether non-trailer lines from the trailer block should be included.</p> </li> <li> <p><code>separator=<sep></code>: specify a separator inserted between trailer lines. When this option is not given each trailer line is terminated with a line feed character. The string <sep> may contain the literal formatting codes described above. To use comma as separator one must use <code>%x2C</code> as it would otherwise be parsed as next option. E.g., <code>%(trailers:key=Ticket,separator=%x2C )</code> shows all trailer lines whose key is "Ticket" separated by a comma and a space.</p> </li> <li> <p><code>unfold[=<bool>]</code>: make it behave as if interpret-trailer’s <code>--unfold</code> option was given. E.g., <code>%(trailers:only,unfold=true)</code> unfolds and shows all trailer lines.</p> </li> <li> <p><code>keyonly[=<bool>]</code>: only show the key part of the trailer.</p> </li> <li> <p><code>valueonly[=<bool>]</code>: only show the value part of the trailer.</p> </li> <li> <p><code>key_value_separator=<sep></code>: specify a separator inserted between trailer lines. When this option is not given each trailer key-value pair is separated by ": ". Otherwise it shares the same semantics as <code>separator=<sep></code> above.</p> </li> </ul> </div> </dd> </dl> </div> </li> </ul> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> Some placeholders may depend on other options given to the revision traversal engine. For example, the <code>%g*</code> reflog options will insert an empty string unless we are traversing reflog entries (e.g., by <code>git log -g</code>). The <code>%d</code> and <code>%D</code> placeholders will use the "short" decoration format if <code>--decorate</code> was not already provided on the command line. </td> </tr> </table> </div> <p>The boolean options accept an optional value <code>[=<bool-value>]</code>. The values <code>true</code>, <code>false</code>, <code>on</code>, <code>off</code> etc. are all accepted. See the "boolean" sub-section in "EXAMPLES" in <a href="git-config">git-config[1]</a>. If a boolean option is given with no value, it’s enabled.</p> <p>If you add a <code>+</code> (plus sign) after <code>%</code> of a placeholder, a line-feed is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.</p> <p>If you add a <code>-</code> (minus sign) after <code>%</code> of a placeholder, all consecutive line-feeds immediately preceding the expansion are deleted if and only if the placeholder expands to an empty string.</p> <p>If you add a ` ` (space) after <code>%</code> of a placeholder, a space is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.</p> <div class="ulist"> <ul> <li> <p><code>tformat:</code></p> <p>The <code>tformat:</code> format works exactly like <code>format:</code>, except that it provides "terminator" semantics instead of "separator" semantics. In other words, each commit has the message terminator character (usually a newline) appended, rather than a separator placed between entries. This means that the final entry of a single-line format will be properly terminated with a new line, just as the "oneline" format does. For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log -2 --pretty=format:%h 4da45bef \ + | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/' +4da45be +7134973 -- NO NEWLINE + +$ git log -2 --pretty=tformat:%h 4da45bef \ + | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/' +4da45be +7134973</pre> </div> </div> <p>In addition, any unrecognized string that has a <code>%</code> in it is interpreted as if it has <code>tformat:</code> in front of it. For example, these two are equivalent:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log -2 --pretty=tformat:%h 4da45bef +$ git log -2 --pretty=%h 4da45bef</pre> </div> </div> </li> </ul> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Print the list of commits reachable from the current branch.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git rev-list HEAD</pre> </div> </div> </li> <li> <p>Print the list of commits on this branch, but not present in the upstream branch.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git rev-list @{upstream}..HEAD</pre> </div> </div> </li> <li> <p>Format commits with their author and commit message (see also the porcelain <a href="git-log">git-log[1]</a>).</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git rev-list --format=medium HEAD</pre> </div> </div> </li> <li> <p>Format commits along with their diffs (see also the porcelain <a href="git-log">git-log[1]</a>, which can do this in a single process).</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git rev-list HEAD | +git diff-tree --stdin --format=medium -p</pre> </div> </div> </li> <li> <p>Print the list of commits on the current branch that touched any file in the <code>Documentation</code> directory.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git rev-list HEAD -- Documentation/</pre> </div> </div> </li> <li> <p>Print the list of commits authored by you in the past year, on any branch, tag, or other ref.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git rev-list --author=you@example.com --since=1.year.ago --all</pre> </div> </div> </li> <li> <p>Print the list of objects reachable from the current branch (i.e., all commits and the blobs and trees they contain).</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git rev-list --objects HEAD</pre> </div> </div> </li> <li> <p>Compare the disk size of all reachable objects, versus those reachable from reflogs, versus the total packed size. This can tell you whether running <code>git repack -ad</code> might reduce the repository size (by dropping unreachable objects), and whether expiring reflogs might help.</p> <div class="listingblock"> <div class="content"> <pre># reachable objects +git rev-list --disk-usage --objects --all +# plus reflogs +git rev-list --disk-usage --objects --all --reflog +# total disk size used +du -c .git/objects/pack/*.pack .git/objects/??/* +# alternative to du: add up "size" and "size-pack" fields +git count-objects -v</pre> </div> </div> </li> <li> <p>Report the disk size of each branch, not including objects used by the current branch. This can find outliers that are contributing to a bloated repository size (e.g., because somebody accidentally committed large build artifacts).</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git for-each-ref --format='%(refname)' | +while read branch +do + size=$(git rev-list --disk-usage --objects HEAD..$branch) + echo "$size $branch" +done | +sort -n</pre> </div> </div> </li> <li> <p>Compare the on-disk size of branches in one group of refs, excluding another. If you co-mingle objects from multiple remotes in a single repository, this can show which remotes are contributing to the repository size (taking the size of <code>origin</code> as a baseline).</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git rev-list --disk-usage --objects --remotes=$suspect --not --remotes=origin</pre> </div> </div> </li> </ul> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-rev-list" class="_attribution-link">https://git-scm.com/docs/git-rev-list</a> + </p> +</div> diff --git a/devdocs/git/git-rev-parse.html b/devdocs/git/git-rev-parse.html new file mode 100644 index 00000000..c1f449c5 --- /dev/null +++ b/devdocs/git/git-rev-parse.html @@ -0,0 +1,107 @@ +<h1>git-rev-parse</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-rev-parse - Pick out and massage parameters</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git rev-parse [<options>] <args>…</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Many Git porcelainish commands take a mixture of flags (i.e. parameters that begin with a dash <code>-</code>) and parameters meant for the underlying <code>git rev-list</code> command they use internally and flags and parameters for the other commands they use downstream of <code>git rev-list</code>. This command is used to distinguish between them.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_operation_modes"> +Operation Modes</h3> <p>Each of these options must appear first on the command line.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---parseopt"> --parseopt </dt> <dd> <p>Use <code>git rev-parse</code> in option parsing mode (see PARSEOPT section below).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---sq-quote"> --sq-quote </dt> <dd> <p>Use <code>git rev-parse</code> in shell quoting mode (see SQ-QUOTE section below). In contrast to the <code>--sq</code> option below, this mode only does quoting. Nothing else is done to command input.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_options_for_parseopt"> +Options for --parseopt</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---keep-dashdash"> --keep-dashdash </dt> <dd> <p>Only meaningful in <code>--parseopt</code> mode. Tells the option parser to echo out the first <code>--</code> met instead of skipping it.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---stop-at-non-option"> --stop-at-non-option </dt> <dd> <p>Only meaningful in <code>--parseopt</code> mode. Lets the option parser stop at the first non-option argument. This can be used to parse sub-commands that take options themselves.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---stuck-long"> --stuck-long </dt> <dd> <p>Only meaningful in <code>--parseopt</code> mode. Output the options in their long form if available, and with their arguments stuck.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_options_for_filtering"> +Options for Filtering</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---revs-only"> --revs-only </dt> <dd> <p>Do not output flags and parameters not meant for <code>git rev-list</code> command.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---no-revs"> --no-revs </dt> <dd> <p>Do not output flags and parameters meant for <code>git rev-list</code> command.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---flags"> --flags </dt> <dd> <p>Do not output non-flag parameters.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---no-flags"> --no-flags </dt> <dd> <p>Do not output flag parameters.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_options_for_output"> +Options for Output</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---defaultltarggt"> --default <arg> </dt> <dd> <p>If there is no parameter given by the user, use <code><arg></code> instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---prefixltarggt"> --prefix <arg> </dt> <dd> <p>Behave as if <code>git rev-parse</code> was invoked from the <code><arg></code> subdirectory of the working tree. Any relative filenames are resolved as if they are prefixed by <code><arg></code> and will be printed in that form.</p> <p>This can be used to convert arguments to a command run in a subdirectory so that they can still be used after moving to the top-level of the repository. For example:</p> <div class="listingblock"> <div class="content"> <pre>prefix=$(git rev-parse --show-prefix) +cd "$(git rev-parse --show-toplevel)" +# rev-parse provides the -- needed for 'set' +eval "set $(git rev-parse --sq --prefix "$prefix" -- "$@")"</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---verify"> --verify </dt> <dd> <p>Verify that exactly one parameter is provided, and that it can be turned into a raw 20-byte SHA-1 that can be used to access the object database. If so, emit it to the standard output; otherwise, error out.</p> <p>If you want to make sure that the output actually names an object in your object database and/or can be used as a specific type of object you require, you can add the <code>^{type}</code> peeling operator to the parameter. For example, <code>git rev-parse "$VAR^{commit}"</code> will make sure <code>$VAR</code> names an existing object that is a commit-ish (i.e. a commit, or an annotated tag that points at a commit). To make sure that <code>$VAR</code> names an existing object of any type, <code>git rev-parse "$VAR^{object}"</code> can be used.</p> <p>Note that if you are verifying a name from an untrusted source, it is wise to use <code>--end-of-options</code> so that the name argument is not mistaken for another option.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---quiet"> --quiet </dt> <dd> <p>Only meaningful in <code>--verify</code> mode. Do not output an error message if the first argument is not a valid object name; instead exit with non-zero status silently. SHA-1s for valid object names are printed to stdout on success.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---sq"> --sq </dt> <dd> <p>Usually the output is made one line per flag and parameter. This option makes output a single line, properly quoted for consumption by shell. Useful when you expect your parameter to contain whitespaces and newlines (e.g. when using pickaxe <code>-S</code> with <code>git diff-*</code>). In contrast to the <code>--sq-quote</code> option, the command input is still interpreted as usual.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---shortlength"> --short[=length] </dt> <dd> <p>Same as <code>--verify</code> but shortens the object name to a unique prefix with at least <code>length</code> characters. The minimum length is 4, the default is the effective value of the <code>core.abbrev</code> configuration variable (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---not"> --not </dt> <dd> <p>When showing object names, prefix them with <code>^</code> and strip <code>^</code> prefix from the object names that already have one.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---abbrev-refstrictloose"> --abbrev-ref[=(strict|loose)] </dt> <dd> <p>A non-ambiguous short name of the objects name. The option core.warnAmbiguousRefs is used to select the strict abbreviation mode.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---symbolic"> --symbolic </dt> <dd> <p>Usually the object names are output in SHA-1 form (with possible <code>^</code> prefix); this option makes them output in a form as close to the original input as possible.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---symbolic-full-name"> --symbolic-full-name </dt> <dd> <p>This is similar to --symbolic, but it omits input that are not refs (i.e. branch or tag names; or more explicitly disambiguating "heads/master" form, when you want to name the "master" branch when there is an unfortunately named tag "master"), and shows them as full refnames (e.g. "refs/heads/master").</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_options_for_objects"> +Options for Objects</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---all"> --all </dt> <dd> <p>Show all refs found in <code>refs/</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---branchespattern"> --branches[=pattern] </dt> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---tagspattern"> --tags[=pattern] </dt> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---remotespattern"> --remotes[=pattern] </dt> <dd> <p>Show all branches, tags, or remote-tracking branches, respectively (i.e., refs found in <code>refs/heads</code>, <code>refs/tags</code>, or <code>refs/remotes</code>, respectively).</p> <p>If a <code>pattern</code> is given, only refs matching the given shell glob are shown. If the pattern does not contain a globbing character (<code>?</code>, <code>*</code>, or <code>[</code>), it is turned into a prefix match by appending <code>/*</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---globpattern"> --glob=pattern </dt> <dd> <p>Show all refs matching the shell glob pattern <code>pattern</code>. If the pattern does not start with <code>refs/</code>, this is automatically prepended. If the pattern does not contain a globbing character (<code>?</code>, <code>*</code>, or <code>[</code>), it is turned into a prefix match by appending <code>/*</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---excludeltglob-patterngt"> --exclude=<glob-pattern> </dt> <dd> <p>Do not include refs matching <code><glob-pattern></code> that the next <code>--all</code>, <code>--branches</code>, <code>--tags</code>, <code>--remotes</code>, or <code>--glob</code> would otherwise consider. Repetitions of this option accumulate exclusion patterns up to the next <code>--all</code>, <code>--branches</code>, <code>--tags</code>, <code>--remotes</code>, or <code>--glob</code> option (other options or arguments do not clear accumulated patterns).</p> <p>The patterns given should not begin with <code>refs/heads</code>, <code>refs/tags</code>, or <code>refs/remotes</code> when applied to <code>--branches</code>, <code>--tags</code>, or <code>--remotes</code>, respectively, and they must begin with <code>refs/</code> when applied to <code>--glob</code> or <code>--all</code>. If a trailing <code>/*</code> is intended, it must be given explicitly.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---exclude-hiddenfetchreceiveuploadpack"> --exclude-hidden=[fetch|receive|uploadpack] </dt> <dd> <p>Do not include refs that would be hidden by <code>git-fetch</code>, <code>git-receive-pack</code> or <code>git-upload-pack</code> by consulting the appropriate <code>fetch.hideRefs</code>, <code>receive.hideRefs</code> or <code>uploadpack.hideRefs</code> configuration along with <code>transfer.hideRefs</code> (see <a href="git-config">git-config[1]</a>). This option affects the next pseudo-ref option <code>--all</code> or <code>--glob</code> and is cleared after processing them.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---disambiguateltprefixgt"> --disambiguate=<prefix> </dt> <dd> <p>Show every object whose name begins with the given prefix. The <prefix> must be at least 4 hexadecimal digits long to avoid listing each and every object in the repository by mistake.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_options_for_files"> +Options for Files</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---local-env-vars"> --local-env-vars </dt> <dd> <p>List the GIT_* environment variables that are local to the repository (e.g. GIT_DIR or GIT_WORK_TREE, but not GIT_EDITOR). Only the names of the variables are listed, not their value, even if they are set.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---path-formatabsoluterelative"> --path-format=(absolute|relative) </dt> <dd> <p>Controls the behavior of certain other options. If specified as absolute, the paths printed by those options will be absolute and canonical. If specified as relative, the paths will be relative to the current working directory if that is possible. The default is option specific.</p> <p>This option may be specified multiple times and affects only the arguments that follow it on the command line, either to the end of the command line or the next instance of this option.</p> </dd> </dl> </div> <p>The following options are modified by <code>--path-format</code>:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---git-dir"> --git-dir </dt> <dd> <p>Show <code>$GIT_DIR</code> if defined. Otherwise show the path to the .git directory. The path shown, when relative, is relative to the current working directory.</p> <p>If <code>$GIT_DIR</code> is not defined and the current directory is not detected to lie in a Git repository or work tree print a message to stderr and exit with nonzero status.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---git-common-dir"> --git-common-dir </dt> <dd> <p>Show <code>$GIT_COMMON_DIR</code> if defined, else <code>$GIT_DIR</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---resolve-git-dirltpathgt"> --resolve-git-dir <path> </dt> <dd> <p>Check if <path> is a valid repository or a gitfile that points at a valid repository, and print the location of the repository. If <path> is a gitfile then the resolved path to the real repository is printed.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---git-pathltpathgt"> --git-path <path> </dt> <dd> <p>Resolve "$GIT_DIR/<path>" and takes other path relocation variables such as $GIT_OBJECT_DIRECTORY, $GIT_INDEX_FILE… into account. For example, if $GIT_OBJECT_DIRECTORY is set to /foo/bar then "git rev-parse --git-path objects/abc" returns /foo/bar/abc.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---show-toplevel"> --show-toplevel </dt> <dd> <p>Show the (by default, absolute) path of the top-level directory of the working tree. If there is no working tree, report an error.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---show-superproject-working-tree"> --show-superproject-working-tree </dt> <dd> <p>Show the absolute path of the root of the superproject’s working tree (if exists) that uses the current repository as its submodule. Outputs nothing if the current repository is not used as a submodule by any project.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---shared-index-path"> --shared-index-path </dt> <dd> <p>Show the path to the shared index file in split index mode, or empty if not in split-index mode.</p> </dd> </dl> </div> <p>The following options are unaffected by <code>--path-format</code>:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---absolute-git-dir"> --absolute-git-dir </dt> <dd> <p>Like <code>--git-dir</code>, but its output is always the canonicalized absolute path.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---is-inside-git-dir"> --is-inside-git-dir </dt> <dd> <p>When the current working directory is below the repository directory print "true", otherwise "false".</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---is-inside-work-tree"> --is-inside-work-tree </dt> <dd> <p>When the current working directory is inside the work tree of the repository print "true", otherwise "false".</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---is-bare-repository"> --is-bare-repository </dt> <dd> <p>When the repository is bare print "true", otherwise "false".</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---is-shallow-repository"> --is-shallow-repository </dt> <dd> <p>When the repository is shallow print "true", otherwise "false".</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---show-cdup"> --show-cdup </dt> <dd> <p>When the command is invoked from a subdirectory, show the path of the top-level directory relative to the current directory (typically a sequence of "../", or an empty string).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---show-prefix"> --show-prefix </dt> <dd> <p>When the command is invoked from a subdirectory, show the path of the current directory relative to the top-level directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---show-object-formatstorageinputoutput"> --show-object-format[=(storage|input|output)] </dt> <dd> <p>Show the object format (hash algorithm) used for the repository for storage inside the <code>.git</code> directory, input, or output. For input, multiple algorithms may be printed, space-separated. If not specified, the default is "storage".</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_other_options"> +Other Options</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---sincedatestring"> --since=datestring </dt> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---afterdatestring"> --after=datestring </dt> <dd> <p>Parse the date string, and output the corresponding --max-age= parameter for <code>git rev-list</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---untildatestring"> --until=datestring </dt> <dt class="hdlist1" id="Documentation/git-rev-parse.txt---beforedatestring"> --before=datestring </dt> <dd> <p>Parse the date string, and output the corresponding --min-age= parameter for <code>git rev-list</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-ltargsgt82308203"> <args>… </dt> <dd> <p>Flags and parameters to be parsed.</p> </dd> </dl> </div> </div> </div> <h2 id="_specifying_revisions">Specifying revisions</h2> <div class="sectionbody"> <p>A revision parameter <code><rev></code> typically, but not necessarily, names a commit object. It uses what is called an <code>extended SHA-1</code> syntax. Here are various ways to spell object names. The ones listed near the end of this list name trees and blobs contained in a commit.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> This document shows the "raw" syntax as seen by git. The shell and other UIs might require additional quoting to protect special characters and to avoid word splitting. </td> </tr> </table> </div> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltsha1gtemegemdae86e1950b1277e545cee180551750029cfe735ememdae86eem"> <em><sha1></em>, e.g. <em>dae86e1950b1277e545cee180551750029cfe735</em>, <em>dae86e</em> </dt> <dd> <p>The full SHA-1 object name (40-byte hexadecimal string), or a leading substring that is unique within the repository. E.g. dae86e1950b1277e545cee180551750029cfe735 and dae86e both name the same commit object if there is no other object in your repository whose object name starts with dae86e.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltdescribeOutputgtemegemv1742-679-g3bee7fbem"> <em><describeOutput></em>, e.g. <em>v1.7.4.2-679-g3bee7fb</em> </dt> <dd> <p>Output from <code>git describe</code>; i.e. a closest tag, optionally followed by a dash and a number of commits, followed by a dash, a <code>g</code>, and an abbreviated object name.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrefnamegtemegemmasterememheadsmasterememrefsheadsmasterem"> <em><refname></em>, e.g. <em>master</em>, <em>heads/master</em>, <em>refs/heads/master</em> </dt> <dd> <p>A symbolic ref name. E.g. <code>master</code> typically means the commit object referenced by <code>refs/heads/master</code>. If you happen to have both <code>heads/master</code> and <code>tags/master</code>, you can explicitly say <code>heads/master</code> to tell Git which one you mean. When ambiguous, a <code><refname></code> is disambiguated by taking the first match in the following rules:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>If <code>$GIT_DIR/<refname></code> exists, that is what you mean (this is usually useful only for <code>HEAD</code>, <code>FETCH_HEAD</code>, <code>ORIG_HEAD</code>, <code>MERGE_HEAD</code>, <code>REBASE_HEAD</code>, <code>REVERT_HEAD</code>, <code>CHERRY_PICK_HEAD</code>, <code>BISECT_HEAD</code> and <code>AUTO_MERGE</code>);</p> </li> <li> <p>otherwise, <code>refs/<refname></code> if it exists;</p> </li> <li> <p>otherwise, <code>refs/tags/<refname></code> if it exists;</p> </li> <li> <p>otherwise, <code>refs/heads/<refname></code> if it exists;</p> </li> <li> <p>otherwise, <code>refs/remotes/<refname></code> if it exists;</p> </li> <li> <p>otherwise, <code>refs/remotes/<refname>/HEAD</code> if it exists.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-codeHEADcode"> <code>HEAD</code> </dt> <dd> <p>names the commit on which you based the changes in the working tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-codeFETCHHEADcode"> <code>FETCH_HEAD</code> </dt> <dd> <p>records the branch which you fetched from a remote repository with your last <code>git fetch</code> invocation.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-codeORIGHEADcode"> <code>ORIG_HEAD</code> </dt> <dd> <p>is created by commands that move your <code>HEAD</code> in a drastic way (<code>git +am</code>, <code>git merge</code>, <code>git rebase</code>, <code>git reset</code>), to record the position of the <code>HEAD</code> before their operation, so that you can easily change the tip of the branch back to the state before you ran them.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-codeMERGEHEADcode"> <code>MERGE_HEAD</code> </dt> <dd> <p>records the commit(s) which you are merging into your branch when you run <code>git merge</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-codeREBASEHEADcode"> <code>REBASE_HEAD</code> </dt> <dd> <p>during a rebase, records the commit at which the operation is currently stopped, either because of conflicts or an <code>edit</code> command in an interactive rebase.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-codeREVERTHEADcode"> <code>REVERT_HEAD</code> </dt> <dd> <p>records the commit which you are reverting when you run <code>git revert</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-codeCHERRYPICKHEADcode"> <code>CHERRY_PICK_HEAD</code> </dt> <dd> <p>records the commit which you are cherry-picking when you run <code>git +cherry-pick</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-codeBISECTHEADcode"> <code>BISECT_HEAD</code> </dt> <dd> <p>records the current commit to be tested when you run <code>git bisect +--no-checkout</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-codeAUTOMERGEcode"> <code>AUTO_MERGE</code> </dt> <dd> <p>records a tree object corresponding to the state the <code>ort</code> merge strategy wrote to the working tree when a merge operation resulted in conflicts.</p> </dd> </dl> </div> </li> </ol> </div> <p>Note that any of the <code>refs/*</code> cases above may come either from the <code>$GIT_DIR/refs</code> directory or from the <code>$GIT_DIR/packed-refs</code> file. While the ref name encoding is unspecified, UTF-8 is preferred as some output processing may assume ref names in UTF-8.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emem"> <em>@</em> </dt> <dd> <p><code>@</code> alone is a shortcut for <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrefnamegtltdategtemegemmasteryesterdayememHEAD5minutesagoem"> <em>[<refname>]@{<date>}</em>, e.g. <em>master@{yesterday}</em>, <em>HEAD@{5 minutes ago}</em> </dt> <dd> <p>A ref followed by the suffix <code>@</code> with a date specification enclosed in a brace pair (e.g. <code>{yesterday}</code>, <code>{1 month 2 weeks 3 days 1 hour 1 second ago}</code> or <code>{1979-02-26 18:30:00}</code>) specifies the value of the ref at a prior point in time. This suffix may only be used immediately following a ref name and the ref must have an existing log (<code>$GIT_DIR/logs/<ref></code>). Note that this looks up the state of your <strong>local</strong> ref at a given time; e.g., what was in your local <code>master</code> branch last week. If you want to look at commits made during certain times, see <code>--since</code> and <code>--until</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrefnamegtltngtemegemmaster1em"> <em><refname>@{<n>}</em>, e.g. <em>master@{1}</em> </dt> <dd> <p>A ref followed by the suffix <code>@</code> with an ordinal specification enclosed in a brace pair (e.g. <code>{1}</code>, <code>{15}</code>) specifies the n-th prior value of that ref. For example <code>master@{1}</code> is the immediate prior value of <code>master</code> while <code>master@{5}</code> is the 5th prior value of <code>master</code>. This suffix may only be used immediately following a ref name and the ref must have an existing log (<code>$GIT_DIR/logs/<refname></code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltngtemegem1em"> <em>@{<n>}</em>, e.g. <em>@{1}</em> </dt> <dd> <p>You can use the <code>@</code> construct with an empty ref part to get at a reflog entry of the current branch. For example, if you are on branch <code>blabla</code> then <code>@{1}</code> means the same as <code>blabla@{1}</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-em-ltngtemegem-1em"> <em>@{-<n>}</em>, e.g. <em>@{-1}</em> </dt> <dd> <p>The construct <code>@{-<n>}</code> means the <n>th branch/commit checked out before the current one.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltbranchnamegtupstreamemegemmasterupstreamememuem"> <em>[<branchname>]@{upstream}</em>, e.g. <em>master@{upstream}</em>, <em>@{u}</em> </dt> <dd> <p>A branch B may be set up to build on top of a branch X (configured with <code>branch.<name>.merge</code>) at a remote R (configured with <code>branch.<name>.remote</code>). B@{u} refers to the remote-tracking branch for the branch X taken from remote R, typically found at <code>refs/remotes/R/X</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltbranchnamegtpushemegemmasterpushemempushem"> <em>[<branchname>]@{push}</em>, e.g. <em>master@{push}</em>, <em>@{push}</em> </dt> <dd> <p>The suffix <code>@{push}</code> reports the branch "where we would push to" if <code>git push</code> were run while <code>branchname</code> was checked out (or the current <code>HEAD</code> if no branchname is specified). Like for <code>@{upstream}</code>, we report the remote-tracking branch that corresponds to that branch at the remote.</p> <p>Here’s an example to make it more clear:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config push.default current +$ git config remote.pushdefault myfork +$ git switch -c mybranch origin/master + +$ git rev-parse --symbolic-full-name @{upstream} +refs/remotes/origin/master + +$ git rev-parse --symbolic-full-name @{push} +refs/remotes/myfork/mybranch</pre> </div> </div> <p>Note in the example that we set up a triangular workflow, where we pull from one location and push to another. In a non-triangular workflow, <code>@{push}</code> is the same as <code>@{upstream}</code>, and there is no need for it.</p> <p>This suffix is also accepted when spelled in uppercase, and means the same thing no matter the case.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrevgtltngtemegemHEADv1510em"> <em><rev>^[<n>]</em>, e.g. <em>HEAD^, v1.5.1^0</em> </dt> <dd> <p>A suffix <code>^</code> to a revision parameter means the first parent of that commit object. <code>^<n></code> means the <n>th parent (i.e. <code><rev>^</code> is equivalent to <code><rev>^1</code>). As a special rule, <code><rev>^0</code> means the commit itself and is used when <code><rev></code> is the object name of a tag object that refers to a commit object.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrevgtltngtemegemHEADmaster3em"> <em><rev>~[<n>]</em>, e.g. <em>HEAD~, master~3</em> </dt> <dd> <p>A suffix <code>~</code> to a revision parameter means the first parent of that commit object. A suffix <code>~<n></code> to a revision parameter means the commit object that is the <n>th generation ancestor of the named commit object, following only the first parents. I.e. <code><rev>~3</code> is equivalent to <code><rev>^^^</code> which is equivalent to <code><rev>^1^1^1</code>. See below for an illustration of the usage of this form.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrevgtlttypegtemegemv0998commitem"> <em><rev>^{<type>}</em>, e.g. <em>v0.99.8^{commit}</em> </dt> <dd> <p>A suffix <code>^</code> followed by an object type name enclosed in brace pair means dereference the object at <code><rev></code> recursively until an object of type <code><type></code> is found or the object cannot be dereferenced anymore (in which case, barf). For example, if <code><rev></code> is a commit-ish, <code><rev>^{commit}</code> describes the corresponding commit object. Similarly, if <code><rev></code> is a tree-ish, <code><rev>^{tree}</code> describes the corresponding tree object. <code><rev>^0</code> is a short-hand for <code><rev>^{commit}</code>.</p> <p><code><rev>^{object}</code> can be used to make sure <code><rev></code> names an object that exists, without requiring <code><rev></code> to be a tag, and without dereferencing <code><rev></code>; because a tag is already an object, it does not have to be dereferenced even once to get to an object.</p> <p><code><rev>^{tag}</code> can be used to ensure that <code><rev></code> identifies an existing tag object.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrevgtemegemv0998em"> <em><rev>^{}</em>, e.g. <em>v0.99.8^{}</em> </dt> <dd> <p>A suffix <code>^</code> followed by an empty brace pair means the object could be a tag, and dereference the tag recursively until a non-tag object is found.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrevgtlttextgtemegemHEADfixnastybugem"> <em><rev>^{/<text>}</em>, e.g. <em>HEAD^{/fix nasty bug}</em> </dt> <dd> <p>A suffix <code>^</code> to a revision parameter, followed by a brace pair that contains a text led by a slash, is the same as the <code>:/fix nasty bug</code> syntax below except that it returns the youngest matching commit which is reachable from the <code><rev></code> before <code>^</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emlttextgtemegemfixnastybugem"> <em>:/<text></em>, e.g. <em>:/fix nasty bug</em> </dt> <dd> <p>A colon, followed by a slash, followed by a text, names a commit whose commit message matches the specified regular expression. This name returns the youngest matching commit which is reachable from any ref, including HEAD. The regular expression can match any part of the commit message. To match messages starting with a string, one can use e.g. <code>:/^foo</code>. The special sequence <code>:/!</code> is reserved for modifiers to what is matched. <code>:/!-foo</code> performs a negative match, while <code>:/!!foo</code> matches a literal <code>!</code> character, followed by <code>foo</code>. Any other sequence beginning with <code>:/!</code> is reserved for now. Depending on the given text, the shell’s word splitting rules might require additional quoting.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrevgtltpathgtemegemHEADREADMEememmasterREADMEem"> <em><rev>:<path></em>, e.g. <em>HEAD:README</em>, <em>master:./README</em> </dt> <dd> <p>A suffix <code>:</code> followed by a path names the blob or tree at the given path in the tree-ish object named by the part before the colon. A path starting with <code>./</code> or <code>../</code> is relative to the current working directory. The given path will be converted to be relative to the working tree’s root directory. This is most useful to address a blob or tree from a commit or tree that has the same tree structure as the working tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltngtltpathgtemegem0READMEememREADMEem"> <em>:[<n>:]<path></em>, e.g. <em>:0:README</em>, <em>:README</em> </dt> <dd> <p>A colon, optionally followed by a stage number (0 to 3) and a colon, followed by a path, names a blob object in the index at the given path. A missing stage number (and the colon that follows it) names a stage 0 entry. During a merge, stage 1 is the common ancestor, stage 2 is the target branch’s version (typically the current branch), and stage 3 is the version from the branch which is being merged.</p> </dd> </dl> </div> <p>Here is an illustration, by Jon Loeliger. Both commit nodes B and C are parents of commit node A. Parent commits are ordered left-to-right.</p> <div class="literalblock"> <div class="content"> <pre>G H I J + \ / \ / + D E F + \ | / \ + \ | / | + \|/ | + B C + \ / + \ / + A</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>A = = A^0 +B = A^ = A^1 = A~1 +C = = A^2 +D = A^^ = A^1^1 = A~2 +E = B^2 = A^^2 +F = B^3 = A^^3 +G = A^^^ = A^1^1^1 = A~3 +H = D^2 = B^^2 = A^^^2 = A~2^2 +I = F^ = B^3^ = A^^3^ +J = F^2 = B^3^2 = A^^3^2</pre> </div> </div> </div> <h2 id="_specifying_ranges">Specifying ranges</h2> <div class="sectionbody"> <p>History traversing commands such as <code>git log</code> operate on a set of commits, not just a single commit.</p> <p>For these commands, specifying a single revision, using the notation described in the previous section, means the set of commits <code>reachable</code> from the given commit.</p> <p>Specifying several revisions means the set of commits reachable from any of the given commits.</p> <p>A commit’s reachable set is the commit itself and the commits in its ancestry chain.</p> <p>There are several notations to specify a set of connected commits (called a "revision range"), illustrated below.</p> <div class="sect2"> <h3 id="_commit_exclusions"> +Commit Exclusions</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrevgtemcaretNotation"> <em>^<rev></em> (caret) Notation </dt> <dd> <p>To exclude commits reachable from a commit, a prefix <code>^</code> notation is used. E.g. <code>^r1 r2</code> means commits reachable from <code>r2</code> but exclude the ones reachable from <code>r1</code> (i.e. <code>r1</code> and its ancestors).</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_dotted_range_notations"> +Dotted Range Notations</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-Theememtwo-dotRangeNotation"> The <em>..</em> (two-dot) Range Notation </dt> <dd> <p>The <code>^r1 r2</code> set operation appears so often that there is a shorthand for it. When you have two commits <code>r1</code> and <code>r2</code> (named according to the syntax explained in SPECIFYING REVISIONS above), you can ask for commits that are reachable from r2 excluding those that are reachable from r1 by <code>^r1 r2</code> and it can be written as <code>r1..r2</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-Theememthree-dotSymmetricDifferenceNotation"> The <em>...</em> (three-dot) Symmetric Difference Notation </dt> <dd> <p>A similar notation <code>r1...r2</code> is called symmetric difference of <code>r1</code> and <code>r2</code> and is defined as <code>r1 r2 --not $(git merge-base --all r1 r2)</code>. It is the set of commits that are reachable from either one of <code>r1</code> (left side) or <code>r2</code> (right side) but not from both.</p> </dd> </dl> </div> <p>In these two shorthand notations, you can omit one end and let it default to HEAD. For example, <code>origin..</code> is a shorthand for <code>origin..HEAD</code> and asks "What did I do since I forked from the origin branch?" Similarly, <code>..origin</code> is a shorthand for <code>HEAD..origin</code> and asks "What did the origin do since I forked from them?" Note that <code>..</code> would mean <code>HEAD..HEAD</code> which is an empty range that is both reachable and unreachable from HEAD.</p> <p>Commands that are specifically designed to take two distinct ranges (e.g. "git range-diff R1 R2" to compare two ranges) do exist, but they are exceptions. Unless otherwise noted, all "git" commands that operate on a set of commits work on a single revision range. In other words, writing two "two-dot range notation" next to each other, e.g.</p> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$ git log A..B C..D</pre> </div> </div> <p>does <strong>not</strong> specify two revision ranges for most commands. Instead it will name a single connected set of commits, i.e. those that are reachable from either B or D but are reachable from neither A or C. In a linear history like this:</p> <div class="literalblock"> <div class="content"> <pre>---A---B---o---o---C---D</pre> </div> </div> <p>because A and B are reachable from C, the revision range specified by these two dotted ranges is a single commit D.</p> </div> <div class="sect2"> <h3 id="_other_rev_parent_shorthand_notations"> +Other <rev>^ Parent Shorthand Notations</h3> <p>Three other shorthands exist, particularly useful for merge commits, for naming a set that is formed by a commit and its parent commits.</p> <p>The <code>r1^@</code> notation means all parents of <code>r1</code>.</p> <p>The <code>r1^!</code> notation includes commit <code>r1</code> but excludes all of its parents. By itself, this notation denotes the single commit <code>r1</code>.</p> <p>The <code><rev>^-[<n>]</code> notation includes <code><rev></code> but excludes the <n>th parent (i.e. a shorthand for <code><rev>^<n>..<rev></code>), with <code><n></code> = 1 if not given. This is typically useful for merge commits where you can just pass <code><commit>^-</code> to get all the commits in the branch that was merged in merge commit <code><commit></code> (including <code><commit></code> itself).</p> <p>While <code><rev>^<n></code> was about specifying a single commit parent, these three notations also consider its parents. For example you can say <code>HEAD^2^@</code>, however you cannot say <code>HEAD^@^2</code>.</p> </div> </div> <h2 id="_revision_range_summary">Revision range summary</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrevgtem"> <em><rev></em> </dt> <dd> <p>Include commits that are reachable from <rev> (i.e. <rev> and its ancestors).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrevgtem-1"> <em>^<rev></em> </dt> <dd> <p>Exclude commits that are reachable from <rev> (i.e. <rev> and its ancestors).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrev1gtltrev2gtem"> <em><rev1>..<rev2></em> </dt> <dd> <p>Include commits that are reachable from <rev2> but exclude those that are reachable from <rev1>. When either <rev1> or <rev2> is omitted, it defaults to <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrev1gtltrev2gtem-1"> <em><rev1>...<rev2></em> </dt> <dd> <p>Include commits that are reachable from either <rev1> or <rev2> but exclude those that are reachable from both. When either <rev1> or <rev2> is omitted, it defaults to <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrevgtemegemHEADem"> <em><rev>^@</em>, e.g. <em>HEAD^@</em> </dt> <dd> <p>A suffix <code>^</code> followed by an at sign is the same as listing all parents of <code><rev></code> (meaning, include anything reachable from its parents, but not the commit itself).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrevgtemegemHEADem-1"> <em><rev>^!</em>, e.g. <em>HEAD^!</em> </dt> <dd> <p>A suffix <code>^</code> followed by an exclamation mark is the same as giving commit <code><rev></code> and all its parents prefixed with <code>^</code> to exclude them (and their ancestors).</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-emltrevgt-ltngtemegemHEAD-HEAD-2em"> <em><rev>^-<n></em>, e.g. <em>HEAD^-, HEAD^-2</em> </dt> <dd> <p>Equivalent to <code><rev>^<n>..<rev></code>, with <code><n></code> = 1 if not given.</p> </dd> </dl> </div> <p>Here are a handful of examples using the Loeliger illustration above, with each step in the notation’s expansion and selection carefully spelt out:</p> <div class="literalblock"> <div class="content"> <pre> Args Expanded arguments Selected commits + D G H D + D F G H I J D F + ^G D H D + ^D B E I J F B + ^D B C E I J F B C + C I J F C + B..C = ^B C C + B...C = B ^F C G H D E B C + B^- = B^..B + = ^B^1 B E I J F B + C^@ = C^1 + = F I J F + B^@ = B^1 B^2 B^3 + = D E F D G H E F I J + C^! = C ^C^@ + = C ^C^1 + = C ^F C + B^! = B ^B^@ + = B ^B^1 ^B^2 ^B^3 + = B ^D ^E ^F B + F^! D = F ^I ^J D G H D F</pre> </div> </div> </div> <h2 id="_parseopt">Parseopt</h2> <div class="sectionbody"> <p>In <code>--parseopt</code> mode, <code>git rev-parse</code> helps massaging options to bring to shell scripts the same facilities C builtins have. It works as an option normalizer (e.g. splits single switches aggregate values), a bit like <code>getopt(1)</code> does.</p> <p>It takes on the standard input the specification of the options to parse and understand, and echoes on the standard output a string suitable for <code>sh(1)</code> <code>eval</code> to replace the arguments with normalized ones. In case of error, it outputs usage on the standard error stream, and exits with code 129.</p> <p>Note: Make sure you quote the result when passing it to <code>eval</code>. See below for an example.</p> <div class="sect2"> <h3 id="_input_format"> +Input Format</h3> <p><code>git rev-parse --parseopt</code> input format is fully text based. It has two parts, separated by a line that contains only <code>--</code>. The lines before the separator (should be one or more) are used for the usage. The lines after the separator describe the options.</p> <p>Each line of options has this format:</p> <div class="listingblock"> <div class="content"> <pre><opt-spec><flags>*<arg-hint>? SP+ help LF</pre> </div> </div> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-codeltopt-specgtcode"> <code><opt-spec></code> </dt> <dd> <p>its format is the short option character, then the long option name separated by a comma. Both parts are not required, though at least one is necessary. May not contain any of the <code><flags></code> characters. <code>h,help</code>, <code>dry-run</code> and <code>f</code> are examples of correct <code><opt-spec></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-codeltflagsgtcode"> <code><flags></code> </dt> <dd> <p><code><flags></code> are of <code>*</code>, <code>=</code>, <code>?</code> or <code>!</code>.</p> <div class="ulist"> <ul> <li> <p>Use <code>=</code> if the option takes an argument.</p> </li> <li> <p>Use <code>?</code> to mean that the option takes an optional argument. You probably want to use the <code>--stuck-long</code> mode to be able to unambiguously parse the optional argument.</p> </li> <li> <p>Use <code>*</code> to mean that this option should not be listed in the usage generated for the <code>-h</code> argument. It’s shown for <code>--help-all</code> as documented in <a href="gitcli">gitcli[7]</a>.</p> </li> <li> <p>Use <code>!</code> to not make the corresponding negated long option available.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-rev-parse.txt-codeltarg-hintgtcode"> <code><arg-hint></code> </dt> <dd> <p><code><arg-hint></code>, if specified, is used as a name of the argument in the help output, for options that take arguments. <code><arg-hint></code> is terminated by the first whitespace. It is customary to use a dash to separate words in a multi-word argument hint.</p> </dd> </dl> </div> <p>The remainder of the line, after stripping the spaces, is used as the help associated with the option.</p> <p>Blank lines are ignored, and lines that don’t match this specification are used as option group headers (start the line with a space to create such lines on purpose).</p> </div> <div class="sect2"> <h3 id="_example"> +Example</h3> <div class="listingblock"> <div class="content"> <pre>OPTS_SPEC="\ +some-command [<options>] <args>... + +some-command does foo and bar! +-- +h,help! show the help + +foo some nifty option --foo +bar= some cool option --bar with an argument +baz=arg another cool option --baz with a named argument +qux?path qux may take a path argument but has meaning by itself + + An option group Header +C? option C with an optional argument" + +eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"</pre> </div> </div> </div> <div class="sect2"> <h3 id="_usage_text"> +Usage text</h3> <p>When <code>"$@"</code> is <code>-h</code> or <code>--help</code> in the above example, the following usage text would be shown:</p> <div class="listingblock"> <div class="content"> <pre>usage: some-command [<options>] <args>... + + some-command does foo and bar! + + -h, --help show the help + --[no-]foo some nifty option --foo + --[no-]bar ... some cool option --bar with an argument + --[no-]baz <arg> another cool option --baz with a named argument + --[no-]qux[=<path>] qux may take a path argument but has meaning by itself + +An option group Header + -C[...] option C with an optional argument</pre> </div> </div> </div> </div> <h2 id="_sq_quote">Sq-quote</h2> <div class="sectionbody"> <p>In <code>--sq-quote</code> mode, <code>git rev-parse</code> echoes on the standard output a single line suitable for <code>sh(1)</code> <code>eval</code>. This line is made by normalizing the arguments following <code>--sq-quote</code>. Nothing other than quoting the arguments is done.</p> <p>If you want command input to still be interpreted as usual by <code>git rev-parse</code> before the output is shell quoted, see the <code>--sq</code> option.</p> <div class="sect2"> <h3 id="_example_2"> +Example</h3> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat >your-git-script.sh <<\EOF +#!/bin/sh +args=$(git rev-parse --sq-quote "$@") # quote user-supplied arguments +command="git frotz -n24 $args" # and use it inside a handcrafted + # command line +eval "$command" +EOF + +$ sh your-git-script.sh "a b'c"</pre> </div> </div> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Print the object name of the current commit:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rev-parse --verify HEAD</pre> </div> </div> </li> <li> <p>Print the commit object name from the revision in the $REV shell variable:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rev-parse --verify --end-of-options $REV^{commit}</pre> </div> </div> <p>This will error out if $REV is empty or not a valid revision.</p> </li> <li> <p>Similar to above:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rev-parse --default master --verify --end-of-options $REV</pre> </div> </div> <p>but if $REV is empty, the commit object name from master will be printed.</p> </li> </ul> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-rev-parse" class="_attribution-link">https://git-scm.com/docs/git-rev-parse</a> + </p> +</div> diff --git a/devdocs/git/git-revert.html b/devdocs/git/git-revert.html new file mode 100644 index 00000000..30c9a42e --- /dev/null +++ b/devdocs/git/git-revert.html @@ -0,0 +1,7 @@ +<h1>git-revert</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-revert - Revert some existing commits</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git revert [--[no-]edit] [-n] [-m <parent-number>] [-s] [-S[<keyid>]] <commit>… +git revert (--continue | --skip | --abort | --quit)</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Given one or more existing commits, revert the changes that the related patches introduce, and record some new commits that record them. This requires your working tree to be clean (no modifications from the HEAD commit).</p> <p>Note: <code>git revert</code> is used to record some new commits to reverse the effect of some earlier commits (often only a faulty one). If you want to throw away all uncommitted changes in your working directory, you should see <a href="git-reset">git-reset[1]</a>, particularly the <code>--hard</code> option. If you want to extract specific files as they were in another commit, you should see <a href="git-restore">git-restore[1]</a>, specifically the <code>--source</code> option. Take care with these alternatives as both will discard uncommitted changes in your working directory.</p> <p>See "Reset, restore and revert" in <a href="git">git[1]</a> for the differences between the three commands.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-revert.txt-ltcommitgt82308203"> <commit>… </dt> <dd> <p>Commits to revert. For a more complete list of ways to spell commit names, see <a href="gitrevisions">gitrevisions[7]</a>. Sets of commits can also be given but no traversal is done by default, see <a href="git-rev-list">git-rev-list[1]</a> and its <code>--no-walk</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt--e"> -e </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---edit"> --edit </dt> <dd> <p>With this option, <code>git revert</code> will let you edit the commit message prior to committing the revert. This is the default if you run the command from a terminal.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt--mparent-number"> -m parent-number </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---mainlineparent-number"> --mainline parent-number </dt> <dd> <p>Usually you cannot revert a merge because you do not know which side of the merge should be considered the mainline. This option specifies the parent number (starting from 1) of the mainline and allows revert to reverse the change relative to the specified parent.</p> <p>Reverting a merge commit declares that you will never want the tree changes brought in by the merge. As a result, later merges will only bring in tree changes introduced by commits that are not ancestors of the previously reverted merge. This may or may not be what you want.</p> <p>See the <a href="https://git-scm.com/docs/howto/revert-a-faulty-merge">revert-a-faulty-merge How-To</a> for more details.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---no-edit"> --no-edit </dt> <dd> <p>With this option, <code>git revert</code> will not start the commit message editor.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---cleanupltmodegt"> --cleanup=<mode> </dt> <dd> <p>This option determines how the commit message will be cleaned up before being passed on to the commit machinery. See <a href="git-commit">git-commit[1]</a> for more details. In particular, if the <code><mode></code> is given a value of <code>scissors</code>, scissors will be appended to <code>MERGE_MSG</code> before being passed on in the case of a conflict.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---no-commit"> --no-commit </dt> <dd> <p>Usually the command automatically creates some commits with commit log messages stating which commits were reverted. This flag applies the changes necessary to revert the named commits to your working tree and the index, but does not make the commits. In addition, when this option is used, your index does not have to match the HEAD commit. The revert is done against the beginning state of your index.</p> <p>This is useful when reverting more than one commits' effect to your index in a row.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt--Sltkeyidgt"> -S[<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---gpg-signltkeyidgt"> --gpg-sign[=<keyid>] </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---no-gpg-sign"> --no-gpg-sign </dt> <dd> <p>GPG-sign commits. The <code>keyid</code> argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space. <code>--no-gpg-sign</code> is useful to countermand both <code>commit.gpgSign</code> configuration variable, and earlier <code>--gpg-sign</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---signoff"> --signoff </dt> <dd> <p>Add a <code>Signed-off-by</code> trailer at the end of the commit message. See the signoff option in <a href="git-commit">git-commit[1]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---strategyltstrategygt"> --strategy=<strategy> </dt> <dd> <p>Use the given merge strategy. Should only be used once. See the MERGE STRATEGIES section in <a href="git-merge">git-merge[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt--Xltoptiongt"> -X<option> </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---strategy-optionltoptiongt"> --strategy-option=<option> </dt> <dd> <p>Pass the merge strategy-specific option through to the merge strategy. See <a href="git-merge">git-merge[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---rerere-autoupdate"> --rerere-autoupdate </dt> <dt class="hdlist1" id="Documentation/git-revert.txt---no-rerere-autoupdate"> --no-rerere-autoupdate </dt> <dd> <p>After the rerere mechanism reuses a recorded resolution on the current conflict to update the files in the working tree, allow it to also update the index with the result of resolution. <code>--no-rerere-autoupdate</code> is a good way to double-check what <code>rerere</code> did and catch potential mismerges, before committing the result to the index with a separate <code>git add</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---reference"> --reference </dt> <dd> <p>Instead of starting the body of the log message with "This reverts <full object name of the commit being reverted>.", refer to the commit using "--pretty=reference" format (cf. <a href="git-log">git-log[1]</a>). The <code>revert.reference</code> configuration variable can be used to enable this option by default.</p> </dd> </dl> </div> </div> <h2 id="_sequencer_subcommands">Sequencer subcommands</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-revert.txt---continue"> --continue </dt> <dd> <p>Continue the operation in progress using the information in <code>.git/sequencer</code>. Can be used to continue after resolving conflicts in a failed cherry-pick or revert.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---skip"> --skip </dt> <dd> <p>Skip the current commit and continue with the rest of the sequence.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---quit"> --quit </dt> <dd> <p>Forget about the current operation in progress. Can be used to clear the sequencer state after a failed cherry-pick or revert.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt---abort"> --abort </dt> <dd> <p>Cancel the operation and return to the pre-sequence state.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-revert.txt-codegitrevertHEAD3code"> <code>git revert HEAD~3</code> </dt> <dd> <p>Revert the changes specified by the fourth last commit in HEAD and create a new commit with the reverted changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-revert.txt-codegitrevert-nmaster5master2code"> <code>git revert -n master~5..master~2</code> </dt> <dd> <p>Revert the changes done by commits from the fifth last commit in master (included) to the third last commit in master (included), but do not create any commit with the reverted changes. The revert only modifies the working tree and the index.</p> </dd> </dl> </div> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>While git creates a basic commit message automatically, it is <code>strongly</code> recommended to explain why the original commit is being reverted. In addition, repeatedly reverting reverts will result in increasingly unwieldy subject lines, for example <code>Reapply "Reapply "<original subject>""</code>. Please consider rewording these to be shorter and more unique.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-revert.txt-revertreference"> revert.reference </dt> <dd> <p>Setting this variable to true makes <code>git revert</code> behave as if the <code>--reference</code> option is given.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-cherry-pick">git-cherry-pick[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-revert" class="_attribution-link">https://git-scm.com/docs/git-revert</a> + </p> +</div> diff --git a/devdocs/git/git-rm.html b/devdocs/git/git-rm.html new file mode 100644 index 00000000..902af601 --- /dev/null +++ b/devdocs/git/git-rm.html @@ -0,0 +1,11 @@ +<h1>git-rm</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-rm - Remove files from the working tree and from the index</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git rm [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch] + [--quiet] [--pathspec-from-file=<file> [--pathspec-file-nul]] + [--] [<pathspec>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Remove files matching pathspec from the index, or from the working tree and the index. <code>git rm</code> will not remove a file from just your working directory. (There is no option to remove a file only from the working tree and yet keep it in the index; use <code>/bin/rm</code> if you want to do that.) The files being removed have to be identical to the tip of the branch, and no updates to their contents can be staged in the index, though that default behavior can be overridden with the <code>-f</code> option. When <code>--cached</code> is given, the staged content has to match either the tip of the branch or the file on disk, allowing the file to be removed from just the index. When sparse-checkouts are in use (see <a href="git-sparse-checkout">git-sparse-checkout[1]</a>), <code>git rm</code> will only remove paths within the sparse-checkout patterns.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rm.txt-ltpathspecgt82308203"> <pathspec>… </dt> <dd> <p>Files to remove. A leading directory name (e.g. <code>dir</code> to remove <code>dir/file1</code> and <code>dir/file2</code>) can be given to remove all files in the directory, and recursively all sub-directories, but this requires the <code>-r</code> option to be explicitly given.</p> <p>The command removes only the paths that are known to Git.</p> <p>File globbing matches across directory boundaries. Thus, given two directories <code>d</code> and <code>d2</code>, there is a difference between using <code>git rm 'd*'</code> and <code>git rm 'd/*'</code>, as the former will also remove all of directory <code>d2</code>.</p> <p>For more details, see the <code>pathspec</code> entry in <a href="gitglossary">gitglossary[7]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rm.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-rm.txt---force"> --force </dt> <dd> <p>Override the up-to-date check.</p> </dd> <dt class="hdlist1" id="Documentation/git-rm.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-rm.txt---dry-run"> --dry-run </dt> <dd> <p>Don’t actually remove any file(s). Instead, just show if they exist in the index and would otherwise be removed by the command.</p> </dd> <dt class="hdlist1" id="Documentation/git-rm.txt--r"> -r </dt> <dd> <p>Allow recursive removal when a leading directory name is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-rm.txt---"> -- </dt> <dd> <p>This option can be used to separate command-line options from the list of files, (useful when filenames might be mistaken for command-line options).</p> </dd> <dt class="hdlist1" id="Documentation/git-rm.txt---cached"> --cached </dt> <dd> <p>Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone.</p> </dd> <dt class="hdlist1" id="Documentation/git-rm.txt---ignore-unmatch"> --ignore-unmatch </dt> <dd> <p>Exit with a zero status even if no files matched.</p> </dd> <dt class="hdlist1" id="Documentation/git-rm.txt---sparse"> --sparse </dt> <dd> <p>Allow updating index entries outside of the sparse-checkout cone. Normally, <code>git rm</code> refuses to update index entries whose paths do not fit within the sparse-checkout cone. See <a href="git-sparse-checkout">git-sparse-checkout[1]</a> for more.</p> </dd> <dt class="hdlist1" id="Documentation/git-rm.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-rm.txt---quiet"> --quiet </dt> <dd> <p><code>git rm</code> normally outputs one line (in the form of an <code>rm</code> command) for each file removed. This option suppresses that output.</p> </dd> <dt class="hdlist1" id="Documentation/git-rm.txt---pathspec-from-fileltfilegt"> --pathspec-from-file=<file> </dt> <dd> <p>Pathspec is passed in <code><file></code> instead of commandline args. If <code><file></code> is exactly <code>-</code> then standard input is used. Pathspec elements are separated by LF or CR/LF. Pathspec elements can be quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>). See also <code>--pathspec-file-nul</code> and global <code>--literal-pathspecs</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-rm.txt---pathspec-file-nul"> --pathspec-file-nul </dt> <dd> <p>Only meaningful with <code>--pathspec-from-file</code>. Pathspec elements are separated with NUL character and all other characters are taken literally (including newlines and quotes).</p> </dd> </dl> </div> </div> <h2 id="_removing_files_that_have_disappeared_from_the_filesystem">Removing files that have disappeared from the filesystem</h2> <div class="sectionbody"> <p>There is no option for <code>git rm</code> to remove from the index only the paths that have disappeared from the filesystem. However, depending on the use case, there are several ways that can be done.</p> <div class="sect2"> <h3 id="_using_git_commit_a"> +Using “git commit -a”</h3> <p>If you intend that your next commit should record all modifications of tracked files in the working tree and record all removals of files that have been removed from the working tree with <code>rm</code> (as opposed to <code>git rm</code>), use <code>git commit -a</code>, as it will automatically notice and record all removals. You can also have a similar effect without committing by using <code>git add -u</code>.</p> </div> <div class="sect2"> <h3 id="_using_git_add_a"> +Using “git add -A”</h3> <p>When accepting a new code drop for a vendor branch, you probably want to record both the removal of paths and additions of new paths as well as modifications of existing paths.</p> <p>Typically you would first remove all tracked files from the working tree using this command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git ls-files -z | xargs -0 rm -f</pre> </div> </div> <p>and then untar the new code in the working tree. Alternately you could <code>rsync</code> the changes into the working tree.</p> <p>After that, the easiest way to record all removals, additions, and modifications in the working tree is:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git add -A</pre> </div> </div> <p>See <a href="git-add">git-add[1]</a>.</p> </div> <div class="sect2"> <h3 id="_other_ways"> +Other ways</h3> <p>If all you really want to do is to remove from the index the files that are no longer present in the working tree (perhaps because your working tree is dirty so that you cannot use <code>git commit -a</code>), use the following command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git diff --name-only --diff-filter=D -z | xargs -0 git rm --cached</pre> </div> </div> </div> </div> <h2 id="_submodules">Submodules</h2> <div class="sectionbody"> <p>Only submodules using a gitfile (which means they were cloned with a Git version 1.7.8 or newer) will be removed from the work tree, as their repository lives inside the .git directory of the superproject. If a submodule (or one of those nested inside it) still uses a .git directory, <code>git rm</code> will move the submodules git directory into the superprojects git directory to protect the submodule’s history. If it exists the submodule.<name> section in the <a href="gitmodules">gitmodules[5]</a> file will also be removed and that file will be staged (unless --cached or -n are used).</p> <p>A submodule is considered up to date when the HEAD is the same as recorded in the index, no tracked files are modified and no untracked files that aren’t ignored are present in the submodule’s work tree. Ignored files are deemed expendable and won’t stop a submodule’s work tree from being removed.</p> <p>If you only want to remove the local checkout of a submodule from your work tree without committing the removal, use <a href="git-submodule">git-submodule[1]</a> <code>deinit</code> instead. Also see <a href="gitsubmodules">gitsubmodules[7]</a> for details on submodule removal.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-rm.txt-codegitrmDocumentationtxtcode"> <code>git rm Documentation/\*.txt</code> </dt> <dd> <p>Removes all <code>*.txt</code> files from the index that are under the <code>Documentation</code> directory and any of its subdirectories.</p> <p>Note that the asterisk <code>*</code> is quoted from the shell in this example; this lets Git, and not the shell, expand the pathnames of files and subdirectories under the <code>Documentation/</code> directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-rm.txt-codegitrm-fgit-shcode"> <code>git rm -f git-*.sh</code> </dt> <dd> <p>Because this example lets the shell expand the asterisk (i.e. you are listing the files explicitly), it does not remove <code>subdir/git-foo.sh</code>.</p> </dd> </dl> </div> </div> <h2 id="_bugs">Bugs</h2> <div class="sectionbody"> <p>Each time a superproject update removes a populated submodule (e.g. when switching between commits before and after the removal) a stale submodule checkout will remain in the old location. Removing the old directory is only safe when it uses a gitfile, as otherwise the history of the submodule will be deleted too. This step will be obsolete when recursive submodule update has been implemented.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-add">git-add[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-rm" class="_attribution-link">https://git-scm.com/docs/git-rm</a> + </p> +</div> diff --git a/devdocs/git/git-send-email.html b/devdocs/git/git-send-email.html new file mode 100644 index 00000000..0d8d43e7 --- /dev/null +++ b/devdocs/git/git-send-email.html @@ -0,0 +1,26 @@ +<h1>git-send-email</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-send-email - Send a collection of patches as emails</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git send-email [<options>] <file|directory>… +git send-email [<options>] <format-patch options> +git send-email --dump-aliases</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Takes the patches given on the command line and emails them out. Patches can be specified as files, directories (which will send all files in the directory), or directly as a revision list. In the last case, any format accepted by <a href="git-format-patch">git-format-patch[1]</a> can be passed to git send-email, as well as options understood by <a href="git-format-patch">git-format-patch[1]</a>.</p> <p>The header of the email is configurable via command-line options. If not specified on the command line, the user will be prompted with a ReadLine enabled interface to provide the necessary information.</p> <p>There are two formats accepted for patch files:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>mbox format files</p> <p>This is what <a href="git-format-patch">git-format-patch[1]</a> generates. Most headers and MIME formatting are ignored.</p> </li> <li> <p>The original format used by Greg Kroah-Hartman’s <code>send_lots_of_email.pl</code> script</p> <p>This format expects the first line of the file to contain the "Cc:" value and the "Subject:" of the message as the second line.</p> </li> </ol> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_composing"> +Composing</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-send-email.txt---annotate"> --annotate </dt> <dd> <p>Review and edit each patch you’re about to send. Default is the value of <code>sendemail.annotate</code>. See the CONFIGURATION section for <code>sendemail.multiEdit</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---bccltaddressgt82308203"> --bcc=<address>,… </dt> <dd> <p>Specify a "Bcc:" value for each email. Default is the value of <code>sendemail.bcc</code>.</p> <p>This option may be specified multiple times.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---ccltaddressgt82308203"> --cc=<address>,… </dt> <dd> <p>Specify a starting "Cc:" value for each email. Default is the value of <code>sendemail.cc</code>.</p> <p>This option may be specified multiple times.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---compose"> --compose </dt> <dd> <p>Invoke a text editor (see GIT_EDITOR in <a href="git-var">git-var[1]</a>) to edit an introductory message for the patch series.</p> <p>When <code>--compose</code> is used, git send-email will use the From, To, Cc, Bcc, Subject, Reply-To, and In-Reply-To headers specified in the message. If the body of the message (what you type after the headers and a blank line) only contains blank (or Git: prefixed) lines, the summary won’t be sent, but the headers mentioned above will be used unless they are removed.</p> <p>Missing From or In-Reply-To headers will be prompted for.</p> <p>See the CONFIGURATION section for <code>sendemail.multiEdit</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---fromltaddressgt"> --from=<address> </dt> <dd> <p>Specify the sender of the emails. If not specified on the command line, the value of the <code>sendemail.from</code> configuration option is used. If neither the command-line option nor <code>sendemail.from</code> are set, then the user will be prompted for the value. The default for the prompt will be the value of GIT_AUTHOR_IDENT, or GIT_COMMITTER_IDENT if that is not set, as returned by "git var -l".</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---reply-toltaddressgt"> --reply-to=<address> </dt> <dd> <p>Specify the address where replies from recipients should go to. Use this if replies to messages should go to another address than what is specified with the --from parameter.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---in-reply-toltidentifiergt"> --in-reply-to=<identifier> </dt> <dd> <p>Make the first mail (or all the mails with <code>--no-thread</code>) appear as a reply to the given Message-ID, which avoids breaking threads to provide a new patch series. The second and subsequent emails will be sent as replies according to the <code>--[no-]chain-reply-to</code> setting.</p> <p>So for example when <code>--thread</code> and <code>--no-chain-reply-to</code> are specified, the second and subsequent patches will be replies to the first one like in the illustration below where <code>[PATCH v2 0/3]</code> is in reply to <code>[PATCH 0/2]</code>:</p> <div class="literalblock"> <div class="content"> <pre>[PATCH 0/2] Here is what I did... + [PATCH 1/2] Clean up and tests + [PATCH 2/2] Implementation + [PATCH v2 0/3] Here is a reroll + [PATCH v2 1/3] Clean up + [PATCH v2 2/3] New tests + [PATCH v2 3/3] Implementation</pre> </div> </div> <p>Only necessary if --compose is also set. If --compose is not set, this will be prompted for.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---subjectltstringgt"> --subject=<string> </dt> <dd> <p>Specify the initial subject of the email thread. Only necessary if --compose is also set. If --compose is not set, this will be prompted for.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---toltaddressgt82308203"> --to=<address>,… </dt> <dd> <p>Specify the primary recipient of the emails generated. Generally, this will be the upstream maintainer of the project involved. Default is the value of the <code>sendemail.to</code> configuration value; if that is unspecified, and --to-cmd is not specified, this will be prompted for.</p> <p>This option may be specified multiple times.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---8bit-encodingltencodinggt"> --8bit-encoding=<encoding> </dt> <dd> <p>When encountering a non-ASCII message or subject that does not declare its encoding, add headers/quoting to indicate it is encoded in <encoding>. Default is the value of the <code>sendemail.assume8bitEncoding</code>; if that is unspecified, this will be prompted for if any non-ASCII files are encountered.</p> <p>Note that no attempts whatsoever are made to validate the encoding.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---compose-encodingltencodinggt"> --compose-encoding=<encoding> </dt> <dd> <p>Specify encoding of compose message. Default is the value of the <code>sendemail.composeencoding</code>; if that is unspecified, UTF-8 is assumed.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---transfer-encoding7bit8bitquoted-printablebase64auto"> --transfer-encoding=(7bit|8bit|quoted-printable|base64|auto) </dt> <dd> <p>Specify the transfer encoding to be used to send the message over SMTP. 7bit will fail upon encountering a non-ASCII message. quoted-printable can be useful when the repository contains files that contain carriage returns, but makes the raw patch email file (as saved from a MUA) much harder to inspect manually. base64 is even more fool proof, but also even more opaque. auto will use 8bit when possible, and quoted-printable otherwise.</p> <p>Default is the value of the <code>sendemail.transferEncoding</code> configuration value; if that is unspecified, default to <code>auto</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---xmailer"> --xmailer </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt---no-xmailer"> --no-xmailer </dt> <dd> <p>Add (or prevent adding) the "X-Mailer:" header. By default, the header is added, but it can be turned off by setting the <code>sendemail.xmailer</code> configuration variable to <code>false</code>.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_sending"> +Sending</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-send-email.txt---envelope-senderltaddressgt"> --envelope-sender=<address> </dt> <dd> <p>Specify the envelope sender used to send the emails. This is useful if your default address is not the address that is subscribed to a list. In order to use the <code>From</code> address, set the value to "auto". If you use the sendmail binary, you must have suitable privileges for the -f parameter. Default is the value of the <code>sendemail.envelopeSender</code> configuration variable; if that is unspecified, choosing the envelope sender is left to your MTA.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---sendmail-cmdltcommandgt"> --sendmail-cmd=<command> </dt> <dd> <p>Specify a command to run to send the email. The command should be sendmail-like; specifically, it must support the <code>-i</code> option. The command will be executed in the shell if necessary. Default is the value of <code>sendemail.sendmailcmd</code>. If unspecified, and if --smtp-server is also unspecified, git-send-email will search for <code>sendmail</code> in <code>/usr/sbin</code>, <code>/usr/lib</code> and $PATH.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---smtp-encryptionltencryptiongt"> --smtp-encryption=<encryption> </dt> <dd> <p>Specify in what way encrypting begins for the SMTP connection. Valid values are <code>ssl</code> and <code>tls</code>. Any other value reverts to plain (unencrypted) SMTP, which defaults to port 25. Despite the names, both values will use the same newer version of TLS, but for historic reasons have these names. <code>ssl</code> refers to "implicit" encryption (sometimes called SMTPS), that uses port 465 by default. <code>tls</code> refers to "explicit" encryption (often known as STARTTLS), that uses port 25 by default. Other ports might be used by the SMTP server, which are not the default. Commonly found alternative port for <code>tls</code> and unencrypted is 587. You need to check your provider’s documentation or your server configuration to make sure for your own case. Default is the value of <code>sendemail.smtpEncryption</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---smtp-domainltFQDNgt"> --smtp-domain=<FQDN> </dt> <dd> <p>Specifies the Fully Qualified Domain Name (FQDN) used in the HELO/EHLO command to the SMTP server. Some servers require the FQDN to match your IP address. If not set, git send-email attempts to determine your FQDN automatically. Default is the value of <code>sendemail.smtpDomain</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---smtp-authltmechanismsgt"> --smtp-auth=<mechanisms> </dt> <dd> <p>Whitespace-separated list of allowed SMTP-AUTH mechanisms. This setting forces using only the listed mechanisms. Example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git send-email --smtp-auth="PLAIN LOGIN GSSAPI" ...</pre> </div> </div> <p>If at least one of the specified mechanisms matches the ones advertised by the SMTP server and if it is supported by the utilized SASL library, the mechanism is used for authentication. If neither <code>sendemail.smtpAuth</code> nor <code>--smtp-auth</code> is specified, all mechanisms supported by the SASL library can be used. The special value <code>none</code> maybe specified to completely disable authentication independently of <code>--smtp-user</code></p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---smtp-passltpasswordgt"> --smtp-pass[=<password>] </dt> <dd> <p>Password for SMTP-AUTH. The argument is optional: If no argument is specified, then the empty string is used as the password. Default is the value of <code>sendemail.smtpPass</code>, however <code>--smtp-pass</code> always overrides this value.</p> <p>Furthermore, passwords need not be specified in configuration files or on the command line. If a username has been specified (with <code>--smtp-user</code> or a <code>sendemail.smtpUser</code>), but no password has been specified (with <code>--smtp-pass</code> or <code>sendemail.smtpPass</code>), then a password is obtained using <code>git-credential</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---no-smtp-auth"> --no-smtp-auth </dt> <dd> <p>Disable SMTP authentication. Short hand for <code>--smtp-auth=none</code></p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---smtp-serverlthostgt"> --smtp-server=<host> </dt> <dd> <p>If set, specifies the outgoing SMTP server to use (e.g. <code>smtp.example.com</code> or a raw IP address). If unspecified, and if <code>--sendmail-cmd</code> is also unspecified, the default is to search for <code>sendmail</code> in <code>/usr/sbin</code>, <code>/usr/lib</code> and $PATH if such a program is available, falling back to <code>localhost</code> otherwise.</p> <p>For backward compatibility, this option can also specify a full pathname of a sendmail-like program instead; the program must support the <code>-i</code> option. This method does not support passing arguments or using plain command names. For those use cases, consider using <code>--sendmail-cmd</code> instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---smtp-server-portltportgt"> --smtp-server-port=<port> </dt> <dd> <p>Specifies a port different from the default port (SMTP servers typically listen to smtp port 25, but may also listen to submission port 587, or the common SSL smtp port 465); symbolic port names (e.g. "submission" instead of 587) are also accepted. The port can also be set with the <code>sendemail.smtpServerPort</code> configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---smtp-server-optionltoptiongt"> --smtp-server-option=<option> </dt> <dd> <p>If set, specifies the outgoing SMTP server option to use. Default value can be specified by the <code>sendemail.smtpServerOption</code> configuration option.</p> <p>The --smtp-server-option option must be repeated for each option you want to pass to the server. Likewise, different lines in the configuration files must be used for each option.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---smtp-ssl"> --smtp-ssl </dt> <dd> <p>Legacy alias for <code>--smtp-encryption ssl</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---smtp-ssl-cert-path"> --smtp-ssl-cert-path </dt> <dd> <p>Path to a store of trusted CA certificates for SMTP SSL/TLS certificate validation (either a directory that has been processed by <code>c_rehash</code>, or a single file containing one or more PEM format certificates concatenated together: see verify(1) -CAfile and -CApath for more information on these). Set it to an empty string to disable certificate verification. Defaults to the value of the <code>sendemail.smtpsslcertpath</code> configuration variable, if set, or the backing SSL library’s compiled-in default otherwise (which should be the best choice on most platforms).</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---smtp-userltusergt"> --smtp-user=<user> </dt> <dd> <p>Username for SMTP-AUTH. Default is the value of <code>sendemail.smtpUser</code>; if a username is not specified (with <code>--smtp-user</code> or <code>sendemail.smtpUser</code>), then authentication is not attempted.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---smtp-debug01"> --smtp-debug=0|1 </dt> <dd> <p>Enable (1) or disable (0) debug output. If enabled, SMTP commands and replies will be printed. Useful to debug TLS connection and authentication problems.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---batch-sizeltnumgt"> --batch-size=<num> </dt> <dd> <p>Some email servers (e.g. smtp.163.com) limit the number emails to be sent per session (connection) and this will lead to a failure when sending many messages. With this option, send-email will disconnect after sending $<num> messages and wait for a few seconds (see --relogin-delay) and reconnect, to work around such a limit. You may want to use some form of credential helper to avoid having to retype your password every time this happens. Defaults to the <code>sendemail.smtpBatchSize</code> configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---relogin-delayltintgt"> --relogin-delay=<int> </dt> <dd> <p>Waiting $<int> seconds before reconnecting to SMTP server. Used together with --batch-size option. Defaults to the <code>sendemail.smtpReloginDelay</code> configuration variable.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_automating"> +Automating</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-send-email.txt---no-toccbcc"> --no-[to|cc|bcc] </dt> <dd> <p>Clears any list of "To:", "Cc:", "Bcc:" addresses previously set via config.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---no-identity"> --no-identity </dt> <dd> <p>Clears the previously read value of <code>sendemail.identity</code> set via config, if any.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---to-cmdltcommandgt"> --to-cmd=<command> </dt> <dd> <p>Specify a command to execute once per patch file which should generate patch file specific "To:" entries. Output of this command must be single email address per line. Default is the value of <code>sendemail.tocmd</code> configuration value.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---cc-cmdltcommandgt"> --cc-cmd=<command> </dt> <dd> <p>Specify a command to execute once per patch file which should generate patch file specific "Cc:" entries. Output of this command must be single email address per line. Default is the value of <code>sendemail.ccCmd</code> configuration value.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---header-cmdltcommandgt"> --header-cmd=<command> </dt> <dd> <p>Specify a command that is executed once per outgoing message and output RFC 2822 style header lines to be inserted into them. When the <code>sendemail.headerCmd</code> configuration variable is set, its value is always used. When --header-cmd is provided at the command line, its value takes precedence over the <code>sendemail.headerCmd</code> configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---no-header-cmd"> --no-header-cmd </dt> <dd> <p>Disable any header command in use.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---no-chain-reply-to"> --[no-]chain-reply-to </dt> <dd> <p>If this is set, each email will be sent as a reply to the previous email sent. If disabled with "--no-chain-reply-to", all emails after the first will be sent as replies to the first email sent. When using this, it is recommended that the first file given be an overview of the entire patch series. Disabled by default, but the <code>sendemail.chainReplyTo</code> configuration variable can be used to enable it.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---identityltidentitygt"> --identity=<identity> </dt> <dd> <p>A configuration identity. When given, causes values in the <code>sendemail.<identity></code> subsection to take precedence over values in the <code>sendemail</code> section. The default identity is the value of <code>sendemail.identity</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---no-signed-off-by-cc"> --[no-]signed-off-by-cc </dt> <dd> <p>If this is set, add emails found in the <code>Signed-off-by</code> trailer or Cc: lines to the cc list. Default is the value of <code>sendemail.signedoffbycc</code> configuration value; if that is unspecified, default to --signed-off-by-cc.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---no-cc-cover"> --[no-]cc-cover </dt> <dd> <p>If this is set, emails found in Cc: headers in the first patch of the series (typically the cover letter) are added to the cc list for each email set. Default is the value of <code>sendemail.cccover</code> configuration value; if that is unspecified, default to --no-cc-cover.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---no-to-cover"> --[no-]to-cover </dt> <dd> <p>If this is set, emails found in To: headers in the first patch of the series (typically the cover letter) are added to the to list for each email set. Default is the value of <code>sendemail.tocover</code> configuration value; if that is unspecified, default to --no-to-cover.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---suppress-ccltcategorygt"> --suppress-cc=<category> </dt> <dd> <p>Specify an additional category of recipients to suppress the auto-cc of:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>author</code> will avoid including the patch author.</p> </li> <li> <p><code>self</code> will avoid including the sender.</p> </li> <li> <p><code>cc</code> will avoid including anyone mentioned in Cc lines in the patch header except for self (use <code>self</code> for that).</p> </li> <li> <p><code>bodycc</code> will avoid including anyone mentioned in Cc lines in the patch body (commit message) except for self (use <code>self</code> for that).</p> </li> <li> <p><code>sob</code> will avoid including anyone mentioned in the Signed-off-by trailers except for self (use <code>self</code> for that).</p> </li> <li> <p><code>misc-by</code> will avoid including anyone mentioned in Acked-by, Reviewed-by, Tested-by and other "-by" lines in the patch body, except Signed-off-by (use <code>sob</code> for that).</p> </li> <li> <p><code>cccmd</code> will avoid running the --cc-cmd.</p> </li> <li> <p><code>body</code> is equivalent to <code>sob</code> + <code>bodycc</code> + <code>misc-by</code>.</p> </li> <li> <p><code>all</code> will suppress all auto cc values.</p> </li> </ul> </div> </div> </div> <p>Default is the value of <code>sendemail.suppresscc</code> configuration value; if that is unspecified, default to <code>self</code> if --suppress-from is specified, as well as <code>body</code> if --no-signed-off-cc is specified.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---no-suppress-from"> --[no-]suppress-from </dt> <dd> <p>If this is set, do not add the From: address to the cc: list. Default is the value of <code>sendemail.suppressFrom</code> configuration value; if that is unspecified, default to --no-suppress-from.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---no-thread"> --[no-]thread </dt> <dd> <p>If this is set, the In-Reply-To and References headers will be added to each email sent. Whether each mail refers to the previous email (<code>deep</code> threading per <code>git format-patch</code> wording) or to the first email (<code>shallow</code> threading) is governed by "--[no-]chain-reply-to".</p> <p>If disabled with "--no-thread", those headers will not be added (unless specified with --in-reply-to). Default is the value of the <code>sendemail.thread</code> configuration value; if that is unspecified, default to --thread.</p> <p>It is up to the user to ensure that no In-Reply-To header already exists when <code>git send-email</code> is asked to add it (especially note that <code>git format-patch</code> can be configured to do the threading itself). Failure to do so may not produce the expected result in the recipient’s MUA.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_administering"> +Administering</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-send-email.txt---confirmltmodegt"> --confirm=<mode> </dt> <dd> <p>Confirm just before sending:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>always</code> will always confirm before sending</p> </li> <li> <p><code>never</code> will never confirm before sending</p> </li> <li> <p><code>cc</code> will confirm before sending when send-email has automatically added addresses from the patch to the Cc list</p> </li> <li> <p><code>compose</code> will confirm before sending the first message when using --compose.</p> </li> <li> <p><code>auto</code> is equivalent to <code>cc</code> + <code>compose</code></p> </li> </ul> </div> </div> </div> <p>Default is the value of <code>sendemail.confirm</code> configuration value; if that is unspecified, default to <code>auto</code> unless any of the suppress options have been specified, in which case default to <code>compose</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---dry-run"> --dry-run </dt> <dd> <p>Do everything except actually send the emails.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---no-format-patch"> --[no-]format-patch </dt> <dd> <p>When an argument may be understood either as a reference or as a file name, choose to understand it as a format-patch argument (<code>--format-patch</code>) or as a file name (<code>--no-format-patch</code>). By default, when such a conflict occurs, git send-email will fail.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---quiet"> --quiet </dt> <dd> <p>Make git-send-email less verbose. One line per email should be all that is output.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---no-validate"> --[no-]validate </dt> <dd> <p>Perform sanity checks on patches. Currently, validation means the following:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>Invoke the sendemail-validate hook if present (see <a href="githooks">githooks[5]</a>).</p> </li> <li> <p>Warn of patches that contain lines longer than 998 characters unless a suitable transfer encoding (<code>auto</code>, <code>base64</code>, or <code>quoted-printable</code>) is used; this is due to SMTP limits as described by <a href="https://www.ietf.org/rfc/rfc5322.txt" class="bare">https://www.ietf.org/rfc/rfc5322.txt</a>.</p> </li> </ul> </div> </div> </div> <p>Default is the value of <code>sendemail.validate</code>; if this is not set, default to <code>--validate</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt---force"> --force </dt> <dd> <p>Send emails even if safety checks would prevent it.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_information"> +Information</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-send-email.txt---dump-aliases"> --dump-aliases </dt> <dd> <p>Instead of the normal operation, dump the shorthand alias names from the configured alias file(s), one per line in alphabetical order. Note that this only includes the alias name and not its expanded email addresses. See <code>sendemail.aliasesfile</code> for more information about aliases.</p> </dd> </dl> </div> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailidentity"> sendemail.identity </dt> <dd> <p>A configuration identity. When given, causes values in the <code>sendemail.<identity></code> subsection to take precedence over values in the <code>sendemail</code> section. The default identity is the value of <code>sendemail.identity</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailsmtpEncryption"> sendemail.smtpEncryption </dt> <dd> <p>See <a href="git-send-email">git-send-email[1]</a> for description. Note that this setting is not subject to the <code>identity</code> mechanism.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailsmtpsslcertpath"> sendemail.smtpsslcertpath </dt> <dd> <p>Path to ca-certificates (either a directory or a single file). Set it to an empty string to disable certificate verification.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailltidentitygt"> sendemail.<identity>.* </dt> <dd> <p>Identity-specific versions of the <code>sendemail.*</code> parameters found below, taking precedence over those when this identity is selected, through either the command-line or <code>sendemail.identity</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailmultiEdit"> sendemail.multiEdit </dt> <dd> <p>If true (default), a single editor instance will be spawned to edit files you have to edit (patches when <code>--annotate</code> is used, and the summary when <code>--compose</code> is used). If false, files will be edited one after the other, spawning a new editor each time.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailconfirm"> sendemail.confirm </dt> <dd> <p>Sets the default for whether to confirm before sending. Must be one of <code>always</code>, <code>never</code>, <code>cc</code>, <code>compose</code>, or <code>auto</code>. See <code>--confirm</code> in the <a href="git-send-email">git-send-email[1]</a> documentation for the meaning of these values.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailaliasesFile"> sendemail.aliasesFile </dt> <dd> <p>To avoid typing long email addresses, point this to one or more email aliases files. You must also supply <code>sendemail.aliasFileType</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailaliasFileType"> sendemail.aliasFileType </dt> <dd> <p>Format of the file(s) specified in sendemail.aliasesFile. Must be one of <code>mutt</code>, <code>mailrc</code>, <code>pine</code>, <code>elm</code>, <code>gnus</code>, or <code>sendmail</code>.</p> <p>What an alias file in each format looks like can be found in the documentation of the email program of the same name. The differences and limitations from the standard formats are described below:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendmail"> sendmail </dt> <dd> <div class="ulist"> <ul> <li> <p>Quoted aliases and quoted addresses are not supported: lines that contain a <code>"</code> symbol are ignored.</p> </li> <li> <p>Redirection to a file (<code>/path/name</code>) or pipe (<code>|command</code>) is not supported.</p> </li> <li> <p>File inclusion (<code>:include: /path/name</code>) is not supported.</p> </li> <li> <p>Warnings are printed on the standard error output for any explicitly unsupported constructs, and any other lines that are not recognized by the parser.</p> </li> </ul> </div> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailannotate"> sendemail.annotate </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailbcc"> sendemail.bcc </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailcc"> sendemail.cc </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailccCmd"> sendemail.ccCmd </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailchainReplyTo"> sendemail.chainReplyTo </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailenvelopeSender"> sendemail.envelopeSender </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailfrom"> sendemail.from </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailheaderCmd"> sendemail.headerCmd </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailsignedoffbycc"> sendemail.signedoffbycc </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailsmtpPass"> sendemail.smtpPass </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailsuppresscc"> sendemail.suppresscc </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailsuppressFrom"> sendemail.suppressFrom </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailto"> sendemail.to </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailtocmd"> sendemail.tocmd </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailsmtpDomain"> sendemail.smtpDomain </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailsmtpServer"> sendemail.smtpServer </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailsmtpServerPort"> sendemail.smtpServerPort </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailsmtpServerOption"> sendemail.smtpServerOption </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailsmtpUser"> sendemail.smtpUser </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailthread"> sendemail.thread </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailtransferEncoding"> sendemail.transferEncoding </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailvalidate"> sendemail.validate </dt> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailxmailer"> sendemail.xmailer </dt> <dd> <p>These configuration variables all provide a default for <a href="git-send-email">git-send-email[1]</a> command-line options. See its documentation for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailsignedoffccdeprecated"> sendemail.signedoffcc (deprecated) </dt> <dd> <p>Deprecated alias for <code>sendemail.signedoffbycc</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailsmtpBatchSize"> sendemail.smtpBatchSize </dt> <dd> <p>Number of messages to be sent per connection, after that a relogin will happen. If the value is 0 or undefined, send all messages in one connection. See also the <code>--batch-size</code> option of <a href="git-send-email">git-send-email[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailsmtpReloginDelay"> sendemail.smtpReloginDelay </dt> <dd> <p>Seconds to wait before reconnecting to the smtp server. See also the <code>--relogin-delay</code> option of <a href="git-send-email">git-send-email[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-email.txt-sendemailforbidSendmailVariables"> sendemail.forbidSendmailVariables </dt> <dd> <p>To avoid common misconfiguration mistakes, <a href="git-send-email">git-send-email[1]</a> will abort with a warning if any configuration options for "sendmail" exist. Set this variable to bypass the check.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_use_gmail_as_the_smtp_server"> +Use gmail as the smtp server</h3> <p>To use <code>git send-email</code> to send your patches through the GMail SMTP server, edit ~/.gitconfig to specify your account settings:</p> <div class="listingblock"> <div class="content"> <pre>[sendemail] + smtpEncryption = tls + smtpServer = smtp.gmail.com + smtpUser = yourname@gmail.com + smtpServerPort = 587</pre> </div> </div> <p>If you have multi-factor authentication set up on your Gmail account, you can generate an app-specific password for use with <code>git send-email</code>. Visit <a href="https://security.google.com/settings/security/apppasswords" class="bare">https://security.google.com/settings/security/apppasswords</a> to create it.</p> <p>Once your commits are ready to be sent to the mailing list, run the following commands:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$ git format-patch --cover-letter -M origin/master -o outgoing/ +$ edit outgoing/0000-* +$ git send-email outgoing/*</pre> </div> </div> <p>The first time you run it, you will be prompted for your credentials. Enter the app-specific or your regular password as appropriate. If you have credential helper configured (see <a href="git-credential">git-credential[1]</a>), the password will be saved in the credential store so you won’t have to type it the next time.</p> <p>Note: the following core Perl modules that may be installed with your distribution of Perl are required: MIME::Base64, MIME::QuotedPrint, Net::Domain and Net::SMTP. These additional Perl modules are also required: Authen::SASL and Mail::Address.</p> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-format-patch">git-format-patch[1]</a>, <a href="git-imap-send">git-imap-send[1]</a>, mbox(5)</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-send-email" class="_attribution-link">https://git-scm.com/docs/git-send-email</a> + </p> +</div> diff --git a/devdocs/git/git-send-pack.html b/devdocs/git/git-send-pack.html new file mode 100644 index 00000000..da6a7fcd --- /dev/null +++ b/devdocs/git/git-send-pack.html @@ -0,0 +1,10 @@ +<h1>git-send-pack</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-send-pack - Push objects over Git protocol to another repository</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git send-pack [--mirror] [--dry-run] [--force] + [--receive-pack=<git-receive-pack>] + [--verbose] [--thin] [--atomic] + [--[no-]signed | --signed=(true|false|if-asked)] + [<host>:]<directory> (--all | <ref>…)</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Usually you would want to use <code>git push</code>, which is a higher-level wrapper of this command, instead. See <a href="git-push">git-push[1]</a>.</p> <p>Invokes <code>git-receive-pack</code> on a possibly remote repository, and updates it from the current repository, sending named refs.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-send-pack.txt---receive-packltgit-receive-packgt"> --receive-pack=<git-receive-pack> </dt> <dd> <p>Path to the <code>git-receive-pack</code> program on the remote end. Sometimes useful when pushing to a remote repository over ssh, and you do not have the program in a directory on the default $PATH.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-pack.txt---execltgit-receive-packgt"> --exec=<git-receive-pack> </dt> <dd> <p>Same as --receive-pack=<git-receive-pack>.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-pack.txt---all"> --all </dt> <dd> <p>Instead of explicitly specifying which refs to update, update all heads that locally exist.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-pack.txt---stdin"> --stdin </dt> <dd> <p>Take the list of refs from stdin, one per line. If there are refs specified on the command line in addition to this option, then the refs from stdin are processed after those on the command line.</p> <p>If <code>--stateless-rpc</code> is specified together with this option then the list of refs must be in packet format (pkt-line). Each ref must be in a separate packet, and the list must end with a flush packet.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-pack.txt---dry-run"> --dry-run </dt> <dd> <p>Do everything except actually send the updates.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-pack.txt---force"> --force </dt> <dd> <p>Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. This flag disables the check. This means that the remote repository can lose commits; use it with care.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-pack.txt---verbose"> --verbose </dt> <dd> <p>Run verbosely.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-pack.txt---thin"> --thin </dt> <dd> <p>Send a "thin" pack, which records objects in deltified form based on objects not included in the pack to reduce network traffic.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-pack.txt---atomic"> --atomic </dt> <dd> <p>Use an atomic transaction for updating the refs. If any of the refs fails to update then the entire push will fail without changing any refs.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-pack.txt---no-signed"> --[no-]signed </dt> <dt class="hdlist1" id="Documentation/git-send-pack.txt---signedtruefalseif-asked"> --signed=(true|false|if-asked) </dt> <dd> <p>GPG-sign the push request to update refs on the receiving side, to allow it to be checked by the hooks and/or be logged. If <code>false</code> or <code>--no-signed</code>, no signing will be attempted. If <code>true</code> or <code>--signed</code>, the push will fail if the server does not support signed pushes. If set to <code>if-asked</code>, sign if and only if the server supports signed pushes. The push will also fail if the actual call to <code>gpg --sign</code> fails. See <a href="git-receive-pack">git-receive-pack[1]</a> for the details on the receiving end.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-pack.txt---push-optionltstringgt"> --push-option=<string> </dt> <dd> <p>Pass the specified string as a push option for consumption by hooks on the server side. If the server doesn’t support push options, error out. See <a href="git-push">git-push[1]</a> and <a href="githooks">githooks[5]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-pack.txt-lthostgt"> <host> </dt> <dd> <p>A remote host to house the repository. When this part is specified, <code>git-receive-pack</code> is invoked via ssh.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-pack.txt-ltdirectorygt"> <directory> </dt> <dd> <p>The repository to update.</p> </dd> <dt class="hdlist1" id="Documentation/git-send-pack.txt-ltrefgt82308203"> <ref>… </dt> <dd> <p>The remote refs to update.</p> </dd> </dl> </div> </div> <h2 id="_specifying_the_refs">Specifying the refs</h2> <div class="sectionbody"> <p>There are three ways to specify which refs to update on the remote end.</p> <p>With the <code>--all</code> flag, all refs that exist locally are transferred to the remote side. You cannot specify any <code><ref></code> if you use this flag.</p> <p>Without <code>--all</code> and without any <code><ref></code>, the heads that exist both on the local side and on the remote side are updated.</p> <p>When one or more <code><ref></code> are specified explicitly (whether on the command line or via <code>--stdin</code>), it can be either a single pattern, or a pair of such patterns separated by a colon ":" (this means that a ref name cannot have a colon in it). A single pattern <code><name></code> is just shorthand for <code><name>:<name></code>.</p> <p>Each pattern pair consists of the source side (before the colon) and the destination side (after the colon). The ref to be pushed is determined by finding a match that matches the source side, and where it is pushed is determined by using the destination side. The rules used to match a ref are the same rules used by <code>git rev-parse</code> to resolve a symbolic ref name. See <a href="git-rev-parse">git-rev-parse[1]</a>.</p> <div class="ulist"> <ul> <li> <p>It is an error if <src> does not match exactly one of the local refs.</p> </li> <li> <p>It is an error if <dst> matches more than one remote ref.</p> </li> <li> <p>If <dst> does not match any remote ref, either</p> <div class="ulist"> <ul> <li> <p>it has to start with "refs/"; <dst> is used as the destination literally in this case.</p> </li> <li> <p><src> == <dst> and the ref that matched the <src> must not exist in the set of remote refs; the ref matched <src> locally is used as the name of the destination.</p> </li> </ul> </div> </li> </ul> </div> <p>Without <code>--force</code>, the <src> ref is stored at the remote only if <dst> does not exist, or <dst> is a proper subset (i.e. an ancestor) of <src>. This check, known as the "fast-forward check", is performed to avoid accidentally overwriting the remote ref and losing other people’s commits from there.</p> <p>With <code>--force</code>, the fast-forward check is disabled for all refs.</p> <p>Optionally, a <ref> parameter can be prefixed with a plus <code>+</code> sign to disable the fast-forward check only on that ref.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-send-pack" class="_attribution-link">https://git-scm.com/docs/git-send-pack</a> + </p> +</div> diff --git a/devdocs/git/git-sh-i18n--envsubst.html b/devdocs/git/git-sh-i18n--envsubst.html new file mode 100644 index 00000000..d6849147 --- /dev/null +++ b/devdocs/git/git-sh-i18n--envsubst.html @@ -0,0 +1,11 @@ +<h1>git-sh-i18n--envsubst</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-sh-i18n—envsubst - Git’s own envsubst(1) for i18n fallbacks</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content">eval_gettext () { + printf "%s" "$1" | ( + export PATH $(git sh-i18n--envsubst --variables "$1"); + git sh-i18n--envsubst "$1" + ) +}</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This is not a command the end user would want to run. Ever. This documentation is meant for people who are studying the plumbing scripts and/or are writing new ones.</p> <p><code>git sh-i18n--envsubst</code> is Git’s stripped-down copy of the GNU <code>envsubst(1)</code> program that comes with the GNU gettext package. It’s used internally by <a href="git-sh-i18n">git-sh-i18n[1]</a> to interpolate the variables passed to the <code>eval_gettext</code> function.</p> <p>No promises are made about the interface, or that this program won’t disappear without warning in the next version of Git. Don’t use it.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-sh-i18n--envsubst" class="_attribution-link">https://git-scm.com/docs/git-sh-i18n--envsubst</a> + </p> +</div> diff --git a/devdocs/git/git-sh-i18n.html b/devdocs/git/git-sh-i18n.html new file mode 100644 index 00000000..2b7cc97d --- /dev/null +++ b/devdocs/git/git-sh-i18n.html @@ -0,0 +1,6 @@ +<h1>git-sh-i18n</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-sh-i18n - Git’s i18n setup code for shell scripts</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content">. "$(git --exec-path)/git-sh-i18n"</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This is not a command the end user would want to run. Ever. This documentation is meant for people who are studying the Porcelain-ish scripts and/or are writing new ones.</p> <p>The 'git sh-i18n scriptlet is designed to be sourced (using <code>.</code>) by Git’s porcelain programs implemented in shell script. It provides wrappers for the GNU <code>gettext</code> and <code>eval_gettext</code> functions accessible through the <code>gettext.sh</code> script, and provides pass-through fallbacks on systems without GNU gettext.</p> </div> <h2 id="_functions">Functions</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-sh-i18n.txt-gettext"> gettext </dt> <dd> <p>Currently a dummy fall-through function implemented as a wrapper around <code>printf(1)</code>. Will be replaced by a real gettext implementation in a later version.</p> </dd> <dt class="hdlist1" id="Documentation/git-sh-i18n.txt-evalgettext"> eval_gettext </dt> <dd> <p>Currently a dummy fall-through function implemented as a wrapper around <code>printf(1)</code> with variables expanded by the <a href="git-sh-i18n--envsubst">git-sh-i18n--envsubst[1]</a> helper. Will be replaced by a real gettext implementation in a later version.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-sh-i18n" class="_attribution-link">https://git-scm.com/docs/git-sh-i18n</a> + </p> +</div> diff --git a/devdocs/git/git-sh-setup.html b/devdocs/git/git-sh-setup.html new file mode 100644 index 00000000..e3a745da --- /dev/null +++ b/devdocs/git/git-sh-setup.html @@ -0,0 +1,7 @@ +<h1>git-sh-setup</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-sh-setup - Common Git shell script setup code</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content">. "$(git --exec-path)/git-sh-setup"</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This is not a command the end user would want to run. Ever. This documentation is meant for people who are studying the Porcelain-ish scripts and/or are writing new ones.</p> <p>The <code>git sh-setup</code> scriptlet is designed to be sourced (using <code>.</code>) by other shell scripts to set up some variables pointing at the normal Git directories and a few helper shell functions.</p> <p>Before sourcing it, your script should set up a few variables; <code>USAGE</code> (and <code>LONG_USAGE</code>, if any) is used to define the message given by <code>usage()</code> shell function. <code>SUBDIRECTORY_OK</code> can be set if the script can run from a subdirectory of the working tree (some commands do not).</p> <p>The scriptlet sets <code>GIT_DIR</code> and <code>GIT_OBJECT_DIRECTORY</code> shell variables, but does <strong>not</strong> export them to the environment.</p> </div> <h2 id="_functions">Functions</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-sh-setup.txt-die"> die </dt> <dd> <p>exit after emitting the supplied error message to the standard error stream.</p> </dd> <dt class="hdlist1" id="Documentation/git-sh-setup.txt-usage"> usage </dt> <dd> <p>die with the usage message.</p> </dd> <dt class="hdlist1" id="Documentation/git-sh-setup.txt-setreflogaction"> set_reflog_action </dt> <dd> <p>Set <code>GIT_REFLOG_ACTION</code> environment to a given string (typically the name of the program) unless it is already set. Whenever the script runs a <code>git</code> command that updates refs, a reflog entry is created using the value of this string to leave the record of what command updated the ref.</p> </dd> <dt class="hdlist1" id="Documentation/git-sh-setup.txt-giteditor"> git_editor </dt> <dd> <p>runs an editor of user’s choice (GIT_EDITOR, core.editor, VISUAL or EDITOR) on a given file, but error out if no editor is specified and the terminal is dumb.</p> </dd> <dt class="hdlist1" id="Documentation/git-sh-setup.txt-isbarerepository"> is_bare_repository </dt> <dd> <p>outputs <code>true</code> or <code>false</code> to the standard output stream to indicate if the repository is a bare repository (i.e. without an associated working tree).</p> </dd> <dt class="hdlist1" id="Documentation/git-sh-setup.txt-cdtotoplevel"> cd_to_toplevel </dt> <dd> <p>runs chdir to the toplevel of the working tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-sh-setup.txt-requireworktree"> require_work_tree </dt> <dd> <p>checks if the current directory is within the working tree of the repository, and otherwise dies.</p> </dd> <dt class="hdlist1" id="Documentation/git-sh-setup.txt-requireworktreeexists"> require_work_tree_exists </dt> <dd> <p>checks if the working tree associated with the repository exists, and otherwise dies. Often done before calling cd_to_toplevel, which is impossible to do if there is no working tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-sh-setup.txt-requirecleanworktreeltactiongtlthintgt"> require_clean_work_tree <action> [<hint>] </dt> <dd> <p>checks that the working tree and index associated with the repository have no uncommitted changes to tracked files. Otherwise it emits an error message of the form <code>Cannot +<action>: <reason>. <hint></code>, and dies. Example:</p> <div class="listingblock"> <div class="content"> <pre>require_clean_work_tree rebase "Please commit or stash them."</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-sh-setup.txt-getauthoridentfromcommit"> get_author_ident_from_commit </dt> <dd> <p>outputs code for use with eval to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL and GIT_AUTHOR_DATE variables for a given commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-sh-setup.txt-createvirtualbase"> create_virtual_base </dt> <dd> <p>modifies the first file so only lines in common with the second file remain. If there is insufficient common material, then the first file is left empty. The result is suitable as a virtual base input for a 3-way merge.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-sh-setup" class="_attribution-link">https://git-scm.com/docs/git-sh-setup</a> + </p> +</div> diff --git a/devdocs/git/git-shell.html b/devdocs/git/git-shell.html new file mode 100644 index 00000000..75ca370a --- /dev/null +++ b/devdocs/git/git-shell.html @@ -0,0 +1,24 @@ +<h1>git-shell</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-shell - Restricted login shell for Git-only SSH access</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content">chsh -s $(command -v git-shell) <user> +git clone <user>@localhost:/path/to/repo.git +ssh <user>@localhost</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This is a login shell for SSH accounts to provide restricted Git access. It permits execution only of server-side Git commands implementing the pull/push functionality, plus custom commands present in a subdirectory named <code>git-shell-commands</code> in the user’s home directory.</p> </div> <h2 id="_commands">Commands</h2> <div class="sectionbody"> <p><code>git shell</code> accepts the following commands after the <code>-c</code> option:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-shell.txt-emgitreceive-packltargumentgtem"> <em>git receive-pack <argument></em> </dt> <dt class="hdlist1" id="Documentation/git-shell.txt-emgitupload-packltargumentgtem"> <em>git upload-pack <argument></em> </dt> <dt class="hdlist1" id="Documentation/git-shell.txt-emgitupload-archiveltargumentgtem"> <em>git upload-archive <argument></em> </dt> <dd> <p>Call the corresponding server-side command to support the client’s <code>git push</code>, <code>git fetch</code>, or <code>git archive --remote</code> request.</p> </dd> <dt class="hdlist1" id="Documentation/git-shell.txt-emcvsserverem"> <em>cvs server</em> </dt> <dd> <p>Imitate a CVS server. See <a href="git-cvsserver">git-cvsserver[1]</a>.</p> </dd> </dl> </div> <p>If a <code>~/git-shell-commands</code> directory is present, <code>git shell</code> will also handle other, custom commands by running "<code>git-shell-commands/<command> <arguments></code>" from the user’s home directory.</p> </div> <h2 id="_interactive_use">Interactive use</h2> <div class="sectionbody"> <p>By default, the commands above can be executed only with the <code>-c</code> option; the shell is not interactive.</p> <p>If a <code>~/git-shell-commands</code> directory is present, <code>git shell</code> can also be run interactively (with no arguments). If a <code>help</code> command is present in the <code>git-shell-commands</code> directory, it is run to provide the user with an overview of allowed actions. Then a "git> " prompt is presented at which one can enter any of the commands from the <code>git-shell-commands</code> directory, or <code>exit</code> to close the connection.</p> <p>Generally this mode is used as an administrative interface to allow users to list repositories they have access to, create, delete, or rename repositories, or change repository descriptions and permissions.</p> <p>If a <code>no-interactive-login</code> command exists, then it is run and the interactive shell is aborted.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>To disable interactive logins, displaying a greeting instead:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ chsh -s /usr/bin/git-shell +$ mkdir $HOME/git-shell-commands +$ cat >$HOME/git-shell-commands/no-interactive-login <<\EOF +#!/bin/sh +printf '%s\n' "Hi $USER! You've successfully authenticated, but I do not" +printf '%s\n' "provide interactive shell access." +exit 128 +EOF +$ chmod +x $HOME/git-shell-commands/no-interactive-login</pre> </div> </div> <p>To enable git-cvsserver access (which should generally have the <code>no-interactive-login</code> example above as a prerequisite, as creating the git-shell-commands directory allows interactive logins):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat >$HOME/git-shell-commands/cvs <<\EOF +if ! test $# = 1 && test "$1" = "server" +then + echo >&2 "git-cvsserver only handles \"server\"" + exit 1 +fi +exec git cvsserver server +EOF +$ chmod +x $HOME/git-shell-commands/cvs</pre> </div> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p>ssh(1), <a href="git-daemon">git-daemon[1]</a>, contrib/git-shell-commands/README</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-shell" class="_attribution-link">https://git-scm.com/docs/git-shell</a> + </p> +</div> diff --git a/devdocs/git/git-shortlog.html b/devdocs/git/git-shortlog.html new file mode 100644 index 00000000..252a1268 --- /dev/null +++ b/devdocs/git/git-shortlog.html @@ -0,0 +1,55 @@ +<h1>git-shortlog</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-shortlog - Summarize <code>git log</code> output</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git shortlog [<options>] [<revision-range>] [[--] <path>…] +git log --pretty=short | git shortlog [<options>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Summarizes <code>git log</code> output in a format suitable for inclusion in release announcements. Each commit will be grouped by author and title.</p> <p>Additionally, "[PATCH]" will be stripped from the commit description.</p> <p>If no revisions are passed on the command line and either standard input is not a terminal or there is no current branch, <code>git shortlog</code> will output a summary of the log read from standard input, without reference to the current repository.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-shortlog.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---numbered"> --numbered </dt> <dd> <p>Sort output according to the number of commits per author instead of author alphabetic order.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---summary"> --summary </dt> <dd> <p>Suppress commit description and provide a commit count summary only.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt--e"> -e </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---email"> --email </dt> <dd> <p>Show the email address of each author.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---formatltformatgt"> --format[=<format>] </dt> <dd> <p>Instead of the commit subject, use some other information to describe each commit. <code><format></code> can be any string accepted by the <code>--format</code> option of <code>git log</code>, such as <code>* [%h] %s</code>. (See the "PRETTY FORMATS" section of <a href="git-log">git-log[1]</a>.)</p> <div class="literalblock"> <div class="content"> <pre>Each pretty-printed commit will be rewrapped before it is shown.</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---dateltformatgt"> --date=<format> </dt> <dd> <p>Show dates formatted according to the given date string. (See the <code>--date</code> option in the "Commit Formatting" section of <a href="git-log">git-log[1]</a>). Useful with <code>--group=format:<format></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---grouplttypegt"> --group=<type> </dt> <dd> <p>Group commits based on <code><type></code>. If no <code>--group</code> option is specified, the default is <code>author</code>. <code><type></code> is one of:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>author</code>, commits are grouped by author</p> </li> <li> <p><code>committer</code>, commits are grouped by committer (the same as <code>-c</code>)</p> </li> <li> <p><code>trailer:<field></code>, the <code><field></code> is interpreted as a case-insensitive commit message trailer (see <a href="git-interpret-trailers">git-interpret-trailers[1]</a>). For example, if your project uses <code>Reviewed-by</code> trailers, you might want to see who has been reviewing with <code>git shortlog -ns --group=trailer:reviewed-by</code>.</p> </li> <li> <p><code>format:<format></code>, any string accepted by the <code>--format</code> option of <code>git log</code>. (See the "PRETTY FORMATS" section of <a href="git-log">git-log[1]</a>.)</p> <p>Note that commits that do not include the trailer will not be counted. Likewise, commits with multiple trailers (e.g., multiple signoffs) may be counted more than once (but only once per unique trailer value in that commit).</p> <p>Shortlog will attempt to parse each trailer value as a <code>name <email></code> identity. If successful, the mailmap is applied and the email is omitted unless the <code>--email</code> option is specified. If the value cannot be parsed as an identity, it will be taken literally and completely.</p> </li> </ul> </div> </div> </div> <p>If <code>--group</code> is specified multiple times, commits are counted under each value (but again, only once per unique value in that commit). For example, <code>git shortlog --group=author --group=trailer:co-authored-by</code> counts both authors and co-authors.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt--c"> -c </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---committer"> --committer </dt> <dd> <p>This is an alias for <code>--group=committer</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt--wltwidthgtltindent1gtltindent2gt"> -w[<width>[,<indent1>[,<indent2>]]] </dt> <dd> <p>Linewrap the output by wrapping each line at <code>width</code>. The first line of each entry is indented by <code>indent1</code> spaces, and the second and subsequent lines are indented by <code>indent2</code> spaces. <code>width</code>, <code>indent1</code>, and <code>indent2</code> default to 76, 6 and 9 respectively.</p> <p>If width is <code>0</code> (zero) then indent the lines of the output without wrapping them.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt-ltrevision-rangegt"> <revision-range> </dt> <dd> <p>Show only commits in the specified revision range. When no <revision-range> is specified, it defaults to <code>HEAD</code> (i.e. the whole history leading to the current commit). <code>origin..HEAD</code> specifies all the commits reachable from the current commit (i.e. <code>HEAD</code>), but not from <code>origin</code>. For a complete list of ways to spell <revision-range>, see the "Specifying Ranges" section of <a href="gitrevisions">gitrevisions[7]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---ltpathgt82308203"> [--] <path>… </dt> <dd> <p>Consider only commits that are enough to explain how the files that match the specified paths came to be.</p> <p>Paths may need to be prefixed with <code>--</code> to separate them from options or the revision range, when confusion arises.</p> </dd> </dl> </div> <div class="sect2"> <h3 id="_commit_limiting"> +Commit Limiting</h3> <p>Besides specifying a range of commits that should be listed using the special notations explained in the description, additional commit limiting may be applied.</p> <p>Using more options generally further limits the output (e.g. <code>--since=<date1></code> limits to commits newer than <code><date1></code>, and using it with <code>--grep=<pattern></code> further limits to commits whose log message has a line that matches <code><pattern></code>), unless otherwise noted.</p> <p>Note that these are applied before commit ordering and formatting options, such as <code>--reverse</code>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-shortlog.txt--ltnumbergt"> -<number> </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt--nltnumbergt"> -n <number> </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---max-countltnumbergt"> --max-count=<number> </dt> <dd> <p>Limit the number of commits to output.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---skipltnumbergt"> --skip=<number> </dt> <dd> <p>Skip <code>number</code> commits before starting to show the commit output.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---sinceltdategt"> --since=<date> </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---afterltdategt"> --after=<date> </dt> <dd> <p>Show commits more recent than a specific date.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---since-as-filterltdategt"> --since-as-filter=<date> </dt> <dd> <p>Show all commits more recent than a specific date. This visits all commits in the range, rather than stopping at the first commit which is older than a specific date.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---untilltdategt"> --until=<date> </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---beforeltdategt"> --before=<date> </dt> <dd> <p>Show commits older than a specific date.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---authorltpatterngt"> --author=<pattern> </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---committerltpatterngt"> --committer=<pattern> </dt> <dd> <p>Limit the commits output to ones with author/committer header lines that match the specified pattern (regular expression). With more than one <code>--author=<pattern></code>, commits whose author matches any of the given patterns are chosen (similarly for multiple <code>--committer=<pattern></code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---grep-reflogltpatterngt"> --grep-reflog=<pattern> </dt> <dd> <p>Limit the commits output to ones with reflog entries that match the specified pattern (regular expression). With more than one <code>--grep-reflog</code>, commits whose reflog message matches any of the given patterns are chosen. It is an error to use this option unless <code>--walk-reflogs</code> is in use.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---grepltpatterngt"> --grep=<pattern> </dt> <dd> <p>Limit the commits output to ones with a log message that matches the specified pattern (regular expression). With more than one <code>--grep=<pattern></code>, commits whose message matches any of the given patterns are chosen (but see <code>--all-match</code>).</p> <p>When <code>--notes</code> is in effect, the message from the notes is matched as if it were part of the log message.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---all-match"> --all-match </dt> <dd> <p>Limit the commits output to ones that match all given <code>--grep</code>, instead of ones that match at least one.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---invert-grep"> --invert-grep </dt> <dd> <p>Limit the commits output to ones with a log message that do not match the pattern specified with <code>--grep=<pattern></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt--i"> -i </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---regexp-ignore-case"> --regexp-ignore-case </dt> <dd> <p>Match the regular expression limiting patterns without regard to letter case.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---basic-regexp"> --basic-regexp </dt> <dd> <p>Consider the limiting patterns to be basic regular expressions; this is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt--E"> -E </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---extended-regexp"> --extended-regexp </dt> <dd> <p>Consider the limiting patterns to be extended regular expressions instead of the default basic regular expressions.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt--F"> -F </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---fixed-strings"> --fixed-strings </dt> <dd> <p>Consider the limiting patterns to be fixed strings (don’t interpret pattern as a regular expression).</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt--P"> -P </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---perl-regexp"> --perl-regexp </dt> <dd> <p>Consider the limiting patterns to be Perl-compatible regular expressions.</p> <p>Support for these types of regular expressions is an optional compile-time dependency. If Git wasn’t compiled with support for them providing this option will cause it to die.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---remove-empty"> --remove-empty </dt> <dd> <p>Stop when a given path disappears from the tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---merges"> --merges </dt> <dd> <p>Print only merge commits. This is exactly the same as <code>--min-parents=2</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---no-merges"> --no-merges </dt> <dd> <p>Do not print commits with more than one parent. This is exactly the same as <code>--max-parents=1</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---min-parentsltnumbergt"> --min-parents=<number> </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---max-parentsltnumbergt"> --max-parents=<number> </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---no-min-parents"> --no-min-parents </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---no-max-parents"> --no-max-parents </dt> <dd> <p>Show only commits which have at least (or at most) that many parent commits. In particular, <code>--max-parents=1</code> is the same as <code>--no-merges</code>, <code>--min-parents=2</code> is the same as <code>--merges</code>. <code>--max-parents=0</code> gives all root commits and <code>--min-parents=3</code> all octopus merges.</p> <p><code>--no-min-parents</code> and <code>--no-max-parents</code> reset these limits (to no limit) again. Equivalent forms are <code>--min-parents=0</code> (any commit has 0 or more parents) and <code>--max-parents=-1</code> (negative numbers denote no upper limit).</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---first-parent"> --first-parent </dt> <dd> <p>When finding commits to include, follow only the first parent commit upon seeing a merge commit. This option can give a better overview when viewing the evolution of a particular topic branch, because merges into a topic branch tend to be only about adjusting to updated upstream from time to time, and this option allows you to ignore the individual commits brought in to your history by such a merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---exclude-first-parent-only"> --exclude-first-parent-only </dt> <dd> <p>When finding commits to exclude (with a <code>^</code>), follow only the first parent commit upon seeing a merge commit. This can be used to find the set of changes in a topic branch from the point where it diverged from the remote branch, given that arbitrary merges can be valid topic branch changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---not"> --not </dt> <dd> <p>Reverses the meaning of the <code>^</code> prefix (or lack thereof) for all following revision specifiers, up to the next <code>--not</code>. When used on the command line before --stdin, the revisions passed through stdin will not be affected by it. Conversely, when passed via standard input, the revisions passed on the command line will not be affected by it.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---all"> --all </dt> <dd> <p>Pretend as if all the refs in <code>refs/</code>, along with <code>HEAD</code>, are listed on the command line as <code><commit></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---branchesltpatterngt"> --branches[=<pattern>] </dt> <dd> <p>Pretend as if all the refs in <code>refs/heads</code> are listed on the command line as <code><commit></code>. If <code><pattern></code> is given, limit branches to ones matching given shell glob. If pattern lacks <code>?</code>, <code>*</code>, or <code>[</code>, <code>/*</code> at the end is implied.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---tagsltpatterngt"> --tags[=<pattern>] </dt> <dd> <p>Pretend as if all the refs in <code>refs/tags</code> are listed on the command line as <code><commit></code>. If <code><pattern></code> is given, limit tags to ones matching given shell glob. If pattern lacks <code>?</code>, <code>*</code>, or <code>[</code>, <code>/*</code> at the end is implied.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---remotesltpatterngt"> --remotes[=<pattern>] </dt> <dd> <p>Pretend as if all the refs in <code>refs/remotes</code> are listed on the command line as <code><commit></code>. If <code><pattern></code> is given, limit remote-tracking branches to ones matching given shell glob. If pattern lacks <code>?</code>, <code>*</code>, or <code>[</code>, <code>/*</code> at the end is implied.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---globltglob-patterngt"> --glob=<glob-pattern> </dt> <dd> <p>Pretend as if all the refs matching shell glob <code><glob-pattern></code> are listed on the command line as <code><commit></code>. Leading <code>refs/</code>, is automatically prepended if missing. If pattern lacks <code>?</code>, <code>*</code>, or <code>[</code>, <code>/*</code> at the end is implied.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---excludeltglob-patterngt"> --exclude=<glob-pattern> </dt> <dd> <p>Do not include refs matching <code><glob-pattern></code> that the next <code>--all</code>, <code>--branches</code>, <code>--tags</code>, <code>--remotes</code>, or <code>--glob</code> would otherwise consider. Repetitions of this option accumulate exclusion patterns up to the next <code>--all</code>, <code>--branches</code>, <code>--tags</code>, <code>--remotes</code>, or <code>--glob</code> option (other options or arguments do not clear accumulated patterns).</p> <p>The patterns given should not begin with <code>refs/heads</code>, <code>refs/tags</code>, or <code>refs/remotes</code> when applied to <code>--branches</code>, <code>--tags</code>, or <code>--remotes</code>, respectively, and they must begin with <code>refs/</code> when applied to <code>--glob</code> or <code>--all</code>. If a trailing <code>/*</code> is intended, it must be given explicitly.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---exclude-hiddenfetchreceiveuploadpack"> --exclude-hidden=[fetch|receive|uploadpack] </dt> <dd> <p>Do not include refs that would be hidden by <code>git-fetch</code>, <code>git-receive-pack</code> or <code>git-upload-pack</code> by consulting the appropriate <code>fetch.hideRefs</code>, <code>receive.hideRefs</code> or <code>uploadpack.hideRefs</code> configuration along with <code>transfer.hideRefs</code> (see <a href="git-config">git-config[1]</a>). This option affects the next pseudo-ref option <code>--all</code> or <code>--glob</code> and is cleared after processing them.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---reflog"> --reflog </dt> <dd> <p>Pretend as if all objects mentioned by reflogs are listed on the command line as <code><commit></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---alternate-refs"> --alternate-refs </dt> <dd> <p>Pretend as if all objects mentioned as ref tips of alternate repositories were listed on the command line. An alternate repository is any repository whose object directory is specified in <code>objects/info/alternates</code>. The set of included objects may be modified by <code>core.alternateRefsCommand</code>, etc. See <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---single-worktree"> --single-worktree </dt> <dd> <p>By default, all working trees will be examined by the following options when there are more than one (see <a href="git-worktree">git-worktree[1]</a>): <code>--all</code>, <code>--reflog</code> and <code>--indexed-objects</code>. This option forces them to examine the current working tree only.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---ignore-missing"> --ignore-missing </dt> <dd> <p>Upon seeing an invalid object name in the input, pretend as if the bad input was not given.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---bisect"> --bisect </dt> <dd> <p>Pretend as if the bad bisection ref <code>refs/bisect/bad</code> was listed and as if it was followed by <code>--not</code> and the good bisection refs <code>refs/bisect/good-*</code> on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---stdin"> --stdin </dt> <dd> <p>In addition to getting arguments from the command line, read them from standard input as well. This accepts commits and pseudo-options like <code>--all</code> and <code>--glob=</code>. When a <code>--</code> separator is seen, the following input is treated as paths and used to limit the result. Flags like <code>--not</code> which are read via standard input are only respected for arguments passed in the same way and will not influence any subsequent command line arguments.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---cherry-mark"> --cherry-mark </dt> <dd> <p>Like <code>--cherry-pick</code> (see below) but mark equivalent commits with <code>=</code> rather than omitting them, and inequivalent ones with <code>+</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---cherry-pick"> --cherry-pick </dt> <dd> <p>Omit any commit that introduces the same change as another commit on the “other side” when the set of commits are limited with symmetric difference.</p> <p>For example, if you have two branches, <code>A</code> and <code>B</code>, a usual way to list all commits on only one side of them is with <code>--left-right</code> (see the example below in the description of the <code>--left-right</code> option). However, it shows the commits that were cherry-picked from the other branch (for example, “3rd on b” may be cherry-picked from branch A). With this option, such pairs of commits are excluded from the output.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---left-only"> --left-only </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---right-only"> --right-only </dt> <dd> <p>List only commits on the respective side of a symmetric difference, i.e. only those which would be marked <code><</code> resp. <code>></code> by <code>--left-right</code>.</p> <p>For example, <code>--cherry-pick --right-only A...B</code> omits those commits from <code>B</code> which are in <code>A</code> or are patch-equivalent to a commit in <code>A</code>. In other words, this lists the <code>+</code> commits from <code>git cherry A B</code>. More precisely, <code>--cherry-pick --right-only --no-merges</code> gives the exact list.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---cherry"> --cherry </dt> <dd> <p>A synonym for <code>--right-only --cherry-mark --no-merges</code>; useful to limit the output to the commits on our side and mark those that have been applied to the other side of a forked history with <code>git log --cherry upstream...mybranch</code>, similar to <code>git cherry upstream mybranch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt--g"> -g </dt> <dt class="hdlist1" id="Documentation/git-shortlog.txt---walk-reflogs"> --walk-reflogs </dt> <dd> <p>Instead of walking the commit ancestry chain, walk reflog entries from the most recent one to older ones. When this option is used you cannot specify commits to exclude (that is, <code>^commit</code>, <code>commit1..commit2</code>, and <code>commit1...commit2</code> notations cannot be used).</p> <p>With <code>--pretty</code> format other than <code>oneline</code> and <code>reference</code> (for obvious reasons), this causes the output to have two extra lines of information taken from the reflog. The reflog designator in the output may be shown as <code>ref@{Nth}</code> (where <code>Nth</code> is the reverse-chronological index in the reflog) or as <code>ref@{timestamp}</code> (with the timestamp for that entry), depending on a few rules:</p> <div class="openblock"> <div class="content"> <div class="olist arabic"> <ol class="arabic"> <li> <p>If the starting point is specified as <code>ref@{Nth}</code>, show the index format.</p> </li> <li> <p>If the starting point was specified as <code>ref@{now}</code>, show the timestamp format.</p> </li> <li> <p>If neither was used, but <code>--date</code> was given on the command line, show the timestamp in the format requested by <code>--date</code>.</p> </li> <li> <p>Otherwise, show the index format.</p> </li> </ol> </div> </div> </div> <p>Under <code>--pretty=oneline</code>, the commit message is prefixed with this information on the same line. This option cannot be combined with <code>--reverse</code>. See also <a href="git-reflog">git-reflog[1]</a>.</p> <p>Under <code>--pretty=reference</code>, this information will not be shown at all.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---merge"> --merge </dt> <dd> <p>After a failed merge, show refs that touch files having a conflict and don’t exist on all heads to merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---boundary"> --boundary </dt> <dd> <p>Output excluded boundary commits. Boundary commits are prefixed with <code>-</code>.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_history_simplification"> +History Simplification</h3> <p>Sometimes you are only interested in parts of the history, for example the commits modifying a particular <path>. But there are two parts of <code>History Simplification</code>, one part is selecting the commits and the other is how to do it, as there are various strategies to simplify the history.</p> <p>The following options select the commits to be shown:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-shortlog.txt-ltpathsgt"> <paths> </dt> <dd> <p>Commits modifying the given <paths> are selected.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---simplify-by-decoration"> --simplify-by-decoration </dt> <dd> <p>Commits that are referred by some branch or tag are selected.</p> </dd> </dl> </div> <p>Note that extra commits can be shown to give a meaningful history.</p> <p>The following options affect the way the simplification is performed:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-shortlog.txt-Defaultmode"> Default mode </dt> <dd> <p>Simplifies the history to the simplest history explaining the final state of the tree. Simplest because it prunes some side branches if the end result is the same (i.e. merging branches with the same content)</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---show-pulls"> --show-pulls </dt> <dd> <p>Include all commits from the default mode, but also any merge commits that are not TREESAME to the first parent but are TREESAME to a later parent. This mode is helpful for showing the merge commits that "first introduced" a change to a branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---full-history"> --full-history </dt> <dd> <p>Same as the default mode, but does not prune some history.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---dense"> --dense </dt> <dd> <p>Only the selected commits are shown, plus some to have a meaningful history.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---sparse"> --sparse </dt> <dd> <p>All commits in the simplified history are shown.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---simplify-merges"> --simplify-merges </dt> <dd> <p>Additional option to <code>--full-history</code> to remove some needless merges from the resulting history, as there are no selected commits contributing to this merge.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---ancestry-pathltcommitgt"> --ancestry-path[=<commit>] </dt> <dd> <p>When given a range of commits to display (e.g. <code>commit1..commit2</code> or <code>commit2 ^commit1</code>), only display commits in that range that are ancestors of <commit>, descendants of <commit>, or <commit> itself. If no commit is specified, use <code>commit1</code> (the excluded part of the range) as <commit>. Can be passed multiple times; if so, a commit is included if it is any of the commits given or if it is an ancestor or descendant of one of them.</p> </dd> </dl> </div> <p>A more detailed explanation follows.</p> <p>Suppose you specified <code>foo</code> as the <paths>. We shall call commits that modify <code>foo</code> !TREESAME, and the rest TREESAME. (In a diff filtered for <code>foo</code>, they look different and equal, respectively.)</p> <p>In the following, we will always refer to the same example history to illustrate the differences between simplification settings. We assume that you are filtering for a file <code>foo</code> in this commit graph:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M---N---O---P---Q + / / / / / / + I B C D E Y + \ / / / / / + `-------------' X</pre> </div> </div> <p>The horizontal line of history A---Q is taken to be the first parent of each merge. The commits are:</p> <div class="ulist"> <ul> <li> <p><code>I</code> is the initial commit, in which <code>foo</code> exists with contents “asdf”, and a file <code>quux</code> exists with contents “quux”. Initial commits are compared to an empty tree, so <code>I</code> is !TREESAME.</p> </li> <li> <p>In <code>A</code>, <code>foo</code> contains just “foo”.</p> </li> <li> <p><code>B</code> contains the same change as <code>A</code>. Its merge <code>M</code> is trivial and hence TREESAME to all parents.</p> </li> <li> <p><code>C</code> does not change <code>foo</code>, but its merge <code>N</code> changes it to “foobar”, so it is not TREESAME to any parent.</p> </li> <li> <p><code>D</code> sets <code>foo</code> to “baz”. Its merge <code>O</code> combines the strings from <code>N</code> and <code>D</code> to “foobarbaz”; i.e., it is not TREESAME to any parent.</p> </li> <li> <p><code>E</code> changes <code>quux</code> to “xyzzy”, and its merge <code>P</code> combines the strings to “quux xyzzy”. <code>P</code> is TREESAME to <code>O</code>, but not to <code>E</code>.</p> </li> <li> <p><code>X</code> is an independent root commit that added a new file <code>side</code>, and <code>Y</code> modified it. <code>Y</code> is TREESAME to <code>X</code>. Its merge <code>Q</code> added <code>side</code> to <code>P</code>, and <code>Q</code> is TREESAME to <code>P</code>, but not to <code>Y</code>.</p> </li> </ul> </div> <p><code>rev-list</code> walks backwards through history, including or excluding commits based on whether <code>--full-history</code> and/or parent rewriting (via <code>--parents</code> or <code>--children</code>) are used. The following settings are available.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-shortlog.txt-Defaultmode-1"> Default mode </dt> <dd> <p>Commits are included if they are not TREESAME to any parent (though this can be changed, see <code>--sparse</code> below). If the commit was a merge, and it was TREESAME to one parent, follow only that parent. (Even if there are several TREESAME parents, follow only one of them.) Otherwise, follow all parents.</p> <p>This results in:</p> <div class="listingblock"> <div class="content"> <pre> .-A---N---O + / / / + I---------D</pre> </div> </div> <p>Note how the rule to only follow the TREESAME parent, if one is available, removed <code>B</code> from consideration entirely. <code>C</code> was considered via <code>N</code>, but is TREESAME. Root commits are compared to an empty tree, so <code>I</code> is !TREESAME.</p> <p>Parent/child relations are only visible with <code>--parents</code>, but that does not affect the commits selected in default mode, so we have shown the parent lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---full-historywithoutparentrewriting"> --full-history without parent rewriting </dt> <dd> <p>This mode differs from the default in one point: always follow all parents of a merge, even if it is TREESAME to one of them. Even if more than one side of the merge has commits that are included, this does not imply that the merge itself is! In the example, we get</p> <div class="listingblock"> <div class="content"> <pre> I A B N D O P Q</pre> </div> </div> <p><code>M</code> was excluded because it is TREESAME to both parents. <code>E</code>, <code>C</code> and <code>B</code> were all walked, but only <code>B</code> was !TREESAME, so the others do not appear.</p> <p>Note that without parent rewriting, it is not really possible to talk about the parent/child relationships between the commits, so we show them disconnected.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---full-historywithparentrewriting"> --full-history with parent rewriting </dt> <dd> <p>Ordinary commits are only included if they are !TREESAME (though this can be changed, see <code>--sparse</code> below).</p> <p>Merges are always included. However, their parent list is rewritten: Along each parent, prune away commits that are not included themselves. This results in</p> <div class="listingblock"> <div class="content"> <pre> .-A---M---N---O---P---Q + / / / / / + I B / D / + \ / / / / + `-------------'</pre> </div> </div> <p>Compare to <code>--full-history</code> without rewriting above. Note that <code>E</code> was pruned away because it is TREESAME, but the parent list of P was rewritten to contain <code>E</code>'s parent <code>I</code>. The same happened for <code>C</code> and <code>N</code>, and <code>X</code>, <code>Y</code> and <code>Q</code>.</p> </dd> </dl> </div> <p>In addition to the above settings, you can change whether TREESAME affects inclusion:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-shortlog.txt---dense-1"> --dense </dt> <dd> <p>Commits that are walked are included if they are not TREESAME to any parent.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---sparse-1"> --sparse </dt> <dd> <p>All commits that are walked are included.</p> <p>Note that without <code>--full-history</code>, this still simplifies merges: if one of the parents is TREESAME, we follow only that one, so the other sides of the merge are never walked.</p> </dd> <dt class="hdlist1" id="Documentation/git-shortlog.txt---simplify-merges-1"> --simplify-merges </dt> <dd> <p>First, build a history graph in the same way that <code>--full-history</code> with parent rewriting does (see above).</p> <p>Then simplify each commit <code>C</code> to its replacement <code>C'</code> in the final history according to the following rules:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>Set <code>C'</code> to <code>C</code>.</p> </li> <li> <p>Replace each parent <code>P</code> of <code>C'</code> with its simplification <code>P'</code>. In the process, drop parents that are ancestors of other parents or that are root commits TREESAME to an empty tree, and remove duplicates, but take care to never drop all parents that we are TREESAME to.</p> </li> <li> <p>If after this parent rewriting, <code>C'</code> is a root or merge commit (has zero or >1 parents), a boundary commit, or !TREESAME, it remains. Otherwise, it is replaced with its only parent.</p> </li> </ul> </div> </div> </div> <p>The effect of this is best shown by way of comparing to <code>--full-history</code> with parent rewriting. The example turns into:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M---N---O + / / / + I B D + \ / / + `---------'</pre> </div> </div> <p>Note the major differences in <code>N</code>, <code>P</code>, and <code>Q</code> over <code>--full-history</code>:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p><code>N</code>'s parent list had <code>I</code> removed, because it is an ancestor of the other parent <code>M</code>. Still, <code>N</code> remained because it is !TREESAME.</p> </li> <li> <p><code>P</code>'s parent list similarly had <code>I</code> removed. <code>P</code> was then removed completely, because it had one parent and is TREESAME.</p> </li> <li> <p><code>Q</code>'s parent list had <code>Y</code> simplified to <code>X</code>. <code>X</code> was then removed, because it was a TREESAME root. <code>Q</code> was then removed completely, because it had one parent and is TREESAME.</p> </li> </ul> </div> </div> </div> </dd> </dl> </div> <p>There is another simplification mode available:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-shortlog.txt---ancestry-pathltcommitgt-1"> --ancestry-path[=<commit>] </dt> <dd> <p>Limit the displayed commits to those which are an ancestor of <commit>, or which are a descendant of <commit>, or are <commit> itself.</p> <p>As an example use case, consider the following commit history:</p> <div class="listingblock"> <div class="content"> <pre> D---E-------F + / \ \ + B---C---G---H---I---J + / \ + A-------K---------------L--M</pre> </div> </div> <p>A regular <code>D..M</code> computes the set of commits that are ancestors of <code>M</code>, but excludes the ones that are ancestors of <code>D</code>. This is useful to see what happened to the history leading to <code>M</code> since <code>D</code>, in the sense that “what does <code>M</code> have that did not exist in <code>D</code>”. The result in this example would be all the commits, except <code>A</code> and <code>B</code> (and <code>D</code> itself, of course).</p> <p>When we want to find out what commits in <code>M</code> are contaminated with the bug introduced by <code>D</code> and need fixing, however, we might want to view only the subset of <code>D..M</code> that are actually descendants of <code>D</code>, i.e. excluding <code>C</code> and <code>K</code>. This is exactly what the <code>--ancestry-path</code> option does. Applied to the <code>D..M</code> range, it results in:</p> <div class="listingblock"> <div class="content"> <pre> E-------F + \ \ + G---H---I---J + \ + L--M</pre> </div> </div> <p>We can also use <code>--ancestry-path=D</code> instead of <code>--ancestry-path</code> which means the same thing when applied to the <code>D..M</code> range but is just more explicit.</p> <p>If we instead are interested in a given topic within this range, and all commits affected by that topic, we may only want to view the subset of <code>D..M</code> which contain that topic in their ancestry path. So, using <code>--ancestry-path=H D..M</code> for example would result in:</p> <div class="listingblock"> <div class="content"> <pre> E + \ + G---H---I---J + \ + L--M</pre> </div> </div> <p>Whereas <code>--ancestry-path=K D..M</code> would result in</p> <div class="listingblock"> <div class="content"> <pre> K---------------L--M</pre> </div> </div> </dd> </dl> </div> <p>Before discussing another option, <code>--show-pulls</code>, we need to create a new example history.</p> <p>A common problem users face when looking at simplified history is that a commit they know changed a file somehow does not appear in the file’s simplified history. Let’s demonstrate a new example and show how options such as <code>--full-history</code> and <code>--simplify-merges</code> works in that case:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M-----C--N---O---P + / / \ \ \/ / / + I B \ R-'`-Z' / + \ / \/ / + \ / /\ / + `---X--' `---Y--'</pre> </div> </div> <p>For this example, suppose <code>I</code> created <code>file.txt</code> which was modified by <code>A</code>, <code>B</code>, and <code>X</code> in different ways. The single-parent commits <code>C</code>, <code>Z</code>, and <code>Y</code> do not change <code>file.txt</code>. The merge commit <code>M</code> was created by resolving the merge conflict to include both changes from <code>A</code> and <code>B</code> and hence is not TREESAME to either. The merge commit <code>R</code>, however, was created by ignoring the contents of <code>file.txt</code> at <code>M</code> and taking only the contents of <code>file.txt</code> at <code>X</code>. Hence, <code>R</code> is TREESAME to <code>X</code> but not <code>M</code>. Finally, the natural merge resolution to create <code>N</code> is to take the contents of <code>file.txt</code> at <code>R</code>, so <code>N</code> is TREESAME to <code>R</code> but not <code>C</code>. The merge commits <code>O</code> and <code>P</code> are TREESAME to their first parents, but not to their second parents, <code>Z</code> and <code>Y</code> respectively.</p> <p>When using the default mode, <code>N</code> and <code>R</code> both have a TREESAME parent, so those edges are walked and the others are ignored. The resulting history graph is:</p> <div class="listingblock"> <div class="content"> <pre> I---X</pre> </div> </div> <p>When using <code>--full-history</code>, Git walks every edge. This will discover the commits <code>A</code> and <code>B</code> and the merge <code>M</code>, but also will reveal the merge commits <code>O</code> and <code>P</code>. With parent rewriting, the resulting graph is:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M--------N---O---P + / / \ \ \/ / / + I B \ R-'`--' / + \ / \/ / + \ / /\ / + `---X--' `------'</pre> </div> </div> <p>Here, the merge commits <code>O</code> and <code>P</code> contribute extra noise, as they did not actually contribute a change to <code>file.txt</code>. They only merged a topic that was based on an older version of <code>file.txt</code>. This is a common issue in repositories using a workflow where many contributors work in parallel and merge their topic branches along a single trunk: many unrelated merges appear in the <code>--full-history</code> results.</p> <p>When using the <code>--simplify-merges</code> option, the commits <code>O</code> and <code>P</code> disappear from the results. This is because the rewritten second parents of <code>O</code> and <code>P</code> are reachable from their first parents. Those edges are removed and then the commits look like single-parent commits that are TREESAME to their parent. This also happens to the commit <code>N</code>, resulting in a history view as follows:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M--. + / / \ + I B R + \ / / + \ / / + `---X--'</pre> </div> </div> <p>In this view, we see all of the important single-parent changes from <code>A</code>, <code>B</code>, and <code>X</code>. We also see the carefully-resolved merge <code>M</code> and the not-so-carefully-resolved merge <code>R</code>. This is usually enough information to determine why the commits <code>A</code> and <code>B</code> "disappeared" from history in the default view. However, there are a few issues with this approach.</p> <p>The first issue is performance. Unlike any previous option, the <code>--simplify-merges</code> option requires walking the entire commit history before returning a single result. This can make the option difficult to use for very large repositories.</p> <p>The second issue is one of auditing. When many contributors are working on the same repository, it is important which merge commits introduced a change into an important branch. The problematic merge <code>R</code> above is not likely to be the merge commit that was used to merge into an important branch. Instead, the merge <code>N</code> was used to merge <code>R</code> and <code>X</code> into the important branch. This commit may have information about why the change <code>X</code> came to override the changes from <code>A</code> and <code>B</code> in its commit message.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-shortlog.txt---show-pulls-1"> --show-pulls </dt> <dd> <p>In addition to the commits shown in the default history, show each merge commit that is not TREESAME to its first parent but is TREESAME to a later parent.</p> <p>When a merge commit is included by <code>--show-pulls</code>, the merge is treated as if it "pulled" the change from another branch. When using <code>--show-pulls</code> on this example (and no other options) the resulting graph is:</p> <div class="listingblock"> <div class="content"> <pre> I---X---R---N</pre> </div> </div> <p>Here, the merge commits <code>R</code> and <code>N</code> are included because they pulled the commits <code>X</code> and <code>R</code> into the base branch, respectively. These merges are the reason the commits <code>A</code> and <code>B</code> do not appear in the default history.</p> <p>When <code>--show-pulls</code> is paired with <code>--simplify-merges</code>, the graph includes all of the necessary information:</p> <div class="listingblock"> <div class="content"> <pre> .-A---M--. N + / / \ / + I B R + \ / / + \ / / + `---X--'</pre> </div> </div> <p>Notice that since <code>M</code> is reachable from <code>R</code>, the edge from <code>N</code> to <code>M</code> was simplified away. However, <code>N</code> still appears in the history as an important commit because it "pulled" the change <code>R</code> into the main branch.</p> </dd> </dl> </div> <p>The <code>--simplify-by-decoration</code> option allows you to view only the big picture of the topology of the history, by omitting commits that are not referenced by tags. Commits are marked as !TREESAME (in other words, kept after history simplification rules described above) if (1) they are referenced by tags, or (2) they change the contents of the paths given on the command line. All other commits are marked as TREESAME (subject to be simplified away).</p> </div> </div> <h2 id="_mapping_authors">Mapping authors</h2> <div class="sectionbody"> <p>See <a href="gitmailmap">gitmailmap[5]</a>.</p> <p>Note that if <code>git shortlog</code> is run outside of a repository (to process log contents on standard input), it will look for a <code>.mailmap</code> file in the current directory.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-shortlog" class="_attribution-link">https://git-scm.com/docs/git-shortlog</a> + </p> +</div> diff --git a/devdocs/git/git-show-branch.html b/devdocs/git/git-show-branch.html new file mode 100644 index 00000000..4e0cdd55 --- /dev/null +++ b/devdocs/git/git-show-branch.html @@ -0,0 +1,28 @@ +<h1>git-show-branch</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-show-branch - Show branches and their commits</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git show-branch [-a | --all] [-r | --remotes] [--topo-order | --date-order] + [--current] [--color[=<when>] | --no-color] [--sparse] + [--more=<n> | --list | --independent | --merge-base] + [--no-name | --sha1-name] [--topics] + [(<rev> | <glob>)…] +git show-branch (-g | --reflog)[=<n>[,<base>]] [--list] [<ref>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Shows the commit ancestry graph starting from the commits named with <rev>s or <glob>s (or all refs under refs/heads and/or refs/tags) semi-visually.</p> <p>It cannot show more than 29 branches and commits at a time.</p> <p>It uses <code>showbranch.default</code> multi-valued configuration items if no <rev> or <glob> is given on the command line.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show-branch.txt-ltrevgt"> <rev> </dt> <dd> <p>Arbitrary extended SHA-1 expression (see <a href="gitrevisions">gitrevisions[7]</a>) that typically names a branch head or a tag.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt-ltglobgt"> <glob> </dt> <dd> <p>A glob pattern that matches branch or tag names under refs/. For example, if you have many topic branches under refs/heads/topic, giving <code>topic/*</code> would show all of them.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt--r"> -r </dt> <dt class="hdlist1" id="Documentation/git-show-branch.txt---remotes"> --remotes </dt> <dd> <p>Show the remote-tracking branches.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-show-branch.txt---all"> --all </dt> <dd> <p>Show both remote-tracking branches and local branches.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt---current"> --current </dt> <dd> <p>With this option, the command includes the current branch in the list of revs to be shown when it is not given on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt---topo-order"> --topo-order </dt> <dd> <p>By default, the branches and their commits are shown in reverse chronological order. This option makes them appear in topological order (i.e., descendant commits are shown before their parents).</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt---date-order"> --date-order </dt> <dd> <p>This option is similar to <code>--topo-order</code> in the sense that no parent comes before all of its children, but otherwise commits are ordered according to their commit date.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt---sparse"> --sparse </dt> <dd> <p>By default, the output omits merges that are reachable from only one tip being shown. This option makes them visible.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt---moreltngt"> --more=<n> </dt> <dd> <p>Usually the command stops output upon showing the commit that is the common ancestor of all the branches. This flag tells the command to go <n> more common commits beyond that. When <n> is negative, display only the <ref>s given, without showing the commit ancestry tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt---list"> --list </dt> <dd> <p>Synonym to <code>--more=-1</code></p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt---merge-base"> --merge-base </dt> <dd> <p>Instead of showing the commit list, determine possible merge bases for the specified commits. All merge bases will be contained in all specified commits. This is different from how <a href="git-merge-base">git-merge-base[1]</a> handles the case of three or more commits.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt---independent"> --independent </dt> <dd> <p>Among the <ref>s given, display only the ones that cannot be reached from any other <ref>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt---no-name"> --no-name </dt> <dd> <p>Do not show naming strings for each commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt---sha1-name"> --sha1-name </dt> <dd> <p>Instead of naming the commits using the path to reach them from heads (e.g. "master~2" to mean the grandparent of "master"), name them with the unique prefix of their object names.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt---topics"> --topics </dt> <dd> <p>Shows only commits that are NOT on the first branch given. This helps track topic branches by hiding any commit that is already in the main line of development. When given "git show-branch --topics master topic1 topic2", this will show the revisions given by "git rev-list ^master topic1 topic2"</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt--g"> -g </dt> <dt class="hdlist1" id="Documentation/git-show-branch.txt---reflogltngtltbasegtltrefgt"> --reflog[=<n>[,<base>]] [<ref>] </dt> <dd> <p>Shows <n> most recent ref-log entries for the given ref. If <base> is given, <n> entries going back from that entry. <base> can be specified as count or date. When no explicit <ref> parameter is given, it defaults to the current branch (or <code>HEAD</code> if it is detached).</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt---colorltwhengt"> --color[=<when>] </dt> <dd> <p>Color the status sign (one of these: <code>*</code> <code>!</code> <code>+</code> <code>-</code>) of each commit corresponding to the branch it’s in. The value must be always (the default), never, or auto.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-branch.txt---no-color"> --no-color </dt> <dd> <p>Turn off colored output, even when the configuration file gives the default to color output. Same as <code>--color=never</code>.</p> </dd> </dl> </div> <p>Note that --more, --list, --independent, and --merge-base options are mutually exclusive.</p> </div> <h2 id="_output">Output</h2> <div class="sectionbody"> <p>Given N <ref>s, the first N lines are the one-line description from their commit message. The branch head that is pointed at by $GIT_DIR/HEAD is prefixed with an asterisk <code>*</code> character while other heads are prefixed with a <code>!</code> character.</p> <p>Following these N lines, a one-line log for each commit is displayed, indented N places. If a commit is on the I-th branch, the I-th indentation character shows a <code>+</code> sign; otherwise it shows a space. Merge commits are denoted by a <code>-</code> sign. Each commit shows a short name that can be used as an extended SHA-1 to name that commit.</p> <p>The following example shows three branches, "master", "fixes", and "mhf":</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show-branch master fixes mhf +* [master] Add 'git show-branch'. + ! [fixes] Introduce "reset type" flag to "git reset" + ! [mhf] Allow "+remote:local" refspec to cause --force when fetching. +--- + + [mhf] Allow "+remote:local" refspec to cause --force when fetching. + + [mhf~1] Use git-octopus when pulling more than one head. + + [fixes] Introduce "reset type" flag to "git reset" + + [mhf~2] "git fetch --force". + + [mhf~3] Use .git/remote/origin, not .git/branches/origin. + + [mhf~4] Make "git pull" and "git fetch" default to origin + + [mhf~5] Infamous 'octopus merge' + + [mhf~6] Retire git-parse-remote. + + [mhf~7] Multi-head fetch. + + [mhf~8] Start adding the $GIT_DIR/remotes/ support. +*++ [master] Add 'git show-branch'.</pre> </div> </div> <p>These three branches all forked from a common commit, [master], whose commit message is "Add 'git show-branch'". The "fixes" branch adds one commit "Introduce "reset type" flag to "git reset"". The "mhf" branch adds many other commits. The current branch is "master".</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>If you keep your primary branches immediately under <code>refs/heads</code>, and topic branches in subdirectories of it, having the following in the configuration file may help:</p> <div class="listingblock"> <div class="content"> <pre>[showbranch] + default = --topo-order + default = heads/*</pre> </div> </div> <p>With this, <code>git show-branch</code> without extra parameters would show only the primary branches. In addition, if you happen to be on your topic branch, it is shown as well.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show-branch --reflog="10,1 hour ago" --list master</pre> </div> </div> <p>shows 10 reflog entries going back from the tip as of 1 hour ago. Without <code>--list</code>, the output also shows how these tips are topologically related to each other.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show-branch.txt-showBranchdefault"> showBranch.default </dt> <dd> <p>The default set of branches for <a href="git-show-branch">git-show-branch[1]</a>. See <a href="git-show-branch">git-show-branch[1]</a>.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-show-branch" class="_attribution-link">https://git-scm.com/docs/git-show-branch</a> + </p> +</div> diff --git a/devdocs/git/git-show-index.html b/devdocs/git/git-show-index.html new file mode 100644 index 00000000..05a92a14 --- /dev/null +++ b/devdocs/git/git-show-index.html @@ -0,0 +1,6 @@ +<h1>git-show-index</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-show-index - Show packed archive index</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git show-index [--object-format=<hash-algorithm>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Read the <code>.idx</code> file for a Git packfile (created with <a href="git-pack-objects">git-pack-objects[1]</a> or <a href="git-index-pack">git-index-pack[1]</a>) from the standard input, and dump its contents. The output consists of one object per line, with each line containing two or three space-separated columns:</p> <div class="ulist"> <ul> <li> <p>the first column is the offset in bytes of the object within the corresponding packfile</p> </li> <li> <p>the second column is the object id of the object</p> </li> <li> <p>if the index version is 2 or higher, the third column contains the CRC32 of the object data</p> </li> </ul> </div> <p>The objects are output in the order in which they are found in the index file, which should be (in a correctly constructed file) sorted by object id.</p> <p>Note that you can get more information on a packfile by calling <a href="git-verify-pack">git-verify-pack[1]</a>. However, as this command considers only the index file itself, it’s both faster and more flexible.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show-index.txt---object-formatlthash-algorithmgt"> --object-format=<hash-algorithm> </dt> <dd> <p>Specify the given object format (hash algorithm) for the index file. The valid values are <code>sha1</code> and (if enabled) <code>sha256</code>. The default is the algorithm for the current repository (set by <code>extensions.objectFormat</code>), or <code>sha1</code> if no value is set or outside a repository..</p> <p>Note: At present, there is no interoperability between SHA-256 repositories and SHA-1 repositories.</p> </dd> </dl> </div> <p>Historically, we warned that SHA-256 repositories may later need backward incompatible changes when we introduce such interoperability features. Today, we only expect compatible changes. Furthermore, if such changes prove to be necessary, it can be expected that SHA-256 repositories created with today’s Git will be usable by future versions of Git without data loss.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-show-index" class="_attribution-link">https://git-scm.com/docs/git-show-index</a> + </p> +</div> diff --git a/devdocs/git/git-show-ref.html b/devdocs/git/git-show-ref.html new file mode 100644 index 00000000..88952431 --- /dev/null +++ b/devdocs/git/git-show-ref.html @@ -0,0 +1,26 @@ +<h1>git-show-ref</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-show-ref - List references in a local repository</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git show-ref [--head] [-d | --dereference] + [-s | --hash[=<n>]] [--abbrev[=<n>]] [--tags] + [--heads] [--] [<pattern>…] +git show-ref --verify [-q | --quiet] [-d | --dereference] + [-s | --hash[=<n>]] [--abbrev[=<n>]] + [--] [<ref>…] +git show-ref --exclude-existing[=<pattern>] +git show-ref --exists <ref></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Displays references available in a local repository along with the associated commit IDs. Results can be filtered using a pattern and tags can be dereferenced into object IDs. Additionally, it can be used to test whether a particular ref exists.</p> <p>By default, shows the tags, heads, and remote refs.</p> <p>The <code>--exclude-existing</code> form is a filter that does the inverse. It reads refs from stdin, one ref per line, and shows those that don’t exist in the local repository.</p> <p>The <code>--exists</code> form can be used to check for the existence of a single references. This form does not verify whether the reference resolves to an actual object.</p> <p>Use of this utility is encouraged in favor of directly accessing files under the <code>.git</code> directory.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show-ref.txt---head"> --head </dt> <dd> <p>Show the HEAD reference, even if it would normally be filtered out.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt---heads"> --heads </dt> <dt class="hdlist1" id="Documentation/git-show-ref.txt---tags"> --tags </dt> <dd> <p>Limit to "refs/heads" and "refs/tags", respectively. These options are not mutually exclusive; when given both, references stored in "refs/heads" and "refs/tags" are displayed.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt--d"> -d </dt> <dt class="hdlist1" id="Documentation/git-show-ref.txt---dereference"> --dereference </dt> <dd> <p>Dereference tags into object IDs as well. They will be shown with <code>^{}</code> appended.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-show-ref.txt---hashltngt"> --hash[=<n>] </dt> <dd> <p>Only show the OID, not the reference name. When combined with <code>--dereference</code>, the dereferenced tag will still be shown after the OID.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt---verify"> --verify </dt> <dd> <p>Enable stricter reference checking by requiring an exact ref path. Aside from returning an error code of 1, it will also print an error message if <code>--quiet</code> was not specified.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt---exists"> --exists </dt> <dd> <p>Check whether the given reference exists. Returns an exit code of 0 if it does, 2 if it is missing, and 1 in case looking up the reference failed with an error other than the reference being missing.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt---abbrevltngt"> --abbrev[=<n>] </dt> <dd> <p>Abbreviate the object name. When using <code>--hash</code>, you do not have to say <code>--hash --abbrev</code>; <code>--hash=n</code> would do.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-show-ref.txt---quiet"> --quiet </dt> <dd> <p>Do not print any results to stdout. Can be used with <code>--verify</code> to silently check if a reference exists.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt---exclude-existingltpatterngt"> --exclude-existing[=<pattern>] </dt> <dd> <p>Make <code>git show-ref</code> act as a filter that reads refs from stdin of the form <code>^(?:<anything>\s)?<refname>(?:\^{})?$</code> and performs the following actions on each: (1) strip <code>^{}</code> at the end of line if any; (2) ignore if pattern is provided and does not head-match refname; (3) warn if refname is not a well-formed refname and skip; (4) ignore if refname is a ref that exists in the local repository; (5) otherwise output the line.</p> </dd> <dt class="hdlist1" id="Documentation/git-show-ref.txt-ltpatterngt82308203"> <pattern>… </dt> <dd> <p>Show references matching one or more patterns. Patterns are matched from the end of the full name, and only complete parts are matched, e.g. <code>master</code> matches <code>refs/heads/master</code>, <code>refs/remotes/origin/master</code>, <code>refs/tags/jedi/master</code> but not <code>refs/heads/mymaster</code> or <code>refs/remotes/master/jedi</code>.</p> </dd> </dl> </div> </div> <h2 id="_output">Output</h2> <div class="sectionbody"> <p>The output is in the format:</p> <div class="listingblock"> <div class="content"> <pre><oid> SP <ref> LF</pre> </div> </div> <p>For example,</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show-ref --head --dereference +832e76a9899f560a90ffd62ae2ce83bbeff58f54 HEAD +832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/master +832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/origin +3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c +6ddc0964034342519a87fe013781abf31c6db6ad refs/tags/v0.99.9c^{} +055e4ae3ae6eb344cbabf2a5256a49ea66040131 refs/tags/v1.0rc4 +423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{} +...</pre> </div> </div> <p>When using <code>--hash</code> (and not <code>--dereference</code>), the output is in the format:</p> <div class="listingblock"> <div class="content"> <pre><oid> LF</pre> </div> </div> <p>For example,</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show-ref --heads --hash +2e3ba0114a1f52b47df29743d6915d056be13278 +185008ae97960c8d551adcd9e23565194651b5d1 +03adf42c988195b50e1a1935ba5fcbc39b2b029b +...</pre> </div> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>To show all references called "master", whether tags or heads or anything else, and regardless of how deep in the reference naming hierarchy they are, use:</p> <div class="listingblock"> <div class="content"> <pre> git show-ref master</pre> </div> </div> <p>This will show "refs/heads/master" but also "refs/remote/other-repo/master", if such references exist.</p> <p>When using the <code>--verify</code> flag, the command requires an exact path:</p> <div class="listingblock"> <div class="content"> <pre> git show-ref --verify refs/heads/master</pre> </div> </div> <p>will only match the exact branch called "master".</p> <p>If nothing matches, <code>git show-ref</code> will return an error code of 1, and in the case of verification, it will show an error message.</p> <p>For scripting, you can ask it to be quiet with the <code>--quiet</code> flag, which allows you to do things like</p> <div class="listingblock"> <div class="content"> <pre> git show-ref --quiet --verify -- "refs/heads/$headname" || + echo "$headname is not a valid branch"</pre> </div> </div> <p>to check whether a particular branch exists or not (notice how we don’t actually want to show any results, and we want to use the full refname for it in order to not trigger the problem with ambiguous partial matches).</p> <p>To show only tags, or only proper branch heads, use <code>--tags</code> and/or <code>--heads</code> respectively (using both means that it shows tags and heads, but not other random references under the refs/ subdirectory).</p> <p>To do automatic tag object dereferencing, use the <code>-d</code> or <code>--dereference</code> flag, so you can do</p> <div class="listingblock"> <div class="content"> <pre> git show-ref --tags --dereference</pre> </div> </div> <p>to get a listing of all tags together with what they dereference.</p> </div> <h2 id="_files">Files</h2> <div class="sectionbody"> <p><code>.git/refs/*</code>, <code>.git/packed-refs</code></p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-for-each-ref">git-for-each-ref[1]</a>, <a href="git-ls-remote">git-ls-remote[1]</a>, <a href="git-update-ref">git-update-ref[1]</a>, <a href="gitrepository-layout">gitrepository-layout[5]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-show-ref" class="_attribution-link">https://git-scm.com/docs/git-show-ref</a> + </p> +</div> diff --git a/devdocs/git/git-show.html b/devdocs/git/git-show.html new file mode 100644 index 00000000..51e00a03 --- /dev/null +++ b/devdocs/git/git-show.html @@ -0,0 +1,82 @@ +<h1>git-show</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-show - Show various types of objects</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git show [<options>] [<object>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Shows one or more objects (blobs, trees, tags and commits).</p> <p>For commits it shows the log message and textual diff. It also presents the merge commit in a special format as produced by <code>git diff-tree --cc</code>.</p> <p>For tags, it shows the tag message and the referenced objects.</p> <p>For trees, it shows the names (equivalent to <code>git ls-tree</code> with --name-only).</p> <p>For plain blobs, it shows the plain contents.</p> <p>Some options that <code>git log</code> command understands can be used to control how the changes the commit introduces are shown.</p> <p>This manual page describes only the most frequently used options.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show.txt-ltobjectgt82308203"> <object>… </dt> <dd> <p>The names of objects to show (defaults to <code>HEAD</code>). For a more complete list of ways to spell object names, see "SPECIFYING REVISIONS" section in <a href="gitrevisions">gitrevisions[7]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---prettyltformatgt"> --pretty[=<format>] </dt> <dt class="hdlist1" id="Documentation/git-show.txt---formatltformatgt"> --format=<format> </dt> <dd> <p>Pretty-print the contents of the commit logs in a given format, where <code><format></code> can be one of <code>oneline</code>, <code>short</code>, <code>medium</code>, <code>full</code>, <code>fuller</code>, <code>reference</code>, <code>email</code>, <code>raw</code>, <code>format:<string></code> and <code>tformat:<string></code>. When <code><format></code> is none of the above, and has <code>%placeholder</code> in it, it acts as if <code>--pretty=tformat:<format></code> were given.</p> <p>See the "PRETTY FORMATS" section for some additional details for each format. When <code>=<format></code> part is omitted, it defaults to <code>medium</code>.</p> <p>Note: you can specify the default pretty format in the repository configuration (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---abbrev-commit"> --abbrev-commit </dt> <dd> <p>Instead of showing the full 40-byte hexadecimal commit object name, show a prefix that names the object uniquely. "--abbrev=<n>" (which also modifies diff output, if it is displayed) option can be used to specify the minimum length of the prefix.</p> <p>This should make "--pretty=oneline" a whole lot more readable for people using 80-column terminals.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---no-abbrev-commit"> --no-abbrev-commit </dt> <dd> <p>Show the full 40-byte hexadecimal commit object name. This negates <code>--abbrev-commit</code>, either explicit or implied by other options such as "--oneline". It also overrides the <code>log.abbrevCommit</code> variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---oneline"> --oneline </dt> <dd> <p>This is a shorthand for "--pretty=oneline --abbrev-commit" used together.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---encodingltencodinggt"> --encoding=<encoding> </dt> <dd> <p>Commit objects record the character encoding used for the log message in their encoding header; this option can be used to tell the command to re-code the commit log message in the encoding preferred by the user. For non plumbing commands this defaults to UTF-8. Note that if an object claims to be encoded in <code>X</code> and we are outputting in <code>X</code>, we will output the object verbatim; this means that invalid sequences in the original commit may be copied to the output. Likewise, if iconv(3) fails to convert the commit, we will quietly output the original object verbatim.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---expand-tabsltngt"> --expand-tabs=<n> </dt> <dt class="hdlist1" id="Documentation/git-show.txt---expand-tabs"> --expand-tabs </dt> <dt class="hdlist1" id="Documentation/git-show.txt---no-expand-tabs"> --no-expand-tabs </dt> <dd> <p>Perform a tab expansion (replace each tab with enough spaces to fill to the next display column that is a multiple of <code><n></code>) in the log message before showing it in the output. <code>--expand-tabs</code> is a short-hand for <code>--expand-tabs=8</code>, and <code>--no-expand-tabs</code> is a short-hand for <code>--expand-tabs=0</code>, which disables tab expansion.</p> <p>By default, tabs are expanded in pretty formats that indent the log message by 4 spaces (i.e. <code>medium</code>, which is the default, <code>full</code>, and <code>fuller</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---notesltrefgt"> --notes[=<ref>] </dt> <dd> <p>Show the notes (see <a href="git-notes">git-notes[1]</a>) that annotate the commit, when showing the commit log message. This is the default for <code>git log</code>, <code>git show</code> and <code>git whatchanged</code> commands when there is no <code>--pretty</code>, <code>--format</code>, or <code>--oneline</code> option given on the command line.</p> <p>By default, the notes shown are from the notes refs listed in the <code>core.notesRef</code> and <code>notes.displayRef</code> variables (or corresponding environment overrides). See <a href="git-config">git-config[1]</a> for more details.</p> <p>With an optional <code><ref></code> argument, use the ref to find the notes to display. The ref can specify the full refname when it begins with <code>refs/notes/</code>; when it begins with <code>notes/</code>, <code>refs/</code> and otherwise <code>refs/notes/</code> is prefixed to form the full name of the ref.</p> <p>Multiple --notes options can be combined to control which notes are being displayed. Examples: "--notes=foo" will show only notes from "refs/notes/foo"; "--notes=foo --notes" will show both notes from "refs/notes/foo" and from the default notes ref(s).</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---no-notes"> --no-notes </dt> <dd> <p>Do not show notes. This negates the above <code>--notes</code> option, by resetting the list of notes refs from which notes are shown. Options are parsed in the order given on the command line, so e.g. "--notes --notes=foo --no-notes --notes=bar" will only show notes from "refs/notes/bar".</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---show-notes-by-default"> --show-notes-by-default </dt> <dd> <p>Show the default notes unless options for displaying specific notes are given.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---show-notesltrefgt"> --show-notes[=<ref>] </dt> <dt class="hdlist1" id="Documentation/git-show.txt---no-standard-notes"> --[no-]standard-notes </dt> <dd> <p>These options are deprecated. Use the above --notes/--no-notes options instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---show-signature"> --show-signature </dt> <dd> <p>Check the validity of a signed commit object by passing the signature to <code>gpg --verify</code> and show the output.</p> </dd> </dl> </div> </div> <h2 id="_pretty_formats">Pretty formats</h2> <div class="sectionbody"> <p>If the commit is a merge, and if the pretty-format is not <code>oneline</code>, <code>email</code> or <code>raw</code>, an additional line is inserted before the <code>Author:</code> line. This line begins with "Merge: " and the hashes of ancestral commits are printed, separated by spaces. Note that the listed commits may not necessarily be the list of the <strong>direct</strong> parent commits if you have limited your view of history: for example, if you are only interested in changes related to a certain directory or file.</p> <p>There are several built-in formats, and you can define additional formats by setting a pretty.<name> config option to either another format name, or a <code>format:</code> string, as described below (see <a href="git-config">git-config[1]</a>). Here are the details of the built-in formats:</p> <div class="ulist"> <ul> <li> <p><code>oneline</code></p> <div class="literalblock"> <div class="content"> <pre><hash> <title-line></pre> </div> </div> <p>This is designed to be as compact as possible.</p> </li> <li> <p><code>short</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> </li> <li> <p><code>medium</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author> +Date: <author-date></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>full</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author> +Commit: <committer></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>fuller</code></p> <div class="literalblock"> <div class="content"> <pre>commit <hash> +Author: <author> +AuthorDate: <author-date> +Commit: <committer> +CommitDate: <committer-date></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>reference</code></p> <div class="literalblock"> <div class="content"> <pre><abbrev-hash> (<title-line>, <short-author-date>)</pre> </div> </div> <p>This format is used to refer to another commit in a commit message and is the same as <code>--pretty='format:%C(auto)%h (%s, %ad)'</code>. By default, the date is formatted with <code>--date=short</code> unless another <code>--date</code> option is explicitly specified. As with any <code>format:</code> with format placeholders, its output is not affected by other options like <code>--decorate</code> and <code>--walk-reflogs</code>.</p> </li> <li> <p><code>email</code></p> <div class="literalblock"> <div class="content"> <pre>From <hash> <date> +From: <author> +Date: <author-date> +Subject: [PATCH] <title-line></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre><full-commit-message></pre> </div> </div> </li> <li> <p><code>mboxrd</code></p> <p>Like <code>email</code>, but lines in the commit message starting with "From " (preceded by zero or more ">") are quoted with ">" so they aren’t confused as starting a new commit.</p> </li> <li> <p><code>raw</code></p> <p>The <code>raw</code> format shows the entire commit exactly as stored in the commit object. Notably, the hashes are displayed in full, regardless of whether --abbrev or --no-abbrev are used, and <code>parents</code> information show the true parent commits, without taking grafts or history simplification into account. Note that this format affects the way commits are displayed, but not the way the diff is shown e.g. with <code>git log --raw</code>. To get full object names in a raw diff format, use <code>--no-abbrev</code>.</p> </li> <li> <p><code>format:<format-string></code></p> <p>The <code>format:<format-string></code> format allows you to specify which information you want to show. It works a little bit like printf format, with the notable exception that you get a newline with <code>%n</code> instead of <code>\n</code>.</p> <p>E.g, <code>format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"</code> would show something like this:</p> <div class="listingblock"> <div class="content"> <pre>The author of fe6e0ee was Junio C Hamano, 23 hours ago +The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<</pre> </div> </div> <p>The placeholders are:</p> <div class="ulist"> <ul> <li> <p>Placeholders that expand to a single literal character:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show.txt-emnem"> <em>%n</em> </dt> <dd> <p>newline</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emem"> <em>%%</em> </dt> <dd> <p>a raw <code>%</code></p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emx00em"> <em>%x00</em> </dt> <dd> <p><code>%x</code> followed by two hexadecimal digits is replaced with a byte with the hexadecimal digits' value (we will call this "literal formatting code" in the rest of this document).</p> </dd> </dl> </div> </li> <li> <p>Placeholders that affect formatting of later placeholders:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show.txt-emCredem"> <em>%Cred</em> </dt> <dd> <p>switch color to red</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emCgreenem"> <em>%Cgreen</em> </dt> <dd> <p>switch color to green</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emCblueem"> <em>%Cblue</em> </dt> <dd> <p>switch color to blue</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emCresetem"> <em>%Creset</em> </dt> <dd> <p>reset color</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emC82308203em"> <em>%C(…)</em> </dt> <dd> <p>color specification, as described under Values in the "CONFIGURATION FILE" section of <a href="git-config">git-config[1]</a>. By default, colors are shown only when enabled for log output (by <code>color.diff</code>, <code>color.ui</code>, or <code>--color</code>, and respecting the <code>auto</code> settings of the former if we are going to a terminal). <code>%C(auto,...)</code> is accepted as a historical synonym for the default (e.g., <code>%C(auto,red)</code>). Specifying <code>%C(always,...)</code> will show the colors even when color is not otherwise enabled (though consider just using <code>--color=always</code> to enable color for the whole output, including this format and anything else git might color). <code>auto</code> alone (i.e. <code>%C(auto)</code>) will turn on auto coloring on the next placeholders until the color is switched again.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emmem"> <em>%m</em> </dt> <dd> <p>left (<code><</code>), right (<code>></code>) or boundary (<code>-</code>) mark</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emwltwgtlti1gtlti2gtem"> <em>%w([<w>[,<i1>[,<i2>]]])</em> </dt> <dd> <p>switch line wrapping, like the -w option of <a href="git-shortlog">git-shortlog[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emltltNgttruncltruncmtruncem"> <em>%<( <N> [,trunc|ltrunc|mtrunc])</em> </dt> <dd> <p>make the next placeholder take at least N column widths, padding spaces on the right if necessary. Optionally truncate (with ellipsis <code>..</code>) at the left (ltrunc) <code>..ft</code>, the middle (mtrunc) <code>mi..le</code>, or the end (trunc) <code>rig..</code>, if the output is longer than N columns. Note 1: that truncating only works correctly with N >= 2. Note 2: spaces around the N and M (see below) values are optional. Note 3: Emojis and other wide characters will take two display columns, which may over-run column boundaries. Note 4: decomposed character combining marks may be misplaced at padding boundaries.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emltltMgtem"> <em>%<|( <M> )</em> </dt> <dd> <p>make the next placeholder take at least until Mth display column, padding spaces on the right if necessary. Use negative M values for column positions measured from the right hand edge of the terminal window.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emgtltNgtememgtltMgtem"> <em>%>( <N> )</em>, <em>%>|( <M> )</em> </dt> <dd> <p>similar to <code>%<( <N> )</code>, <code>%<|( <M> )</code> respectively, but padding spaces on the left</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emgtgtltNgtememgtgtltMgtem"> <em>%>>( <N> )</em>, <em>%>>|( <M> )</em> </dt> <dd> <p>similar to <code>%>( <N> )</code>, <code>%>|( <M> )</code> respectively, except that if the next placeholder takes more spaces than given and there are spaces on its left, use those spaces</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emgtltltNgtememgtltltMgtem"> <em>%><( <N> )</em>, <em>%><|( <M> )</em> </dt> <dd> <p>similar to <code>%<( <N> )</code>, <code>%<|( <M> )</code> respectively, but padding both sides (i.e. the text is centered)</p> </dd> </dl> </div> </li> <li> <p>Placeholders that expand to information extracted from the commit:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show.txt-emHem"> <em>%H</em> </dt> <dd> <p>commit hash</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emhem"> <em>%h</em> </dt> <dd> <p>abbreviated commit hash</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emTem"> <em>%T</em> </dt> <dd> <p>tree hash</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emtem"> <em>%t</em> </dt> <dd> <p>abbreviated tree hash</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emPem"> <em>%P</em> </dt> <dd> <p>parent hashes</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-empem"> <em>%p</em> </dt> <dd> <p>abbreviated parent hashes</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emanem"> <em>%an</em> </dt> <dd> <p>author name</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emaNem"> <em>%aN</em> </dt> <dd> <p>author name (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emaeem"> <em>%ae</em> </dt> <dd> <p>author email</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emaEem"> <em>%aE</em> </dt> <dd> <p>author email (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emalem"> <em>%al</em> </dt> <dd> <p>author email local-part (the part before the <code>@</code> sign)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emaLem"> <em>%aL</em> </dt> <dd> <p>author local-part (see <code>%al</code>) respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emadem"> <em>%ad</em> </dt> <dd> <p>author date (format respects --date= option)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emaDem"> <em>%aD</em> </dt> <dd> <p>author date, RFC2822 style</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emarem"> <em>%ar</em> </dt> <dd> <p>author date, relative</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-ematem"> <em>%at</em> </dt> <dd> <p>author date, UNIX timestamp</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emaiem"> <em>%ai</em> </dt> <dd> <p>author date, ISO 8601-like format</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emaIem"> <em>%aI</em> </dt> <dd> <p>author date, strict ISO 8601 format</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emasem"> <em>%as</em> </dt> <dd> <p>author date, short format (<code>YYYY-MM-DD</code>)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emahem"> <em>%ah</em> </dt> <dd> <p>author date, human style (like the <code>--date=human</code> option of <a href="git-rev-list">git-rev-list[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emcnem"> <em>%cn</em> </dt> <dd> <p>committer name</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emcNem"> <em>%cN</em> </dt> <dd> <p>committer name (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emceem"> <em>%ce</em> </dt> <dd> <p>committer email</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emcEem"> <em>%cE</em> </dt> <dd> <p>committer email (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emclem"> <em>%cl</em> </dt> <dd> <p>committer email local-part (the part before the <code>@</code> sign)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emcLem"> <em>%cL</em> </dt> <dd> <p>committer local-part (see <code>%cl</code>) respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emcdem"> <em>%cd</em> </dt> <dd> <p>committer date (format respects --date= option)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emcDem"> <em>%cD</em> </dt> <dd> <p>committer date, RFC2822 style</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emcrem"> <em>%cr</em> </dt> <dd> <p>committer date, relative</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emctem"> <em>%ct</em> </dt> <dd> <p>committer date, UNIX timestamp</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emciem"> <em>%ci</em> </dt> <dd> <p>committer date, ISO 8601-like format</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emcIem"> <em>%cI</em> </dt> <dd> <p>committer date, strict ISO 8601 format</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emcsem"> <em>%cs</em> </dt> <dd> <p>committer date, short format (<code>YYYY-MM-DD</code>)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emchem"> <em>%ch</em> </dt> <dd> <p>committer date, human style (like the <code>--date=human</code> option of <a href="git-rev-list">git-rev-list[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emdem"> <em>%d</em> </dt> <dd> <p>ref names, like the --decorate option of <a href="git-log">git-log[1]</a></p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emDem"> <em>%D</em> </dt> <dd> <p>ref names without the " (", ")" wrapping.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emdecorateltoptionsgtem"> <em>%(decorate[:<options>])</em> </dt> <dd> <p>ref names with custom decorations. The <code>decorate</code> string may be followed by a colon and zero or more comma-separated options. Option values may contain literal formatting codes. These must be used for commas (<code>%x2C</code>) and closing parentheses (<code>%x29</code>), due to their role in the option syntax.</p> <div class="ulist"> <ul> <li> <p><code>prefix=<value></code>: Shown before the list of ref names. Defaults to " <code>(</code>".</p> </li> <li> <p><code>suffix=<value></code>: Shown after the list of ref names. Defaults to "<code>)</code>".</p> </li> <li> <p><code>separator=<value></code>: Shown between ref names. Defaults to "<code>,</code> ".</p> </li> <li> <p><code>pointer=<value></code>: Shown between HEAD and the branch it points to, if any. Defaults to " <code>-></code> ".</p> </li> <li> <p><code>tag=<value></code>: Shown before tag names. Defaults to "<code>tag:</code> ".</p> </li> </ul> </div> </dd> </dl> </div> </li> </ul> </div> <p>For example, to produce decorations with no wrapping or tag annotations, and spaces as separators:</p> <p>+ <code>%(decorate:prefix=,suffix=,tag=,separator= )</code></p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show.txt-emdescribeltoptionsgtem"> <em>%(describe[:<options>])</em> </dt> <dd> <p>human-readable name, like <a href="git-describe">git-describe[1]</a>; empty string for undescribable commits. The <code>describe</code> string may be followed by a colon and zero or more comma-separated options. Descriptions can be inconsistent when tags are added or removed at the same time.</p> <div class="ulist"> <ul> <li> <p><code>tags[=<bool-value>]</code>: Instead of only considering annotated tags, consider lightweight tags as well.</p> </li> <li> <p><code>abbrev=<number></code>: Instead of using the default number of hexadecimal digits (which will vary according to the number of objects in the repository with a default of 7) of the abbreviated object name, use <number> digits, or as many digits as needed to form a unique object name.</p> </li> <li> <p><code>match=<pattern></code>: Only consider tags matching the given <code>glob(7)</code> pattern, excluding the "refs/tags/" prefix.</p> </li> <li> <p><code>exclude=<pattern></code>: Do not consider tags matching the given <code>glob(7)</code> pattern, excluding the "refs/tags/" prefix.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emSem"> <em>%S</em> </dt> <dd> <p>ref name given on the command line by which the commit was reached (like <code>git log --source</code>), only works with <code>git log</code></p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emeem"> <em>%e</em> </dt> <dd> <p>encoding</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emsem"> <em>%s</em> </dt> <dd> <p>subject</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emfem"> <em>%f</em> </dt> <dd> <p>sanitized subject line, suitable for a filename</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-embem"> <em>%b</em> </dt> <dd> <p>body</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emBem"> <em>%B</em> </dt> <dd> <p>raw body (unwrapped subject and body)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emNem"> <em>%N</em> </dt> <dd> <p>commit notes</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emGGem"> <em>%GG</em> </dt> <dd> <p>raw verification message from GPG for a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emGem"> <em>%G?</em> </dt> <dd> <p>show "G" for a good (valid) signature, "B" for a bad signature, "U" for a good signature with unknown validity, "X" for a good signature that has expired, "Y" for a good signature made by an expired key, "R" for a good signature made by a revoked key, "E" if the signature cannot be checked (e.g. missing key) and "N" for no signature</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emGSem"> <em>%GS</em> </dt> <dd> <p>show the name of the signer for a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emGKem"> <em>%GK</em> </dt> <dd> <p>show the key used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emGFem"> <em>%GF</em> </dt> <dd> <p>show the fingerprint of the key used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emGPem"> <em>%GP</em> </dt> <dd> <p>show the fingerprint of the primary key whose subkey was used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emGTem"> <em>%GT</em> </dt> <dd> <p>show the trust level for the key used to sign a signed commit</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emgDem"> <em>%gD</em> </dt> <dd> <p>reflog selector, e.g., <code>refs/stash@{1}</code> or <code>refs/stash@{2 +minutes ago}</code>; the format follows the rules described for the <code>-g</code> option. The portion before the <code>@</code> is the refname as given on the command line (so <code>git log -g refs/heads/master</code> would yield <code>refs/heads/master@{0}</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emgdem"> <em>%gd</em> </dt> <dd> <p>shortened reflog selector; same as <code>%gD</code>, but the refname portion is shortened for human readability (so <code>refs/heads/master</code> becomes just <code>master</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emgnem"> <em>%gn</em> </dt> <dd> <p>reflog identity name</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emgNem"> <em>%gN</em> </dt> <dd> <p>reflog identity name (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emgeem"> <em>%ge</em> </dt> <dd> <p>reflog identity email</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emgEem"> <em>%gE</em> </dt> <dd> <p>reflog identity email (respecting .mailmap, see <a href="git-shortlog">git-shortlog[1]</a> or <a href="git-blame">git-blame[1]</a>)</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emgsem"> <em>%gs</em> </dt> <dd> <p>reflog subject</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-emtrailersltoptionsgtem"> <em>%(trailers[:<options>])</em> </dt> <dd> <p>display the trailers of the body as interpreted by <a href="git-interpret-trailers">git-interpret-trailers[1]</a>. The <code>trailers</code> string may be followed by a colon and zero or more comma-separated options. If any option is provided multiple times, the last occurrence wins.</p> <div class="ulist"> <ul> <li> <p><code>key=<key></code>: only show trailers with specified <key>. Matching is done case-insensitively and trailing colon is optional. If option is given multiple times trailer lines matching any of the keys are shown. This option automatically enables the <code>only</code> option so that non-trailer lines in the trailer block are hidden. If that is not desired it can be disabled with <code>only=false</code>. E.g., <code>%(trailers:key=Reviewed-by)</code> shows trailer lines with key <code>Reviewed-by</code>.</p> </li> <li> <p><code>only[=<bool>]</code>: select whether non-trailer lines from the trailer block should be included.</p> </li> <li> <p><code>separator=<sep></code>: specify a separator inserted between trailer lines. When this option is not given each trailer line is terminated with a line feed character. The string <sep> may contain the literal formatting codes described above. To use comma as separator one must use <code>%x2C</code> as it would otherwise be parsed as next option. E.g., <code>%(trailers:key=Ticket,separator=%x2C )</code> shows all trailer lines whose key is "Ticket" separated by a comma and a space.</p> </li> <li> <p><code>unfold[=<bool>]</code>: make it behave as if interpret-trailer’s <code>--unfold</code> option was given. E.g., <code>%(trailers:only,unfold=true)</code> unfolds and shows all trailer lines.</p> </li> <li> <p><code>keyonly[=<bool>]</code>: only show the key part of the trailer.</p> </li> <li> <p><code>valueonly[=<bool>]</code>: only show the value part of the trailer.</p> </li> <li> <p><code>key_value_separator=<sep></code>: specify a separator inserted between trailer lines. When this option is not given each trailer key-value pair is separated by ": ". Otherwise it shares the same semantics as <code>separator=<sep></code> above.</p> </li> </ul> </div> </dd> </dl> </div> </li> </ul> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> Some placeholders may depend on other options given to the revision traversal engine. For example, the <code>%g*</code> reflog options will insert an empty string unless we are traversing reflog entries (e.g., by <code>git log -g</code>). The <code>%d</code> and <code>%D</code> placeholders will use the "short" decoration format if <code>--decorate</code> was not already provided on the command line. </td> </tr> </table> </div> <p>The boolean options accept an optional value <code>[=<bool-value>]</code>. The values <code>true</code>, <code>false</code>, <code>on</code>, <code>off</code> etc. are all accepted. See the "boolean" sub-section in "EXAMPLES" in <a href="git-config">git-config[1]</a>. If a boolean option is given with no value, it’s enabled.</p> <p>If you add a <code>+</code> (plus sign) after <code>%</code> of a placeholder, a line-feed is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.</p> <p>If you add a <code>-</code> (minus sign) after <code>%</code> of a placeholder, all consecutive line-feeds immediately preceding the expansion are deleted if and only if the placeholder expands to an empty string.</p> <p>If you add a ` ` (space) after <code>%</code> of a placeholder, a space is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.</p> <div class="ulist"> <ul> <li> <p><code>tformat:</code></p> <p>The <code>tformat:</code> format works exactly like <code>format:</code>, except that it provides "terminator" semantics instead of "separator" semantics. In other words, each commit has the message terminator character (usually a newline) appended, rather than a separator placed between entries. This means that the final entry of a single-line format will be properly terminated with a new line, just as the "oneline" format does. For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log -2 --pretty=format:%h 4da45bef \ + | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/' +4da45be +7134973 -- NO NEWLINE + +$ git log -2 --pretty=tformat:%h 4da45bef \ + | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/' +4da45be +7134973</pre> </div> </div> <p>In addition, any unrecognized string that has a <code>%</code> in it is interpreted as if it has <code>tformat:</code> in front of it. For example, these two are equivalent:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log -2 --pretty=tformat:%h 4da45bef +$ git log -2 --pretty=%h 4da45bef</pre> </div> </div> </li> </ul> </div> </div> <h2 id="_diff_formatting">Diff formatting</h2> <div class="sectionbody"> <p>The options below can be used to change the way <code>git show</code> generates diff output.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-show.txt--u"> -u </dt> <dt class="hdlist1" id="Documentation/git-show.txt---patch"> --patch </dt> <dd> <p>Generate patch (see <a href="#generate_patch_text_with_p">Generating patch text with -p</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-show.txt---no-patch"> --no-patch </dt> <dd> <p>Suppress all output from the diff machinery. Useful for commands like <code>git show</code> that show the patch by default to squelch their output, or to cancel the effect of options like <code>--patch</code>, <code>--stat</code> earlier on the command line in an alias.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--m"> -m </dt> <dd> <p>Show diffs for merge commits in the default format. This is similar to <code>--diff-merges=on</code>, except <code>-m</code> will produce no output unless <code>-p</code> is given as well.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--c"> -c </dt> <dd> <p>Produce combined diff output for merge commits. Shortcut for <code>--diff-merges=combined -p</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---cc"> --cc </dt> <dd> <p>Produce dense combined diff output for merge commits. Shortcut for <code>--diff-merges=dense-combined -p</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---dd"> --dd </dt> <dd> <p>Produce diff with respect to first parent for both merge and regular commits. Shortcut for <code>--diff-merges=first-parent -p</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---remerge-diff"> --remerge-diff </dt> <dd> <p>Produce remerge-diff output for merge commits. Shortcut for <code>--diff-merges=remerge -p</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---no-diff-merges"> --no-diff-merges </dt> <dd> <p>Synonym for <code>--diff-merges=off</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---diff-mergesltformatgt"> --diff-merges=<format> </dt> <dd> <p>Specify diff format to be used for merge commits. Default is `dense-combined` unless <code>--first-parent</code> is in use, in which case <code>first-parent</code> is the default.</p> <p>The following formats are supported:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show.txt-offnone"> off, none </dt> <dd> <p>Disable output of diffs for merge commits. Useful to override implied value.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-onm"> on, m </dt> <dd> <p>Make diff output for merge commits to be shown in the default format. The default format can be changed using <code>log.diffMerges</code> configuration variable, whose default value is <code>separate</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-first-parent1"> first-parent, 1 </dt> <dd> <p>Show full diff with respect to first parent. This is the same format as <code>--patch</code> produces for non-merge commits.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-separate"> separate </dt> <dd> <p>Show full diff with respect to each of parents. Separate log entry and diff is generated for each parent.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-combinedc"> combined, c </dt> <dd> <p>Show differences from each of the parents to the merge result simultaneously instead of showing pairwise diff between a parent and the result one at a time. Furthermore, it lists only files which were modified from all parents.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-dense-combinedcc"> dense-combined, cc </dt> <dd> <p>Further compress output produced by <code>--diff-merges=combined</code> by omitting uninteresting hunks whose contents in the parents have only two variants and the merge result picks one of them without modification.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-remerger"> remerge, r </dt> <dd> <p>Remerge two-parent merge commits to create a temporary tree object—potentially containing files with conflict markers and such. A diff is then shown between that temporary tree and the actual merge commit.</p> <p>The output emitted when this option is used is subject to change, and so is its interaction with other options (unless explicitly documented).</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---combined-all-paths"> --combined-all-paths </dt> <dd> <p>This flag causes combined diffs (used for merge commits) to list the name of the file from all parents. It thus only has effect when <code>--diff-merges=[dense-]combined</code> is in use, and is likely only useful if filename changes are detected (i.e. when either rename or copy detection have been requested).</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--Ultngt"> -U<n> </dt> <dt class="hdlist1" id="Documentation/git-show.txt---unifiedltngt"> --unified=<n> </dt> <dd> <p>Generate diffs with <n> lines of context instead of the usual three. Implies <code>--patch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---outputltfilegt"> --output=<file> </dt> <dd> <p>Output to a specific file instead of stdout.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---output-indicator-newltchargt"> --output-indicator-new=<char> </dt> <dt class="hdlist1" id="Documentation/git-show.txt---output-indicator-oldltchargt"> --output-indicator-old=<char> </dt> <dt class="hdlist1" id="Documentation/git-show.txt---output-indicator-contextltchargt"> --output-indicator-context=<char> </dt> <dd> <p>Specify the character used to indicate new, old or context lines in the generated patch. Normally they are <code>+</code>, <code>-</code> and ' ' respectively.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---raw"> --raw </dt> <dd> <p>For each commit, show a summary of changes using the raw diff format. See the "RAW OUTPUT FORMAT" section of <a href="git-diff">git-diff[1]</a>. This is different from showing the log itself in raw format, which you can achieve with <code>--format=raw</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---patch-with-raw"> --patch-with-raw </dt> <dd> <p>Synonym for <code>-p --raw</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--t"> -t </dt> <dd> <p>Show the tree objects in the diff output.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---indent-heuristic"> --indent-heuristic </dt> <dd> <p>Enable the heuristic that shifts diff hunk boundaries to make patches easier to read. This is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---no-indent-heuristic"> --no-indent-heuristic </dt> <dd> <p>Disable the indent heuristic.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---minimal"> --minimal </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---patience"> --patience </dt> <dd> <p>Generate a diff using the "patience diff" algorithm.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---histogram"> --histogram </dt> <dd> <p>Generate a diff using the "histogram diff" algorithm.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---anchoredlttextgt"> --anchored=<text> </dt> <dd> <p>Generate a diff using the "anchored diff" algorithm.</p> <p>This option may be specified more than once.</p> <p>If a line exists in both the source and destination, exists only once, and starts with this text, this algorithm attempts to prevent it from appearing as a deletion or addition in the output. It uses the "patience diff" algorithm internally.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---diff-algorithmpatienceminimalhistogrammyers"> --diff-algorithm={patience|minimal|histogram|myers} </dt> <dd> <p>Choose a diff algorithm. The variants are as follows:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show.txt-codedefaultcodecodemyerscode"> <code>default</code>, <code>myers</code> </dt> <dd> <p>The basic greedy diff algorithm. Currently, this is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-codeminimalcode"> <code>minimal</code> </dt> <dd> <p>Spend extra time to make sure the smallest possible diff is produced.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-codepatiencecode"> <code>patience</code> </dt> <dd> <p>Use "patience diff" algorithm when generating patches.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-codehistogramcode"> <code>histogram</code> </dt> <dd> <p>This algorithm extends the patience algorithm to "support low-occurrence common elements".</p> </dd> </dl> </div> </div> </div> <p>For instance, if you configured the <code>diff.algorithm</code> variable to a non-default value and want to use the default one, then you have to use <code>--diff-algorithm=default</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---statltwidthgtltname-widthgtltcountgt"> --stat[=<width>[,<name-width>[,<count>]]] </dt> <dd> <p>Generate a diffstat. By default, as much space as necessary will be used for the filename part, and the rest for the graph part. Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden by <code><width></code>. The width of the filename part can be limited by giving another width <code><name-width></code> after a comma or by setting <code>diff.statNameWidth=<width></code>. The width of the graph part can be limited by using <code>--stat-graph-width=<width></code> or by setting <code>diff.statGraphWidth=<width></code>. Using <code>--stat</code> or <code>--stat-graph-width</code> affects all commands generating a stat graph, while setting <code>diff.statNameWidth</code> or <code>diff.statGraphWidth</code> does not affect <code>git format-patch</code>. By giving a third parameter <code><count></code>, you can limit the output to the first <code><count></code> lines, followed by <code>...</code> if there are more.</p> <p>These parameters can also be set individually with <code>--stat-width=<width></code>, <code>--stat-name-width=<name-width></code> and <code>--stat-count=<count></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---compact-summary"> --compact-summary </dt> <dd> <p>Output a condensed summary of extended header information such as file creations or deletions ("new" or "gone", optionally "+l" if it’s a symlink) and mode changes ("+x" or "-x" for adding or removing executable bit respectively) in diffstat. The information is put between the filename part and the graph part. Implies <code>--stat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---numstat"> --numstat </dt> <dd> <p>Similar to <code>--stat</code>, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly. For binary files, outputs two <code>-</code> instead of saying <code>0 0</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---shortstat"> --shortstat </dt> <dd> <p>Output only the last line of the <code>--stat</code> format containing total number of modified files, as well as number of added and deleted lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--Xltparam1param282308203gt"> -X[<param1,param2,…>] </dt> <dt class="hdlist1" id="Documentation/git-show.txt---dirstatltparam1param282308203gt"> --dirstat[=<param1,param2,…>] </dt> <dd> <p>Output the distribution of relative amount of changes for each sub-directory. The behavior of <code>--dirstat</code> can be customized by passing it a comma separated list of parameters. The defaults are controlled by the <code>diff.dirstat</code> configuration variable (see <a href="git-config">git-config[1]</a>). The following parameters are available:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show.txt-codechangescode"> <code>changes</code> </dt> <dd> <p>Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination. This ignores the amount of pure code movements within a file. In other words, rearranging lines in a file is not counted as much as other changes. This is the default behavior when no parameter is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-codelinescode"> <code>lines</code> </dt> <dd> <p>Compute the dirstat numbers by doing the regular line-based diff analysis, and summing the removed/added line counts. (For binary files, count 64-byte chunks instead, since binary files have no natural concept of lines). This is a more expensive <code>--dirstat</code> behavior than the <code>changes</code> behavior, but it does count rearranged lines within a file as much as other changes. The resulting output is consistent with what you get from the other <code>--*stat</code> options.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-codefilescode"> <code>files</code> </dt> <dd> <p>Compute the dirstat numbers by counting the number of files changed. Each changed file counts equally in the dirstat analysis. This is the computationally cheapest <code>--dirstat</code> behavior, since it does not have to look at the file contents at all.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-codecumulativecode"> <code>cumulative</code> </dt> <dd> <p>Count changes in a child directory for the parent directory as well. Note that when using <code>cumulative</code>, the sum of the percentages reported may exceed 100%. The default (non-cumulative) behavior can be specified with the <code>noncumulative</code> parameter.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-ltlimitgt"> <limit> </dt> <dd> <p>An integer parameter specifies a cut-off percent (3% by default). Directories contributing less than this percentage of the changes are not shown in the output.</p> </dd> </dl> </div> </div> </div> <p>Example: The following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories: <code>--dirstat=files,10,cumulative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---cumulative"> --cumulative </dt> <dd> <p>Synonym for --dirstat=cumulative</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---dirstat-by-fileltparam1param2gt82308203"> --dirstat-by-file[=<param1,param2>…] </dt> <dd> <p>Synonym for --dirstat=files,param1,param2…</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---summary"> --summary </dt> <dd> <p>Output a condensed summary of extended header information such as creations, renames and mode changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---patch-with-stat"> --patch-with-stat </dt> <dd> <p>Synonym for <code>-p --stat</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--z"> -z </dt> <dd> <p>Separate the commits with NULs instead of newlines.</p> <p>Also, when <code>--raw</code> or <code>--numstat</code> has been given, do not munge pathnames and use NULs as output field terminators.</p> <p>Without this option, pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---name-only"> --name-only </dt> <dd> <p>Show only names of changed files. The file names are often encoded in UTF-8. For more information see the discussion about encoding in the <a href="git-log">git-log[1]</a> manual page.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---name-status"> --name-status </dt> <dd> <p>Show only names and status of changed files. See the description of the <code>--diff-filter</code> option on what the status letters mean. Just like <code>--name-only</code> the file names are often encoded in UTF-8.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---submoduleltformatgt"> --submodule[=<format>] </dt> <dd> <p>Specify how differences in submodules are shown. When specifying <code>--submodule=short</code> the <code>short</code> format is used. This format just shows the names of the commits at the beginning and end of the range. When <code>--submodule</code> or <code>--submodule=log</code> is specified, the <code>log</code> format is used. This format lists the commits in the range like <a href="git-submodule">git-submodule[1]</a> <code>summary</code> does. When <code>--submodule=diff</code> is specified, the <code>diff</code> format is used. This format shows an inline diff of the changes in the submodule contents between the commit range. Defaults to <code>diff.submodule</code> or the <code>short</code> format if the config option is unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---colorltwhengt"> --color[=<when>] </dt> <dd> <p>Show colored diff. <code>--color</code> (i.e. without <code>=<when></code>) is the same as <code>--color=always</code>. <code><when></code> can be one of <code>always</code>, <code>never</code>, or <code>auto</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---no-color"> --no-color </dt> <dd> <p>Turn off colored diff. It is the same as <code>--color=never</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---color-movedltmodegt"> --color-moved[=<mode>] </dt> <dd> <p>Moved lines of code are colored differently. The <mode> defaults to <code>no</code> if the option is not given and to <code>zebra</code> if the option with no mode is given. The mode must be one of:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show.txt-no"> no </dt> <dd> <p>Moved lines are not highlighted.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-default"> default </dt> <dd> <p>Is a synonym for <code>zebra</code>. This may change to a more sensible mode in the future.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-plain"> plain </dt> <dd> <p>Any line that is added in one location and was removed in another location will be colored with <code>color.diff.newMoved</code>. Similarly <code>color.diff.oldMoved</code> will be used for removed lines that are added somewhere else in the diff. This mode picks up any moved line, but it is not very useful in a review to determine if a block of code was moved without permutation.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-blocks"> blocks </dt> <dd> <p>Blocks of moved text of at least 20 alphanumeric characters are detected greedily. The detected blocks are painted using either the <code>color.diff.{old,new}Moved</code> color. Adjacent blocks cannot be told apart.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-zebra"> zebra </dt> <dd> <p>Blocks of moved text are detected as in <code>blocks</code> mode. The blocks are painted using either the <code>color.diff.{old,new}Moved</code> color or <code>color.diff.{old,new}MovedAlternative</code>. The change between the two colors indicates that a new block was detected.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-dimmed-zebra"> dimmed-zebra </dt> <dd> <p>Similar to <code>zebra</code>, but additional dimming of uninteresting parts of moved code is performed. The bordering lines of two adjacent blocks are considered interesting, the rest is uninteresting. <code>dimmed_zebra</code> is a deprecated synonym.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---no-color-moved"> --no-color-moved </dt> <dd> <p>Turn off move detection. This can be used to override configuration settings. It is the same as <code>--color-moved=no</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---color-moved-wsltmodesgt"> --color-moved-ws=<modes> </dt> <dd> <p>This configures how whitespace is ignored when performing the move detection for <code>--color-moved</code>. These modes can be given as a comma separated list:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show.txt-no-1"> no </dt> <dd> <p>Do not ignore whitespace when performing move detection.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-ignore-space-at-eol"> ignore-space-at-eol </dt> <dd> <p>Ignore changes in whitespace at EOL.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-ignore-space-change"> ignore-space-change </dt> <dd> <p>Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-ignore-all-space"> ignore-all-space </dt> <dd> <p>Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-allow-indentation-change"> allow-indentation-change </dt> <dd> <p>Initially ignore any whitespace in the move detection, then group the moved code blocks only into a block if the change in whitespace is the same per line. This is incompatible with the other modes.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---no-color-moved-ws"> --no-color-moved-ws </dt> <dd> <p>Do not ignore whitespace when performing move detection. This can be used to override configuration settings. It is the same as <code>--color-moved-ws=no</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---word-diffltmodegt"> --word-diff[=<mode>] </dt> <dd> <p>Show a word diff, using the <mode> to delimit changed words. By default, words are delimited by whitespace; see <code>--word-diff-regex</code> below. The <mode> defaults to <code>plain</code>, and must be one of:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show.txt-color"> color </dt> <dd> <p>Highlight changed words using only colors. Implies <code>--color</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-plain-1"> plain </dt> <dd> <p>Show words as <code>[-removed-]</code> and <code>{+added+}</code>. Makes no attempts to escape the delimiters if they appear in the input, so the output may be ambiguous.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-porcelain"> porcelain </dt> <dd> <p>Use a special line-based format intended for script consumption. Added/removed/unchanged runs are printed in the usual unified diff format, starting with a <code>+</code>/<code>-</code>/` ` character at the beginning of the line and extending to the end of the line. Newlines in the input are represented by a tilde <code>~</code> on a line of its own.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-none"> none </dt> <dd> <p>Disable word diff again.</p> </dd> </dl> </div> </div> </div> <p>Note that despite the name of the first mode, color is used to highlight the changed parts in all modes if enabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---word-diff-regexltregexgt"> --word-diff-regex=<regex> </dt> <dd> <p>Use <regex> to decide what a word is, instead of considering runs of non-whitespace to be a word. Also implies <code>--word-diff</code> unless it was already enabled.</p> <p>Every non-overlapping match of the <regex> is considered a word. Anything between these matches is considered whitespace and ignored(!) for the purposes of finding differences. You may want to append <code>|[^[:space:]]</code> to your regular expression to make sure that it matches all non-whitespace characters. A match that contains a newline is silently truncated(!) at the newline.</p> <p>For example, <code>--word-diff-regex=.</code> will treat each character as a word and, correspondingly, show differences character by character.</p> <p>The regex can also be set via a diff driver or configuration option, see <a href="gitattributes">gitattributes[5]</a> or <a href="git-config">git-config[1]</a>. Giving it explicitly overrides any diff driver or configuration setting. Diff drivers override configuration settings.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---color-wordsltregexgt"> --color-words[=<regex>] </dt> <dd> <p>Equivalent to <code>--word-diff=color</code> plus (if a regex was specified) <code>--word-diff-regex=<regex></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---no-renames"> --no-renames </dt> <dd> <p>Turn off rename detection, even when the configuration file gives the default to do so.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---no-rename-empty"> --[no-]rename-empty </dt> <dd> <p>Whether to use empty blobs as rename source.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---check"> --check </dt> <dd> <p>Warn if changes introduce conflict markers or whitespace errors. What are considered whitespace errors is controlled by <code>core.whitespace</code> configuration. By default, trailing whitespaces (including lines that consist solely of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors. Exits with non-zero status if problems are found. Not compatible with --exit-code.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---ws-error-highlightltkindgt"> --ws-error-highlight=<kind> </dt> <dd> <p>Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code> lines of the diff. Multiple values are separated by comma, <code>none</code> resets previous values, <code>default</code> reset the list to <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. When this option is not given, and the configuration variable <code>diff.wsErrorHighlight</code> is not set, only whitespace errors in <code>new</code> lines are highlighted. The whitespace errors are colored with <code>color.diff.whitespace</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---full-index"> --full-index </dt> <dd> <p>Instead of the first handful of characters, show the full pre- and post-image blob object names on the "index" line when generating patch format output.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---binary"> --binary </dt> <dd> <p>In addition to <code>--full-index</code>, output a binary diff that can be applied with <code>git-apply</code>. Implies <code>--patch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---abbrevltngt"> --abbrev[=<n>] </dt> <dd> <p>Instead of showing the full 40-byte hexadecimal object name in diff-raw format output and diff-tree header lines, show the shortest prefix that is at least <code><n></code> hexdigits long that uniquely refers the object. In diff-patch output format, <code>--full-index</code> takes higher precedence, i.e. if <code>--full-index</code> is specified, full blob names will be shown regardless of <code>--abbrev</code>. Non default number of digits can be specified with <code>--abbrev=<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--Bltngtltmgt"> -B[<n>][/<m>] </dt> <dt class="hdlist1" id="Documentation/git-show.txt---break-rewritesltngtltmgt"> --break-rewrites[=[<n>][/<m>]] </dt> <dd> <p>Break complete rewrite changes into pairs of delete and create. This serves two purposes:</p> <p>It affects the way a change that amounts to a total rewrite of a file not as a series of deletion and insertion mixed together with a very few lines that happen to match textually as the context, but as a single deletion of everything old followed by a single insertion of everything new, and the number <code>m</code> controls this aspect of the -B option (defaults to 60%). <code>-B/70%</code> specifies that less than 30% of the original should remain in the result for Git to consider it a total rewrite (i.e. otherwise the resulting patch will be a series of deletion and insertion mixed together with context lines).</p> <p>When used with -M, a totally-rewritten file is also considered as the source of a rename (usually -M only considers a file that disappeared as the source of a rename), and the number <code>n</code> controls this aspect of the -B option (defaults to 50%). <code>-B20%</code> specifies that a change with addition and deletion compared to 20% or more of the file’s size are eligible for being picked up as a possible source of a rename to another file.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--Mltngt"> -M[<n>] </dt> <dt class="hdlist1" id="Documentation/git-show.txt---find-renamesltngt"> --find-renames[=<n>] </dt> <dd> <p>If generating diffs, detect and report renames for each commit. For following files across renames while traversing history, see <code>--follow</code>. If <code>n</code> is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file’s size). For example, <code>-M90%</code> means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn’t changed. Without a <code>%</code> sign, the number is to be read as a fraction, with a decimal point before it. I.e., <code>-M5</code> becomes 0.5, and is thus the same as <code>-M50%</code>. Similarly, <code>-M05</code> is the same as <code>-M5%</code>. To limit detection to exact renames, use <code>-M100%</code>. The default similarity index is 50%.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--Cltngt"> -C[<n>] </dt> <dt class="hdlist1" id="Documentation/git-show.txt---find-copiesltngt"> --find-copies[=<n>] </dt> <dd> <p>Detect copies as well as renames. See also <code>--find-copies-harder</code>. If <code>n</code> is specified, it has the same meaning as for <code>-M<n></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---find-copies-harder"> --find-copies-harder </dt> <dd> <p>For performance reasons, by default, <code>-C</code> option finds copies only if the original file of the copy was modified in the same changeset. This flag makes the command inspect unmodified files as candidates for the source of copy. This is a very expensive operation for large projects, so use it with caution. Giving more than one <code>-C</code> option has the same effect.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--D"> -D </dt> <dt class="hdlist1" id="Documentation/git-show.txt---irreversible-delete"> --irreversible-delete </dt> <dd> <p>Omit the preimage for deletes, i.e. print only the header but not the diff between the preimage and <code>/dev/null</code>. The resulting patch is not meant to be applied with <code>patch</code> or <code>git apply</code>; this is solely for people who want to just concentrate on reviewing the text after the change. In addition, the output obviously lacks enough information to apply such a patch in reverse, even manually, hence the name of the option.</p> <p>When used together with <code>-B</code>, omit also the preimage in the deletion part of a delete/create pair.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--lltnumgt"> -l<num> </dt> <dd> <p>The <code>-M</code> and <code>-C</code> options involve some preliminary steps that can detect subsets of renames/copies cheaply, followed by an exhaustive fallback portion that compares all remaining unpaired destinations to all relevant sources. (For renames, only remaining unpaired sources are relevant; for copies, all original sources are relevant.) For N sources and destinations, this exhaustive check is O(N^2). This option prevents the exhaustive portion of rename/copy detection from running if the number of source/destination files involved exceeds the specified number. Defaults to diff.renameLimit. Note that a value of 0 is treated as unlimited.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---diff-filterACDMRTUXB82308203"> --diff-filter=[(A|C|D|M|R|T|U|X|B)…[*]] </dt> <dd> <p>Select only files that are Added (<code>A</code>), Copied (<code>C</code>), Deleted (<code>D</code>), Modified (<code>M</code>), Renamed (<code>R</code>), have their type (i.e. regular file, symlink, submodule, …) changed (<code>T</code>), are Unmerged (<code>U</code>), are Unknown (<code>X</code>), or have had their pairing Broken (<code>B</code>). Any combination of the filter characters (including none) can be used. When <code>*</code> (All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.</p> <p>Also, these upper-case letters can be downcased to exclude. E.g. <code>--diff-filter=ad</code> excludes added and deleted paths.</p> <p>Note that not all diffs can feature all types. For instance, copied and renamed entries cannot appear if detection for those types is disabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--Sltstringgt"> -S<string> </dt> <dd> <p>Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file. Intended for the scripter’s use.</p> <p>It is useful when you’re looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting block in the preimage back into <code>-S</code>, and keep going until you get the very first version of the block.</p> <p>Binary files are searched as well.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--Gltregexgt"> -G<regex> </dt> <dd> <p>Look for differences whose patch text contains added/removed lines that match <regex>.</p> <p>To illustrate the difference between <code>-S<regex> --pickaxe-regex</code> and <code>-G<regex></code>, consider a commit with the following diff in the same file:</p> <div class="listingblock"> <div class="content"> <pre>+ return frotz(nitfol, two->ptr, 1, 0); +... +- hit = frotz(nitfol, mf2.ptr, 1, 0);</pre> </div> </div> <p>While <code>git log -G"frotz\(nitfol"</code> will show this commit, <code>git log +-S"frotz\(nitfol" --pickaxe-regex</code> will not (because the number of occurrences of that string did not change).</p> <p>Unless <code>--text</code> is supplied patches of binary files without a textconv filter will be ignored.</p> <p>See the <code>pickaxe</code> entry in <a href="gitdiffcore">gitdiffcore[7]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---find-objectltobject-idgt"> --find-object=<object-id> </dt> <dd> <p>Look for differences that change the number of occurrences of the specified object. Similar to <code>-S</code>, just the argument is different in that it doesn’t search for a specific string but for a specific object id.</p> <p>The object can be a blob or a submodule commit. It implies the <code>-t</code> option in <code>git-log</code> to also find trees.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---pickaxe-all"> --pickaxe-all </dt> <dd> <p>When <code>-S</code> or <code>-G</code> finds a change, show all the changes in that changeset, not just the files that contain the change in <string>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---pickaxe-regex"> --pickaxe-regex </dt> <dd> <p>Treat the <string> given to <code>-S</code> as an extended POSIX regular expression to match.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--Oltorderfilegt"> -O<orderfile> </dt> <dd> <p>Control the order in which files appear in the output. This overrides the <code>diff.orderFile</code> configuration variable (see <a href="git-config">git-config[1]</a>). To cancel <code>diff.orderFile</code>, use <code>-O/dev/null</code>.</p> <p>The output order is determined by the order of glob patterns in <orderfile>. All files with pathnames that match the first pattern are output first, all files with pathnames that match the second pattern (but not the first) are output next, and so on. All files with pathnames that do not match any pattern are output last, as if there was an implicit match-all pattern at the end of the file. If multiple pathnames have the same rank (they match the same pattern but no earlier patterns), their output order relative to each other is the normal order.</p> <p><orderfile> is parsed as follows:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>Blank lines are ignored, so they can be used as separators for readability.</p> </li> <li> <p>Lines starting with a hash ("<code>#</code>") are ignored, so they can be used for comments. Add a backslash ("<code>\</code>") to the beginning of the pattern if it starts with a hash.</p> </li> <li> <p>Each other line contains a single pattern.</p> </li> </ul> </div> </div> </div> <p>Patterns have the same syntax and semantics as patterns used for fnmatch(3) without the FNM_PATHNAME flag, except a pathname also matches a pattern if removing any number of the final pathname components matches the pattern. For example, the pattern "<code>foo*bar</code>" matches "<code>fooasdfbar</code>" and "<code>foo/bar/baz/asdf</code>" but not "<code>foobarx</code>".</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---skip-toltfilegt"> --skip-to=<file> </dt> <dt class="hdlist1" id="Documentation/git-show.txt---rotate-toltfilegt"> --rotate-to=<file> </dt> <dd> <p>Discard the files before the named <file> from the output (i.e. <code>skip to</code>), or move them to the end of the output (i.e. <code>rotate to</code>). These options were invented primarily for the use of the <code>git difftool</code> command, and may not be very useful otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--R"> -R </dt> <dd> <p>Swap two inputs; that is, show differences from index or on-disk file to tree contents.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---relativeltpathgt"> --relative[=<path>] </dt> <dt class="hdlist1" id="Documentation/git-show.txt---no-relative"> --no-relative </dt> <dd> <p>When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option. When you are not in a subdirectory (e.g. in a bare repository), you can name which subdirectory to make the output relative to by giving a <path> as an argument. <code>--no-relative</code> can be used to countermand both <code>diff.relative</code> config option and previous <code>--relative</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-show.txt---text"> --text </dt> <dd> <p>Treat all files as text.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---ignore-cr-at-eol"> --ignore-cr-at-eol </dt> <dd> <p>Ignore carriage-return at the end of line when doing a comparison.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---ignore-space-at-eol"> --ignore-space-at-eol </dt> <dd> <p>Ignore changes in whitespace at EOL.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--b"> -b </dt> <dt class="hdlist1" id="Documentation/git-show.txt---ignore-space-change"> --ignore-space-change </dt> <dd> <p>Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--w"> -w </dt> <dt class="hdlist1" id="Documentation/git-show.txt---ignore-all-space"> --ignore-all-space </dt> <dd> <p>Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---ignore-blank-lines"> --ignore-blank-lines </dt> <dd> <p>Ignore changes whose lines are all blank.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--Iltregexgt"> -I<regex> </dt> <dt class="hdlist1" id="Documentation/git-show.txt---ignore-matching-linesltregexgt"> --ignore-matching-lines=<regex> </dt> <dd> <p>Ignore changes whose all lines match <regex>. This option may be specified more than once.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---inter-hunk-contextltlinesgt"> --inter-hunk-context=<lines> </dt> <dd> <p>Show the context between diff hunks, up to the specified number of lines, thereby fusing hunks that are close to each other. Defaults to <code>diff.interHunkContext</code> or 0 if the config option is unset.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt--W"> -W </dt> <dt class="hdlist1" id="Documentation/git-show.txt---function-context"> --function-context </dt> <dd> <p>Show whole function as context lines for each change. The function names are determined in the same way as <code>git diff</code> works out patch hunk headers (see <code>Defining a custom hunk-header</code> in <a href="gitattributes">gitattributes[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---ext-diff"> --ext-diff </dt> <dd> <p>Allow an external diff helper to be executed. If you set an external diff driver with <a href="gitattributes">gitattributes[5]</a>, you need to use this option with <a href="git-log">git-log[1]</a> and friends.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---no-ext-diff"> --no-ext-diff </dt> <dd> <p>Disallow external diff drivers.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---textconv"> --textconv </dt> <dt class="hdlist1" id="Documentation/git-show.txt---no-textconv"> --no-textconv </dt> <dd> <p>Allow (or disallow) external text conversion filters to be run when comparing binary files. See <a href="gitattributes">gitattributes[5]</a> for details. Because textconv filters are typically a one-way conversion, the resulting diff is suitable for human consumption, but cannot be applied. For this reason, textconv filters are enabled by default only for <a href="git-diff">git-diff[1]</a> and <a href="git-log">git-log[1]</a>, but not for <a href="git-format-patch">git-format-patch[1]</a> or diff plumbing commands.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---ignore-submodulesltwhengt"> --ignore-submodules[=<when>] </dt> <dd> <p>Ignore changes to submodules in the diff generation. <when> can be either "none", "untracked", "dirty" or "all", which is the default. Using "none" will consider the submodule modified when it either contains untracked or modified files or its HEAD differs from the commit recorded in the superproject and can be used to override any settings of the <code>ignore</code> option in <a href="git-config">git-config[1]</a> or <a href="gitmodules">gitmodules[5]</a>. When "untracked" is used submodules are not considered dirty when they only contain untracked content (but they are still scanned for modified content). Using "dirty" ignores all changes to the work tree of submodules, only changes to the commits stored in the superproject are shown (this was the behavior until 1.7.0). Using "all" hides all changes to submodules.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---src-prefixltprefixgt"> --src-prefix=<prefix> </dt> <dd> <p>Show the given source prefix instead of "a/".</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---dst-prefixltprefixgt"> --dst-prefix=<prefix> </dt> <dd> <p>Show the given destination prefix instead of "b/".</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---no-prefix"> --no-prefix </dt> <dd> <p>Do not show any source or destination prefix.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---default-prefix"> --default-prefix </dt> <dd> <p>Use the default source and destination prefixes ("a/" and "b/"). This is usually the default already, but may be used to override config such as <code>diff.noprefix</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---line-prefixltprefixgt"> --line-prefix=<prefix> </dt> <dd> <p>Prepend an additional prefix to every line of output.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt---ita-invisible-in-index"> --ita-invisible-in-index </dt> <dd> <p>By default entries added by "git add -N" appear as an existing empty file in "git diff" and a new file in "git diff --cached". This option makes the entry appear as a new file in "git diff" and non-existent in "git diff --cached". This option could be reverted with <code>--ita-visible-in-index</code>. Both options are experimental and could be removed in future.</p> </dd> </dl> </div> <p>For more detailed explanation on these common options, see also <a href="gitdiffcore">gitdiffcore[7]</a>.</p> </div> <h2 id="generate_patch_text_with_p">Generating patch text with -p</h2> <div class="sectionbody"> <p>Running <a href="git-diff">git-diff[1]</a>, <a href="git-log">git-log[1]</a>, <a href="git-show">git-show[1]</a>, <a href="git-diff-index">git-diff-index[1]</a>, <a href="git-diff-tree">git-diff-tree[1]</a>, or <a href="git-diff-files">git-diff-files[1]</a> with the <code>-p</code> option produces patch text. You can customize the creation of patch text via the <code>GIT_EXTERNAL_DIFF</code> and the <code>GIT_DIFF_OPTS</code> environment variables (see <a href="git">git[1]</a>), and the <code>diff</code> attribute (see <a href="gitattributes">gitattributes[5]</a>).</p> <p>What the -p option produces is slightly different from the traditional diff format:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>It is preceded by a "git diff" header that looks like this:</p> <div class="literalblock"> <div class="content"> <pre>diff --git a/file1 b/file2</pre> </div> </div> <p>The <code>a/</code> and <code>b/</code> filenames are the same unless rename/copy is involved. Especially, even for a creation or a deletion, <code>/dev/null</code> is <code>not</code> used in place of the <code>a/</code> or <code>b/</code> filenames.</p> <p>When a rename/copy is involved, <code>file1</code> and <code>file2</code> show the name of the source file of the rename/copy and the name of the file that the rename/copy produces, respectively.</p> </li> <li> <p>It is followed by one or more extended header lines:</p> <div class="literalblock"> <div class="content"> <pre>old mode <mode> +new mode <mode> +deleted file mode <mode> +new file mode <mode> +copy from <path> +copy to <path> +rename from <path> +rename to <path> +similarity index <number> +dissimilarity index <number> +index <hash>..<hash> <mode></pre> </div> </div> <p>File modes are printed as 6-digit octal numbers including the file type and file permission bits.</p> <p>Path names in extended headers do not include the <code>a/</code> and <code>b/</code> prefixes.</p> <p>The similarity index is the percentage of unchanged lines, and the dissimilarity index is the percentage of changed lines. It is a rounded down integer, followed by a percent sign. The similarity index value of 100% is thus reserved for two equal files, while 100% dissimilarity means that no line from the old file made it into the new one.</p> <p>The index line includes the blob object names before and after the change. The <mode> is included if the file mode does not change; otherwise, separate lines indicate the old and the new mode.</p> </li> <li> <p>Pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>).</p> </li> <li> <p>All the <code>file1</code> files in the output refer to files before the commit, and all the <code>file2</code> files refer to files after the commit. It is incorrect to apply each change to each file sequentially. For example, this patch will swap a and b:</p> <div class="literalblock"> <div class="content"> <pre>diff --git a/a b/b +rename from a +rename to b +diff --git a/b b/a +rename from b +rename to a</pre> </div> </div> </li> <li> <p>Hunk headers mention the name of the function to which the hunk applies. See "Defining a custom hunk-header" in <a href="gitattributes">gitattributes[5]</a> for details of how to tailor this to specific languages.</p> </li> </ol> </div> </div> <h2 id="_combined_diff_format">Combined diff format</h2> <div class="sectionbody"> <p>Any diff-generating command can take the <code>-c</code> or <code>--cc</code> option to produce a <code>combined diff</code> when showing a merge. This is the default format when showing merges with <a href="git-diff">git-diff[1]</a> or <a href="git-show">git-show[1]</a>. Note also that you can give suitable <code>--diff-merges</code> option to any of these commands to force generation of diffs in a specific format.</p> <p>A "combined diff" format looks like this:</p> <div class="listingblock"> <div class="content"> <pre>diff --combined describe.c +index fabadb8,cc95eb0..4866510 +--- a/describe.c ++++ b/describe.c +@@@ -98,20 -98,12 +98,20 @@@ + return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; + } + +- static void describe(char *arg) + -static void describe(struct commit *cmit, int last_one) +++static void describe(char *arg, int last_one) + { + + unsigned char sha1[20]; + + struct commit *cmit; + struct commit_list *list; + static int initialized = 0; + struct commit_name *n; + + + if (get_sha1(arg, sha1) < 0) + + usage(describe_usage); + + cmit = lookup_commit_reference(sha1); + + if (!cmit) + + usage(describe_usage); + + + if (!initialized) { + initialized = 1; + for_each_ref(get_name);</pre> </div> </div> <div class="olist arabic"> <ol class="arabic"> <li> <p>It is preceded by a "git diff" header, that looks like this (when the <code>-c</code> option is used):</p> <div class="literalblock"> <div class="content"> <pre>diff --combined file</pre> </div> </div> <p>or like this (when the <code>--cc</code> option is used):</p> <div class="literalblock"> <div class="content"> <pre>diff --cc file</pre> </div> </div> </li> <li> <p>It is followed by one or more extended header lines (this example shows a merge with two parents):</p> <div class="literalblock"> <div class="content"> <pre>index <hash>,<hash>..<hash> +mode <mode>,<mode>..<mode> +new file mode <mode> +deleted file mode <mode>,<mode></pre> </div> </div> <p>The <code>mode <mode>,<mode>..<mode></code> line appears only if at least one of the <mode> is different from the rest. Extended headers with information about detected content movement (renames and copying detection) are designed to work with the diff of two <tree-ish> and are not used by combined diff format.</p> </li> <li> <p>It is followed by a two-line from-file/to-file header:</p> <div class="literalblock"> <div class="content"> <pre>--- a/file ++++ b/file</pre> </div> </div> <p>Similar to the two-line header for the traditional <code>unified</code> diff format, <code>/dev/null</code> is used to signal created or deleted files.</p> <p>However, if the --combined-all-paths option is provided, instead of a two-line from-file/to-file, you get an N+1 line from-file/to-file header, where N is the number of parents in the merge commit:</p> <div class="literalblock"> <div class="content"> <pre>--- a/file +--- a/file +--- a/file ++++ b/file</pre> </div> </div> <p>This extended format can be useful if rename or copy detection is active, to allow you to see the original name of the file in different parents.</p> </li> <li> <p>Chunk header format is modified to prevent people from accidentally feeding it to <code>patch -p1</code>. Combined diff format was created for review of merge commit changes, and was not meant to be applied. The change is similar to the change in the extended <code>index</code> header:</p> <div class="literalblock"> <div class="content"> <pre>@@@ <from-file-range> <from-file-range> <to-file-range> @@@</pre> </div> </div> <p>There are (number of parents + 1) <code>@</code> characters in the chunk header for combined diff format.</p> </li> </ol> </div> <p>Unlike the traditional <code>unified</code> diff format, which shows two files A and B with a single column that has <code>-</code> (minus — appears in A but removed in B), <code>+</code> (plus — missing in A but added to B), or <code>" "</code> (space — unchanged) prefix, this format compares two or more files file1, file2,… with one file X, and shows how X differs from each of fileN. One column for each of fileN is prepended to the output line to note how X’s line is different from it.</p> <p>A <code>-</code> character in the column N means that the line appears in fileN but it does not appear in the result. A <code>+</code> character in the column N means that the line appears in the result, and fileN does not have that line (in other words, the line was added, from the point of view of that parent).</p> <p>In the above example output, the function signature was changed from both files (hence two <code>-</code> removals from both file1 and file2, plus <code>++</code> to mean one line that was added does not appear in either file1 or file2). Also, eight other lines are the same from file1 but do not appear in file2 (hence prefixed with <code>+</code>).</p> <p>When shown by <code>git diff-tree -c</code>, it compares the parents of a merge commit with the merge result (i.e. file1..fileN are the parents). When shown by <code>git diff-files -c</code>, it compares the two unresolved merge parents with the working tree file (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka "their version").</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-show.txt-codegitshowv100code"> <code>git show v1.0.0</code> </dt> <dd> <p>Shows the tag <code>v1.0.0</code>, along with the object the tag points at.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-codegitshowv100treecode"> <code>git show v1.0.0^{tree}</code> </dt> <dd> <p>Shows the tree pointed to by the tag <code>v1.0.0</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-codegitshow-s--formatsv100commitcode"> <code>git show -s --format=%s v1.0.0^{commit}</code> </dt> <dd> <p>Shows the subject of the commit pointed to by the tag <code>v1.0.0</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-codegitshownext10DocumentationREADMEcode"> <code>git show next~10:Documentation/README</code> </dt> <dd> <p>Shows the contents of the file <code>Documentation/README</code> as they were current in the 10th last commit of the branch <code>next</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-show.txt-codegitshowmasterMakefilemastertMakefilecode"> <code>git show master:Makefile master:t/Makefile</code> </dt> <dd> <p>Concatenates the contents of said Makefiles in the head of the branch <code>master</code>.</p> </dd> </dl> </div> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>Git is to some extent character encoding agnostic.</p> <div class="ulist"> <ul> <li> <p>The contents of the blob objects are uninterpreted sequences of bytes. There is no encoding translation at the core level.</p> </li> <li> <p>Path names are encoded in UTF-8 normalization form C. This applies to tree objects, the index file, ref names, as well as path names in command line arguments, environment variables and config files (<code>.git/config</code> (see <a href="git-config">git-config[1]</a>), <a href="gitignore">gitignore[5]</a>, <a href="gitattributes">gitattributes[5]</a> and <a href="gitmodules">gitmodules[5]</a>).</p> <p>Note that Git at the core level treats path names simply as sequences of non-NUL bytes, there are no path name encoding conversions (except on Mac and Windows). Therefore, using non-ASCII path names will mostly work even on platforms and file systems that use legacy extended ASCII encodings. However, repositories created on such systems will not work properly on UTF-8-based systems (e.g. Linux, Mac, Windows) and vice versa. Additionally, many Git-based tools simply assume path names to be UTF-8 and will fail to display other encodings correctly.</p> </li> <li> <p>Commit log messages are typically encoded in UTF-8, but other extended ASCII encodings are also supported. This includes ISO-8859-x, CP125x and many others, but <code>not</code> UTF-16/32, EBCDIC and CJK multi-byte encodings (GBK, Shift-JIS, Big5, EUC-x, CP9xx etc.).</p> </li> </ul> </div> <p>Although we encourage that the commit log messages are encoded in UTF-8, both the core and Git Porcelain are designed not to force UTF-8 on projects. If all participants of a particular project find it more convenient to use legacy encodings, Git does not forbid it. However, there are a few things to keep in mind.</p> <div class="olist arabic"> <ol class="arabic"> <li> <p><code>git commit</code> and <code>git commit-tree</code> issue a warning if the commit log message given to it does not look like a valid UTF-8 string, unless you explicitly say your project uses a legacy encoding. The way to say this is to have <code>i18n.commitEncoding</code> in <code>.git/config</code> file, like this:</p> <div class="listingblock"> <div class="content"> <pre>[i18n] + commitEncoding = ISO-8859-1</pre> </div> </div> <p>Commit objects created with the above setting record the value of <code>i18n.commitEncoding</code> in their <code>encoding</code> header. This is to help other people who look at them later. Lack of this header implies that the commit log message is encoded in UTF-8.</p> </li> <li> <p><code>git log</code>, <code>git show</code>, <code>git blame</code> and friends look at the <code>encoding</code> header of a commit object, and try to re-code the log message into UTF-8 unless otherwise specified. You can specify the desired output encoding with <code>i18n.logOutputEncoding</code> in <code>.git/config</code> file, like this:</p> <div class="listingblock"> <div class="content"> <pre>[i18n] + logOutputEncoding = ISO-8859-1</pre> </div> </div> <p>If you do not have this configuration variable, the value of <code>i18n.commitEncoding</code> is used instead.</p> </li> </ol> </div> <p>Note that we deliberately chose not to re-code the commit log message when a commit is made to force UTF-8 at the commit object level, because re-coding to UTF-8 is not necessarily a reversible operation.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-show" class="_attribution-link">https://git-scm.com/docs/git-show</a> + </p> +</div> diff --git a/devdocs/git/git-sparse-checkout.html b/devdocs/git/git-sparse-checkout.html new file mode 100644 index 00000000..e7725e42 --- /dev/null +++ b/devdocs/git/git-sparse-checkout.html @@ -0,0 +1,41 @@ +<h1>git-sparse-checkout</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-sparse-checkout - Reduce your working tree to a subset of tracked files</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git sparse-checkout (init | list | set | add | reapply | disable | check-rules) [<options>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This command is used to create sparse checkouts, which change the working tree from having all tracked files present to only having a subset of those files. It can also switch which subset of files are present, or undo and go back to having all tracked files present in the working copy.</p> <p>The subset of files is chosen by providing a list of directories in cone mode (the default), or by providing a list of patterns in non-cone mode.</p> <p>When in a sparse-checkout, other Git commands behave a bit differently. For example, switching branches will not update paths outside the sparse-checkout directories/patterns, and <code>git commit -a</code> will not record paths outside the sparse-checkout directories/patterns as deleted.</p> <p>THIS COMMAND IS EXPERIMENTAL. ITS BEHAVIOR, AND THE BEHAVIOR OF OTHER COMMANDS IN THE PRESENCE OF SPARSE-CHECKOUTS, WILL LIKELY CHANGE IN THE FUTURE.</p> </div> <h2 id="_commands">Commands</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-sparse-checkout.txt-emlistem"> <em>list</em> </dt> <dd> <p>Describe the directories or patterns in the sparse-checkout file.</p> </dd> <dt class="hdlist1" id="Documentation/git-sparse-checkout.txt-emsetem"> <em>set</em> </dt> <dd> <p>Enable the necessary sparse-checkout config settings (<code>core.sparseCheckout</code>, <code>core.sparseCheckoutCone</code>, and <code>index.sparse</code>) if they are not already set to the desired values, populate the sparse-checkout file from the list of arguments following the <code>set</code> subcommand, and update the working directory to match.</p> <p>To ensure that adjusting the sparse-checkout settings within a worktree does not alter the sparse-checkout settings in other worktrees, the <code>set</code> subcommand will upgrade your repository config to use worktree-specific config if not already present. The sparsity defined by the arguments to the <code>set</code> subcommand are stored in the worktree-specific sparse-checkout file. See <a href="git-worktree">git-worktree[1]</a> and the documentation of <code>extensions.worktreeConfig</code> in <a href="git-config">git-config[1]</a> for more details.</p> <p>When the <code>--stdin</code> option is provided, the directories or patterns are read from standard in as a newline-delimited list instead of from the arguments.</p> <p>By default, the input list is considered a list of directories, matching the output of <code>git ls-tree -d --name-only</code>. This includes interpreting pathnames that begin with a double quote (") as C-style quoted strings. Note that all files under the specified directories (at any depth) will be included in the sparse checkout, as well as files that are siblings of either the given directory or any of its ancestors (see <code>CONE PATTERN SET</code> below for more details). In the past, this was not the default, and <code>--cone</code> needed to be specified or <code>core.sparseCheckoutCone</code> needed to be enabled.</p> <p>When <code>--no-cone</code> is passed, the input list is considered a list of patterns. This mode has a number of drawbacks, including not working with some options like <code>--sparse-index</code>. As explained in the "Non-cone Problems" section below, we do not recommend using it.</p> <p>Use the <code>--[no-]sparse-index</code> option to use a sparse index (the default is to not use it). A sparse index reduces the size of the index to be more closely aligned with your sparse-checkout definition. This can have significant performance advantages for commands such as <code>git status</code> or <code>git add</code>. This feature is still experimental. Some commands might be slower with a sparse index until they are properly integrated with the feature.</p> <p><strong>WARNING:</strong> Using a sparse index requires modifying the index in a way that is not completely understood by external tools. If you have trouble with this compatibility, then run <code>git sparse-checkout init --no-sparse-index</code> to rewrite your index to not be sparse. Older versions of Git will not understand the sparse directory entries index extension and may fail to interact with your repository until it is disabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-sparse-checkout.txt-emaddem"> <em>add</em> </dt> <dd> <p>Update the sparse-checkout file to include additional directories (in cone mode) or patterns (in non-cone mode). By default, these directories or patterns are read from the command-line arguments, but they can be read from stdin using the <code>--stdin</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-sparse-checkout.txt-emreapplyem"> <em>reapply</em> </dt> <dd> <p>Reapply the sparsity pattern rules to paths in the working tree. Commands like merge or rebase can materialize paths to do their work (e.g. in order to show you a conflict), and other sparse-checkout commands might fail to sparsify an individual file (e.g. because it has unstaged changes or conflicts). In such cases, it can make sense to run <code>git sparse-checkout reapply</code> later after cleaning up affected paths (e.g. resolving conflicts, undoing or committing changes, etc.).</p> <p>The <code>reapply</code> command can also take <code>--[no-]cone</code> and <code>--[no-]sparse-index</code> flags, with the same meaning as the flags from the <code>set</code> command, in order to change which sparsity mode you are using without needing to also respecify all sparsity paths.</p> </dd> <dt class="hdlist1" id="Documentation/git-sparse-checkout.txt-emdisableem"> <em>disable</em> </dt> <dd> <p>Disable the <code>core.sparseCheckout</code> config setting, and restore the working directory to include all files.</p> </dd> <dt class="hdlist1" id="Documentation/git-sparse-checkout.txt-eminitem"> <em>init</em> </dt> <dd> <p>Deprecated command that behaves like <code>set</code> with no specified paths. May be removed in the future.</p> <p>Historically, <code>set</code> did not handle all the necessary config settings, which meant that both <code>init</code> and <code>set</code> had to be called. Invoking both meant the <code>init</code> step would first remove nearly all tracked files (and in cone mode, ignored files too), then the <code>set</code> step would add many of the tracked files (but not ignored files) back. In addition to the lost files, the performance and UI of this combination was poor.</p> <p>Also, historically, <code>init</code> would not actually initialize the sparse-checkout file if it already existed. This meant it was possible to return to a sparse-checkout without remembering which paths to pass to a subsequent <code>set</code> or <code>add</code> command. However, <code>--cone</code> and <code>--sparse-index</code> options would not be remembered across the disable command, so the easy restore of calling a plain <code>init</code> decreased in utility.</p> </dd> <dt class="hdlist1" id="Documentation/git-sparse-checkout.txt-emcheck-rulesem"> <em>check-rules</em> </dt> <dd> <p>Check whether sparsity rules match one or more paths.</p> <p>By default <code>check-rules</code> reads a list of paths from stdin and outputs only the ones that match the current sparsity rules. The input is expected to consist of one path per line, matching the output of <code>git ls-tree --name-only</code> including that pathnames that begin with a double quote (") are interpreted as C-style quoted strings.</p> <p>When called with the <code>--rules-file <file></code> flag the input files are matched against the sparse checkout rules found in <code><file></code> instead of the current ones. The rules in the files are expected to be in the same form as accepted by <code>git +sparse-checkout set --stdin</code> (in particular, they must be newline-delimited).</p> <p>By default, the rules passed to the <code>--rules-file</code> option are interpreted as cone mode directories. To pass non-cone mode patterns with <code>--rules-file</code>, combine the option with the <code>--no-cone</code> option.</p> <p>When called with the <code>-z</code> flag, the format of the paths input on stdin as well as the output paths are \0 terminated and not quoted. Note that this does not apply to the format of the rules passed with the <code>--rules-file</code> option.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-sparse-checkout.txt-codegitsparse-checkoutsetMYDIR1SUBDIR2code"> <code>git sparse-checkout set MY/DIR1 SUB/DIR2</code> </dt> <dd> <p>Change to a sparse checkout with all files (at any depth) under MY/DIR1/ and SUB/DIR2/ present in the working copy (plus all files immediately under MY/ and SUB/ and the toplevel directory). If already in a sparse checkout, change which files are present in the working copy to this new selection. Note that this command will also delete all ignored files in any directory that no longer has either tracked or non-ignored-untracked files present.</p> </dd> <dt class="hdlist1" id="Documentation/git-sparse-checkout.txt-codegitsparse-checkoutdisablecode"> <code>git sparse-checkout disable</code> </dt> <dd> <p>Repopulate the working directory with all files, disabling sparse checkouts.</p> </dd> <dt class="hdlist1" id="Documentation/git-sparse-checkout.txt-codegitsparse-checkoutaddSOMEDIRECTORYcode"> <code>git sparse-checkout add SOME/DIR/ECTORY</code> </dt> <dd> <p>Add all files under SOME/DIR/ECTORY/ (at any depth) to the sparse checkout, as well as all files immediately under SOME/DIR/ and immediately under SOME/. Must already be in a sparse checkout before using this command.</p> </dd> <dt class="hdlist1" id="Documentation/git-sparse-checkout.txt-codegitsparse-checkoutreapplycode"> <code>git sparse-checkout reapply</code> </dt> <dd> <p>It is possible for commands to update the working tree in a way that does not respect the selected sparsity directories. This can come from tools external to Git writing files, or even affect Git commands because of either special cases (such as hitting conflicts when merging/rebasing), or because some commands didn’t fully support sparse checkouts (e.g. the old <code>recursive</code> merge backend had only limited support). This command reapplies the existing sparse directory specifications to make the working directory match.</p> </dd> </dl> </div> </div> <h2 id="_internalssparse_checkout">Internals — sparse checkout</h2> <div class="sectionbody"> <p>"Sparse checkout" allows populating the working directory sparsely. It uses the skip-worktree bit (see <a href="git-update-index">git-update-index[1]</a>) to tell Git whether a file in the working directory is worth looking at. If the skip-worktree bit is set, and the file is not present in the working tree, then its absence is ignored. Git will avoid populating the contents of those files, which makes a sparse checkout helpful when working in a repository with many files, but only a few are important to the current user.</p> <p>The <code>$GIT_DIR/info/sparse-checkout</code> file is used to define the skip-worktree reference bitmap. When Git updates the working directory, it updates the skip-worktree bits in the index based on this file. The files matching the patterns in the file will appear in the working directory, and the rest will not.</p> </div> <h2 id="_internalsnon_cone_problems">Internals — non-cone problems</h2> <div class="sectionbody"> <p>The <code>$GIT_DIR/info/sparse-checkout</code> file populated by the <code>set</code> and <code>add</code> subcommands is defined to be a bunch of patterns (one per line) using the same syntax as <code>.gitignore</code> files. In cone mode, these patterns are restricted to matching directories (and users only ever need supply or see directory names), while in non-cone mode any gitignore-style pattern is permitted. Using the full gitignore-style patterns in non-cone mode has a number of shortcomings:</p> <div class="ulist"> <ul> <li> <p>Fundamentally, it makes various worktree-updating processes (pull, merge, rebase, switch, reset, checkout, etc.) require O(N*M) pattern matches, where N is the number of patterns and M is the number of paths in the index. This scales poorly.</p> </li> <li> <p>Avoiding the scaling issue has to be done via limiting the number of patterns via specifying leading directory name or glob.</p> </li> <li> <p>Passing globs on the command line is error-prone as users may forget to quote the glob, causing the shell to expand it into all matching files and pass them all individually along to sparse-checkout set/add. While this could also be a problem with e.g. "git grep — *.c", mistakes with grep/log/status appear in the immediate output. With sparse-checkout, the mistake gets recorded at the time the sparse-checkout command is run and might not be problematic until the user later switches branches or rebases or merges, thus putting a delay between the user’s error and when they have a chance to catch/notice it.</p> </li> <li> <p>Related to the previous item, sparse-checkout has an <code>add</code> subcommand but no <code>remove</code> subcommand. Even if a <code>remove</code> subcommand were added, undoing an accidental unquoted glob runs the risk of "removing too much", as it may remove entries that had been included before the accidental add.</p> </li> <li> <p>Non-cone mode uses gitignore-style patterns to select what to <strong>include</strong> (with the exception of negated patterns), while .gitignore files use gitignore-style patterns to select what to <strong>exclude</strong> (with the exception of negated patterns). The documentation on gitignore-style patterns usually does not talk in terms of matching or non-matching, but on what the user wants to "exclude". This can cause confusion for users trying to learn how to specify sparse-checkout patterns to get their desired behavior.</p> </li> <li> <p>Every other git subcommand that wants to provide "special path pattern matching" of some sort uses pathspecs, but non-cone mode for sparse-checkout uses gitignore patterns, which feels inconsistent.</p> </li> <li> <p>It has edge cases where the "right" behavior is unclear. Two examples:</p> <div class="literalblock"> <div class="content"> <pre>First, two users are in a subdirectory, and the first runs + git sparse-checkout set '/toplevel-dir/*.c' +while the second runs + git sparse-checkout set relative-dir +Should those arguments be transliterated into + current/subdirectory/toplevel-dir/*.c +and + current/subdirectory/relative-dir +before inserting into the sparse-checkout file? The user who typed +the first command is probably aware that arguments to set/add are +supposed to be patterns in non-cone mode, and probably would not be +happy with such a transliteration. However, many gitignore-style +patterns are just paths, which might be what the user who typed the +second command was thinking, and they'd be upset if their argument +wasn't transliterated.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Second, what should bash-completion complete on for set/add commands +for non-cone users? If it suggests paths, is it exacerbating the +problem above? Also, if it suggests paths, what if the user has a +file or directory that begins with either a '!' or '#' or has a '*', +'\', '?', '[', or ']' in its name? And if it suggests paths, will +it complete "/pro" to "/proc" (in the root filesystem) rather than to +"/progress.txt" in the current directory? (Note that users are +likely to want to start paths with a leading '/' in non-cone mode, +for the same reason that .gitignore files often have one.) +Completing on files or directories might give nasty surprises in +all these cases.</pre> </div> </div> </li> <li> <p>The excessive flexibility made other extensions essentially impractical. <code>--sparse-index</code> is likely impossible in non-cone mode; even if it is somehow feasible, it would have been far more work to implement and may have been too slow in practice. Some ideas for adding coupling between partial clones and sparse checkouts are only practical with a more restricted set of paths as well.</p> </li> </ul> </div> <p>For all these reasons, non-cone mode is deprecated. Please switch to using cone mode.</p> </div> <h2 id="_internalscone_mode_handling">Internals — cone mode handling</h2> <div class="sectionbody"> <p>The "cone mode", which is the default, lets you specify only what directories to include. For any directory specified, all paths below that directory will be included, and any paths immediately under leading directories (including the toplevel directory) will also be included. Thus, if you specified the directory Documentation/technical/ then your sparse checkout would contain:</p> <div class="ulist"> <ul> <li> <p>all files in the toplevel-directory</p> </li> <li> <p>all files immediately under Documentation/</p> </li> <li> <p>all files at any depth under Documentation/technical/</p> </li> </ul> </div> <p>Also, in cone mode, even if no directories are specified, then the files in the toplevel directory will be included.</p> <p>When changing the sparse-checkout patterns in cone mode, Git will inspect each tracked directory that is not within the sparse-checkout cone to see if it contains any untracked files. If all of those files are ignored due to the <code>.gitignore</code> patterns, then the directory will be deleted. If any of the untracked files within that directory is not ignored, then no deletions will occur within that directory and a warning message will appear. If these files are important, then reset your sparse-checkout definition so they are included, use <code>git add</code> and <code>git commit</code> to store them, then remove any remaining files manually to ensure Git can behave optimally.</p> <p>See also the "Internals — Cone Pattern Set" section to learn how the directories are transformed under the hood into a subset of the Full Pattern Set of sparse-checkout.</p> </div> <h2 id="_internalsfull_pattern_set">Internals — full pattern set</h2> <div class="sectionbody"> <p>The full pattern set allows for arbitrary pattern matches and complicated inclusion/exclusion rules. These can result in O(N*M) pattern matches when updating the index, where N is the number of patterns and M is the number of paths in the index. To combat this performance issue, a more restricted pattern set is allowed when <code>core.sparseCheckoutCone</code> is enabled.</p> <p>The sparse-checkout file uses the same syntax as <code>.gitignore</code> files; see <a href="gitignore">gitignore[5]</a> for details. Here, though, the patterns are usually being used to select which files to include rather than which files to exclude. (However, it can get a bit confusing since gitignore-style patterns have negations defined by patterns which begin with a <code>!</code>, so you can also select files to <code>not</code> include.)</p> <p>For example, to select everything, and then to remove the file <code>unwanted</code> (so that every file will appear in your working tree except the file named <code>unwanted</code>):</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git sparse-checkout set --no-cone '/*' '!unwanted'</pre> </div> </div> <p>These patterns are just placed into the <code>$GIT_DIR/info/sparse-checkout</code> as-is, so the contents of that file at this point would be</p> <div class="listingblock"> <div class="content"> <pre>/* +!unwanted</pre> </div> </div> <p>See also the "Sparse Checkout" section of <a href="git-read-tree">git-read-tree[1]</a> to learn more about the gitignore-style patterns used in sparse checkouts.</p> </div> <h2 id="_internalscone_pattern_set">Internals — cone pattern set</h2> <div class="sectionbody"> <p>In cone mode, only directories are accepted, but they are translated into the same gitignore-style patterns used in the full pattern set. We refer to the particular patterns used in those mode as being of one of two types:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p><strong>Recursive:</strong> All paths inside a directory are included.</p> </li> <li> <p><strong>Parent:</strong> All files immediately inside a directory are included.</p> </li> </ol> </div> <p>Since cone mode always includes files at the toplevel, when running <code>git sparse-checkout set</code> with no directories specified, the toplevel directory is added as a parent pattern. At this point, the sparse-checkout file contains the following patterns:</p> <div class="listingblock"> <div class="content"> <pre>/* +!/*/</pre> </div> </div> <p>This says "include everything immediately under the toplevel directory, but nothing at any level below that."</p> <p>When in cone mode, the <code>git sparse-checkout set</code> subcommand takes a list of directories. The command <code>git sparse-checkout set A/B/C</code> sets the directory <code>A/B/C</code> as a recursive pattern, the directories <code>A</code> and <code>A/B</code> are added as parent patterns. The resulting sparse-checkout file is now</p> <div class="listingblock"> <div class="content"> <pre>/* +!/*/ +/A/ +!/A/*/ +/A/B/ +!/A/B/*/ +/A/B/C/</pre> </div> </div> <p>Here, order matters, so the negative patterns are overridden by the positive patterns that appear lower in the file.</p> <p>Unless <code>core.sparseCheckoutCone</code> is explicitly set to <code>false</code>, Git will parse the sparse-checkout file expecting patterns of these types. Git will warn if the patterns do not match. If the patterns do match the expected format, then Git will use faster hash-based algorithms to compute inclusion in the sparse-checkout. If they do not match, git will behave as though <code>core.sparseCheckoutCone</code> was false, regardless of its setting.</p> <p>In the cone mode case, despite the fact that full patterns are written to the $GIT_DIR/info/sparse-checkout file, the <code>git sparse-checkout +list</code> subcommand will list the directories that define the recursive patterns. For the example sparse-checkout file above, the output is as follows:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git sparse-checkout list +A/B/C</pre> </div> </div> <p>If <code>core.ignoreCase=true</code>, then the pattern-matching algorithm will use a case-insensitive check. This corrects for case mismatched filenames in the <code>git sparse-checkout set</code> command to reflect the expected cone in the working directory.</p> </div> <h2 id="_internalssubmodules">Internals — submodules</h2> <div class="sectionbody"> <p>If your repository contains one or more submodules, then submodules are populated based on interactions with the <code>git submodule</code> command. Specifically, <code>git submodule init -- <path></code> will ensure the submodule at <code><path></code> is present, while <code>git submodule deinit [-f] -- <path></code> will remove the files for the submodule at <code><path></code> (including any untracked files, uncommitted changes, and unpushed history). Similar to how sparse-checkout removes files from the working tree but still leaves entries in the index, deinitialized submodules are removed from the working directory but still have an entry in the index.</p> <p>Since submodules may have unpushed changes or untracked files, removing them could result in data loss. Thus, changing sparse inclusion/exclusion rules will not cause an already checked out submodule to be removed from the working copy. Said another way, just as <code>checkout</code> will not cause submodules to be automatically removed or initialized even when switching between branches that remove or add submodules, using <code>sparse-checkout</code> to reduce or expand the scope of "interesting" files will not cause submodules to be automatically deinitialized or initialized either.</p> <p>Further, the above facts mean that there are multiple reasons that "tracked" files might not be present in the working copy: sparsity pattern application from sparse-checkout, and submodule initialization state. Thus, commands like <code>git grep</code> that work on tracked files in the working copy may return results that are limited by either or both of these restrictions.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-read-tree">git-read-tree[1]</a> <a href="gitignore">gitignore[5]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-sparse-checkout" class="_attribution-link">https://git-scm.com/docs/git-sparse-checkout</a> + </p> +</div> diff --git a/devdocs/git/git-stash.html b/devdocs/git/git-stash.html new file mode 100644 index 00000000..f8d8943c --- /dev/null +++ b/devdocs/git/git-stash.html @@ -0,0 +1,57 @@ +<h1>git-stash</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-stash - Stash the changes in a dirty working directory away</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git stash list [<log-options>] +git stash show [-u | --include-untracked | --only-untracked] [<diff-options>] [<stash>] +git stash drop [-q | --quiet] [<stash>] +git stash pop [--index] [-q | --quiet] [<stash>] +git stash apply [--index] [-q | --quiet] [<stash>] +git stash branch <branchname> [<stash>] +git stash [push [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | --quiet] + [-u | --include-untracked] [-a | --all] [(-m | --message) <message>] + [--pathspec-from-file=<file> [--pathspec-file-nul]] + [--] [<pathspec>…]] +git stash save [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | --quiet] + [-u | --include-untracked] [-a | --all] [<message>] +git stash clear +git stash create [<message>] +git stash store [(-m | --message) <message>] [-q | --quiet] <commit></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Use <code>git stash</code> when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the <code>HEAD</code> commit.</p> <p>The modifications stashed away by this command can be listed with <code>git stash list</code>, inspected with <code>git stash show</code>, and restored (potentially on top of a different commit) with <code>git stash apply</code>. Calling <code>git stash</code> without any arguments is equivalent to <code>git stash push</code>. A stash is by default listed as "WIP on <code>branchname</code> …", but you can give a more descriptive message on the command line when you create one.</p> <p>The latest stash you created is stored in <code>refs/stash</code>; older stashes are found in the reflog of this reference and can be named using the usual reflog syntax (e.g. <code>stash@{0}</code> is the most recently created stash, <code>stash@{1}</code> is the one before it, <code>stash@{2.hours.ago}</code> is also possible). Stashes may also be referenced by specifying just the stash index (e.g. the integer <code>n</code> is equivalent to <code>stash@{n}</code>).</p> </div> <h2 id="_commands">Commands</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-stash.txt-push-p--patch-S--staged-k--no-keep-index-u--include-untracked-a--all-q--quiet-m--messageltmessagegt--pathspec-from-fileltfilegt--pathspec-file-nul--ltpathspecgt82308203"> push [-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [(-m|--message) <message>] [--pathspec-from-file=<file> [--pathspec-file-nul]] [--] [<pathspec>…] </dt> <dd> <p>Save your local modifications to a new <code>stash entry</code> and roll them back to HEAD (in the working tree and in the index). The <message> part is optional and gives the description along with the stashed state.</p> <p>For quickly making a snapshot, you can omit "push". In this mode, non-option arguments are not allowed to prevent a misspelled subcommand from making an unwanted stash entry. The two exceptions to this are <code>stash -p</code> which acts as alias for <code>stash push -p</code> and pathspec elements, which are allowed after a double hyphen <code>--</code> for disambiguation.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-save-p--patch-S--staged-k--no-keep-index-u--include-untracked-a--all-q--quietltmessagegt"> save [-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [<message>] </dt> <dd> <p>This option is deprecated in favour of <code>git stash push</code>. It differs from "stash push" in that it cannot take pathspec. Instead, all non-option arguments are concatenated to form the stash message.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-listltlog-optionsgt"> list [<log-options>] </dt> <dd> <p>List the stash entries that you currently have. Each <code>stash entry</code> is listed with its name (e.g. <code>stash@{0}</code> is the latest entry, <code>stash@{1}</code> is the one before, etc.), the name of the branch that was current when the entry was made, and a short description of the commit the entry was based on.</p> <div class="listingblock"> <div class="content"> <pre>stash@{0}: WIP on submit: 6ebd0e2... Update git-stash documentation +stash@{1}: On master: 9cc0589... Add git-stash</pre> </div> </div> <p>The command takes options applicable to the <code>git log</code> command to control what is shown and how. See <a href="git-log">git-log[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-show-u--include-untracked--only-untrackedltdiff-optionsgtltstashgt"> show [-u|--include-untracked|--only-untracked] [<diff-options>] [<stash>] </dt> <dd> <p>Show the changes recorded in the stash entry as a diff between the stashed contents and the commit back when the stash entry was first created. By default, the command shows the diffstat, but it will accept any format known to <code>git diff</code> (e.g., <code>git stash show -p stash@{1}</code> to view the second most recent entry in patch form). If no <code><diff-option></code> is provided, the default behavior will be given by the <code>stash.showStat</code>, and <code>stash.showPatch</code> config variables. You can also use <code>stash.showIncludeUntracked</code> to set whether <code>--include-untracked</code> is enabled by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-pop--index-q--quietltstashgt"> pop [--index] [-q|--quiet] [<stash>] </dt> <dd> <p>Remove a single stashed state from the stash list and apply it on top of the current working tree state, i.e., do the inverse operation of <code>git stash push</code>. The working directory must match the index.</p> <p>Applying the state can fail with conflicts; in this case, it is not removed from the stash list. You need to resolve the conflicts by hand and call <code>git stash drop</code> manually afterwards.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-apply--index-q--quietltstashgt"> apply [--index] [-q|--quiet] [<stash>] </dt> <dd> <p>Like <code>pop</code>, but do not remove the state from the stash list. Unlike <code>pop</code>, <code><stash></code> may be any commit that looks like a commit created by <code>stash push</code> or <code>stash create</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-branchltbranchnamegtltstashgt"> branch <branchname> [<stash>] </dt> <dd> <p>Creates and checks out a new branch named <code><branchname></code> starting from the commit at which the <code><stash></code> was originally created, applies the changes recorded in <code><stash></code> to the new working tree and index. If that succeeds, and <code><stash></code> is a reference of the form <code>stash@{<revision>}</code>, it then drops the <code><stash></code>.</p> <p>This is useful if the branch on which you ran <code>git stash push</code> has changed enough that <code>git stash apply</code> fails due to conflicts. Since the stash entry is applied on top of the commit that was HEAD at the time <code>git stash</code> was run, it restores the originally stashed state with no conflicts.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-clear"> clear </dt> <dd> <p>Remove all the stash entries. Note that those entries will then be subject to pruning, and may be impossible to recover (see <code>Examples</code> below for a possible strategy).</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-drop-q--quietltstashgt"> drop [-q|--quiet] [<stash>] </dt> <dd> <p>Remove a single stash entry from the list of stash entries.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-create"> create </dt> <dd> <p>Create a stash entry (which is a regular commit object) and return its object name, without storing it anywhere in the ref namespace. This is intended to be useful for scripts. It is probably not the command you want to use; see "push" above.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-store"> store </dt> <dd> <p>Store a given stash created via <code>git stash create</code> (which is a dangling merge commit) in the stash ref, updating the stash reflog. This is intended to be useful for scripts. It is probably not the command you want to use; see "push" above.</p> </dd> </dl> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-stash.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-stash.txt---all"> --all </dt> <dd> <p>This option is only valid for <code>push</code> and <code>save</code> commands.</p> <p>All ignored and untracked files are also stashed and then cleaned up with <code>git clean</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt--u"> -u </dt> <dt class="hdlist1" id="Documentation/git-stash.txt---include-untracked"> --include-untracked </dt> <dt class="hdlist1" id="Documentation/git-stash.txt---no-include-untracked"> --no-include-untracked </dt> <dd> <p>When used with the <code>push</code> and <code>save</code> commands, all untracked files are also stashed and then cleaned up with <code>git clean</code>.</p> <p>When used with the <code>show</code> command, show the untracked files in the stash entry as part of the diff.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt---only-untracked"> --only-untracked </dt> <dd> <p>This option is only valid for the <code>show</code> command.</p> <p>Show only the untracked files in the stash entry as part of the diff.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt---index"> --index </dt> <dd> <p>This option is only valid for <code>pop</code> and <code>apply</code> commands.</p> <p>Tries to reinstate not only the working tree’s changes, but also the index’s ones. However, this can fail, when you have conflicts (which are stored in the index, where you therefore can no longer apply the changes as they were originally).</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt--k"> -k </dt> <dt class="hdlist1" id="Documentation/git-stash.txt---keep-index"> --keep-index </dt> <dt class="hdlist1" id="Documentation/git-stash.txt---no-keep-index"> --no-keep-index </dt> <dd> <p>This option is only valid for <code>push</code> and <code>save</code> commands.</p> <p>All changes already added to the index are left intact.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-stash.txt---patch"> --patch </dt> <dd> <p>This option is only valid for <code>push</code> and <code>save</code> commands.</p> <p>Interactively select hunks from the diff between HEAD and the working tree to be stashed. The stash entry is constructed such that its index state is the same as the index state of your repository, and its worktree contains only the changes you selected interactively. The selected changes are then rolled back from your worktree. See the “Interactive Mode” section of <a href="git-add">git-add[1]</a> to learn how to operate the <code>--patch</code> mode.</p> <p>The <code>--patch</code> option implies <code>--keep-index</code>. You can use <code>--no-keep-index</code> to override this.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt--S"> -S </dt> <dt class="hdlist1" id="Documentation/git-stash.txt---staged"> --staged </dt> <dd> <p>This option is only valid for <code>push</code> and <code>save</code> commands.</p> <p>Stash only the changes that are currently staged. This is similar to basic <code>git commit</code> except the state is committed to the stash instead of current branch.</p> <p>The <code>--patch</code> option has priority over this one.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt---pathspec-from-fileltfilegt"> --pathspec-from-file=<file> </dt> <dd> <p>This option is only valid for <code>push</code> command.</p> <p>Pathspec is passed in <code><file></code> instead of commandline args. If <code><file></code> is exactly <code>-</code> then standard input is used. Pathspec elements are separated by LF or CR/LF. Pathspec elements can be quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>). See also <code>--pathspec-file-nul</code> and global <code>--literal-pathspecs</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt---pathspec-file-nul"> --pathspec-file-nul </dt> <dd> <p>This option is only valid for <code>push</code> command.</p> <p>Only meaningful with <code>--pathspec-from-file</code>. Pathspec elements are separated with NUL character and all other characters are taken literally (including newlines and quotes).</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-stash.txt---quiet"> --quiet </dt> <dd> <p>This option is only valid for <code>apply</code>, <code>drop</code>, <code>pop</code>, <code>push</code>, <code>save</code>, <code>store</code> commands.</p> <p>Quiet, suppress feedback messages.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt---"> -- </dt> <dd> <p>This option is only valid for <code>push</code> command.</p> <p>Separates pathspec from options for disambiguation purposes.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-ltpathspecgt82308203"> <pathspec>… </dt> <dd> <p>This option is only valid for <code>push</code> command.</p> <p>The new stash entry records the modified states only for the files that match the pathspec. The index entries and working tree files are then rolled back to the state in HEAD only for these files, too, leaving files that do not match the pathspec intact.</p> <p>For more details, see the <code>pathspec</code> entry in <a href="gitglossary">gitglossary[7]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-ltstashgt"> <stash> </dt> <dd> <p>This option is only valid for <code>apply</code>, <code>branch</code>, <code>drop</code>, <code>pop</code>, <code>show</code> commands.</p> <p>A reference of the form <code>stash@{<revision>}</code>. When no <code><stash></code> is given, the latest stash is assumed (that is, <code>stash@{0}</code>).</p> </dd> </dl> </div> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>A stash entry is represented as a commit whose tree records the state of the working directory, and its first parent is the commit at <code>HEAD</code> when the entry was created. The tree of the second parent records the state of the index when the entry is made, and it is made a child of the <code>HEAD</code> commit. The ancestry graph looks like this:</p> <div class="literalblock"> <div class="content"> <pre> .----W + / / +-----H----I</pre> </div> </div> <p>where <code>H</code> is the <code>HEAD</code> commit, <code>I</code> is a commit that records the state of the index, and <code>W</code> is a commit that records the state of the working tree.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-stash.txt-Pullingintoadirtytree"> Pulling into a dirty tree </dt> <dd> <p>When you are in the middle of something, you learn that there are upstream changes that are possibly relevant to what you are doing. When your local changes do not conflict with the changes in the upstream, a simple <code>git pull</code> will let you move forward.</p> <p>However, there are cases in which your local changes do conflict with the upstream changes, and <code>git pull</code> refuses to overwrite your changes. In such a case, you can stash your changes away, perform a pull, and then unstash, like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git pull + ... +file foobar not up to date, cannot merge. +$ git stash +$ git pull +$ git stash pop</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-Interruptedworkflow"> Interrupted workflow </dt> <dd> <p>When you are in the middle of something, your boss comes in and demands that you fix something immediately. Traditionally, you would make a commit to a temporary branch to store your changes away, and return to your original branch to make the emergency fix, like this:</p> <div class="listingblock"> <div class="content"> <pre># ... hack hack hack ... +$ git switch -c my_wip +$ git commit -a -m "WIP" +$ git switch master +$ edit emergency fix +$ git commit -a -m "Fix in a hurry" +$ git switch my_wip +$ git reset --soft HEAD^ +# ... continue hacking ...</pre> </div> </div> <p>You can use <code>git stash</code> to simplify the above, like this:</p> <div class="listingblock"> <div class="content"> <pre># ... hack hack hack ... +$ git stash +$ edit emergency fix +$ git commit -a -m "Fix in a hurry" +$ git stash pop +# ... continue hacking ...</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-Testingpartialcommits"> Testing partial commits </dt> <dd> <p>You can use <code>git stash push --keep-index</code> when you want to make two or more commits out of the changes in the work tree, and you want to test each change before committing:</p> <div class="listingblock"> <div class="content"> <pre># ... hack hack hack ... +$ git add --patch foo # add just first part to the index +$ git stash push --keep-index # save all other changes to the stash +$ edit/build/test first part +$ git commit -m 'First part' # commit fully tested change +$ git stash pop # prepare to work on all other changes +# ... repeat above five steps until one commit remains ... +$ edit/build/test remaining parts +$ git commit foo -m 'Remaining parts'</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-Savingunrelatedchangesforfutureuse"> Saving unrelated changes for future use </dt> <dd> <p>When you are in the middle of massive changes and you find some unrelated issue that you don’t want to forget to fix, you can do the change(s), stage them, and use <code>git stash push --staged</code> to stash them out for future use. This is similar to committing the staged changes, only the commit ends-up being in the stash and not on the current branch.</p> <div class="listingblock"> <div class="content"> <pre># ... hack hack hack ... +$ git add --patch foo # add unrelated changes to the index +$ git stash push --staged # save these changes to the stash +# ... hack hack hack, finish current changes ... +$ git commit -m 'Massive' # commit fully tested changes +$ git switch fixup-branch # switch to another branch +$ git stash pop # to finish work on the saved changes</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-Recoveringstashentriesthatwerecleareddroppederroneously"> Recovering stash entries that were cleared/dropped erroneously </dt> <dd> <p>If you mistakenly drop or clear stash entries, they cannot be recovered through the normal safety mechanisms. However, you can try the following incantation to get a list of stash entries that are still in your repository, but not reachable any more:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git fsck --unreachable | +grep commit | cut -d\ -f3 | +xargs git log --merges --no-walk --grep=WIP</pre> </div> </div> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-stash.txt-stashshowIncludeUntracked"> stash.showIncludeUntracked </dt> <dd> <p>If this is set to true, the <code>git stash show</code> command will show the untracked files of a stash entry. Defaults to false. See the description of the <code>show</code> command in <a href="git-stash">git-stash[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-stashshowPatch"> stash.showPatch </dt> <dd> <p>If this is set to true, the <code>git stash show</code> command without an option will show the stash entry in patch form. Defaults to false. See the description of the <code>show</code> command in <a href="git-stash">git-stash[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-stash.txt-stashshowStat"> stash.showStat </dt> <dd> <p>If this is set to true, the <code>git stash show</code> command without an option will show a diffstat of the stash entry. Defaults to true. See the description of the <code>show</code> command in <a href="git-stash">git-stash[1]</a>.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-checkout">git-checkout[1]</a>, <a href="git-commit">git-commit[1]</a>, <a href="git-reflog">git-reflog[1]</a>, <a href="git-reset">git-reset[1]</a>, <a href="git-switch">git-switch[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-stash" class="_attribution-link">https://git-scm.com/docs/git-stash</a> + </p> +</div> diff --git a/devdocs/git/git-status.html b/devdocs/git/git-status.html new file mode 100644 index 00000000..b8200ed3 --- /dev/null +++ b/devdocs/git/git-status.html @@ -0,0 +1,91 @@ +<h1>git-status</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-status - Show the working tree status</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git status [<options>] [--] [<pathspec>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Displays paths that have differences between the index file and the current HEAD commit, paths that have differences between the working tree and the index file, and paths in the working tree that are not tracked by Git (and are not ignored by <a href="gitignore">gitignore[5]</a>). The first are what you <code>would</code> commit by running <code>git commit</code>; the second and third are what you <code>could</code> commit by running <code>git add</code> before running <code>git commit</code>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-status.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-status.txt---short"> --short </dt> <dd> <p>Give the output in the short-format.</p> </dd> <dt class="hdlist1" id="Documentation/git-status.txt--b"> -b </dt> <dt class="hdlist1" id="Documentation/git-status.txt---branch"> --branch </dt> <dd> <p>Show the branch and tracking info even in short-format.</p> </dd> <dt class="hdlist1" id="Documentation/git-status.txt---show-stash"> --show-stash </dt> <dd> <p>Show the number of entries currently stashed away.</p> </dd> <dt class="hdlist1" id="Documentation/git-status.txt---porcelainltversiongt"> --porcelain[=<version>] </dt> <dd> <p>Give the output in an easy-to-parse format for scripts. This is similar to the short output, but will remain stable across Git versions and regardless of user configuration. See below for details.</p> <p>The version parameter is used to specify the format version. This is optional and defaults to the original version <code>v1</code> format.</p> </dd> <dt class="hdlist1" id="Documentation/git-status.txt---long"> --long </dt> <dd> <p>Give the output in the long-format. This is the default.</p> </dd> <dt class="hdlist1" id="Documentation/git-status.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-status.txt---verbose"> --verbose </dt> <dd> <p>In addition to the names of files that have been changed, also show the textual changes that are staged to be committed (i.e., like the output of <code>git diff --cached</code>). If <code>-v</code> is specified twice, then also show the changes in the working tree that have not yet been staged (i.e., like the output of <code>git diff</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-status.txt--ultmodegt"> -u[<mode>] </dt> <dt class="hdlist1" id="Documentation/git-status.txt---untracked-filesltmodegt"> --untracked-files[=<mode>] </dt> <dd> <p>Show untracked files.</p> <div class="openblock"> <div class="content"> <p>The mode parameter is used to specify the handling of untracked files. It is optional: it defaults to <code>all</code>, and if specified, it must be stuck to the option (e.g. <code>-uno</code>, but not <code>-u no</code>).</p> <p>The possible options are:</p> <div class="ulist"> <ul> <li> <p><code>no</code> - Show no untracked files.</p> </li> <li> <p><code>normal</code> - Shows untracked files and directories.</p> </li> <li> <p><code>all</code> - Also shows individual files in untracked directories.</p> </li> </ul> </div> <p>When <code>-u</code> option is not used, untracked files and directories are shown (i.e. the same as specifying <code>normal</code>), to help you avoid forgetting to add newly created files. Because it takes extra work to find untracked files in the filesystem, this mode may take some time in a large working tree. Consider enabling untracked cache and split index if supported (see <code>git update-index --untracked-cache</code> and <code>git update-index +--split-index</code>), Otherwise you can use <code>no</code> to have <code>git status</code> return more quickly without showing untracked files.</p> <p>The default can be changed using the status.showUntrackedFiles configuration variable documented in <a href="git-config">git-config[1]</a>.</p> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-status.txt---ignore-submodulesltwhengt"> --ignore-submodules[=<when>] </dt> <dd> <p>Ignore changes to submodules when looking for changes. <when> can be either "none", "untracked", "dirty" or "all", which is the default. Using "none" will consider the submodule modified when it either contains untracked or modified files or its HEAD differs from the commit recorded in the superproject and can be used to override any settings of the <code>ignore</code> option in <a href="git-config">git-config[1]</a> or <a href="gitmodules">gitmodules[5]</a>. When "untracked" is used submodules are not considered dirty when they only contain untracked content (but they are still scanned for modified content). Using "dirty" ignores all changes to the work tree of submodules, only changes to the commits stored in the superproject are shown (this was the behavior before 1.7.0). Using "all" hides all changes to submodules (and suppresses the output of submodule summaries when the config option <code>status.submoduleSummary</code> is set).</p> </dd> <dt class="hdlist1" id="Documentation/git-status.txt---ignoredltmodegt"> --ignored[=<mode>] </dt> <dd> <p>Show ignored files as well.</p> <div class="openblock"> <div class="content"> <p>The mode parameter is used to specify the handling of ignored files. It is optional: it defaults to <code>traditional</code>.</p> <p>The possible options are:</p> <div class="ulist"> <ul> <li> <p><code>traditional</code> - Shows ignored files and directories, unless --untracked-files=all is specified, in which case individual files in ignored directories are displayed.</p> </li> <li> <p><code>no</code> - Show no ignored files.</p> </li> <li> <p><code>matching</code> - Shows ignored files and directories matching an ignore pattern.</p> </li> </ul> </div> <p>When <code>matching</code> mode is specified, paths that explicitly match an ignored pattern are shown. If a directory matches an ignore pattern, then it is shown, but not paths contained in the ignored directory. If a directory does not match an ignore pattern, but all contents are ignored, then the directory is not shown, but all contents are shown.</p> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-status.txt--z"> -z </dt> <dd> <p>Terminate entries with NUL, instead of LF. This implies the <code>--porcelain=v1</code> output format if no other format is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-status.txt---columnltoptionsgt"> --column[=<options>] </dt> <dt class="hdlist1" id="Documentation/git-status.txt---no-column"> --no-column </dt> <dd> <p>Display untracked files in columns. See configuration variable <code>column.status</code> for option syntax. <code>--column</code> and <code>--no-column</code> without options are equivalent to <code>always</code> and <code>never</code> respectively.</p> </dd> <dt class="hdlist1" id="Documentation/git-status.txt---ahead-behind"> --ahead-behind </dt> <dt class="hdlist1" id="Documentation/git-status.txt---no-ahead-behind"> --no-ahead-behind </dt> <dd> <p>Display or do not display detailed ahead/behind counts for the branch relative to its upstream branch. Defaults to true.</p> </dd> <dt class="hdlist1" id="Documentation/git-status.txt---renames"> --renames </dt> <dt class="hdlist1" id="Documentation/git-status.txt---no-renames"> --no-renames </dt> <dd> <p>Turn on/off rename detection regardless of user configuration. See also <a href="git-diff">git-diff[1]</a> <code>--no-renames</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-status.txt---find-renamesltngt"> --find-renames[=<n>] </dt> <dd> <p>Turn on rename detection, optionally setting the similarity threshold. See also <a href="git-diff">git-diff[1]</a> <code>--find-renames</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-status.txt-ltpathspecgt82308203"> <pathspec>… </dt> <dd> <p>See the <code>pathspec</code> entry in <a href="gitglossary">gitglossary[7]</a>.</p> </dd> </dl> </div> </div> <h2 id="_output">Output</h2> <div class="sectionbody"> <p>The output from this command is designed to be used as a commit template comment. The default, long format, is designed to be human readable, verbose and descriptive. Its contents and format are subject to change at any time.</p> <p>The paths mentioned in the output, unlike many other Git commands, are made relative to the current directory if you are working in a subdirectory (this is on purpose, to help cutting and pasting). See the status.relativePaths config option below.</p> <div class="sect2"> <h3 id="_short_format"> +Short Format</h3> <p>In the short-format, the status of each path is shown as one of these forms</p> <div class="literalblock"> <div class="content"> <pre>XY PATH +XY ORIG_PATH -> PATH</pre> </div> </div> <p>where <code>ORIG_PATH</code> is where the renamed/copied contents came from. <code>ORIG_PATH</code> is only shown when the entry is renamed or copied. The <code>XY</code> is a two-letter status code.</p> <p>The fields (including the <code>-></code>) are separated from each other by a single space. If a filename contains whitespace or other nonprintable characters, that field will be quoted in the manner of a C string literal: surrounded by ASCII double quote (34) characters, and with interior special characters backslash-escaped.</p> <p>There are three different types of states that are shown using this format, and each one uses the <code>XY</code> syntax differently:</p> <div class="ulist"> <ul> <li> <p>When a merge is occurring and the merge was successful, or outside of a merge situation, <code>X</code> shows the status of the index and <code>Y</code> shows the status of the working tree.</p> </li> <li> <p>When a merge conflict has occurred and has not yet been resolved, <code>X</code> and <code>Y</code> show the state introduced by each head of the merge, relative to the common ancestor. These paths are said to be <code>unmerged</code>.</p> </li> <li> <p>When a path is untracked, <code>X</code> and <code>Y</code> are always the same, since they are unknown to the index. <code>??</code> is used for untracked paths. Ignored files are not listed unless <code>--ignored</code> is used; if it is, ignored files are indicated by <code>!!</code>.</p> </li> </ul> </div> <p>Note that the term <code>merge</code> here also includes rebases using the default <code>--merge</code> strategy, cherry-picks, and anything else using the merge machinery.</p> <p>In the following table, these three classes are shown in separate sections, and these characters are used for <code>X</code> and <code>Y</code> fields for the first two sections that show tracked paths:</p> <div class="ulist"> <ul> <li> <p>' ' = unmodified</p> </li> <li> <p><code>M</code> = modified</p> </li> <li> <p><code>T</code> = file type changed (regular file, symbolic link or submodule)</p> </li> <li> <p><code>A</code> = added</p> </li> <li> <p><code>D</code> = deleted</p> </li> <li> <p><code>R</code> = renamed</p> </li> <li> <p><code>C</code> = copied (if config option status.renames is set to "copies")</p> </li> <li> <p><code>U</code> = updated but unmerged</p> </li> </ul> </div> <div class="literalblock"> <div class="content"> <pre>X Y Meaning +------------------------------------------------- + [AMD] not updated +M [ MTD] updated in index +T [ MTD] type changed in index +A [ MTD] added to index +D deleted from index +R [ MTD] renamed in index +C [ MTD] copied in index +[MTARC] index and work tree matches +[ MTARC] M work tree changed since index +[ MTARC] T type changed in work tree since index +[ MTARC] D deleted in work tree + R renamed in work tree + C copied in work tree +------------------------------------------------- +D D unmerged, both deleted +A U unmerged, added by us +U D unmerged, deleted by them +U A unmerged, added by them +D U unmerged, deleted by us +A A unmerged, both added +U U unmerged, both modified +------------------------------------------------- +? ? untracked +! ! ignored +-------------------------------------------------</pre> </div> </div> <p>Submodules have more state and instead report</p> <div class="ulist"> <ul> <li> <p><code>M</code> = the submodule has a different HEAD than recorded in the index</p> </li> <li> <p><code>m</code> = the submodule has modified content</p> </li> <li> <p><code>?</code> = the submodule has untracked files</p> </li> </ul> </div> <p>This is since modified content or untracked files in a submodule cannot be added via <code>git add</code> in the superproject to prepare a commit.</p> <p><code>m</code> and <code>?</code> are applied recursively. For example if a nested submodule in a submodule contains an untracked file, this is reported as <code>?</code> as well.</p> <p>If -b is used the short-format status is preceded by a line</p> <div class="literalblock"> <div class="content"> <pre>## branchname tracking info</pre> </div> </div> </div> <div class="sect2"> <h3 id="_porcelain_format_version_1"> +Porcelain Format Version 1</h3> <p>Version 1 porcelain format is similar to the short format, but is guaranteed not to change in a backwards-incompatible way between Git versions or based on user configuration. This makes it ideal for parsing by scripts. The description of the short format above also describes the porcelain format, with a few exceptions:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>The user’s color.status configuration is not respected; color will always be off.</p> </li> <li> <p>The user’s status.relativePaths configuration is not respected; paths shown will always be relative to the repository root.</p> </li> </ol> </div> <p>There is also an alternate -z format recommended for machine parsing. In that format, the status field is the same, but some other things change. First, the <code>-></code> is omitted from rename entries and the field order is reversed (e.g <code>from -> to</code> becomes <code>to from</code>). Second, a NUL (ASCII 0) follows each filename, replacing space as a field separator and the terminating newline (but a space still separates the status field from the first filename). Third, filenames containing special characters are not specially formatted; no quoting or backslash-escaping is performed.</p> <p>Any submodule changes are reported as modified <code>M</code> instead of <code>m</code> or single <code>?</code>.</p> </div> <div class="sect2"> <h3 id="_porcelain_format_version_2"> +Porcelain Format Version 2</h3> <p>Version 2 format adds more detailed information about the state of the worktree and changed items. Version 2 also defines an extensible set of easy to parse optional headers.</p> <p>Header lines start with "#" and are added in response to specific command line arguments. Parsers should ignore headers they don’t recognize.</p> <div class="sect3"> <h4 id="_branch_headers"> +Branch Headers</h4> <p>If <code>--branch</code> is given, a series of header lines are printed with information about the current branch.</p> <div class="literalblock"> <div class="content"> <pre>Line Notes +------------------------------------------------------------ +# branch.oid <commit> | (initial) Current commit. +# branch.head <branch> | (detached) Current branch. +# branch.upstream <upstream_branch> If upstream is set. +# branch.ab +<ahead> -<behind> If upstream is set and + the commit is present. +------------------------------------------------------------</pre> </div> </div> </div> <div class="sect3"> <h4 id="_stash_information"> +Stash Information</h4> <p>If <code>--show-stash</code> is given, one line is printed showing the number of stash entries if non-zero:</p> <div class="literalblock"> <div class="content"> <pre># stash <N></pre> </div> </div> </div> <div class="sect3"> <h4 id="_changed_tracked_entries"> +Changed Tracked Entries</h4> <p>Following the headers, a series of lines are printed for tracked entries. One of three different line formats may be used to describe an entry depending on the type of change. Tracked entries are printed in an undefined order; parsers should allow for a mixture of the 3 line types in any order.</p> <p>Ordinary changed entries have the following format:</p> <div class="literalblock"> <div class="content"> <pre>1 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <path></pre> </div> </div> <p>Renamed or copied entries have the following format:</p> <div class="literalblock"> <div class="content"> <pre>2 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <X><score> <path><sep><origPath></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Field Meaning +-------------------------------------------------------- +<XY> A 2 character field containing the staged and + unstaged XY values described in the short format, + with unchanged indicated by a "." rather than + a space. +<sub> A 4 character field describing the submodule state. + "N..." when the entry is not a submodule. + "S<c><m><u>" when the entry is a submodule. + <c> is "C" if the commit changed; otherwise ".". + <m> is "M" if it has tracked changes; otherwise ".". + <u> is "U" if there are untracked changes; otherwise ".". +<mH> The octal file mode in HEAD. +<mI> The octal file mode in the index. +<mW> The octal file mode in the worktree. +<hH> The object name in HEAD. +<hI> The object name in the index. +<X><score> The rename or copy score (denoting the percentage + of similarity between the source and target of the + move or copy). For example "R100" or "C75". +<path> The pathname. In a renamed/copied entry, this + is the target path. +<sep> When the `-z` option is used, the 2 pathnames are separated + with a NUL (ASCII 0x00) byte; otherwise, a tab (ASCII 0x09) + byte separates them. +<origPath> The pathname in the commit at HEAD or in the index. + This is only present in a renamed/copied entry, and + tells where the renamed/copied contents came from. +--------------------------------------------------------</pre> </div> </div> <p>Unmerged entries have the following format; the first character is a "u" to distinguish from ordinary changed entries.</p> <div class="literalblock"> <div class="content"> <pre>u <XY> <sub> <m1> <m2> <m3> <mW> <h1> <h2> <h3> <path></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Field Meaning +-------------------------------------------------------- +<XY> A 2 character field describing the conflict type + as described in the short format. +<sub> A 4 character field describing the submodule state + as described above. +<m1> The octal file mode in stage 1. +<m2> The octal file mode in stage 2. +<m3> The octal file mode in stage 3. +<mW> The octal file mode in the worktree. +<h1> The object name in stage 1. +<h2> The object name in stage 2. +<h3> The object name in stage 3. +<path> The pathname. +--------------------------------------------------------</pre> </div> </div> </div> <div class="sect3"> <h4 id="_other_items"> +Other Items</h4> <p>Following the tracked entries (and if requested), a series of lines will be printed for untracked and then ignored items found in the worktree.</p> <p>Untracked items have the following format:</p> <div class="literalblock"> <div class="content"> <pre>? <path></pre> </div> </div> <p>Ignored items have the following format:</p> <div class="literalblock"> <div class="content"> <pre>! <path></pre> </div> </div> </div> <div class="sect3"> <h4 id="_pathname_format_notes_and_z"> +Pathname Format Notes and -z</h4> <p>When the <code>-z</code> option is given, pathnames are printed as is and without any quoting and lines are terminated with a NUL (ASCII 0x00) byte.</p> <p>Without the <code>-z</code> option, pathnames with "unusual" characters are quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>).</p> </div> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>The command honors <code>color.status</code> (or <code>status.color</code> — they mean the same thing and the latter is kept for backward compatibility) and <code>color.status.<slot></code> configuration variables to colorize its output.</p> <p>If the config variable <code>status.relativePaths</code> is set to false, then all paths shown are relative to the repository root, not to the current directory.</p> <p>If <code>status.submoduleSummary</code> is set to a non zero number or true (identical to -1 or an unlimited number), the submodule summary will be enabled for the long format and a summary of commits for modified submodules will be shown (see --summary-limit option of <a href="git-submodule">git-submodule[1]</a>). Please note that the summary output from the status command will be suppressed for all submodules when <code>diff.ignoreSubmodules</code> is set to <code>all</code> or only for those submodules where <code>submodule.<name>.ignore=all</code>. To also view the summary for ignored submodules you can either use the --ignore-submodules=dirty command line option or the <code>git submodule summary</code> command, which shows a similar output but does not honor these settings.</p> </div> <h2 id="_background_refresh">Background refresh</h2> <div class="sectionbody"> <p>By default, <code>git status</code> will automatically refresh the index, updating the cached stat information from the working tree and writing out the result. Writing out the updated index is an optimization that isn’t strictly necessary (<code>status</code> computes the values for itself, but writing them out is just to save subsequent programs from repeating our computation). When <code>status</code> is run in the background, the lock held during the write may conflict with other simultaneous processes, causing them to fail. Scripts running <code>status</code> in the background should consider using <code>git --no-optional-locks status</code> (see <a href="git">git[1]</a> for details).</p> </div> <h2 id="_untracked_files_and_performance">Untracked files and performance</h2> <div class="sectionbody"> <p><code>git status</code> can be very slow in large worktrees if/when it needs to search for untracked files and directories. There are many configuration options available to speed this up by either avoiding the work or making use of cached results from previous Git commands. There is no single optimum set of settings right for everyone. We’ll list a summary of the relevant options to help you, but before going into the list, you may want to run <code>git status</code> again, because your configuration may already be caching <code>git status</code> results, so it could be faster on subsequent runs.</p> <div class="ulist"> <ul> <li> <p>The <code>--untracked-files=no</code> flag or the <code>status.showUntrackedfiles=false</code> config (see above for both): indicate that <code>git status</code> should not report untracked files. This is the fastest option. <code>git status</code> will not list the untracked files, so you need to be careful to remember if you create any new files and manually <code>git add</code> them.</p> </li> <li> <p><code>advice.statusUoption=false</code> (see <a href="git-config">git-config[1]</a>): setting this variable to <code>false</code> disables the warning message given when enumerating untracked files takes more than 2 seconds. In a large project, it may take longer and the user may have already accepted the trade off (e.g. using "-uno" may not be an acceptable option for the user), in which case, there is no point issuing the warning message, and in such a case, disabling the warning may be the best.</p> </li> <li> <p><code>core.untrackedCache=true</code> (see <a href="git-update-index">git-update-index[1]</a>): enable the untracked cache feature and only search directories that have been modified since the previous <code>git status</code> command. Git remembers the set of untracked files within each directory and assumes that if a directory has not been modified, then the set of untracked files within has not changed. This is much faster than enumerating the contents of every directory, but still not without cost, because Git still has to search for the set of modified directories. The untracked cache is stored in the <code>.git/index</code> file. The reduced cost of searching for untracked files is offset slightly by the increased size of the index and the cost of keeping it up-to-date. That reduced search time is usually worth the additional size.</p> </li> <li> <p><code>core.untrackedCache=true</code> and <code>core.fsmonitor=true</code> or <code>core.fsmonitor=<hook_command_pathname></code> (see <a href="git-update-index">git-update-index[1]</a>): enable both the untracked cache and FSMonitor features and only search directories that have been modified since the previous <code>git status</code> command. This is faster than using just the untracked cache alone because Git can also avoid searching for modified directories. Git only has to enumerate the exact set of directories that have changed recently. While the FSMonitor feature can be enabled without the untracked cache, the benefits are greatly reduced in that case.</p> </li> </ul> </div> <p>Note that after you turn on the untracked cache and/or FSMonitor features it may take a few <code>git status</code> commands for the various caches to warm up before you see improved command times. This is normal.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gitignore">gitignore[5]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-status" class="_attribution-link">https://git-scm.com/docs/git-status</a> + </p> +</div> diff --git a/devdocs/git/git-stripspace.html b/devdocs/git/git-stripspace.html new file mode 100644 index 00000000..abcd8e10 --- /dev/null +++ b/devdocs/git/git-stripspace.html @@ -0,0 +1,30 @@ +<h1>git-stripspace</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-stripspace - Remove unnecessary whitespace</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git stripspace [-s | --strip-comments] +git stripspace [-c | --comment-lines]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Read text, such as commit messages, notes, tags and branch descriptions, from the standard input and clean it in the manner used by Git.</p> <p>With no arguments, this will:</p> <div class="ulist"> <ul> <li> <p>remove trailing whitespace from all lines</p> </li> <li> <p>collapse multiple consecutive empty lines into one empty line</p> </li> <li> <p>remove empty lines from the beginning and end of the input</p> </li> <li> <p>add a missing <code>\n</code> to the last line if necessary.</p> </li> </ul> </div> <p>In the case where the input consists entirely of whitespace characters, no output will be produced.</p> <p><strong>NOTE</strong>: This is intended for cleaning metadata. Prefer the <code>--whitespace=fix</code> mode of <a href="git-apply">git-apply[1]</a> for correcting whitespace of patches or files in the repository.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-stripspace.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-stripspace.txt---strip-comments"> --strip-comments </dt> <dd> <p>Skip and remove all lines starting with a comment character (default <code>#</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-stripspace.txt--c"> -c </dt> <dt class="hdlist1" id="Documentation/git-stripspace.txt---comment-lines"> --comment-lines </dt> <dd> <p>Prepend the comment character and a blank space to each line. Lines will automatically be terminated with a newline. On empty lines, only the comment character will be prepended.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>Given the following noisy input with <code>$</code> indicating the end of a line:</p> <div class="listingblock"> <div class="content"> <pre>|A brief introduction $ +| $ +|$ +|A new paragraph$ +|# with a commented-out line $ +|explaining lots of stuff.$ +|$ +|# An old paragraph, also commented-out. $ +| $ +|The end.$ +| $</pre> </div> </div> <p>Use <code>git stripspace</code> with no arguments to obtain:</p> <div class="listingblock"> <div class="content"> <pre>|A brief introduction$ +|$ +|A new paragraph$ +|# with a commented-out line$ +|explaining lots of stuff.$ +|$ +|# An old paragraph, also commented-out.$ +|$ +|The end.$</pre> </div> </div> <p>Use <code>git stripspace --strip-comments</code> to obtain:</p> <div class="listingblock"> <div class="content"> <pre>|A brief introduction$ +|$ +|A new paragraph$ +|explaining lots of stuff.$ +|$ +|The end.$</pre> </div> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-stripspace" class="_attribution-link">https://git-scm.com/docs/git-stripspace</a> + </p> +</div> diff --git a/devdocs/git/git-submodule.html b/devdocs/git/git-submodule.html new file mode 100644 index 00000000..81cedbaa --- /dev/null +++ b/devdocs/git/git-submodule.html @@ -0,0 +1,19 @@ +<h1>git-submodule</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-submodule - Initialize, update or inspect submodules</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git submodule [--quiet] [--cached] +git submodule [--quiet] add [<options>] [--] <repository> [<path>] +git submodule [--quiet] status [--cached] [--recursive] [--] [<path>…] +git submodule [--quiet] init [--] [<path>…] +git submodule [--quiet] deinit [-f|--force] (--all|[--] <path>…) +git submodule [--quiet] update [<options>] [--] [<path>…] +git submodule [--quiet] set-branch [<options>] [--] <path> +git submodule [--quiet] set-url [--] <path> <newurl> +git submodule [--quiet] summary [<options>] [--] [<path>…] +git submodule [--quiet] foreach [--recursive] <command> +git submodule [--quiet] sync [--recursive] [--] [<path>…] +git submodule [--quiet] absorbgitdirs [--] [<path>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Inspects, updates and manages submodules.</p> <p>For more information about submodules, see <a href="gitsubmodules">gitsubmodules[7]</a>.</p> </div> <h2 id="_commands">Commands</h2> <div class="sectionbody"> <p>With no arguments, shows the status of existing submodules. Several subcommands are available to perform operations on the submodules.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-submodule.txt-add-bltbranchgt-f--force--nameltnamegt--referenceltrepositorygt--depthltdepthgt--ltrepositorygtltpathgt"> add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--depth <depth>] [--] <repository> [<path>] </dt> <dd> <p>Add the given repository as a submodule at the given path to the changeset to be committed next to the current project: the current project is termed the "superproject".</p> <p><repository> is the URL of the new submodule’s origin repository. This may be either an absolute URL, or (if it begins with ./ or ../), the location relative to the superproject’s default remote repository (Please note that to specify a repository <code>foo.git</code> which is located right next to a superproject <code>bar.git</code>, you’ll have to use <code>../foo.git</code> instead of <code>./foo.git</code> - as one might expect when following the rules for relative URLs - because the evaluation of relative URLs in Git is identical to that of relative directories).</p> <p>The default remote is the remote of the remote-tracking branch of the current branch. If no such remote-tracking branch exists or the HEAD is detached, "origin" is assumed to be the default remote. If the superproject doesn’t have a default remote configured the superproject is its own authoritative upstream and the current working directory is used instead.</p> <p>The optional argument <path> is the relative location for the cloned submodule to exist in the superproject. If <path> is not given, the canonical part of the source repository is used ("repo" for "/path/to/repo.git" and "foo" for "host.xz:foo/.git"). If <path> exists and is already a valid Git repository, then it is staged for commit without cloning. The <path> is also used as the submodule’s logical name in its configuration entries unless <code>--name</code> is used to specify a logical name.</p> <p>The given URL is recorded into <code>.gitmodules</code> for use by subsequent users cloning the superproject. If the URL is given relative to the superproject’s repository, the presumption is the superproject and submodule repositories will be kept together in the same relative location, and only the superproject’s URL needs to be provided. git-submodule will correctly locate the submodule using the relative URL in <code>.gitmodules</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt-status--cached--recursive--ltpathgt82308203"> status [--cached] [--recursive] [--] [<path>…] </dt> <dd> <p>Show the status of the submodules. This will print the SHA-1 of the currently checked out commit for each submodule, along with the submodule path and the output of <code>git describe</code> for the SHA-1. Each SHA-1 will possibly be prefixed with <code>-</code> if the submodule is not initialized, <code>+</code> if the currently checked out submodule commit does not match the SHA-1 found in the index of the containing repository and <code>U</code> if the submodule has merge conflicts.</p> <p>If <code>--cached</code> is specified, this command will instead print the SHA-1 recorded in the superproject for each submodule.</p> <p>If <code>--recursive</code> is specified, this command will recurse into nested submodules, and show their status as well.</p> <p>If you are only interested in changes of the currently initialized submodules with respect to the commit recorded in the index or the HEAD, <a href="git-status">git-status[1]</a> and <a href="git-diff">git-diff[1]</a> will provide that information too (and can also report changes to a submodule’s work tree).</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt-init--ltpathgt82308203"> init [--] [<path>…] </dt> <dd> <p>Initialize the submodules recorded in the index (which were added and committed elsewhere) by setting <code>submodule.$name.url</code> in <code>.git/config</code>, using the same setting from <code>.gitmodules</code> as a template. If the URL is relative, it will be resolved using the default remote. If there is no default remote, the current repository will be assumed to be upstream.</p> <p>Optional <path> arguments limit which submodules will be initialized. If no path is specified and submodule.active has been configured, submodules configured to be active will be initialized, otherwise all submodules are initialized.</p> <p>It will also copy the value of <code>submodule.$name.update</code>, if present in the <code>.gitmodules</code> file, to <code>.git/config</code>, but (1) this command does not alter existing information in <code>.git/config</code>, and (2) <code>submodule.$name.update</code> that is set to a custom command is <strong>not</strong> copied for security reasons.</p> <p>You can then customize the submodule clone URLs in <code>.git/config</code> for your local setup and proceed to <code>git submodule update</code>; you can also just use <code>git submodule update --init</code> without the explicit <code>init</code> step if you do not intend to customize any submodule locations.</p> <p>See the add subcommand for the definition of default remote.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt-deinit-f--force--all--ltpathgt82308203"> deinit [-f|--force] (--all|[--] <path>…) </dt> <dd> <p>Unregister the given submodules, i.e. remove the whole <code>submodule.$name</code> section from .git/config together with their work tree. Further calls to <code>git submodule update</code>, <code>git submodule foreach</code> and <code>git submodule sync</code> will skip any unregistered submodules until they are initialized again, so use this command if you don’t want to have a local checkout of the submodule in your working tree anymore.</p> <p>When the command is run without pathspec, it errors out, instead of deinit-ing everything, to prevent mistakes.</p> <p>If <code>--force</code> is specified, the submodule’s working tree will be removed even if it contains local modifications.</p> <p>If you really want to remove a submodule from the repository and commit that use <a href="git-rm">git-rm[1]</a> instead. See <a href="gitsubmodules">gitsubmodules[7]</a> for removal options.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt-update--init--remote-N--no-fetch--no-recommend-shallow-f--force--checkout--rebase--merge--referenceltrepositorygt--depthltdepthgt--recursive--jobsltngt--no-single-branch--filterltfilterspecgt--ltpathgt82308203"> update [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [-f|--force] [--checkout|--rebase|--merge] [--reference <repository>] [--depth <depth>] [--recursive] [--jobs <n>] [--[no-]single-branch] [--filter <filter spec>] [--] [<path>…] </dt> <dd> <div class="openblock"> <div class="content"> <p>Update the registered submodules to match what the superproject expects by cloning missing submodules, fetching missing commits in submodules and updating the working tree of the submodules. The "updating" can be done in several ways depending on command line options and the value of <code>submodule.<name>.update</code> configuration variable. The command line option takes precedence over the configuration variable. If neither is given, a <code>checkout</code> is performed. (note: what is in <code>.gitmodules</code> file is irrelevant at this point; see <code>git submodule init</code> above for how <code>.gitmodules</code> is used). The <code>update</code> procedures supported both from the command line as well as through the <code>submodule.<name>.update</code> configuration are:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-submodule.txt-checkout"> checkout </dt> <dd> <p>the commit recorded in the superproject will be checked out in the submodule on a detached HEAD.</p> <p>If <code>--force</code> is specified, the submodule will be checked out (using <code>git checkout --force</code>), even if the commit specified in the index of the containing repository already matches the commit checked out in the submodule.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt-rebase"> rebase </dt> <dd> <p>the current branch of the submodule will be rebased onto the commit recorded in the superproject.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt-merge"> merge </dt> <dd> <p>the commit recorded in the superproject will be merged into the current branch in the submodule.</p> </dd> </dl> </div> <p>The following update procedures have additional limitations:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-submodule.txt-customcommand"> custom command </dt> <dd> <p>mechanism for running arbitrary commands with the commit ID as an argument. Specifically, if the <code>submodule.<name>.update</code> configuration variable is set to <code>!custom command</code>, the object name of the commit recorded in the superproject for the submodule is appended to the <code>custom command</code> string and executed. Note that this mechanism is not supported in the <code>.gitmodules</code> file or on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt-none"> none </dt> <dd> <p>the submodule is not updated. This update procedure is not allowed on the command line.</p> </dd> </dl> </div> <p>If the submodule is not yet initialized, and you just want to use the setting as stored in <code>.gitmodules</code>, you can automatically initialize the submodule with the <code>--init</code> option.</p> <p>If <code>--recursive</code> is specified, this command will recurse into the registered submodules, and update any nested submodules within.</p> <p>If <code>--filter <filter spec></code> is specified, the given partial clone filter will be applied to the submodule. See <a href="git-rev-list">git-rev-list[1]</a> for details on filter specifications.</p> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt-set-branch-b--branchltbranchgt--ltpathgt"> set-branch (-b|--branch) <branch> [--] <path> </dt> <dt class="hdlist1" id="Documentation/git-submodule.txt-set-branch-d--default--ltpathgt"> set-branch (-d|--default) [--] <path> </dt> <dd> <p>Sets the default remote tracking branch for the submodule. The <code>--branch</code> option allows the remote branch to be specified. The <code>--default</code> option removes the submodule.<name>.branch configuration key, which causes the tracking branch to default to the remote <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt-set-url--ltpathgtltnewurlgt"> set-url [--] <path> <newurl> </dt> <dd> <p>Sets the URL of the specified submodule to <newurl>. Then, it will automatically synchronize the submodule’s new remote URL configuration.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt-summary--cached--files-n--summary-limitltngtcommit--ltpathgt82308203"> summary [--cached|--files] [(-n|--summary-limit) <n>] [commit] [--] [<path>…] </dt> <dd> <p>Show commit summary between the given commit (defaults to HEAD) and working tree/index. For a submodule in question, a series of commits in the submodule between the given super project commit and the index or working tree (switched by <code>--cached</code>) are shown. If the option <code>--files</code> is given, show the series of commits in the submodule between the index of the super project and the working tree of the submodule (this option doesn’t allow to use the <code>--cached</code> option or to provide an explicit commit).</p> <p>Using the <code>--submodule=log</code> option with <a href="git-diff">git-diff[1]</a> will provide that information too.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt-foreach--recursiveltcommandgt"> foreach [--recursive] <command> </dt> <dd> <p>Evaluates an arbitrary shell command in each checked out submodule. The command has access to the variables $name, $sm_path, $displaypath, $sha1 and $toplevel: $name is the name of the relevant submodule section in <code>.gitmodules</code>, $sm_path is the path of the submodule as recorded in the immediate superproject, $displaypath contains the relative path from the current working directory to the submodules root directory, $sha1 is the commit as recorded in the immediate superproject, and $toplevel is the absolute path to the top-level of the immediate superproject. Note that to avoid conflicts with <code>$PATH</code> on Windows, the <code>$path</code> variable is now a deprecated synonym of <code>$sm_path</code> variable. Any submodules defined in the superproject but not checked out are ignored by this command. Unless given <code>--quiet</code>, foreach prints the name of each submodule before evaluating the command. If <code>--recursive</code> is given, submodules are traversed recursively (i.e. the given shell command is evaluated in nested submodules as well). A non-zero return from the command in any submodule causes the processing to terminate. This can be overridden by adding <code>|| :</code> to the end of the command.</p> <p>As an example, the command below will show the path and currently checked out commit for each submodule:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git submodule foreach 'echo $sm_path `git rev-parse HEAD`'</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt-sync--recursive--ltpathgt82308203"> sync [--recursive] [--] [<path>…] </dt> <dd> <p>Synchronizes submodules' remote URL configuration setting to the value specified in <code>.gitmodules</code>. It will only affect those submodules which already have a URL entry in .git/config (that is the case when they are initialized or freshly added). This is useful when submodule URLs change upstream and you need to update your local repositories accordingly.</p> <p><code>git submodule sync</code> synchronizes all submodules while <code>git submodule sync -- A</code> synchronizes submodule "A" only.</p> <p>If <code>--recursive</code> is specified, this command will recurse into the registered submodules, and sync any nested submodules within.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt-absorbgitdirs"> absorbgitdirs </dt> <dd> <p>If a git directory of a submodule is inside the submodule, move the git directory of the submodule into its superproject’s <code>$GIT_DIR/modules</code> path and then connect the git directory and its working directory by setting the <code>core.worktree</code> and adding a .git file pointing to the git directory embedded in the superprojects git directory.</p> <p>A repository that was cloned independently and later added as a submodule or old setups have the submodules git directory inside the submodule instead of embedded into the superprojects git directory.</p> <p>This command is recursive by default.</p> </dd> </dl> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-submodule.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-submodule.txt---quiet"> --quiet </dt> <dd> <p>Only print error messages.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---progress"> --progress </dt> <dd> <p>This option is only valid for add and update commands. Progress status is reported on the standard error stream by default when it is attached to a terminal, unless -q is specified. This flag forces progress status even if the standard error stream is not directed to a terminal.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---all"> --all </dt> <dd> <p>This option is only valid for the deinit command. Unregister all submodules in the working tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt--bltbranchgt"> -b <branch> </dt> <dt class="hdlist1" id="Documentation/git-submodule.txt---branchltbranchgt"> --branch <branch> </dt> <dd> <p>Branch of repository to add as submodule. The name of the branch is recorded as <code>submodule.<name>.branch</code> in <code>.gitmodules</code> for <code>update --remote</code>. A special value of <code>.</code> is used to indicate that the name of the branch in the submodule should be the same name as the current branch in the current repository. If the option is not specified, it defaults to the remote <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-submodule.txt---force"> --force </dt> <dd> <p>This option is only valid for add, deinit and update commands. When running add, allow adding an otherwise ignored submodule path. When running deinit the submodule working trees will be removed even if they contain local changes. When running update (only effective with the checkout procedure), throw away local changes in submodules when switching to a different commit; and always run a checkout operation in the submodule, even if the commit listed in the index of the containing repository matches the commit checked out in the submodule.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---cached"> --cached </dt> <dd> <p>This option is only valid for status and summary commands. These commands typically use the commit found in the submodule HEAD, but with this option, the commit stored in the index is used instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---files"> --files </dt> <dd> <p>This option is only valid for the summary command. This command compares the commit in the index with that in the submodule HEAD when this option is used.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-submodule.txt---summary-limit"> --summary-limit </dt> <dd> <p>This option is only valid for the summary command. Limit the summary size (number of commits shown in total). Giving 0 will disable the summary; a negative number means unlimited (the default). This limit only applies to modified submodules. The size is always limited to 1 for added/deleted/typechanged submodules.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---remote"> --remote </dt> <dd> <p>This option is only valid for the update command. Instead of using the superproject’s recorded SHA-1 to update the submodule, use the status of the submodule’s remote-tracking branch. The remote used is branch’s remote (<code>branch.<name>.remote</code>), defaulting to <code>origin</code>. The remote branch used defaults to the remote <code>HEAD</code>, but the branch name may be overridden by setting the <code>submodule.<name>.branch</code> option in either <code>.gitmodules</code> or <code>.git/config</code> (with <code>.git/config</code> taking precedence).</p> <p>This works for any of the supported update procedures (<code>--checkout</code>, <code>--rebase</code>, etc.). The only change is the source of the target SHA-1. For example, <code>submodule update --remote --merge</code> will merge upstream submodule changes into the submodules, while <code>submodule update +--merge</code> will merge superproject gitlink changes into the submodules.</p> <p>In order to ensure a current tracking branch state, <code>update --remote</code> fetches the submodule’s remote repository before calculating the SHA-1. If you don’t want to fetch, you should use <code>submodule update +--remote --no-fetch</code>.</p> <p>Use this option to integrate changes from the upstream subproject with your submodule’s current HEAD. Alternatively, you can run <code>git pull</code> from the submodule, which is equivalent except for the remote branch name: <code>update --remote</code> uses the default upstream repository and <code>submodule.<name>.branch</code>, while <code>git pull</code> uses the submodule’s <code>branch.<name>.merge</code>. Prefer <code>submodule.<name>.branch</code> if you want to distribute the default upstream branch with the superproject and <code>branch.<name>.merge</code> if you want a more native feel while working in the submodule itself.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt--N"> -N </dt> <dt class="hdlist1" id="Documentation/git-submodule.txt---no-fetch"> --no-fetch </dt> <dd> <p>This option is only valid for the update command. Don’t fetch new objects from the remote site.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---checkout"> --checkout </dt> <dd> <p>This option is only valid for the update command. Checkout the commit recorded in the superproject on a detached HEAD in the submodule. This is the default behavior, the main use of this option is to override <code>submodule.$name.update</code> when set to a value other than <code>checkout</code>. If the key <code>submodule.$name.update</code> is either not explicitly set or set to <code>checkout</code>, this option is implicit.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---merge"> --merge </dt> <dd> <p>This option is only valid for the update command. Merge the commit recorded in the superproject into the current branch of the submodule. If this option is given, the submodule’s HEAD will not be detached. If a merge failure prevents this process, you will have to resolve the resulting conflicts within the submodule with the usual conflict resolution tools. If the key <code>submodule.$name.update</code> is set to <code>merge</code>, this option is implicit.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---rebase"> --rebase </dt> <dd> <p>This option is only valid for the update command. Rebase the current branch onto the commit recorded in the superproject. If this option is given, the submodule’s HEAD will not be detached. If a merge failure prevents this process, you will have to resolve these failures with <a href="git-rebase">git-rebase[1]</a>. If the key <code>submodule.$name.update</code> is set to <code>rebase</code>, this option is implicit.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---init"> --init </dt> <dd> <p>This option is only valid for the update command. Initialize all submodules for which "git submodule init" has not been called so far before updating.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---name"> --name </dt> <dd> <p>This option is only valid for the add command. It sets the submodule’s name to the given string instead of defaulting to its path. The name must be valid as a directory name and may not end with a <code>/</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---referenceltrepositorygt"> --reference <repository> </dt> <dd> <p>This option is only valid for add and update commands. These commands sometimes need to clone a remote repository. In this case, this option will be passed to the <a href="git-clone">git-clone[1]</a> command.</p> <p><strong>NOTE</strong>: Do <strong>not</strong> use this option unless you have read the note for <a href="git-clone">git-clone[1]</a>'s <code>--reference</code>, <code>--shared</code>, and <code>--dissociate</code> options carefully.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---dissociate"> --dissociate </dt> <dd> <p>This option is only valid for add and update commands. These commands sometimes need to clone a remote repository. In this case, this option will be passed to the <a href="git-clone">git-clone[1]</a> command.</p> <p><strong>NOTE</strong>: see the NOTE for the <code>--reference</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---recursive"> --recursive </dt> <dd> <p>This option is only valid for foreach, update, status and sync commands. Traverse submodules recursively. The operation is performed not only in the submodules of the current repo, but also in any nested submodules inside those submodules (and so on).</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---depth"> --depth </dt> <dd> <p>This option is valid for add and update commands. Create a <code>shallow</code> clone with a history truncated to the specified number of revisions. See <a href="git-clone">git-clone[1]</a></p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---no-recommend-shallow"> --[no-]recommend-shallow </dt> <dd> <p>This option is only valid for the update command. The initial clone of a submodule will use the recommended <code>submodule.<name>.shallow</code> as provided by the <code>.gitmodules</code> file by default. To ignore the suggestions use <code>--no-recommend-shallow</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt--jltngt"> -j <n> </dt> <dt class="hdlist1" id="Documentation/git-submodule.txt---jobsltngt"> --jobs <n> </dt> <dd> <p>This option is only valid for the update command. Clone new submodules in parallel with as many jobs. Defaults to the <code>submodule.fetchJobs</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt---no-single-branch"> --[no-]single-branch </dt> <dd> <p>This option is only valid for the update command. Clone only one branch during update: HEAD or one specified by --branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-submodule.txt-ltpathgt82308203"> <path>… </dt> <dd> <p>Paths to submodule(s). When specified this will restrict the command to only operate on the submodules found at the specified paths. (This argument is required with add).</p> </dd> </dl> </div> </div> <h2 id="_files">Files</h2> <div class="sectionbody"> <p>When initializing submodules, a <code>.gitmodules</code> file in the top-level directory of the containing repository is used to find the url of each submodule. This file should be formatted in the same way as <code>$GIT_DIR/config</code>. The key to each submodule url is "submodule.$name.url". See <a href="gitmodules">gitmodules[5]</a> for details.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gitsubmodules">gitsubmodules[7]</a>, <a href="gitmodules">gitmodules[5]</a>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-submodule" class="_attribution-link">https://git-scm.com/docs/git-submodule</a> + </p> +</div> diff --git a/devdocs/git/git-svn.html b/devdocs/git/git-svn.html new file mode 100644 index 00000000..e8fedbc3 --- /dev/null +++ b/devdocs/git/git-svn.html @@ -0,0 +1,79 @@ +<h1>git-svn</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-svn - Bidirectional operation between a Subversion repository and Git</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git svn <command> [<options>] [<arguments>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p><code>git svn</code> is a simple conduit for changesets between Subversion and Git. It provides a bidirectional flow of changes between a Subversion and a Git repository.</p> <p><code>git svn</code> can track a standard Subversion repository, following the common "trunk/branches/tags" layout, with the --stdlayout option. It can also follow branches and tags in any layout with the -T/-t/-b options (see options to <code>init</code> below, and also the <code>clone</code> command).</p> <p>Once tracking a Subversion repository (with any of the above methods), the Git repository can be updated from Subversion by the <code>fetch</code> command and Subversion updated from Git by the <code>dcommit</code> command.</p> </div> <h2 id="_commands">Commands</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt-eminitem"> <em>init</em> </dt> <dd> <p>Initializes an empty Git repository with additional metadata directories for <code>git svn</code>. The Subversion URL may be specified as a command-line argument, or as full URL arguments to -T/-t/-b. Optionally, the target directory to operate on can be specified as a second argument. Normally this command initializes the current directory.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt--Tlttrunksubdirgt"> -T<trunk_subdir> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---trunklttrunksubdirgt"> --trunk=<trunk_subdir> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt--tlttagssubdirgt"> -t<tags_subdir> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---tagslttagssubdirgt"> --tags=<tags_subdir> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt--bltbranchessubdirgt"> -b<branches_subdir> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---branchesltbranchessubdirgt"> --branches=<branches_subdir> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---stdlayout"> --stdlayout </dt> <dd> <p>These are optional command-line options for init. Each of these flags can point to a relative repository path (--tags=project/tags) or a full url (--tags=https://foo.org/project/tags). You can specify more than one --tags and/or --branches options, in case your Subversion repository places tags or branches under multiple paths. The option --stdlayout is a shorthand way of setting trunk,tags,branches as the relative paths, which is the Subversion default. If any of the other options are given as well, they take precedence.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---no-metadata"> --no-metadata </dt> <dd> <p>Set the <code>noMetadata</code> option in the [svn-remote] config. This option is not recommended, please read the <code>svn.noMetadata</code> section of this manpage before using this option.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---use-svm-props"> --use-svm-props </dt> <dd> <p>Set the <code>useSvmProps</code> option in the [svn-remote] config.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---use-svnsync-props"> --use-svnsync-props </dt> <dd> <p>Set the <code>useSvnsyncProps</code> option in the [svn-remote] config.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---rewrite-rootltURLgt"> --rewrite-root=<URL> </dt> <dd> <p>Set the <code>rewriteRoot</code> option in the [svn-remote] config.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---rewrite-uuidltUUIDgt"> --rewrite-uuid=<UUID> </dt> <dd> <p>Set the <code>rewriteUUID</code> option in the [svn-remote] config.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---usernameltusergt"> --username=<user> </dt> <dd> <p>For transports that SVN handles authentication for (http, https, and plain svn), specify the username. For other transports (e.g. <code>svn+ssh://</code>), you must include the username in the URL, e.g. <code>svn+ssh://foo@svn.bar.com/project</code></p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---prefixltprefixgt"> --prefix=<prefix> </dt> <dd> <p>This allows one to specify a prefix which is prepended to the names of remotes if trunk/branches/tags are specified. The prefix does not automatically include a trailing slash, so be sure you include one in the argument if that is what you want. If --branches/-b is specified, the prefix must include a trailing slash. Setting a prefix (with a trailing slash) is strongly encouraged in any case, as your SVN-tracking refs will then be located at "refs/remotes/$prefix/<strong>", which is compatible with Git’s own remote-tracking ref layout (refs/remotes/$remote/</strong>). Setting a prefix is also useful if you wish to track multiple projects that share a common repository. By default, the prefix is set to <code>origin/</code>.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> Before Git v2.0, the default prefix was "" (no prefix). This meant that SVN-tracking refs were put at "refs/remotes/*", which is incompatible with how Git’s own remote-tracking refs are organized. If you still want the old default, you can get it by passing <code>--prefix ""</code> on the command line (<code>--prefix=""</code> may not work if your Perl’s Getopt::Long is < v2.37). </td> </tr> </table> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---ignore-refsltregexgt"> --ignore-refs=<regex> </dt> <dd> <p>When passed to <code>init</code> or <code>clone</code> this regular expression will be preserved as a config key. See <code>fetch</code> for a description of <code>--ignore-refs</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---ignore-pathsltregexgt"> --ignore-paths=<regex> </dt> <dd> <p>When passed to <code>init</code> or <code>clone</code> this regular expression will be preserved as a config key. See <code>fetch</code> for a description of <code>--ignore-paths</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---include-pathsltregexgt"> --include-paths=<regex> </dt> <dd> <p>When passed to <code>init</code> or <code>clone</code> this regular expression will be preserved as a config key. See <code>fetch</code> for a description of <code>--include-paths</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---no-minimize-url"> --no-minimize-url </dt> <dd> <p>When tracking multiple directories (using --stdlayout, --branches, or --tags options), git svn will attempt to connect to the root (or highest allowed level) of the Subversion repository. This default allows better tracking of history if entire projects are moved within a repository, but may cause issues on repositories where read access restrictions are in place. Passing <code>--no-minimize-url</code> will allow git svn to accept URLs as-is without attempting to connect to a higher level directory. This option is off by default when only one URL/branch is tracked (it would do little good).</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emfetchem"> <em>fetch</em> </dt> <dd> <p>Fetch unfetched revisions from the Subversion remote we are tracking. The name of the [svn-remote "…"] section in the $GIT_DIR/config file may be specified as an optional command-line argument.</p> <p>This automatically updates the rev_map if needed (see <code>$GIT_DIR/svn/**/.rev_map.*</code> in the FILES section below for details).</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt---localtime"> --localtime </dt> <dd> <p>Store Git commit times in the local time zone instead of UTC. This makes <code>git log</code> (even without --date=local) show the same times that <code>svn log</code> would in the local time zone.</p> <p>This doesn’t interfere with interoperating with the Subversion repository you cloned from, but if you wish for your local Git repository to be able to interoperate with someone else’s local Git repository, either don’t use this option or you should both use it in the same local time zone.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---parent"> --parent </dt> <dd> <p>Fetch only from the SVN parent of the current HEAD.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---ignore-refsltregexgt-1"> --ignore-refs=<regex> </dt> <dd> <p>Ignore refs for branches or tags matching the Perl regular expression. A "negative look-ahead assertion" like <code>^refs/remotes/origin/(?!tags/wanted-tag|wanted-branch).*$</code> can be used to allow only certain refs.</p> <div class="verseblock"> <pre class="content">config key: svn-remote.<name>.ignore-refs</pre> </div> <p>If the ignore-refs configuration key is set, and the command-line option is also given, both regular expressions will be used.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---ignore-pathsltregexgt-1"> --ignore-paths=<regex> </dt> <dd> <p>This allows one to specify a Perl regular expression that will cause skipping of all matching paths from checkout from SVN. The <code>--ignore-paths</code> option should match for every <code>fetch</code> (including automatic fetches due to <code>clone</code>, <code>dcommit</code>, <code>rebase</code>, etc) on a given repository.</p> <div class="verseblock"> <pre class="content">config key: svn-remote.<name>.ignore-paths</pre> </div> <p>If the ignore-paths configuration key is set, and the command-line option is also given, both regular expressions will be used.</p> <p>Examples:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt-Skipdocdirectoryforeveryfetch"> Skip "doc*" directory for every fetch </dt> <dd> <div class="listingblock"> <div class="content"> <pre>--ignore-paths="^doc"</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-Skipbranchesandtagsoffirstleveldirectories"> Skip "branches" and "tags" of first level directories </dt> <dd> <div class="listingblock"> <div class="content"> <pre>--ignore-paths="^[^/]+/(?:branches|tags)"</pre> </div> </div> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---include-pathsltregexgt-1"> --include-paths=<regex> </dt> <dd> <p>This allows one to specify a Perl regular expression that will cause the inclusion of only matching paths from checkout from SVN. The <code>--include-paths</code> option should match for every <code>fetch</code> (including automatic fetches due to <code>clone</code>, <code>dcommit</code>, <code>rebase</code>, etc) on a given repository. <code>--ignore-paths</code> takes precedence over <code>--include-paths</code>.</p> <div class="verseblock"> <pre class="content">config key: svn-remote.<name>.include-paths</pre> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---log-window-sizeltngt"> --log-window-size=<n> </dt> <dd> <p>Fetch <n> log entries per request when scanning Subversion history. The default is 100. For very large Subversion repositories, larger values may be needed for <code>clone</code>/<code>fetch</code> to complete in reasonable time. But overly large values may lead to higher memory usage and request timeouts.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emcloneem"> <em>clone</em> </dt> <dd> <p>Runs <code>init</code> and <code>fetch</code>. It will automatically create a directory based on the basename of the URL passed to it; or if a second argument is passed; it will create a directory and work within that. It accepts all arguments that the <code>init</code> and <code>fetch</code> commands accept; with the exception of <code>--fetch-all</code> and <code>--parent</code>. After a repository is cloned, the <code>fetch</code> command will be able to update revisions without affecting the working tree; and the <code>rebase</code> command will be able to update the working tree with the latest changes.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt---preserve-empty-dirs"> --preserve-empty-dirs </dt> <dd> <p>Create a placeholder file in the local Git repository for each empty directory fetched from Subversion. This includes directories that become empty by removing all entries in the Subversion repository (but not the directory itself). The placeholder files are also tracked and removed when no longer necessary.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---placeholder-filenameltfilenamegt"> --placeholder-filename=<filename> </dt> <dd> <p>Set the name of placeholder files created by --preserve-empty-dirs. Default: ".gitignore"</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emrebaseem"> <em>rebase</em> </dt> <dd> <p>This fetches revisions from the SVN parent of the current HEAD and rebases the current (uncommitted to SVN) work against it.</p> <p>This works similarly to <code>svn update</code> or <code>git pull</code> except that it preserves linear history with <code>git rebase</code> instead of <code>git merge</code> for ease of dcommitting with <code>git svn</code>.</p> <p>This accepts all options that <code>git svn fetch</code> and <code>git rebase</code> accept. However, <code>--fetch-all</code> only fetches from the current [svn-remote], and not all [svn-remote] definitions.</p> <p>Like <code>git rebase</code>; this requires that the working tree be clean and have no uncommitted changes.</p> <p>This automatically updates the rev_map if needed (see <code>$GIT_DIR/svn/**/.rev_map.*</code> in the FILES section below for details).</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt--l"> -l </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---local"> --local </dt> <dd> <p>Do not fetch remotely; only run <code>git rebase</code> against the last fetched commit from the upstream SVN.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emdcommitem"> <em>dcommit</em> </dt> <dd> <p>Commit each diff from the current branch directly to the SVN repository, and then rebase or reset (depending on whether or not there is a diff between SVN and head). This will create a revision in SVN for each commit in Git.</p> <p>When an optional Git branch name (or a Git commit object name) is specified as an argument, the subcommand works on the specified branch, not on the current branch.</p> <p>Use of <code>dcommit</code> is preferred to <code>set-tree</code> (below).</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt---no-rebase"> --no-rebase </dt> <dd> <p>After committing, do not rebase or reset.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---commit-urlltURLgt"> --commit-url <URL> </dt> <dd> <p>Commit to this SVN URL (the full path). This is intended to allow existing <code>git svn</code> repositories created with one transport method (e.g. <code>svn://</code> or <code>http://</code> for anonymous read) to be reused if a user is later given access to an alternate transport method (e.g. <code>svn+ssh://</code> or <code>https://</code>) for commit.</p> <div class="verseblock"> <pre class="content">config key: svn-remote.<name>.commiturl +config key: svn.commiturl (overwrites all svn-remote.<name>.commiturl options)</pre> </div> <p>Note that the SVN URL of the commiturl config key includes the SVN branch. If you rather want to set the commit URL for an entire SVN repository use svn-remote.<name>.pushurl instead.</p> <p>Using this option for any other purpose (don’t ask) is very strongly discouraged.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---mergeinfoltmergeinfogt"> --mergeinfo=<mergeinfo> </dt> <dd> <p>Add the given merge information during the dcommit (e.g. <code>--mergeinfo="/branches/foo:1-10"</code>). All svn server versions can store this information (as a property), and svn clients starting from version 1.5 can make use of it. To specify merge information from multiple branches, use a single space character between the branches (<code>--mergeinfo="/branches/foo:1-10 /branches/bar:3,5-6,8"</code>)</p> <div class="verseblock"> <pre class="content">config key: svn.pushmergeinfo</pre> </div> <p>This option will cause git-svn to attempt to automatically populate the svn:mergeinfo property in the SVN repository when possible. Currently, this can only be done when dcommitting non-fast-forward merges where all parents but the first have already been pushed into SVN.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---interactive"> --interactive </dt> <dd> <p>Ask the user to confirm that a patch set should actually be sent to SVN. For each patch, one may answer "yes" (accept this patch), "no" (discard this patch), "all" (accept all patches), or "quit".</p> <p><code>git svn dcommit</code> returns immediately if answer is "no" or "quit", without committing anything to SVN.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-embranchem"> <em>branch</em> </dt> <dd> <p>Create a branch in the SVN repository.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt--m"> -m </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---message"> --message </dt> <dd> <p>Allows to specify the commit message.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt--t"> -t </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---tag"> --tag </dt> <dd> <p>Create a tag by using the tags_subdir instead of the branches_subdir specified during git svn init.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt--dltpathgt"> -d<path> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---destinationltpathgt"> --destination=<path> </dt> <dd> <p>If more than one --branches (or --tags) option was given to the <code>init</code> or <code>clone</code> command, you must provide the location of the branch (or tag) you wish to create in the SVN repository. <path> specifies which path to use to create the branch or tag and should match the pattern on the left-hand side of one of the configured branches or tags refspecs. You can see these refspecs with the commands</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git config --get-all svn-remote.<name>.branches +git config --get-all svn-remote.<name>.tags</pre> </div> </div> <p>where <name> is the name of the SVN repository as specified by the -R option to <code>init</code> (or "svn" by default).</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---username"> --username </dt> <dd> <p>Specify the SVN username to perform the commit as. This option overrides the <code>username</code> configuration property.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---commit-url"> --commit-url </dt> <dd> <p>Use the specified URL to connect to the destination Subversion repository. This is useful in cases where the source SVN repository is read-only. This option overrides configuration property <code>commiturl</code>.</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git config --get-all svn-remote.<name>.commiturl</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---parents"> --parents </dt> <dd> <p>Create parent folders. This parameter is equivalent to the parameter --parents on svn cp commands and is useful for non-standard repository layouts.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emtagem"> <em>tag</em> </dt> <dd> <p>Create a tag in the SVN repository. This is a shorthand for <code>branch -t</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emlogem"> <em>log</em> </dt> <dd> <p>This should make it easy to look up svn log messages when svn users refer to -r/--revision numbers.</p> <p>The following features from ‘svn log’ are supported:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt--rltngtltngt"> -r <n>[:<n>] </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---revisionltngtltngt"> --revision=<n>[:<n>] </dt> <dd> <p>is supported, non-numeric args are not: HEAD, NEXT, BASE, PREV, etc …</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---verbose"> --verbose </dt> <dd> <p>it’s not completely compatible with the --verbose output in svn log, but reasonably close.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---limitltngt"> --limit=<n> </dt> <dd> <p>is NOT the same as --max-count, doesn’t count merged/excluded commits</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---incremental"> --incremental </dt> <dd> <p>supported</p> </dd> </dl> </div> </div> </div> <p>New features:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt---show-commit"> --show-commit </dt> <dd> <p>shows the Git commit sha1, as well</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---oneline"> --oneline </dt> <dd> <p>our version of --pretty=oneline</p> </dd> </dl> </div> </div> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> SVN itself only stores times in UTC and nothing else. The regular svn client converts the UTC time to the local time (or based on the TZ= environment). This command has the same behaviour. </td> </tr> </table> </div> <p>Any other arguments are passed directly to <code>git log</code></p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emblameem"> <em>blame</em> </dt> <dd> <p>Show what revision and author last modified each line of a file. The output of this mode is format-compatible with the output of ‘svn blame’ by default. Like the SVN blame command, local uncommitted changes in the working tree are ignored; the version of the file in the HEAD revision is annotated. Unknown arguments are passed directly to <code>git blame</code>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt---git-format"> --git-format </dt> <dd> <p>Produce output in the same format as <code>git blame</code>, but with SVN revision numbers instead of Git commit hashes. In this mode, changes that haven’t been committed to SVN (including local working-copy edits) are shown as revision 0.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emfind-revem"> <em>find-rev</em> </dt> <dd> <p>When given an SVN revision number of the form <code>rN</code>, returns the corresponding Git commit hash (this can optionally be followed by a tree-ish to specify which branch should be searched). When given a tree-ish, returns the corresponding SVN revision number.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt--B"> -B </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---before"> --before </dt> <dd> <p>Don’t require an exact match if given an SVN revision, instead find the commit corresponding to the state of the SVN repository (on the current branch) at the specified revision.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt--A"> -A </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---after"> --after </dt> <dd> <p>Don’t require an exact match if given an SVN revision; if there is not an exact match return the closest match searching forward in the history.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emset-treeem"> <em>set-tree</em> </dt> <dd> <p>You should consider using <code>dcommit</code> instead of this command. Commit specified commit or tree objects to SVN. This relies on your imported fetch data being up to date. This makes absolutely no attempts to do patching when committing to SVN, it simply overwrites files with those specified in the tree or commit. All merging is assumed to have taken place independently of <code>git svn</code> functions.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emcreate-ignoreem"> <em>create-ignore</em> </dt> <dd> <p>Recursively finds the svn:ignore property on directories and creates matching .gitignore files. The resulting files are staged to be committed, but are not committed. Use -r/--revision to refer to a specific revision.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emshow-ignoreem"> <em>show-ignore</em> </dt> <dd> <p>Recursively finds and lists the svn:ignore property on directories. The output is suitable for appending to the $GIT_DIR/info/exclude file.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emmkdirsem"> <em>mkdirs</em> </dt> <dd> <p>Attempts to recreate empty directories that core Git cannot track based on information in $GIT_DIR/svn/<refname>/unhandled.log files. Empty directories are automatically recreated when using "git svn clone" and "git svn rebase", so "mkdirs" is intended for use after commands like "git checkout" or "git reset". (See the svn-remote.<name>.automkdirs config file option for more information.)</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emcommit-diffem"> <em>commit-diff</em> </dt> <dd> <p>Commits the diff of two tree-ish arguments from the command-line. This command does not rely on being inside a <code>git svn +init</code>-ed repository. This command takes three arguments, (a) the original tree to diff against, (b) the new tree result, (c) the URL of the target Subversion repository. The final argument (URL) may be omitted if you are working from a <code>git svn</code>-aware repository (that has been <code>init</code>-ed with <code>git svn</code>). The -r<revision> option is required for this.</p> <p>The commit message is supplied either directly with the <code>-m</code> or <code>-F</code> option, or indirectly from the tag or commit when the second tree-ish denotes such an object, or it is requested by invoking an editor (see <code>--edit</code> option below).</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt--mltmsggt"> -m <msg> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---messageltmsggt"> --message=<msg> </dt> <dd> <p>Use the given <code>msg</code> as the commit message. This option disables the <code>--edit</code> option.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt--Fltfilenamegt"> -F <filename> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---fileltfilenamegt"> --file=<filename> </dt> <dd> <p>Take the commit message from the given file. This option disables the <code>--edit</code> option.</p> </dd> </dl> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-eminfoem"> <em>info</em> </dt> <dd> <p>Shows information about a file or directory similar to what ‘svn info’ provides. Does not currently support a -r/--revision argument. Use the --url option to output only the value of the <code>URL:</code> field.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emproplistem"> <em>proplist</em> </dt> <dd> <p>Lists the properties stored in the Subversion repository about a given file or directory. Use -r/--revision to refer to a specific Subversion revision.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-empropgetem"> <em>propget</em> </dt> <dd> <p>Gets the Subversion property given as the first argument, for a file. A specific revision can be specified with -r/--revision.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-empropsetem"> <em>propset</em> </dt> <dd> <p>Sets the Subversion property given as the first argument, to the value given as the second argument for the file given as the third argument.</p> <p>Example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git svn propset svn:keywords "FreeBSD=%H" devel/py-tipper/Makefile</pre> </div> </div> <p>This will set the property <code>svn:keywords</code> to <code>FreeBSD=%H</code> for the file <code>devel/py-tipper/Makefile</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emshow-externalsem"> <em>show-externals</em> </dt> <dd> <p>Shows the Subversion externals. Use -r/--revision to specify a specific revision.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emgcem"> <em>gc</em> </dt> <dd> <p>Compress $GIT_DIR/svn/<refname>/unhandled.log files and remove $GIT_DIR/svn/<refname>/index files.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-emresetem"> <em>reset</em> </dt> <dd> <p>Undoes the effects of <code>fetch</code> back to the specified revision. This allows you to re-<code>fetch</code> an SVN revision. Normally the contents of an SVN revision should never change and <code>reset</code> should not be necessary. However, if SVN permissions change, or if you alter your --ignore-paths option, a <code>fetch</code> may fail with "not found in commit" (file not previously visible) or "checksum mismatch" (missed a modification). If the problem file cannot be ignored forever (with --ignore-paths) the only way to repair the repo is to use <code>reset</code>.</p> <p>Only the rev_map and refs/remotes/git-svn are changed (see <code>$GIT_DIR/svn/**/.rev_map.*</code> in the FILES section below for details). Follow <code>reset</code> with a <code>fetch</code> and then <code>git reset</code> or <code>git rebase</code> to move local branches onto the new tree.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt--rltngt"> -r <n> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---revisionltngt"> --revision=<n> </dt> <dd> <p>Specify the most recent revision to keep. All later revisions are discarded.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---parent-1"> --parent </dt> <dd> <p>Discard the specified revision as well, keeping the nearest parent instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-Example"> Example: </dt> <dd> <p>Assume you have local changes in "master", but you need to refetch "r2".</p> <div class="listingblock"> <div class="content"> <pre> r1---r2---r3 remotes/git-svn + \ + A---B master</pre> </div> </div> <p>Fix the ignore-paths or SVN permissions problem that caused "r2" to be incomplete in the first place. Then:</p> <div class="verseblock"> <pre class="content" data-language="shell">git svn reset -r2 -p +git svn fetch</pre> </div> <div class="listingblock"> <div class="content"> <pre> r1---r2'--r3' remotes/git-svn + \ + r2---r3---A---B master</pre> </div> </div> <p>Then fixup "master" with <code>git rebase</code>. Do NOT use <code>git merge</code> or your history will not be compatible with a future <code>dcommit</code>!</p> <div class="verseblock"> <pre class="content" data-language="shell">git rebase --onto remotes/git-svn A^ master</pre> </div> <div class="listingblock"> <div class="content"> <pre> r1---r2'--r3' remotes/git-svn + \ + A'--B' master</pre> </div> </div> </dd> </dl> </div> </dd> </dl> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt---sharedfalsetrueumaskgroupallworldeverybody"> --shared[=(false|true|umask|group|all|world|everybody)] </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---templatelttemplate-directorygt"> --template=<template-directory> </dt> <dd> <p>Only used with the <code>init</code> command. These are passed directly to <code>git init</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt--rltarggt"> -r <arg> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---revisionltarggt"> --revision <arg> </dt> <dd> <p>Used with the <code>fetch</code> command.</p> <p>This allows revision ranges for partial/cauterized history to be supported. $NUMBER, $NUMBER1:$NUMBER2 (numeric ranges), $NUMBER:HEAD, and BASE:$NUMBER are all supported.</p> <p>This can allow you to make partial mirrors when running fetch; but is generally not recommended because history will be skipped and lost.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt--"> - </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---stdin"> --stdin </dt> <dd> <p>Only used with the <code>set-tree</code> command.</p> <p>Read a list of commits from stdin and commit them in reverse order. Only the leading sha1 is read from each line, so <code>git rev-list --pretty=oneline</code> output can be used.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---rmdir"> --rmdir </dt> <dd> <p>Only used with the <code>dcommit</code>, <code>set-tree</code> and <code>commit-diff</code> commands.</p> <p>Remove directories from the SVN tree if there are no files left behind. SVN can version empty directories, and they are not removed by default if there are no files left in them. Git cannot version empty directories. Enabling this flag will make the commit to SVN act like Git.</p> <div class="verseblock"> <pre class="content">config key: svn.rmdir</pre> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt--e"> -e </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---edit"> --edit </dt> <dd> <p>Only used with the <code>dcommit</code>, <code>set-tree</code> and <code>commit-diff</code> commands.</p> <p>Edit the commit message before committing to SVN. This is off by default for objects that are commits, and forced on when committing tree objects.</p> <div class="verseblock"> <pre class="content">config key: svn.edit</pre> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt--lltnumgt"> -l<num> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---find-copies-harder"> --find-copies-harder </dt> <dd> <p>Only used with the <code>dcommit</code>, <code>set-tree</code> and <code>commit-diff</code> commands.</p> <p>They are both passed directly to <code>git diff-tree</code>; see <a href="git-diff-tree">git-diff-tree[1]</a> for more information.</p> <div class="verseblock"> <pre class="content">config key: svn.l +config key: svn.findcopiesharder</pre> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt--Altfilenamegt"> -A<filename> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---authors-fileltfilenamegt"> --authors-file=<filename> </dt> <dd> <p>Syntax is compatible with the file used by <code>git cvsimport</code> but an empty email address can be supplied with <code><></code>:</p> <div class="listingblock"> <div class="content"> <pre> loginname = Joe User <user@example.com></pre> </div> </div> <p>If this option is specified and <code>git svn</code> encounters an SVN committer name that does not exist in the authors-file, <code>git svn</code> will abort operation. The user will then have to add the appropriate entry. Re-running the previous <code>git svn</code> command after the authors-file is modified should continue operation.</p> <div class="verseblock"> <pre class="content">config key: svn.authorsfile</pre> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---authors-progltfilenamegt"> --authors-prog=<filename> </dt> <dd> <p>If this option is specified, for each SVN committer name that does not exist in the authors file, the given file is executed with the committer name as the first argument. The program is expected to return a single line of the form "Name <email>" or "Name <>", which will be treated as if included in the authors file.</p> <p>Due to historical reasons a relative <code>filename</code> is first searched relative to the current directory for <code>init</code> and <code>clone</code> and relative to the root of the working tree for <code>fetch</code>. If <code>filename</code> is not found, it is searched like any other command in <code>$PATH</code>.</p> <div class="verseblock"> <pre class="content">config key: svn.authorsProg</pre> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---quiet"> --quiet </dt> <dd> <p>Make <code>git svn</code> less verbose. Specify a second time to make it even less verbose.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt--m-1"> -m </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---merge"> --merge </dt> <dt class="hdlist1" id="Documentation/git-svn.txt--sltstrategygt"> -s<strategy> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---strategyltstrategygt"> --strategy=<strategy> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt--p-1"> -p </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---rebase-merges"> --rebase-merges </dt> <dd> <p>These are only used with the <code>dcommit</code> and <code>rebase</code> commands.</p> <p>Passed directly to <code>git rebase</code> when using <code>dcommit</code> if a <code>git reset</code> cannot be used (see <code>dcommit</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---dry-run"> --dry-run </dt> <dd> <p>This can be used with the <code>dcommit</code>, <code>rebase</code>, <code>branch</code> and <code>tag</code> commands.</p> <p>For <code>dcommit</code>, print out the series of Git arguments that would show which diffs would be committed to SVN.</p> <p>For <code>rebase</code>, display the local branch associated with the upstream svn repository associated with the current branch and the URL of svn repository that will be fetched from.</p> <p>For <code>branch</code> and <code>tag</code>, display the urls that will be used for copying when creating the branch or tag.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---use-log-author"> --use-log-author </dt> <dd> <p>When retrieving svn commits into Git (as part of <code>fetch</code>, <code>rebase</code>, or <code>dcommit</code> operations), look for the first <code>From:</code> line or <code>Signed-off-by</code> trailer in the log message and use that as the author string.</p> <div class="verseblock"> <pre class="content">config key: svn.useLogAuthor</pre> </div> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---add-author-from"> --add-author-from </dt> <dd> <p>When committing to svn from Git (as part of <code>set-tree</code> or <code>dcommit</code> operations), if the existing log message doesn’t already have a <code>From:</code> or <code>Signed-off-by</code> trailer, append a <code>From:</code> line based on the Git commit’s author string. If you use this, then <code>--use-log-author</code> will retrieve a valid author string for all commits.</p> <div class="verseblock"> <pre class="content">config key: svn.addAuthorFrom</pre> </div> </dd> </dl> </div> </div> <h2 id="_advanced_options">Advanced options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt--iltGITSVNIDgt"> -i<GIT_SVN_ID> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---idltGITSVNIDgt"> --id <GIT_SVN_ID> </dt> <dd> <p>This sets GIT_SVN_ID (instead of using the environment). This allows the user to override the default refname to fetch from when tracking a single URL. The <code>log</code> and <code>dcommit</code> commands no longer require this switch as an argument.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt--Rltremotenamegt"> -R<remote name> </dt> <dt class="hdlist1" id="Documentation/git-svn.txt---svn-remoteltremotenamegt"> --svn-remote <remote name> </dt> <dd> <p>Specify the [svn-remote "<remote name>"] section to use, this allows SVN multiple repositories to be tracked. Default: "svn"</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt---follow-parent"> --follow-parent </dt> <dd> <p>This option is only relevant if we are tracking branches (using one of the repository layout options --trunk, --tags, --branches, --stdlayout). For each tracked branch, try to find out where its revision was copied from, and set a suitable parent in the first Git commit for the branch. This is especially helpful when we’re tracking a directory that has been moved around within the repository. If this feature is disabled, the branches created by <code>git svn</code> will all be linear and not share any history, meaning that there will be no information on where branches were branched off or merged. However, following long/convoluted histories can take a long time, so disabling this feature may speed up the cloning process. This feature is enabled by default, use --no-follow-parent to disable it.</p> <div class="verseblock"> <pre class="content">config key: svn.followparent</pre> </div> </dd> </dl> </div> </div> <h2 id="_config_file_only_options">Config file-only options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt-svnnoMetadata"> svn.noMetadata </dt> <dt class="hdlist1" id="Documentation/git-svn.txt-svn-remoteltnamegtnoMetadata"> svn-remote.<name>.noMetadata </dt> <dd> <p>This gets rid of the <code>git-svn-id:</code> lines at the end of every commit.</p> <p>This option can only be used for one-shot imports as <code>git svn</code> will not be able to fetch again without metadata. Additionally, if you lose your <code>$GIT_DIR/svn/**/.rev_map.*</code> files, <code>git svn</code> will not be able to rebuild them.</p> <p>The <code>git svn log</code> command will not work on repositories using this, either. Using this conflicts with the <code>useSvmProps</code> option for (hopefully) obvious reasons.</p> <p>This option is NOT recommended as it makes it difficult to track down old references to SVN revision numbers in existing documentation, bug reports, and archives. If you plan to eventually migrate from SVN to Git and are certain about dropping SVN history, consider <a href="https://github.com/newren/git-filter-repo">git-filter-repo</a> instead. filter-repo also allows reformatting of metadata for ease-of-reading and rewriting authorship info for non-"svn.authorsFile" users.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-svnuseSvmProps"> svn.useSvmProps </dt> <dt class="hdlist1" id="Documentation/git-svn.txt-svn-remoteltnamegtuseSvmProps"> svn-remote.<name>.useSvmProps </dt> <dd> <p>This allows <code>git svn</code> to re-map repository URLs and UUIDs from mirrors created using SVN::Mirror (or svk) for metadata.</p> <p>If an SVN revision has a property, "svm:headrev", it is likely that the revision was created by SVN::Mirror (also used by SVK). The property contains a repository UUID and a revision. We want to make it look like we are mirroring the original URL, so introduce a helper function that returns the original identity URL and UUID, and use it when generating metadata in commit messages.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-svnuseSvnsyncProps"> svn.useSvnsyncProps </dt> <dt class="hdlist1" id="Documentation/git-svn.txt-svn-remoteltnamegtuseSvnsyncprops"> svn-remote.<name>.useSvnsyncprops </dt> <dd> <p>Similar to the useSvmProps option; this is for users of the svnsync(1) command distributed with SVN 1.4.x and later.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-svn-remoteltnamegtrewriteRoot"> svn-remote.<name>.rewriteRoot </dt> <dd> <p>This allows users to create repositories from alternate URLs. For example, an administrator could run <code>git svn</code> on the server locally (accessing via file://) but wish to distribute the repository with a public http:// or svn:// URL in the metadata so users of it will see the public URL.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-svn-remoteltnamegtrewriteUUID"> svn-remote.<name>.rewriteUUID </dt> <dd> <p>Similar to the useSvmProps option; this is for users who need to remap the UUID manually. This may be useful in situations where the original UUID is not available via either useSvmProps or useSvnsyncProps.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-svn-remoteltnamegtpushurl"> svn-remote.<name>.pushurl </dt> <dd> <p>Similar to Git’s <code>remote.<name>.pushurl</code>, this key is designed to be used in cases where <code>url</code> points to an SVN repository via a read-only transport, to provide an alternate read/write transport. It is assumed that both keys point to the same repository. Unlike <code>commiturl</code>, <code>pushurl</code> is a base path. If either <code>commiturl</code> or <code>pushurl</code> could be used, <code>commiturl</code> takes precedence.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-svnbrokenSymlinkWorkaround"> svn.brokenSymlinkWorkaround </dt> <dd> <p>This disables potentially expensive checks to workaround broken symlinks checked into SVN by broken clients. Set this option to "false" if you track a SVN repository with many empty blobs that are not symlinks. This option may be changed while <code>git svn</code> is running and take effect on the next revision fetched. If unset, <code>git svn</code> assumes this option to be "true".</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-svnpathnameencoding"> svn.pathnameencoding </dt> <dd> <p>This instructs git svn to recode pathnames to a given encoding. It can be used by windows users and by those who work in non-utf8 locales to avoid corrupted file names with non-ASCII characters. Valid encodings are the ones supported by Perl’s Encode module.</p> </dd> <dt class="hdlist1" id="Documentation/git-svn.txt-svn-remoteltnamegtautomkdirs"> svn-remote.<name>.automkdirs </dt> <dd> <p>Normally, the "git svn clone" and "git svn rebase" commands attempt to recreate empty directories that are in the Subversion repository. If this option is set to "false", then empty directories will only be created if the "git svn mkdirs" command is run explicitly. If unset, <code>git svn</code> assumes this option to be "true".</p> </dd> </dl> </div> <p>Since the noMetadata, rewriteRoot, rewriteUUID, useSvnsyncProps and useSvmProps options all affect the metadata generated and used by <code>git svn</code>; they <strong>must</strong> be set in the configuration file before any history is imported and these settings should never be changed once they are set.</p> <p>Additionally, only one of these options can be used per svn-remote section because they affect the <code>git-svn-id:</code> metadata line, except for rewriteRoot and rewriteUUID which can be used together.</p> </div> <h2 id="_basic_examples">Basic examples</h2> <div class="sectionbody"> <p>Tracking and contributing to the trunk of a Subversion-managed project (ignoring tags and branches):</p> <div class="listingblock"> <div class="content"> <pre># Clone a repo (like git clone): + git svn clone http://svn.example.com/project/trunk +# Enter the newly cloned directory: + cd trunk +# You should be on master branch, double-check with 'git branch' + git branch +# Do some work and commit locally to Git: + git commit ... +# Something is committed to SVN, rebase your local changes against the +# latest changes in SVN: + git svn rebase +# Now commit your changes (that were committed previously using Git) to SVN, +# as well as automatically updating your working HEAD: + git svn dcommit +# Append svn:ignore settings to the default Git exclude file: + git svn show-ignore >> .git/info/exclude</pre> </div> </div> <p>Tracking and contributing to an entire Subversion-managed project (complete with a trunk, tags and branches):</p> <div class="listingblock"> <div class="content"> <pre># Clone a repo with standard SVN directory layout (like git clone): + git svn clone http://svn.example.com/project --stdlayout --prefix svn/ +# Or, if the repo uses a non-standard directory layout: + git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/ +# View all branches and tags you have cloned: + git branch -r +# Create a new branch in SVN + git svn branch waldo +# Reset your master to trunk (or any other branch, replacing 'trunk' +# with the appropriate name): + git reset --hard svn/trunk +# You may only dcommit to one branch/tag/trunk at a time. The usage +# of dcommit/rebase/show-ignore should be the same as above.</pre> </div> </div> <p>The initial <code>git svn clone</code> can be quite time-consuming (especially for large Subversion repositories). If multiple people (or one person with multiple machines) want to use <code>git svn</code> to interact with the same Subversion repository, you can do the initial <code>git svn clone</code> to a repository on a server and have each person clone that repository with <code>git clone</code>:</p> <div class="listingblock"> <div class="content"> <pre># Do the initial import on a server + ssh server "cd /pub && git svn clone http://svn.example.com/project [options...]" +# Clone locally - make sure the refs/remotes/ space matches the server + mkdir project + cd project + git init + git remote add origin server:/pub/project + git config --replace-all remote.origin.fetch '+refs/remotes/*:refs/remotes/*' + git fetch +# Prevent fetch/pull from remote Git server in the future, +# we only want to use git svn for future updates + git config --remove-section remote.origin +# Create a local branch from one of the branches just fetched + git checkout -b master FETCH_HEAD +# Initialize 'git svn' locally (be sure to use the same URL and +# --stdlayout/-T/-b/-t/--prefix options as were used on server) + git svn init http://svn.example.com/project [options...] +# Pull the latest changes from Subversion + git svn rebase</pre> </div> </div> </div> <h2 id="_rebase_vs_pullmerge">Rebase vs. pull/merge</h2> <div class="sectionbody"> <p>Prefer to use <code>git svn rebase</code> or <code>git rebase</code>, rather than <code>git pull</code> or <code>git merge</code> to synchronize unintegrated commits with a <code>git svn</code> branch. Doing so will keep the history of unintegrated commits linear with respect to the upstream SVN repository and allow the use of the preferred <code>git svn dcommit</code> subcommand to push unintegrated commits back into SVN.</p> <p>Originally, <code>git svn</code> recommended that developers pulled or merged from the <code>git svn</code> branch. This was because the author favored <code>git svn set-tree B</code> to commit a single head rather than the <code>git svn set-tree A..B</code> notation to commit multiple commits. Use of <code>git pull</code> or <code>git merge</code> with <code>git svn set-tree A..B</code> will cause non-linear history to be flattened when committing into SVN and this can lead to merge commits unexpectedly reversing previous commits in SVN.</p> </div> <h2 id="_merge_tracking">Merge tracking</h2> <div class="sectionbody"> <p>While <code>git svn</code> can track copy history (including branches and tags) for repositories adopting a standard layout, it cannot yet represent merge history that happened inside git back upstream to SVN users. Therefore it is advised that users keep history as linear as possible inside Git to ease compatibility with SVN (see the CAVEATS section below).</p> </div> <h2 id="_handling_of_svn_branches">Handling of svn branches</h2> <div class="sectionbody"> <p>If <code>git svn</code> is configured to fetch branches (and --follow-branches is in effect), it sometimes creates multiple Git branches for one SVN branch, where the additional branches have names of the form <code>branchname@nnn</code> (with nnn an SVN revision number). These additional branches are created if <code>git svn</code> cannot find a parent commit for the first commit in an SVN branch, to connect the branch to the history of the other branches.</p> <p>Normally, the first commit in an SVN branch consists of a copy operation. <code>git svn</code> will read this commit to get the SVN revision the branch was created from. It will then try to find the Git commit that corresponds to this SVN revision, and use that as the parent of the branch. However, it is possible that there is no suitable Git commit to serve as parent. This will happen, among other reasons, if the SVN branch is a copy of a revision that was not fetched by <code>git svn</code> (e.g. because it is an old revision that was skipped with <code>--revision</code>), or if in SVN a directory was copied that is not tracked by <code>git svn</code> (such as a branch that is not tracked at all, or a subdirectory of a tracked branch). In these cases, <code>git svn</code> will still create a Git branch, but instead of using an existing Git commit as the parent of the branch, it will read the SVN history of the directory the branch was copied from and create appropriate Git commits. This is indicated by the message "Initializing parent: <branchname>".</p> <p>Additionally, it will create a special branch named <code><branchname>@<SVN-Revision></code>, where <SVN-Revision> is the SVN revision number the branch was copied from. This branch will point to the newly created parent commit of the branch. If in SVN the branch was deleted and later recreated from a different version, there will be multiple such branches with an <code>@</code>.</p> <p>Note that this may mean that multiple Git commits are created for a single SVN revision.</p> <p>An example: in an SVN repository with a standard trunk/tags/branches layout, a directory trunk/sub is created in r.100. In r.200, trunk/sub is branched by copying it to branches/. <code>git svn clone -s</code> will then create a branch <code>sub</code>. It will also create new Git commits for r.100 through r.199 and use these as the history of branch <code>sub</code>. Thus there will be two Git commits for each revision from r.100 to r.199 (one containing trunk/, one containing trunk/sub/). Finally, it will create a branch <code>sub@200</code> pointing to the new parent commit of branch <code>sub</code> (i.e. the commit for r.200 and trunk/sub/).</p> </div> <h2 id="_caveats">Caveats</h2> <div class="sectionbody"> <p>For the sake of simplicity and interoperating with Subversion, it is recommended that all <code>git svn</code> users clone, fetch and dcommit directly from the SVN server, and avoid all <code>git clone</code>/<code>pull</code>/<code>merge</code>/<code>push</code> operations between Git repositories and branches. The recommended method of exchanging code between Git branches and users is <code>git format-patch</code> and <code>git am</code>, or just 'dcommit’ing to the SVN repository.</p> <p>Running <code>git merge</code> or <code>git pull</code> is NOT recommended on a branch you plan to <code>dcommit</code> from because Subversion users cannot see any merges you’ve made. Furthermore, if you merge or pull from a Git branch that is a mirror of an SVN branch, <code>dcommit</code> may commit to the wrong branch.</p> <p>If you do merge, note the following rule: <code>git svn dcommit</code> will attempt to commit on top of the SVN commit named in</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git log --grep=^git-svn-id: --first-parent -1</pre> </div> </div> <p>You <code>must</code> therefore ensure that the most recent commit of the branch you want to dcommit to is the <code>first</code> parent of the merge. Chaos will ensue otherwise, especially if the first parent is an older commit on the same SVN branch.</p> <p><code>git clone</code> does not clone branches under the refs/remotes/ hierarchy or any <code>git svn</code> metadata, or config. So repositories created and managed with using <code>git svn</code> should use <code>rsync</code> for cloning, if cloning is to be done at all.</p> <p>Since <code>dcommit</code> uses rebase internally, any Git branches you <code>git push</code> to before <code>dcommit</code> on will require forcing an overwrite of the existing ref on the remote repository. This is generally considered bad practice, see the <a href="git-push">git-push[1]</a> documentation for details.</p> <p>Do not use the --amend option of <a href="git-commit">git-commit[1]</a> on a change you’ve already dcommitted. It is considered bad practice to --amend commits you’ve already pushed to a remote repository for other users, and dcommit with SVN is analogous to that.</p> <p>When cloning an SVN repository, if none of the options for describing the repository layout is used (--trunk, --tags, --branches, --stdlayout), <code>git svn clone</code> will create a Git repository with completely linear history, where branches and tags appear as separate directories in the working copy. While this is the easiest way to get a copy of a complete repository, for projects with many branches it will lead to a working copy many times larger than just the trunk. Thus for projects using the standard directory structure (trunk/branches/tags), it is recommended to clone with option <code>--stdlayout</code>. If the project uses a non-standard structure, and/or if branches and tags are not required, it is easiest to only clone one directory (typically trunk), without giving any repository layout options. If the full history with branches and tags is required, the options <code>--trunk</code> / <code>--branches</code> / <code>--tags</code> must be used.</p> <p>When using multiple --branches or --tags, <code>git svn</code> does not automatically handle name collisions (for example, if two branches from different paths have the same name, or if a branch and a tag have the same name). In these cases, use <code>init</code> to set up your Git repository then, before your first <code>fetch</code>, edit the $GIT_DIR/config file so that the branches and tags are associated with different name spaces. For example:</p> <div class="literalblock"> <div class="content"> <pre>branches = stable/*:refs/remotes/svn/stable/* +branches = debug/*:refs/remotes/svn/debug/*</pre> </div> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p><code>git svn</code> stores [svn-remote] configuration information in the repository $GIT_DIR/config file. It is similar the core Git [remote] sections except <code>fetch</code> keys do not accept glob arguments; but they are instead handled by the <code>branches</code> and <code>tags</code> keys. Since some SVN repositories are oddly configured with multiple projects glob expansions such those listed below are allowed:</p> <div class="listingblock"> <div class="content"> <pre>[svn-remote "project-a"] + url = http://server.org/svn + fetch = trunk/project-a:refs/remotes/project-a/trunk + branches = branches/*/project-a:refs/remotes/project-a/branches/* + branches = branches/release_*:refs/remotes/project-a/branches/release_* + branches = branches/re*se:refs/remotes/project-a/branches/* + tags = tags/*/project-a:refs/remotes/project-a/tags/*</pre> </div> </div> <p>Keep in mind that the <code>*</code> (asterisk) wildcard of the local ref (right of the <code>:</code>) <strong>must</strong> be the farthest right path component; however the remote wildcard may be anywhere as long as it’s an independent path component (surrounded by <code>/</code> or EOL). This type of configuration is not automatically created by <code>init</code> and should be manually entered with a text-editor or using <code>git config</code>.</p> <p>Also note that only one asterisk is allowed per word. For example:</p> <div class="literalblock"> <div class="content"> <pre>branches = branches/re*se:refs/remotes/project-a/branches/*</pre> </div> </div> <p>will match branches <code>release</code>, <code>rese</code>, <code>re123se</code>, however</p> <div class="literalblock"> <div class="content"> <pre>branches = branches/re*s*e:refs/remotes/project-a/branches/*</pre> </div> </div> <p>will produce an error.</p> <p>It is also possible to fetch a subset of branches or tags by using a comma-separated list of names within braces. For example:</p> <div class="listingblock"> <div class="content"> <pre>[svn-remote "huge-project"] + url = http://server.org/svn + fetch = trunk/src:refs/remotes/trunk + branches = branches/{red,green}/src:refs/remotes/project-a/branches/* + tags = tags/{1.0,2.0}/src:refs/remotes/project-a/tags/*</pre> </div> </div> <p>Multiple fetch, branches, and tags keys are supported:</p> <div class="listingblock"> <div class="content"> <pre>[svn-remote "messy-repo"] + url = http://server.org/svn + fetch = trunk/project-a:refs/remotes/project-a/trunk + fetch = branches/demos/june-project-a-demo:refs/remotes/project-a/demos/june-demo + branches = branches/server/*:refs/remotes/project-a/branches/* + branches = branches/demos/2011/*:refs/remotes/project-a/2011-demos/* + tags = tags/server/*:refs/remotes/project-a/tags/*</pre> </div> </div> <p>Creating a branch in such a configuration requires disambiguating which location to use using the -d or --destination flag:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git svn branch -d branches/server release-2-3-0</pre> </div> </div> <p>Note that git-svn keeps track of the highest revision in which a branch or tag has appeared. If the subset of branches or tags is changed after fetching, then $GIT_DIR/svn/.metadata must be manually edited to remove (or reset) branches-maxRev and/or tags-maxRev as appropriate.</p> </div> <h2 id="_files">Files</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-svn.txt-GITDIRsvnrevmap"> $GIT_DIR/svn/**/.rev_map.* </dt> <dd> <p>Mapping between Subversion revision numbers and Git commit names. In a repository where the noMetadata option is not set, this can be rebuilt from the git-svn-id: lines that are at the end of every commit (see the <code>svn.noMetadata</code> section above for details).</p> <p><code>git svn fetch</code> and <code>git svn rebase</code> automatically update the rev_map if it is missing or not up to date. <code>git svn reset</code> automatically rewinds it.</p> </dd> </dl> </div> </div> <h2 id="_bugs">Bugs</h2> <div class="sectionbody"> <p>We ignore all SVN properties except svn:executable. Any unhandled properties are logged to $GIT_DIR/svn/<refname>/unhandled.log</p> <p>Renamed and copied directories are not detected by Git and hence not tracked when committing to SVN. I do not plan on adding support for this as it’s quite difficult and time-consuming to get working for all the possible corner cases (Git doesn’t do it, either). Committing renamed and copied files is fully supported if they’re similar enough for Git to detect them.</p> <p>In SVN, it is possible (though discouraged) to commit changes to a tag (because a tag is just a directory copy, thus technically the same as a branch). When cloning an SVN repository, <code>git svn</code> cannot know if such a commit to a tag will happen in the future. Thus it acts conservatively and imports all SVN tags as branches, prefixing the tag name with <code>tags/</code>.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-rebase">git-rebase[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-svn" class="_attribution-link">https://git-scm.com/docs/git-svn</a> + </p> +</div> diff --git a/devdocs/git/git-switch.html b/devdocs/git/git-switch.html new file mode 100644 index 00000000..9a8064e7 --- /dev/null +++ b/devdocs/git/git-switch.html @@ -0,0 +1,17 @@ +<h1>git-switch</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-switch - Switch branches</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git switch [<options>] [--no-guess] <branch> +git switch [<options>] --detach [<start-point>] +git switch [<options>] (-c|-C) <new-branch> [<start-point>] +git switch [<options>] --orphan <new-branch></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Switch to a specified branch. The working tree and the index are updated to match the branch. All new commits will be added to the tip of this branch.</p> <p>Optionally a new branch could be created with either <code>-c</code>, <code>-C</code>, automatically from a remote branch of same name (see <code>--guess</code>), or detach the working tree from any branch with <code>--detach</code>, along with switching.</p> <p>Switching branches does not require a clean index and working tree (i.e. no differences compared to <code>HEAD</code>). The operation is aborted however if the operation leads to loss of local changes, unless told otherwise with <code>--discard-changes</code> or <code>--merge</code>.</p> <p>THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-switch.txt-ltbranchgt"> <branch> </dt> <dd> <p>Branch to switch to.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt-ltnew-branchgt"> <new-branch> </dt> <dd> <p>Name for the new branch.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt-ltstart-pointgt"> <start-point> </dt> <dd> <p>The starting point for the new branch. Specifying a <code><start-point></code> allows you to create a branch based on some other point in history than where HEAD currently points. (Or, in the case of <code>--detach</code>, allows you to inspect and detach from some other point.)</p> <p>You can use the <code>@{-N}</code> syntax to refer to the N-th last branch/commit switched to using "git switch" or "git checkout" operation. You may also specify <code>-</code> which is synonymous to <code>@{-1}</code>. This is often used to switch quickly between two branches, or to undo a branch switch by mistake.</p> <p>As a special case, you may use <code>A...B</code> as a shortcut for the merge base of <code>A</code> and <code>B</code> if there is exactly one merge base. You can leave out at most one of <code>A</code> and <code>B</code>, in which case it defaults to <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt--cltnew-branchgt"> -c <new-branch> </dt> <dt class="hdlist1" id="Documentation/git-switch.txt---createltnew-branchgt"> --create <new-branch> </dt> <dd> <p>Create a new branch named <code><new-branch></code> starting at <code><start-point></code> before switching to the branch. This is a convenient shortcut for:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch <new-branch> +$ git switch <new-branch></pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt--Cltnew-branchgt"> -C <new-branch> </dt> <dt class="hdlist1" id="Documentation/git-switch.txt---force-createltnew-branchgt"> --force-create <new-branch> </dt> <dd> <p>Similar to <code>--create</code> except that if <code><new-branch></code> already exists, it will be reset to <code><start-point></code>. This is a convenient shortcut for:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch -f <new-branch> +$ git switch <new-branch></pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt--d"> -d </dt> <dt class="hdlist1" id="Documentation/git-switch.txt---detach"> --detach </dt> <dd> <p>Switch to a commit for inspection and discardable experiments. See the "DETACHED HEAD" section in <a href="git-checkout">git-checkout[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt---guess"> --guess </dt> <dt class="hdlist1" id="Documentation/git-switch.txt---no-guess"> --no-guess </dt> <dd> <p>If <code><branch></code> is not found but there does exist a tracking branch in exactly one remote (call it <code><remote></code>) with a matching name, treat as equivalent to</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -c <branch> --track <remote>/<branch></pre> </div> </div> <p>If the branch exists in multiple remotes and one of them is named by the <code>checkout.defaultRemote</code> configuration variable, we’ll use that one for the purposes of disambiguation, even if the <code><branch></code> isn’t unique across all remotes. Set it to e.g. <code>checkout.defaultRemote=origin</code> to always checkout remote branches from there if <code><branch></code> is ambiguous but exists on the <code>origin</code> remote. See also <code>checkout.defaultRemote</code> in <a href="git-config">git-config[1]</a>.</p> <p><code>--guess</code> is the default behavior. Use <code>--no-guess</code> to disable it.</p> <p>The default behavior can be set via the <code>checkout.guess</code> configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-switch.txt---force"> --force </dt> <dd> <p>An alias for <code>--discard-changes</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt---discard-changes"> --discard-changes </dt> <dd> <p>Proceed even if the index or the working tree differs from <code>HEAD</code>. Both the index and working tree are restored to match the switching target. If <code>--recurse-submodules</code> is specified, submodule content is also restored to match the switching target. This is used to throw away local changes.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt--m"> -m </dt> <dt class="hdlist1" id="Documentation/git-switch.txt---merge"> --merge </dt> <dd> <p>If you have local modifications to one or more files that are different between the current branch and the branch to which you are switching, the command refuses to switch branches in order to preserve your modifications in context. However, with this option, a three-way merge between the current branch, your working tree contents, and the new branch is done, and you will be on the new branch.</p> <p>When a merge conflict happens, the index entries for conflicting paths are left unmerged, and you need to resolve the conflicts and mark the resolved paths with <code>git add</code> (or <code>git rm</code> if the merge should result in deletion of the path).</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt---conflictltstylegt"> --conflict=<style> </dt> <dd> <p>The same as <code>--merge</code> option above, but changes the way the conflicting hunks are presented, overriding the <code>merge.conflictStyle</code> configuration variable. Possible values are "merge" (default), "diff3", and "zdiff3".</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-switch.txt---quiet"> --quiet </dt> <dd> <p>Quiet, suppress feedback messages.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt---progress"> --progress </dt> <dt class="hdlist1" id="Documentation/git-switch.txt---no-progress"> --no-progress </dt> <dd> <p>Progress status is reported on the standard error stream by default when it is attached to a terminal, unless <code>--quiet</code> is specified. This flag enables progress reporting even if not attached to a terminal, regardless of <code>--quiet</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt--t"> -t </dt> <dt class="hdlist1" id="Documentation/git-switch.txt---trackdirectinherit"> --track [direct|inherit] </dt> <dd> <p>When creating a new branch, set up "upstream" configuration. <code>-c</code> is implied. See <code>--track</code> in <a href="git-branch">git-branch[1]</a> for details.</p> <p>If no <code>-c</code> option is given, the name of the new branch will be derived from the remote-tracking branch, by looking at the local part of the refspec configured for the corresponding remote, and then stripping the initial part up to the "*". This would tell us to use <code>hack</code> as the local branch when branching off of <code>origin/hack</code> (or <code>remotes/origin/hack</code>, or even <code>refs/remotes/origin/hack</code>). If the given name has no slash, or the above guessing results in an empty name, the guessing is aborted. You can explicitly give a name with <code>-c</code> in such a case.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt---no-track"> --no-track </dt> <dd> <p>Do not set up "upstream" configuration, even if the <code>branch.autoSetupMerge</code> configuration variable is true.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt---orphanltnew-branchgt"> --orphan <new-branch> </dt> <dd> <p>Create a new unborn branch, named <code><new-branch></code>. All tracked files are removed.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt---ignore-other-worktrees"> --ignore-other-worktrees </dt> <dd> <p><code>git switch</code> refuses when the wanted ref is already checked out by another worktree. This option makes it check the ref out anyway. In other words, the ref can be held by more than one worktree.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt---recurse-submodules"> --recurse-submodules </dt> <dt class="hdlist1" id="Documentation/git-switch.txt---no-recurse-submodules"> --no-recurse-submodules </dt> <dd> <p>Using <code>--recurse-submodules</code> will update the content of all active submodules according to the commit recorded in the superproject. If nothing (or <code>--no-recurse-submodules</code>) is used, submodules working trees will not be updated. Just like <a href="git-submodule">git-submodule[1]</a>, this will detach <code>HEAD</code> of the submodules.</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>The following command switches to the "master" branch:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch master</pre> </div> </div> <p>After working in the wrong branch, switching to the correct branch would be done using:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch mytopic</pre> </div> </div> <p>However, your "wrong" branch and correct "mytopic" branch may differ in files that you have modified locally, in which case the above switch would fail like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch mytopic +error: You have local changes to 'frotz'; not switching branches.</pre> </div> </div> <p>You can give the <code>-m</code> flag to the command, which would try a three-way merge:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -m mytopic +Auto-merging frotz</pre> </div> </div> <p>After this three-way merge, the local modifications are <code>not</code> registered in your index file, so <code>git diff</code> would show you what changes you made since the tip of the new branch.</p> <p>To switch back to the previous branch before we switched to mytopic (i.e. "master" branch):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -</pre> </div> </div> <p>You can grow a new branch from any commit. For example, switch to "HEAD~3" and create branch "fixup":</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -c fixup HEAD~3 +Switched to a new branch 'fixup'</pre> </div> </div> <p>If you want to start a new branch from a remote branch of the same name:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch new-topic +Branch 'new-topic' set up to track remote branch 'new-topic' from 'origin' +Switched to a new branch 'new-topic'</pre> </div> </div> <p>To check out commit <code>HEAD~3</code> for temporary inspection or experiment without creating a new branch:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch --detach HEAD~3 +HEAD is now at 9fc9555312 Merge branch 'cc/shared-index-permbits'</pre> </div> </div> <p>If it turns out whatever you have done is worth keeping, you can always create a new name for it (without switching away):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -c good-surprises</pre> </div> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Everything below this line in this section is selectively included from the <a href="git-config">git-config[1]</a> documentation. The content is the same as what’s found there:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-switch.txt-checkoutdefaultRemote"> checkout.defaultRemote </dt> <dd> <p>When you run <code>git checkout <something></code> or <code>git switch <something></code> and only have one remote, it may implicitly fall back on checking out and tracking e.g. <code>origin/<something></code>. This stops working as soon as you have more than one remote with a <code><something></code> reference. This setting allows for setting the name of a preferred remote that should always win when it comes to disambiguation. The typical use-case is to set this to <code>origin</code>.</p> <p>Currently this is used by <a href="git-switch">git-switch[1]</a> and <a href="git-checkout">git-checkout[1]</a> when <code>git checkout <something></code> or <code>git switch <something></code> will checkout the <code><something></code> branch on another remote, and by <a href="git-worktree">git-worktree[1]</a> when <code>git worktree add</code> refers to a remote branch. This setting might be used for other checkout-like commands or functionality in the future.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt-checkoutguess"> checkout.guess </dt> <dd> <p>Provides the default value for the <code>--guess</code> or <code>--no-guess</code> option in <code>git checkout</code> and <code>git switch</code>. See <a href="git-switch">git-switch[1]</a> and <a href="git-checkout">git-checkout[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt-checkoutworkers"> checkout.workers </dt> <dd> <p>The number of parallel workers to use when updating the working tree. The default is one, i.e. sequential execution. If set to a value less than one, Git will use as many workers as the number of logical cores available. This setting and <code>checkout.thresholdForParallelism</code> affect all commands that perform checkout. E.g. checkout, clone, reset, sparse-checkout, etc.</p> <p>Note: Parallel checkout usually delivers better performance for repositories located on SSDs or over NFS. For repositories on spinning disks and/or machines with a small number of cores, the default sequential checkout often performs better. The size and compression level of a repository might also influence how well the parallel version performs.</p> </dd> <dt class="hdlist1" id="Documentation/git-switch.txt-checkoutthresholdForParallelism"> checkout.thresholdForParallelism </dt> <dd> <p>When running parallel checkout with a small number of files, the cost of subprocess spawning and inter-process communication might outweigh the parallelization gains. This setting allows you to define the minimum number of files for which parallel checkout should be attempted. The default is 100.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-checkout">git-checkout[1]</a>, <a href="git-branch">git-branch[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-switch" class="_attribution-link">https://git-scm.com/docs/git-switch</a> + </p> +</div> diff --git a/devdocs/git/git-symbolic-ref.html b/devdocs/git/git-symbolic-ref.html new file mode 100644 index 00000000..90abc125 --- /dev/null +++ b/devdocs/git/git-symbolic-ref.html @@ -0,0 +1,8 @@ +<h1>git-symbolic-ref</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-symbolic-ref - Read, modify and delete symbolic refs</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git symbolic-ref [-m <reason>] <name> <ref> +git symbolic-ref [-q] [--short] [--no-recurse] <name> +git symbolic-ref --delete [-q] <name></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Given one argument, reads which branch head the given symbolic ref refers to and outputs its path, relative to the <code>.git/</code> directory. Typically you would give <code>HEAD</code> as the <name> argument to see which branch your working tree is on.</p> <p>Given two arguments, creates or updates a symbolic ref <name> to point at the given branch <ref>.</p> <p>Given <code>--delete</code> and an additional argument, deletes the given symbolic ref.</p> <p>A symbolic ref is a regular file that stores a string that begins with <code>ref: refs/</code>. For example, your <code>.git/HEAD</code> is a regular file whose content is <code>ref: refs/heads/master</code>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-symbolic-ref.txt--d"> -d </dt> <dt class="hdlist1" id="Documentation/git-symbolic-ref.txt---delete"> --delete </dt> <dd> <p>Delete the symbolic ref <name>.</p> </dd> <dt class="hdlist1" id="Documentation/git-symbolic-ref.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-symbolic-ref.txt---quiet"> --quiet </dt> <dd> <p>Do not issue an error message if the <name> is not a symbolic ref but a detached HEAD; instead exit with non-zero status silently.</p> </dd> <dt class="hdlist1" id="Documentation/git-symbolic-ref.txt---short"> --short </dt> <dd> <p>When showing the value of <name> as a symbolic ref, try to shorten the value, e.g. from <code>refs/heads/master</code> to <code>master</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-symbolic-ref.txt---recurse"> --recurse </dt> <dt class="hdlist1" id="Documentation/git-symbolic-ref.txt---no-recurse"> --no-recurse </dt> <dd> <p>When showing the value of <name> as a symbolic ref, if <name> refers to another symbolic ref, follow such a chain of symbolic refs until the result no longer points at a symbolic ref (<code>--recurse</code>, which is the default). <code>--no-recurse</code> stops after dereferencing only a single level of symbolic ref.</p> </dd> <dt class="hdlist1" id="Documentation/git-symbolic-ref.txt--m"> -m </dt> <dd> <p>Update the reflog for <name> with <reason>. This is valid only when creating or updating a symbolic ref.</p> </dd> </dl> </div> </div> <h2 id="_notes">Notes</h2> <div class="sectionbody"> <p>In the past, <code>.git/HEAD</code> was a symbolic link pointing at <code>refs/heads/master</code>. When we wanted to switch to another branch, we did <code>ln -sf refs/heads/newbranch .git/HEAD</code>, and when we wanted to find out which branch we are on, we did <code>readlink .git/HEAD</code>. But symbolic links are not entirely portable, so they are now deprecated and symbolic refs (as described above) are used by default.</p> <p><code>git symbolic-ref</code> will exit with status 0 if the contents of the symbolic ref were printed correctly, with status 1 if the requested name is not a symbolic ref, or 128 if another error occurs.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-symbolic-ref" class="_attribution-link">https://git-scm.com/docs/git-symbolic-ref</a> + </p> +</div> diff --git a/devdocs/git/git-tag.html b/devdocs/git/git-tag.html new file mode 100644 index 00000000..90f2029b --- /dev/null +++ b/devdocs/git/git-tag.html @@ -0,0 +1,40 @@ +<h1>git-tag</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-tag - Create, list, delete or verify a tag object signed with GPG</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] [-e] + <tagname> [<commit> | <object>] +git tag -d <tagname>… +git tag [-n[<num>]] -l [--contains <commit>] [--no-contains <commit>] + [--points-at <object>] [--column[=<options>] | --no-column] + [--create-reflog] [--sort=<key>] [--format=<format>] + [--merged <commit>] [--no-merged <commit>] [<pattern>…] +git tag -v [--format=<format>] <tagname>…</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Add a tag reference in <code>refs/tags/</code>, unless <code>-d/-l/-v</code> is given to delete, list or verify tags.</p> <p>Unless <code>-f</code> is given, the named tag must not yet exist.</p> <p>If one of <code>-a</code>, <code>-s</code>, or <code>-u <key-id></code> is passed, the command creates a <code>tag</code> object, and requires a tag message. Unless <code>-m <msg></code> or <code>-F <file></code> is given, an editor is started for the user to type in the tag message.</p> <p>If <code>-m <msg></code> or <code>-F <file></code> is given and <code>-a</code>, <code>-s</code>, and <code>-u <key-id></code> are absent, <code>-a</code> is implied.</p> <p>Otherwise, a tag reference that points directly at the given object (i.e., a lightweight tag) is created.</p> <p>A GnuPG signed tag object will be created when <code>-s</code> or <code>-u +<key-id></code> is used. When <code>-u <key-id></code> is not used, the committer identity for the current user is used to find the GnuPG key for signing. The configuration variable <code>gpg.program</code> is used to specify custom GnuPG binary.</p> <p>Tag objects (created with <code>-a</code>, <code>-s</code>, or <code>-u</code>) are called "annotated" tags; they contain a creation date, the tagger name and e-mail, a tagging message, and an optional GnuPG signature. Whereas a "lightweight" tag is simply a name for an object (usually a commit object).</p> <p>Annotated tags are meant for release while lightweight tags are meant for private or temporary object labels. For this reason, some git commands for naming objects (like <code>git describe</code>) will ignore lightweight tags by default.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-tag.txt--a"> -a </dt> <dt class="hdlist1" id="Documentation/git-tag.txt---annotate"> --annotate </dt> <dd> <p>Make an unsigned, annotated tag object</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-tag.txt---sign"> --sign </dt> <dd> <p>Make a GPG-signed tag, using the default e-mail address’s key. The default behavior of tag GPG-signing is controlled by <code>tag.gpgSign</code> configuration variable if it exists, or disabled otherwise. See <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt---no-sign"> --no-sign </dt> <dd> <p>Override <code>tag.gpgSign</code> configuration variable that is set to force each and every tag to be signed.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt--ultkey-idgt"> -u <key-id> </dt> <dt class="hdlist1" id="Documentation/git-tag.txt---local-userltkey-idgt"> --local-user=<key-id> </dt> <dd> <p>Make a GPG-signed tag, using the given key.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-tag.txt---force"> --force </dt> <dd> <p>Replace an existing tag with the given name (instead of failing)</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt--d"> -d </dt> <dt class="hdlist1" id="Documentation/git-tag.txt---delete"> --delete </dt> <dd> <p>Delete existing tags with the given names.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-tag.txt---verify"> --verify </dt> <dd> <p>Verify the GPG signature of the given tag names.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt--nltnumgt"> -n<num> </dt> <dd> <p><num> specifies how many lines from the annotation, if any, are printed when using -l. Implies <code>--list</code>.</p> <p>The default is not to print any annotation lines. If no number is given to <code>-n</code>, only the first line is printed. If the tag is not annotated, the commit message is displayed instead.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt--l"> -l </dt> <dt class="hdlist1" id="Documentation/git-tag.txt---list"> --list </dt> <dd> <p>List tags. With optional <code><pattern>...</code>, e.g. <code>git tag --list +'v-*'</code>, list only the tags that match the pattern(s).</p> <p>Running "git tag" without arguments also lists all tags. The pattern is a shell wildcard (i.e., matched using fnmatch(3)). Multiple patterns may be given; if any of them matches, the tag is shown.</p> <p>This option is implicitly supplied if any other list-like option such as <code>--contains</code> is provided. See the documentation for each of those options for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt---sortltkeygt"> --sort=<key> </dt> <dd> <p>Sort based on the key given. Prefix <code>-</code> to sort in descending order of the value. You may use the --sort=<key> option multiple times, in which case the last key becomes the primary key. Also supports "version:refname" or "v:refname" (tag names are treated as versions). The "version:refname" sort order can also be affected by the "versionsort.suffix" configuration variable. The keys supported are the same as those in <code>git for-each-ref</code>. Sort order defaults to the value configured for the <code>tag.sort</code> variable if it exists, or lexicographic order otherwise. See <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt---colorltwhengt"> --color[=<when>] </dt> <dd> <p>Respect any colors specified in the <code>--format</code> option. The <code><when></code> field must be one of <code>always</code>, <code>never</code>, or <code>auto</code> (if <code><when></code> is absent, behave as if <code>always</code> was given).</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt--i"> -i </dt> <dt class="hdlist1" id="Documentation/git-tag.txt---ignore-case"> --ignore-case </dt> <dd> <p>Sorting and filtering tags are case insensitive.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt---omit-empty"> --omit-empty </dt> <dd> <p>Do not print a newline after formatted refs where the format expands to the empty string.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt---columnltoptionsgt"> --column[=<options>] </dt> <dt class="hdlist1" id="Documentation/git-tag.txt---no-column"> --no-column </dt> <dd> <p>Display tag listing in columns. See configuration variable <code>column.tag</code> for option syntax. <code>--column</code> and <code>--no-column</code> without options are equivalent to <code>always</code> and <code>never</code> respectively.</p> <p>This option is only applicable when listing tags without annotation lines.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt---containsltcommitgt"> --contains [<commit>] </dt> <dd> <p>Only list tags which contain the specified commit (HEAD if not specified). Implies <code>--list</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt---no-containsltcommitgt"> --no-contains [<commit>] </dt> <dd> <p>Only list tags which don’t contain the specified commit (HEAD if not specified). Implies <code>--list</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt---mergedltcommitgt"> --merged [<commit>] </dt> <dd> <p>Only list tags whose commits are reachable from the specified commit (<code>HEAD</code> if not specified).</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt---no-mergedltcommitgt"> --no-merged [<commit>] </dt> <dd> <p>Only list tags whose commits are not reachable from the specified commit (<code>HEAD</code> if not specified).</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt---points-atltobjectgt"> --points-at <object> </dt> <dd> <p>Only list tags of the given object (HEAD if not specified). Implies <code>--list</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt--mltmsggt"> -m <msg> </dt> <dt class="hdlist1" id="Documentation/git-tag.txt---messageltmsggt"> --message=<msg> </dt> <dd> <p>Use the given tag message (instead of prompting). If multiple <code>-m</code> options are given, their values are concatenated as separate paragraphs. Implies <code>-a</code> if none of <code>-a</code>, <code>-s</code>, or <code>-u <key-id></code> is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt--Fltfilegt"> -F <file> </dt> <dt class="hdlist1" id="Documentation/git-tag.txt---fileltfilegt"> --file=<file> </dt> <dd> <p>Take the tag message from the given file. Use <code>-</code> to read the message from the standard input. Implies <code>-a</code> if none of <code>-a</code>, <code>-s</code>, or <code>-u <key-id></code> is given.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt--e"> -e </dt> <dt class="hdlist1" id="Documentation/git-tag.txt---edit"> --edit </dt> <dd> <p>The message taken from file with <code>-F</code> and command line with <code>-m</code> are usually used as the tag message unmodified. This option lets you further edit the message taken from these sources.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt---cleanupltmodegt"> --cleanup=<mode> </dt> <dd> <p>This option sets how the tag message is cleaned up. The <code><mode></code> can be one of <code>verbatim</code>, <code>whitespace</code> and <code>strip</code>. The <code>strip</code> mode is default. The <code>verbatim</code> mode does not change message at all, <code>whitespace</code> removes just leading/trailing whitespace lines and <code>strip</code> removes both whitespace and commentary.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt---create-reflog"> --create-reflog </dt> <dd> <p>Create a reflog for the tag. To globally enable reflogs for tags, see <code>core.logAllRefUpdates</code> in <a href="git-config">git-config[1]</a>. The negated form <code>--no-create-reflog</code> only overrides an earlier <code>--create-reflog</code>, but currently does not negate the setting of <code>core.logAllRefUpdates</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt---formatltformatgt"> --format=<format> </dt> <dd> <p>A string that interpolates <code>%(fieldname)</code> from a tag ref being shown and the object it points at. The format is the same as that of <a href="git-for-each-ref">git-for-each-ref[1]</a>. When unspecified, defaults to <code>%(refname:strip=2)</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt-lttagnamegt"> <tagname> </dt> <dd> <p>The name of the tag to create, delete, or describe. The new tag name must pass all checks defined by <a href="git-check-ref-format">git-check-ref-format[1]</a>. Some of these checks may restrict the characters allowed in a tag name.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt-ltcommitgt"> <commit> </dt> <dt class="hdlist1" id="Documentation/git-tag.txt-ltobjectgt"> <object> </dt> <dd> <p>The object that the new tag will refer to, usually a commit. Defaults to HEAD.</p> </dd> </dl> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>By default, <code>git tag</code> in sign-with-default mode (-s) will use your committer identity (of the form <code>Your Name <your@email.address></code>) to find a key. If you want to use a different default key, you can specify it in the repository configuration as follows:</p> <div class="listingblock"> <div class="content"> <pre>[user] + signingKey = <gpg-key_id></pre> </div> </div> <p><code>pager.tag</code> is only respected when listing tags, i.e., when <code>-l</code> is used or implied. The default is to use a pager. See <a href="git-config">git-config[1]</a>.</p> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_on_re_tagging"> +On Re-tagging</h3> <p>What should you do when you tag a wrong commit and you would want to re-tag?</p> <p>If you never pushed anything out, just re-tag it. Use "-f" to replace the old one. And you’re done.</p> <p>But if you have pushed things out (or others could just read your repository directly), then others will have already seen the old tag. In that case you can do one of two things:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>The sane thing. Just admit you screwed up, and use a different name. Others have already seen one tag-name, and if you keep the same name, you may be in the situation that two people both have "version X", but they actually have <code>different</code> "X"'s. So just call it "X.1" and be done with it.</p> </li> <li> <p>The insane thing. You really want to call the new version "X" too, <code>even though</code> others have already seen the old one. So just use <code>git tag -f</code> again, as if you hadn’t already published the old one.</p> </li> </ol> </div> <p>However, Git does <strong>not</strong> (and it should not) change tags behind users back. So if somebody already got the old tag, doing a <code>git pull</code> on your tree shouldn’t just make them overwrite the old one.</p> <p>If somebody got a release tag from you, you cannot just change the tag for them by updating your own one. This is a big security issue, in that people MUST be able to trust their tag-names. If you really want to do the insane thing, you need to just fess up to it, and tell people that you messed up. You can do that by making a very public announcement saying:</p> <div class="listingblock"> <div class="content"> <pre>Ok, I messed up, and I pushed out an earlier version tagged as X. I +then fixed something, and retagged the *fixed* tree as X again. + +If you got the wrong tag, and want the new one, please delete +the old one and fetch the new one by doing: + + git tag -d X + git fetch origin tag X + +to get my updated tag. + +You can test which tag you have by doing + + git rev-parse X + +which should return 0123456789abcdef.. if you have the new version. + +Sorry for the inconvenience.</pre> </div> </div> <p>Does this seem a bit complicated? It <strong>should</strong> be. There is no way that it would be correct to just "fix" it automatically. People need to know that their tags might have been changed.</p> </div> <div class="sect2"> <h3 id="_on_automatic_following"> +On Automatic following</h3> <p>If you are following somebody else’s tree, you are most likely using remote-tracking branches (eg. <code>refs/remotes/origin/master</code>). You usually want the tags from the other end.</p> <p>On the other hand, if you are fetching because you would want a one-shot merge from somebody else, you typically do not want to get tags from there. This happens more often for people near the toplevel but not limited to them. Mere mortals when pulling from each other do not necessarily want to automatically get private anchor point tags from the other person.</p> <p>Often, "please pull" messages on the mailing list just provide two pieces of information: a repo URL and a branch name; this is designed to be easily cut&pasted at the end of a <code>git fetch</code> command line:</p> <div class="listingblock"> <div class="content"> <pre>Linus, please pull from + + git://git..../proj.git master + +to get the following updates...</pre> </div> </div> <p>becomes:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git pull git://git..../proj.git master</pre> </div> </div> <p>In such a case, you do not want to automatically follow the other person’s tags.</p> <p>One important aspect of Git is its distributed nature, which largely means there is no inherent "upstream" or "downstream" in the system. On the face of it, the above example might seem to indicate that the tag namespace is owned by the upper echelon of people and that tags only flow downwards, but that is not the case. It only shows that the usage pattern determines who are interested in whose tags.</p> <p>A one-shot pull is a sign that a commit history is now crossing the boundary between one circle of people (e.g. "people who are primarily interested in the networking part of the kernel") who may have their own set of tags (e.g. "this is the third release candidate from the networking group to be proposed for general consumption with 2.6.21 release") to another circle of people (e.g. "people who integrate various subsystem improvements"). The latter are usually not interested in the detailed tags used internally in the former group (that is what "internal" means). That is why it is desirable not to follow tags automatically in this case.</p> <p>It may well be that among networking people, they may want to exchange the tags internal to their group, but in that workflow they are most likely tracking each other’s progress by having remote-tracking branches. Again, the heuristic to automatically follow such tags is a good thing.</p> </div> <div class="sect2"> <h3 id="_on_backdating_tags"> +On Backdating Tags</h3> <p>If you have imported some changes from another VCS and would like to add tags for major releases of your work, it is useful to be able to specify the date to embed inside of the tag object; such data in the tag object affects, for example, the ordering of tags in the gitweb interface.</p> <p>To set the date used in future tag objects, set the environment variable GIT_COMMITTER_DATE (see the later discussion of possible values; the most common form is "YYYY-MM-DD HH:MM").</p> <p>For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ GIT_COMMITTER_DATE="2006-10-02 10:31" git tag -s v1.0.1</pre> </div> </div> </div> </div> <h2 id="_date_formats">Date formats</h2> <div class="sectionbody"> <p>The <code>GIT_AUTHOR_DATE</code> and <code>GIT_COMMITTER_DATE</code> environment variables support the following date formats:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-tag.txt-Gitinternalformat"> Git internal format </dt> <dd> <p>It is <code><unix-timestamp> <time-zone-offset></code>, where <code><unix-timestamp></code> is the number of seconds since the UNIX epoch. <code><time-zone-offset></code> is a positive or negative offset from UTC. For example CET (which is 1 hour ahead of UTC) is <code>+0100</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt-RFC2822"> RFC 2822 </dt> <dd> <p>The standard email format as described by RFC 2822, for example <code>Thu, 07 Apr 2005 22:13:13 +0200</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-tag.txt-ISO8601"> ISO 8601 </dt> <dd> <p>Time and date specified by the ISO 8601 standard, for example <code>2005-04-07T22:13:13</code>. The parser accepts a space instead of the <code>T</code> character as well. Fractional parts of a second will be ignored, for example <code>2005-04-07T22:13:13.019</code> will be treated as <code>2005-04-07T22:13:13</code>.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> In addition, the date part is accepted in the following formats: <code>YYYY.MM.DD</code>, <code>MM/DD/YYYY</code> and <code>DD.MM.YYYY</code>. </td> </tr> </table> </div> </dd> </dl> </div> </div> <h2 id="_files">Files</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-tag.txt-codeGITDIRTAGEDITMSGcode"> <code>$GIT_DIR/TAG_EDITMSG</code> </dt> <dd> <p>This file contains the message of an in-progress annotated tag. If <code>git tag</code> exits due to an error before creating an annotated tag then the tag message that has been provided by the user in an editor session will be available in this file, but may be overwritten by the next invocation of <code>git tag</code>.</p> </dd> </dl> </div> </div> <h2 id="_notes">Notes</h2> <div class="sectionbody"> <p>When combining multiple <code>--contains</code> and <code>--no-contains</code> filters, only references that contain at least one of the <code>--contains</code> commits and contain none of the <code>--no-contains</code> commits are shown.</p> <p>When combining multiple <code>--merged</code> and <code>--no-merged</code> filters, only references that are reachable from at least one of the <code>--merged</code> commits and from none of the <code>--no-merged</code> commits are shown.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-check-ref-format">git-check-ref-format[1]</a>. <a href="git-config">git-config[1]</a>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-tag" class="_attribution-link">https://git-scm.com/docs/git-tag</a> + </p> +</div> diff --git a/devdocs/git/git-unpack-file.html b/devdocs/git/git-unpack-file.html new file mode 100644 index 00000000..cddb0dbb --- /dev/null +++ b/devdocs/git/git-unpack-file.html @@ -0,0 +1,6 @@ +<h1>git-unpack-file</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-unpack-file - Creates a temporary file with a blob’s contents</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git unpack-file <blob></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Creates a file holding the contents of the blob specified by sha1. It returns the name of the temporary file in the following format: .merge_file_XXXXX</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-unpack-file.txt-ltblobgt"> <blob> </dt> <dd> <p>Must be a blob id</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-unpack-file" class="_attribution-link">https://git-scm.com/docs/git-unpack-file</a> + </p> +</div> diff --git a/devdocs/git/git-unpack-objects.html b/devdocs/git/git-unpack-objects.html new file mode 100644 index 00000000..fb13b524 --- /dev/null +++ b/devdocs/git/git-unpack-objects.html @@ -0,0 +1,6 @@ +<h1>git-unpack-objects</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-unpack-objects - Unpack objects from a packed archive</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git unpack-objects [-n] [-q] [-r] [--strict]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Read a packed archive (.pack) from the standard input, expanding the objects contained within and writing them into the repository in "loose" (one object per file) format.</p> <p>Objects that already exist in the repository will <strong>not</strong> be unpacked from the packfile. Therefore, nothing will be unpacked if you use this command on a packfile that exists within the target repository.</p> <p>See <a href="git-repack">git-repack[1]</a> for options to generate new packs and replace existing ones.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-unpack-objects.txt--n"> -n </dt> <dd> <p> Dry run. Check the pack file without actually unpacking the objects.</p> </dd> <dt class="hdlist1" id="Documentation/git-unpack-objects.txt--q"> -q </dt> <dd> <p>The command usually shows percentage progress. This flag suppresses it.</p> </dd> <dt class="hdlist1" id="Documentation/git-unpack-objects.txt--r"> -r </dt> <dd> <p>When unpacking a corrupt packfile, the command dies at the first corruption. This flag tells it to keep going and make the best effort to recover as many objects as possible.</p> </dd> <dt class="hdlist1" id="Documentation/git-unpack-objects.txt---strict"> --strict </dt> <dd> <p>Don’t write objects with broken content or links.</p> </dd> <dt class="hdlist1" id="Documentation/git-unpack-objects.txt---max-input-sizeltsizegt"> --max-input-size=<size> </dt> <dd> <p>Die, if the pack is larger than <size>.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-unpack-objects" class="_attribution-link">https://git-scm.com/docs/git-unpack-objects</a> + </p> +</div> diff --git a/devdocs/git/git-update-index.html b/devdocs/git/git-update-index.html new file mode 100644 index 00000000..ab39aa6f --- /dev/null +++ b/devdocs/git/git-update-index.html @@ -0,0 +1,42 @@ +<h1>git-update-index</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-update-index - Register file contents in the working tree to the index</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git update-index + [--add] [--remove | --force-remove] [--replace] + [--refresh] [-q] [--unmerged] [--ignore-missing] + [(--cacheinfo <mode>,<object>,<file>)…] + [--chmod=(+|-)x] + [--[no-]assume-unchanged] + [--[no-]skip-worktree] + [--[no-]ignore-skip-worktree-entries] + [--[no-]fsmonitor-valid] + [--ignore-submodules] + [--[no-]split-index] + [--[no-|test-|force-]untracked-cache] + [--[no-]fsmonitor] + [--really-refresh] [--unresolve] [--again | -g] + [--info-only] [--index-info] + [-z] [--stdin] [--index-version <n>] + [--verbose] + [--] [<file>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Modifies the index. Each file mentioned is updated into the index and any <code>unmerged</code> or <code>needs updating</code> state is cleared.</p> <p>See also <a href="git-add">git-add[1]</a> for a more user-friendly way to do some of the most common operations on the index.</p> <p>The way <code>git update-index</code> handles files it is told about can be modified using the various options:</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-update-index.txt---add"> --add </dt> <dd> <p>If a specified file isn’t in the index already then it’s added. Default behaviour is to ignore new files.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---remove"> --remove </dt> <dd> <p>If a specified file is in the index but is missing then it’s removed. Default behavior is to ignore removed files.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---refresh"> --refresh </dt> <dd> <p>Looks at the current index and checks to see if merges or updates are needed by checking stat() information.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt--q"> -q </dt> <dd> <p> Quiet. If --refresh finds that the index needs an update, the default behavior is to error out. This option makes <code>git update-index</code> continue anyway.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---ignore-submodules"> --ignore-submodules </dt> <dd> <p>Do not try to update submodules. This option is only respected when passed before --refresh.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---unmerged"> --unmerged </dt> <dd> <p> If --refresh finds unmerged changes in the index, the default behavior is to error out. This option makes <code>git update-index</code> continue anyway.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---ignore-missing"> --ignore-missing </dt> <dd> <p>Ignores missing files during a --refresh</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---cacheinfoltmodegtltobjectgtltpathgt"> --cacheinfo <mode>,<object>,<path> </dt> <dt class="hdlist1" id="Documentation/git-update-index.txt---cacheinfoltmodegtltobjectgtltpathgt-1"> --cacheinfo <mode> <object> <path> </dt> <dd> <p>Directly insert the specified info into the index. For backward compatibility, you can also give these three arguments as three separate parameters, but new users are encouraged to use a single-parameter form.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---index-info"> --index-info </dt> <dd> <p>Read index information from stdin.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---chmod-x"> --chmod=(+|-)x </dt> <dd> <p>Set the execute permissions on the updated files.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---no-assume-unchanged"> --[no-]assume-unchanged </dt> <dd> <p>When this flag is specified, the object names recorded for the paths are not updated. Instead, this option sets/unsets the "assume unchanged" bit for the paths. When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has a very slow lstat(2) system call (e.g. cifs).</p> <p>Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---really-refresh"> --really-refresh </dt> <dd> <p>Like <code>--refresh</code>, but checks stat information unconditionally, without regard to the "assume unchanged" setting.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---no-skip-worktree"> --[no-]skip-worktree </dt> <dd> <p>When one of these flags is specified, the object names recorded for the paths are not updated. Instead, these options set and unset the "skip-worktree" bit for the paths. See section "Skip-worktree bit" below for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---no-ignore-skip-worktree-entries"> --[no-]ignore-skip-worktree-entries </dt> <dd> <p>Do not remove skip-worktree (AKA "index-only") entries even when the <code>--remove</code> option was specified.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---no-fsmonitor-valid"> --[no-]fsmonitor-valid </dt> <dd> <p>When one of these flags is specified, the object names recorded for the paths are not updated. Instead, these options set and unset the "fsmonitor valid" bit for the paths. See section "File System Monitor" below for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt--g"> -g </dt> <dt class="hdlist1" id="Documentation/git-update-index.txt---again"> --again </dt> <dd> <p>Runs <code>git update-index</code> itself on the paths whose index entries are different from those of the <code>HEAD</code> commit.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---unresolve"> --unresolve </dt> <dd> <p>Restores the <code>unmerged</code> or <code>needs updating</code> state of a file during a merge if it was cleared by accident.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---info-only"> --info-only </dt> <dd> <p>Do not create objects in the object database for all <file> arguments that follow this flag; just insert their object IDs into the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---force-remove"> --force-remove </dt> <dd> <p>Remove the file from the index even when the working directory still has such a file. (Implies --remove.)</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---replace"> --replace </dt> <dd> <p>By default, when a file <code>path</code> exists in the index, <code>git update-index</code> refuses an attempt to add <code>path/file</code>. Similarly if a file <code>path/file</code> exists, a file <code>path</code> cannot be added. With --replace flag, existing entries that conflict with the entry being added are automatically removed with warning messages.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---stdin"> --stdin </dt> <dd> <p>Instead of taking a list of paths from the command line, read a list of paths from the standard input. Paths are separated by LF (i.e. one path per line) by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---verbose"> --verbose </dt> <dd> <p>Report what is being added and removed from the index.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---index-versionltngt"> --index-version <n> </dt> <dd> <p>Write the resulting index out in the named on-disk format version. Supported versions are 2, 3, and 4. The current default version is 2 or 3, depending on whether extra features are used, such as <code>git add -N</code>. With <code>--verbose</code>, also report the version the index file uses before and after this command.</p> <p>Version 4 performs a simple pathname compression that reduces index size by 30%-50% on large repositories, which results in faster load time. Git supports it since version 1.8.0, released in October 2012, and support for it was added to libgit2 in 2016 and to JGit in 2020. Older versions of this manual page called it "relatively young", but it should be considered mature technology these days.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---show-index-version"> --show-index-version </dt> <dd> <p>Report the index format version used by the on-disk index file. See <code>--index-version</code> above.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt--z"> -z </dt> <dd> <p>Only meaningful with <code>--stdin</code> or <code>--index-info</code>; paths are separated with NUL character instead of LF.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---split-index"> --split-index </dt> <dt class="hdlist1" id="Documentation/git-update-index.txt---no-split-index"> --no-split-index </dt> <dd> <p>Enable or disable split index mode. If split-index mode is already enabled and <code>--split-index</code> is given again, all changes in $GIT_DIR/index are pushed back to the shared index file.</p> <p>These options take effect whatever the value of the <code>core.splitIndex</code> configuration variable (see <a href="git-config">git-config[1]</a>). But a warning is emitted when the change goes against the configured value, as the configured value will take effect next time the index is read and this will remove the intended effect of the option.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---untracked-cache"> --untracked-cache </dt> <dt class="hdlist1" id="Documentation/git-update-index.txt---no-untracked-cache"> --no-untracked-cache </dt> <dd> <p>Enable or disable untracked cache feature. Please use <code>--test-untracked-cache</code> before enabling it.</p> <p>These options take effect whatever the value of the <code>core.untrackedCache</code> configuration variable (see <a href="git-config">git-config[1]</a>). But a warning is emitted when the change goes against the configured value, as the configured value will take effect next time the index is read and this will remove the intended effect of the option.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---test-untracked-cache"> --test-untracked-cache </dt> <dd> <p>Only perform tests on the working directory to make sure untracked cache can be used. You have to manually enable untracked cache using <code>--untracked-cache</code> or <code>--force-untracked-cache</code> or the <code>core.untrackedCache</code> configuration variable afterwards if you really want to use it. If a test fails the exit code is 1 and a message explains what is not working as needed, otherwise the exit code is 0 and OK is printed.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---force-untracked-cache"> --force-untracked-cache </dt> <dd> <p>Same as <code>--untracked-cache</code>. Provided for backwards compatibility with older versions of Git where <code>--untracked-cache</code> used to imply <code>--test-untracked-cache</code> but this option would enable the extension unconditionally.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---fsmonitor"> --fsmonitor </dt> <dt class="hdlist1" id="Documentation/git-update-index.txt---no-fsmonitor"> --no-fsmonitor </dt> <dd> <p>Enable or disable files system monitor feature. These options take effect whatever the value of the <code>core.fsmonitor</code> configuration variable (see <a href="git-config">git-config[1]</a>). But a warning is emitted when the change goes against the configured value, as the configured value will take effect next time the index is read and this will remove the intended effect of the option.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt---"> -- </dt> <dd> <p>Do not interpret any more arguments as options.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-index.txt-ltfilegt"> <file> </dt> <dd> <p>Files to act on. Note that files beginning with <code>.</code> are discarded. This includes <code>./file</code> and <code>dir/./file</code>. If you don’t want this, then use cleaner names. The same applies to directories ending <code>/</code> and paths with <code>//</code></p> </dd> </dl> </div> </div> <h2 id="_using_refresh">Using --refresh</h2> <div class="sectionbody"> <p><code>--refresh</code> does not calculate a new sha1 file or bring the index up to date for mode/content changes. But what it <strong>does</strong> do is to "re-match" the stat information of a file with the index, so that you can refresh the index for a file that hasn’t been changed but where the stat entry is out of date.</p> <p>For example, you’d want to do this after doing a <code>git read-tree</code>, to link up the stat index details with the proper files.</p> </div> <h2 id="_using_cacheinfo_or_info_only">Using --cacheinfo or --info-only</h2> <div class="sectionbody"> <p><code>--cacheinfo</code> is used to register a file that is not in the current working directory. This is useful for minimum-checkout merging.</p> <p>To pretend you have a file at path with mode and sha1, say:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git update-index --add --cacheinfo <mode>,<sha1>,<path></pre> </div> </div> <p><code>--info-only</code> is used to register files without placing them in the object database. This is useful for status-only repositories.</p> <p>Both <code>--cacheinfo</code> and <code>--info-only</code> behave similarly: the index is updated but the object database isn’t. <code>--cacheinfo</code> is useful when the object is in the database but the file isn’t available locally. <code>--info-only</code> is useful when the file is available, but you do not wish to update the object database.</p> </div> <h2 id="_using_index_info">Using --index-info</h2> <div class="sectionbody"> <p><code>--index-info</code> is a more powerful mechanism that lets you feed multiple entry definitions from the standard input, and designed specifically for scripts. It can take inputs of three formats:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>mode SP type SP sha1 TAB path</p> <p>This format is to stuff <code>git ls-tree</code> output into the index.</p> </li> <li> <p>mode SP sha1 SP stage TAB path</p> <p>This format is to put higher order stages into the index file and matches <code>git ls-files --stage</code> output.</p> </li> <li> <p>mode SP sha1 TAB path</p> <p>This format is no longer produced by any Git command, but is and will continue to be supported by <code>update-index --index-info</code>.</p> </li> </ol> </div> <p>To place a higher stage entry to the index, the path should first be removed by feeding a mode=0 entry for the path, and then feeding necessary input lines in the third format.</p> <p>For example, starting with this index:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-files -s +100644 8a1218a1024a212bb3db30becd860315f9f3ac52 0 frotz</pre> </div> </div> <p>you can feed the following input to <code>--index-info</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git update-index --index-info +0 0000000000000000000000000000000000000000 frotz +100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1 frotz +100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2 frotz</pre> </div> </div> <p>The first line of the input feeds 0 as the mode to remove the path; the SHA-1 does not matter as long as it is well formatted. Then the second and third line feeds stage 1 and stage 2 entries for that path. After the above, we would end up with this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-files -s +100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1 frotz +100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2 frotz</pre> </div> </div> </div> <h2 id="_using_assume_unchanged_bit">Using “assume unchanged” bit</h2> <div class="sectionbody"> <p>Many operations in Git depend on your filesystem to have an efficient <code>lstat(2)</code> implementation, so that <code>st_mtime</code> information for working tree files can be cheaply checked to see if the file contents have changed from the version recorded in the index file. Unfortunately, some filesystems have inefficient <code>lstat(2)</code>. If your filesystem is one of them, you can set "assume unchanged" bit to paths you have not changed to cause Git not to do this check. Note that setting this bit on a path does not mean Git will check the contents of the file to see if it has changed — it makes Git to omit any checking and assume it has <strong>not</strong> changed. When you make changes to working tree files, you have to explicitly tell Git about it by dropping "assume unchanged" bit, either before or after you modify them.</p> <p>In order to set "assume unchanged" bit, use <code>--assume-unchanged</code> option. To unset, use <code>--no-assume-unchanged</code>. To see which files have the "assume unchanged" bit set, use <code>git ls-files -v</code> (see <a href="git-ls-files">git-ls-files[1]</a>).</p> <p>The command looks at <code>core.ignorestat</code> configuration variable. When this is true, paths updated with <code>git update-index paths...</code> and paths updated with other Git commands that update both index and working tree (e.g. <code>git apply --index</code>, <code>git checkout-index -u</code>, and <code>git read-tree -u</code>) are automatically marked as "assume unchanged". Note that "assume unchanged" bit is <strong>not</strong> set if <code>git update-index --refresh</code> finds the working tree file matches the index (use <code>git update-index --really-refresh</code> if you want to mark them as "assume unchanged").</p> <p>Sometimes users confuse the assume-unchanged bit with the skip-worktree bit. See the final paragraph in the "Skip-worktree bit" section below for an explanation of the differences.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>To update and refresh only the files already checked out:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout-index -n -f -a && git update-index --ignore-missing --refresh</pre> </div> </div> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-update-index.txt-Onaninefficientfilesystemwithcodecoreignorestatcodeset"> On an inefficient filesystem with <code>core.ignorestat</code> set </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git update-index --really-refresh (1) +$ git update-index --no-assume-unchanged foo.c (2) +$ git diff --name-only (3) +$ edit foo.c +$ git diff --name-only (4) +M foo.c +$ git update-index foo.c (5) +$ git diff --name-only (6) +$ edit foo.c +$ git diff --name-only (7) +$ git update-index --no-assume-unchanged foo.c (8) +$ git diff --name-only (9) +M foo.c</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>forces lstat(2) to set "assume unchanged" bits for paths that match index.</p> </li> <li> <p>mark the path to be edited.</p> </li> <li> <p>this does lstat(2) and finds index matches the path.</p> </li> <li> <p>this does lstat(2) and finds index does <strong>not</strong> match the path.</p> </li> <li> <p>registering the new version to index sets "assume unchanged" bit.</p> </li> <li> <p>and it is assumed unchanged.</p> </li> <li> <p>even after you edit it.</p> </li> <li> <p>you can tell about the change after the fact.</p> </li> <li> <p>now it checks with lstat(2) and finds it has been changed.</p> </li> </ol> </div> </dd> </dl> </div> </div> <h2 id="_skip_worktree_bit">Skip-worktree bit</h2> <div class="sectionbody"> <p>Skip-worktree bit can be defined in one (long) sentence: Tell git to avoid writing the file to the working directory when reasonably possible, and treat the file as unchanged when it is not present in the working directory.</p> <p>Note that not all git commands will pay attention to this bit, and some only partially support it.</p> <p>The update-index flags and the read-tree capabilities relating to the skip-worktree bit predated the introduction of the <a href="git-sparse-checkout">git-sparse-checkout[1]</a> command, which provides a much easier way to configure and handle the skip-worktree bits. If you want to reduce your working tree to only deal with a subset of the files in the repository, we strongly encourage the use of <a href="git-sparse-checkout">git-sparse-checkout[1]</a> in preference to the low-level update-index and read-tree primitives.</p> <p>The primary purpose of the skip-worktree bit is to enable sparse checkouts, i.e. to have working directories with only a subset of paths present. When the skip-worktree bit is set, Git commands (such as <code>switch</code>, <code>pull</code>, <code>merge</code>) will avoid writing these files. However, these commands will sometimes write these files anyway in important cases such as conflicts during a merge or rebase. Git commands will also avoid treating the lack of such files as an intentional deletion; for example <code>git add -u</code> will not stage a deletion for these files and <code>git commit -a</code> will not make a commit deleting them either.</p> <p>Although this bit looks similar to assume-unchanged bit, its goal is different. The assume-unchanged bit is for leaving the file in the working tree but having Git omit checking it for changes and presuming that the file has not been changed (though if it can determine without stat’ing the file that it has changed, it is free to record the changes). skip-worktree tells Git to ignore the absence of the file, avoid updating it when possible with commands that normally update much of the working directory (e.g. <code>checkout</code>, <code>switch</code>, <code>pull</code>, etc.), and not have its absence be recorded in commits. Note that in sparse checkouts (setup by <code>git sparse-checkout</code> or by configuring core.sparseCheckout to true), if a file is marked as skip-worktree in the index but is found in the working tree, Git will clear the skip-worktree bit for that file.</p> </div> <h2 id="_split_index">Split index</h2> <div class="sectionbody"> <p>This mode is designed for repositories with very large indexes, and aims at reducing the time it takes to repeatedly write these indexes.</p> <p>In this mode, the index is split into two files, $GIT_DIR/index and $GIT_DIR/sharedindex.<SHA-1>. Changes are accumulated in $GIT_DIR/index, the split index, while the shared index file contains all index entries and stays unchanged.</p> <p>All changes in the split index are pushed back to the shared index file when the number of entries in the split index reaches a level specified by the splitIndex.maxPercentChange config variable (see <a href="git-config">git-config[1]</a>).</p> <p>Each time a new shared index file is created, the old shared index files are deleted if their modification time is older than what is specified by the splitIndex.sharedIndexExpire config variable (see <a href="git-config">git-config[1]</a>).</p> <p>To avoid deleting a shared index file that is still used, its modification time is updated to the current time every time a new split index based on the shared index file is either created or read from.</p> </div> <h2 id="_untracked_cache">Untracked cache</h2> <div class="sectionbody"> <p>This cache is meant to speed up commands that involve determining untracked files such as <code>git status</code>.</p> <p>This feature works by recording the mtime of the working tree directories and then omitting reading directories and stat calls against files in those directories whose mtime hasn’t changed. For this to work the underlying operating system and file system must change the <code>st_mtime</code> field of directories if files in the directory are added, modified or deleted.</p> <p>You can test whether the filesystem supports that with the <code>--test-untracked-cache</code> option. The <code>--untracked-cache</code> option used to implicitly perform that test in older versions of Git, but that’s no longer the case.</p> <p>If you want to enable (or disable) this feature, it is easier to use the <code>core.untrackedCache</code> configuration variable (see <a href="git-config">git-config[1]</a>) than using the <code>--untracked-cache</code> option to <code>git update-index</code> in each repository, especially if you want to do so across all repositories you use, because you can set the configuration variable to <code>true</code> (or <code>false</code>) in your <code>$HOME/.gitconfig</code> just once and have it affect all repositories you touch.</p> <p>When the <code>core.untrackedCache</code> configuration variable is changed, the untracked cache is added to or removed from the index the next time a command reads the index; while when <code>--[no-|force-]untracked-cache</code> are used, the untracked cache is immediately added to or removed from the index.</p> <p>Before 2.17, the untracked cache had a bug where replacing a directory with a symlink to another directory could cause it to incorrectly show files tracked by git as untracked. See the "status: add a failing test showing a core.untrackedCache bug" commit to git.git. A workaround for that is (and this might work for other undiscovered bugs in the future):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git -c core.untrackedCache=false status</pre> </div> </div> <p>This bug has also been shown to affect non-symlink cases of replacing a directory with a file when it comes to the internal structures of the untracked cache, but no case has been reported where this resulted in wrong "git status" output.</p> <p>There are also cases where existing indexes written by git versions before 2.17 will reference directories that don’t exist anymore, potentially causing many "could not open directory" warnings to be printed on "git status". These are new warnings for existing issues that were previously silently discarded.</p> <p>As with the bug described above the solution is to one-off do a "git status" run with <code>core.untrackedCache=false</code> to flush out the leftover bad data.</p> </div> <h2 id="_file_system_monitor">File system monitor</h2> <div class="sectionbody"> <p>This feature is intended to speed up git operations for repos that have large working directories.</p> <p>It enables git to work together with a file system monitor (see <a href="git-fsmonitor--daemon">git-fsmonitor--daemon[1]</a> and the "fsmonitor-watchman" section of <a href="githooks">githooks[5]</a>) that can inform it as to what files have been modified. This enables git to avoid having to lstat() every file to find modified files.</p> <p>When used in conjunction with the untracked cache, it can further improve performance by avoiding the cost of scanning the entire working directory looking for new files.</p> <p>If you want to enable (or disable) this feature, it is easier to use the <code>core.fsmonitor</code> configuration variable (see <a href="git-config">git-config[1]</a>) than using the <code>--fsmonitor</code> option to <code>git +update-index</code> in each repository, especially if you want to do so across all repositories you use, because you can set the configuration variable in your <code>$HOME/.gitconfig</code> just once and have it affect all repositories you touch.</p> <p>When the <code>core.fsmonitor</code> configuration variable is changed, the file system monitor is added to or removed from the index the next time a command reads the index. When <code>--[no-]fsmonitor</code> are used, the file system monitor is immediately added to or removed from the index.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>The command honors <code>core.filemode</code> configuration variable. If your repository is on a filesystem whose executable bits are unreliable, this should be set to <code>false</code> (see <a href="git-config">git-config[1]</a>). This causes the command to ignore differences in file modes recorded in the index and the file mode on the filesystem if they differ only on executable bit. On such an unfortunate filesystem, you may need to use <code>git update-index --chmod=</code>.</p> <p>Quite similarly, if <code>core.symlinks</code> configuration variable is set to <code>false</code> (see <a href="git-config">git-config[1]</a>), symbolic links are checked out as plain files, and this command does not modify a recorded file mode from symbolic link to regular file.</p> <p>The command looks at <code>core.ignorestat</code> configuration variable. See <code>Using "assume unchanged" bit</code> section above.</p> <p>The command also looks at <code>core.trustctime</code> configuration variable. It can be useful when the inode change time is regularly modified by something outside Git (file system crawlers and backup systems use ctime for marking files processed) (see <a href="git-config">git-config[1]</a>).</p> <p>The untracked cache extension can be enabled by the <code>core.untrackedCache</code> configuration variable (see <a href="git-config">git-config[1]</a>).</p> </div> <h2 id="_notes">Notes</h2> <div class="sectionbody"> <p>Users often try to use the assume-unchanged and skip-worktree bits to tell Git to ignore changes to files that are tracked. This does not work as expected, since Git may still check working tree files against the index when performing certain operations. In general, Git does not provide a way to ignore changes to tracked files, so alternate solutions are recommended.</p> <p>For example, if the file you want to change is some sort of config file, the repository can include a sample config file that can then be copied into the ignored name and modified. The repository can even include a script to treat the sample file as a template, modifying and copying it automatically.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-config">git-config[1]</a>, <a href="git-add">git-add[1]</a>, <a href="git-ls-files">git-ls-files[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-update-index" class="_attribution-link">https://git-scm.com/docs/git-update-index</a> + </p> +</div> diff --git a/devdocs/git/git-update-ref.html b/devdocs/git/git-update-ref.html new file mode 100644 index 00000000..34639cf2 --- /dev/null +++ b/devdocs/git/git-update-ref.html @@ -0,0 +1,23 @@ +<h1>git-update-ref</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-update-ref - Update the object name stored in a ref safely</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git update-ref [-m <reason>] [--no-deref] (-d <ref> [<oldvalue>] | [--create-reflog] <ref> <newvalue> [<oldvalue>] | --stdin [-z])</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Given two arguments, stores the <newvalue> in the <ref>, possibly dereferencing the symbolic refs. E.g. <code>git update-ref HEAD +<newvalue></code> updates the current branch head to the new object.</p> <p>Given three arguments, stores the <newvalue> in the <ref>, possibly dereferencing the symbolic refs, after verifying that the current value of the <ref> matches <oldvalue>. E.g. <code>git update-ref refs/heads/master <newvalue> <oldvalue></code> updates the master branch head to <newvalue> only if its current value is <oldvalue>. You can specify 40 "0" or an empty string as <oldvalue> to make sure that the ref you are creating does not exist.</p> <p>It also allows a "ref" file to be a symbolic pointer to another ref file by starting with the four-byte header sequence of "ref:".</p> <p>More importantly, it allows the update of a ref file to follow these symbolic pointers, whether they are symlinks or these "regular file symbolic refs". It follows <strong>real</strong> symlinks only if they start with "refs/": otherwise it will just try to read them and update them as a regular file (i.e. it will allow the filesystem to follow them, but will overwrite such a symlink to somewhere else with a regular filename).</p> <p>If --no-deref is given, <ref> itself is overwritten, rather than the result of following the symbolic pointers.</p> <p>In general, using</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git update-ref HEAD "$head"</pre> </div> </div> <p>should be a <code>lot</code> safer than doing</p> <div class="literalblock"> <div class="content"> <pre>echo "$head" > "$GIT_DIR/HEAD"</pre> </div> </div> <p>both from a symlink following standpoint <strong>and</strong> an error checking standpoint. The "refs/" rule for symlinks means that symlinks that point to "outside" the tree are safe: they’ll be followed for reading but not for writing (so we’ll never write through a ref symlink to some other tree, if you have copied a whole archive by creating a symlink tree).</p> <p>With <code>-d</code> flag, it deletes the named <ref> after verifying it still contains <oldvalue>.</p> <p>With <code>--stdin</code>, update-ref reads instructions from standard input and performs all modifications together. Specify commands of the form:</p> <div class="literalblock"> <div class="content"> <pre>update SP <ref> SP <newvalue> [SP <oldvalue>] LF +create SP <ref> SP <newvalue> LF +delete SP <ref> [SP <oldvalue>] LF +verify SP <ref> [SP <oldvalue>] LF +option SP <opt> LF +start LF +prepare LF +commit LF +abort LF</pre> </div> </div> <p>With <code>--create-reflog</code>, update-ref will create a reflog for each ref even if one would not ordinarily be created.</p> <p>Quote fields containing whitespace as if they were strings in C source code; i.e., surrounded by double-quotes and with backslash escapes. Use 40 "0" characters or the empty string to specify a zero value. To specify a missing value, omit the value and its preceding SP entirely.</p> <p>Alternatively, use <code>-z</code> to specify in NUL-terminated format, without quoting:</p> <div class="literalblock"> <div class="content"> <pre>update SP <ref> NUL <newvalue> NUL [<oldvalue>] NUL +create SP <ref> NUL <newvalue> NUL +delete SP <ref> NUL [<oldvalue>] NUL +verify SP <ref> NUL [<oldvalue>] NUL +option SP <opt> NUL +start NUL +prepare NUL +commit NUL +abort NUL</pre> </div> </div> <p>In this format, use 40 "0" to specify a zero value, and use the empty string to specify a missing value.</p> <p>In either format, values can be specified in any form that Git recognizes as an object name. Commands in any other format or a repeated <ref> produce an error. Command meanings are:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-update-ref.txt-update"> update </dt> <dd> <p>Set <ref> to <newvalue> after verifying <oldvalue>, if given. Specify a zero <newvalue> to ensure the ref does not exist after the update and/or a zero <oldvalue> to make sure the ref does not exist before the update.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-ref.txt-create"> create </dt> <dd> <p>Create <ref> with <newvalue> after verifying it does not exist. The given <newvalue> may not be zero.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-ref.txt-delete"> delete </dt> <dd> <p>Delete <ref> after verifying it exists with <oldvalue>, if given. If given, <oldvalue> may not be zero.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-ref.txt-verify"> verify </dt> <dd> <p>Verify <ref> against <oldvalue> but do not change it. If <oldvalue> is zero or missing, the ref must not exist.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-ref.txt-option"> option </dt> <dd> <p>Modify the behavior of the next command naming a <ref>. The only valid option is <code>no-deref</code> to avoid dereferencing a symbolic ref.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-ref.txt-start"> start </dt> <dd> <p>Start a transaction. In contrast to a non-transactional session, a transaction will automatically abort if the session ends without an explicit commit. This command may create a new empty transaction when the current one has been committed or aborted already.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-ref.txt-prepare"> prepare </dt> <dd> <p>Prepare to commit the transaction. This will create lock files for all queued reference updates. If one reference could not be locked, the transaction will be aborted.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-ref.txt-commit"> commit </dt> <dd> <p>Commit all reference updates queued for the transaction, ending the transaction.</p> </dd> <dt class="hdlist1" id="Documentation/git-update-ref.txt-abort"> abort </dt> <dd> <p>Abort the transaction, releasing all locks if the transaction is in prepared state.</p> </dd> </dl> </div> <p>If all <ref>s can be locked with matching <oldvalue>s simultaneously, all modifications are performed. Otherwise, no modifications are performed. Note that while each individual <ref> is updated or deleted atomically, a concurrent reader may still see a subset of the modifications.</p> </div> <h2 id="_logging_updates">Logging updates</h2> <div class="sectionbody"> <p>If config parameter "core.logAllRefUpdates" is true and the ref is one under "refs/heads/", "refs/remotes/", "refs/notes/", or a pseudoref like HEAD or ORIG_HEAD; or the file "$GIT_DIR/logs/<ref>" exists then <code>git update-ref</code> will append a line to the log file "$GIT_DIR/logs/<ref>" (dereferencing all symbolic refs before creating the log name) describing the change in ref value. Log lines are formatted as:</p> <div class="literalblock"> <div class="content"> <pre>oldsha1 SP newsha1 SP committer LF</pre> </div> </div> <p>Where "oldsha1" is the 40 character hexadecimal value previously stored in <ref>, "newsha1" is the 40 character hexadecimal value of <newvalue> and "committer" is the committer’s name, email address and date in the standard Git committer ident format.</p> <p>Optionally with -m:</p> <div class="literalblock"> <div class="content"> <pre>oldsha1 SP newsha1 SP committer TAB message LF</pre> </div> </div> <p>Where all fields are as described above and "message" is the value supplied to the -m option.</p> <p>An update will fail (without changing <ref>) if the current user is unable to create a new log file, append to the existing log file or does not have committer information available.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-update-ref" class="_attribution-link">https://git-scm.com/docs/git-update-ref</a> + </p> +</div> diff --git a/devdocs/git/git-update-server-info.html b/devdocs/git/git-update-server-info.html new file mode 100644 index 00000000..1584a29b --- /dev/null +++ b/devdocs/git/git-update-server-info.html @@ -0,0 +1,6 @@ +<h1>git-update-server-info</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-update-server-info - Update auxiliary info file to help dumb servers</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git update-server-info [-f | --force]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>A dumb server that does not do on-the-fly pack generations must have some auxiliary information files in $GIT_DIR/info and $GIT_OBJECT_DIRECTORY/info directories to help clients discover what references and packs the server has. This command generates such auxiliary files.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-update-server-info.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-update-server-info.txt---force"> --force </dt> <dd> <p>Update the info files from scratch.</p> </dd> </dl> </div> </div> <h2 id="_output">Output</h2> <div class="sectionbody"> <p>Currently the command updates the following files. Please see <a href="gitrepository-layout">gitrepository-layout[5]</a> for a description of what they are for:</p> <div class="ulist"> <ul> <li> <p>objects/info/packs</p> </li> <li> <p>info/refs</p> </li> </ul> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-update-server-info" class="_attribution-link">https://git-scm.com/docs/git-update-server-info</a> + </p> +</div> diff --git a/devdocs/git/git-upload-archive.html b/devdocs/git/git-upload-archive.html new file mode 100644 index 00000000..33ac52e6 --- /dev/null +++ b/devdocs/git/git-upload-archive.html @@ -0,0 +1,6 @@ +<h1>git-upload-archive</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-upload-archive - Send archive back to git-archive</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git upload-archive <repository></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Invoked by <code>git archive --remote</code> and sends a generated archive to the other end over the Git protocol.</p> <p>This command is usually not invoked directly by the end user. The UI for the protocol is on the <code>git archive</code> side, and the program pair is meant to be used to get an archive from a remote repository.</p> </div> <h2 id="_security">Security</h2> <div class="sectionbody"> <p>In order to protect the privacy of objects that have been removed from history but may not yet have been pruned, <code>git-upload-archive</code> avoids serving archives for commits and trees that are not reachable from the repository’s refs. However, because calculating object reachability is computationally expensive, <code>git-upload-archive</code> implements a stricter but easier-to-check set of rules:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Clients may request a commit or tree that is pointed to directly by a ref. E.g., <code>git archive --remote=origin v1.0</code>.</p> </li> <li> <p>Clients may request a sub-tree within a commit or tree using the <code>ref:path</code> syntax. E.g., <code>git archive --remote=origin v1.0:Documentation</code>.</p> </li> <li> <p>Clients may <code>not</code> use other sha1 expressions, even if the end result is reachable. E.g., neither a relative commit like <code>master^</code> nor a literal sha1 like <code>abcd1234</code> is allowed, even if the result is reachable from the refs.</p> </li> </ol> </div> <p>Note that rule 3 disallows many cases that do not have any privacy implications. These rules are subject to change in future versions of git, and the server accessed by <code>git archive --remote</code> may or may not follow these exact rules.</p> <p>If the config option <code>uploadArchive.allowUnreachable</code> is true, these rules are ignored, and clients may use arbitrary sha1 expressions. This is useful if you do not care about the privacy of unreachable objects, or if your object database is already publicly available for access via non-smart-http.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-upload-archive.txt-ltrepositorygt"> <repository> </dt> <dd> <p>The repository to get a tar archive from.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-upload-archive" class="_attribution-link">https://git-scm.com/docs/git-upload-archive</a> + </p> +</div> diff --git a/devdocs/git/git-upload-pack.html b/devdocs/git/git-upload-pack.html new file mode 100644 index 00000000..cdb27982 --- /dev/null +++ b/devdocs/git/git-upload-pack.html @@ -0,0 +1,7 @@ +<h1>git-upload-pack</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-upload-pack - Send objects packed back to git-fetch-pack</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content">git-upload-pack [--[no-]strict] [--timeout=<n>] [--stateless-rpc] + [--advertise-refs] <directory></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Invoked by <code>git fetch-pack</code>, learns what objects the other side is missing, and sends them after packing.</p> <p>This command is usually not invoked directly by the end user. The UI for the protocol is on the <code>git fetch-pack</code> side, and the program pair is meant to be used to pull updates from a remote repository. For push operations, see <code>git send-pack</code>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-upload-pack.txt---no-strict"> --[no-]strict </dt> <dd> <p>Do not try <directory>/.git/ if <directory> is not a Git directory.</p> </dd> <dt class="hdlist1" id="Documentation/git-upload-pack.txt---timeoutltngt"> --timeout=<n> </dt> <dd> <p>Interrupt transfer after <n> seconds of inactivity.</p> </dd> <dt class="hdlist1" id="Documentation/git-upload-pack.txt---stateless-rpc"> --stateless-rpc </dt> <dd> <p>Perform only a single read-write cycle with stdin and stdout. This fits with the HTTP POST request processing model where a program may read the request, write a response, and must exit.</p> </dd> <dt class="hdlist1" id="Documentation/git-upload-pack.txt---http-backend-info-refs"> --http-backend-info-refs </dt> <dd> <p>Used by <a href="git-http-backend">git-http-backend[1]</a> to serve up <code>$GIT_URL/info/refs?service=git-upload-pack</code> requests. See "Smart Clients" in <a href="gitprotocol-http">gitprotocol-http[5]</a> and "HTTP Transport" in the <a href="gitprotocol-v2">gitprotocol-v2[5]</a> documentation. Also understood by <a href="git-receive-pack">git-receive-pack[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-upload-pack.txt-ltdirectorygt"> <directory> </dt> <dd> <p>The repository to sync from.</p> </dd> </dl> </div> </div> <h2 id="_environment">Environment</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-upload-pack.txt-codeGITPROTOCOLcode"> <code>GIT_PROTOCOL</code> </dt> <dd> <p>Internal variable used for handshaking the wire protocol. Server admins may need to configure some transports to allow this variable to be passed. See the discussion in <a href="git">git[1]</a>.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gitnamespaces">gitnamespaces[7]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-upload-pack" class="_attribution-link">https://git-scm.com/docs/git-upload-pack</a> + </p> +</div> diff --git a/devdocs/git/git-var.html b/devdocs/git/git-var.html new file mode 100644 index 00000000..9803d965 --- /dev/null +++ b/devdocs/git/git-var.html @@ -0,0 +1,10 @@ +<h1>git-var</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-var - Show a Git logical variable</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git var (-l | <variable>)</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Prints a Git logical variable. Exits with code 1 if the variable has no value.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-var.txt--l"> -l </dt> <dd> <p>Display the logical variables. In addition, all the variables of the Git configuration file .git/config are listed as well. (However, the configuration variables listing functionality is deprecated in favor of <code>git config -l</code>.)</p> </dd> </dl> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$ git var GIT_AUTHOR_IDENT +Eric W. Biederman <ebiederm@lnxi.com> 1121223278 -0600</pre> </div> </div> </div> <h2 id="_variables">Variables</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-var.txt-GITAUTHORIDENT"> GIT_AUTHOR_IDENT </dt> <dd> <p>The author of a piece of code.</p> </dd> <dt class="hdlist1" id="Documentation/git-var.txt-GITCOMMITTERIDENT"> GIT_COMMITTER_IDENT </dt> <dd> <p>The person who put a piece of code into Git.</p> </dd> <dt class="hdlist1" id="Documentation/git-var.txt-GITEDITOR"> GIT_EDITOR </dt> <dd> <p>Text editor for use by Git commands. The value is meant to be interpreted by the shell when it is used. Examples: <code>~/bin/vi</code>, <code>$SOME_ENVIRONMENT_VARIABLE</code>, <code>"C:\Program Files\Vim\gvim.exe" +--nofork</code>. The order of preference is the <code>$GIT_EDITOR</code> environment variable, then <code>core.editor</code> configuration, then <code>$VISUAL</code>, then <code>$EDITOR</code>, and then the default chosen at compile time, which is usually <code>vi</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-var.txt-GITSEQUENCEEDITOR"> GIT_SEQUENCE_EDITOR </dt> <dd> <p>Text editor used to edit the <code>todo</code> file while running <code>git rebase +-i</code>. Like <code>GIT_EDITOR</code>, the value is meant to be interpreted by the shell when it is used. The order of preference is the <code>$GIT_SEQUENCE_EDITOR</code> environment variable, then <code>sequence.editor</code> configuration, and then the value of <code>git var +GIT_EDITOR</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-var.txt-GITPAGER"> GIT_PAGER </dt> <dd> <p>Text viewer for use by Git commands (e.g., <code>less</code>). The value is meant to be interpreted by the shell. The order of preference is the <code>$GIT_PAGER</code> environment variable, then <code>core.pager</code> configuration, then <code>$PAGER</code>, and then the default chosen at compile time (usually <code>less</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-var.txt-GITDEFAULTBRANCH"> GIT_DEFAULT_BRANCH </dt> <dd> <p>The name of the first branch created in newly initialized repositories.</p> </dd> <dt class="hdlist1" id="Documentation/git-var.txt-GITSHELLPATH"> GIT_SHELL_PATH </dt> <dd> <p>The path of the binary providing the POSIX shell for commands which use the shell.</p> </dd> <dt class="hdlist1" id="Documentation/git-var.txt-GITATTRSYSTEM"> GIT_ATTR_SYSTEM </dt> <dd> <p>The path to the system <a href="gitattributes">gitattributes[5]</a> file, if one is enabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-var.txt-GITATTRGLOBAL"> GIT_ATTR_GLOBAL </dt> <dd> <p>The path to the global (per-user) <a href="gitattributes">gitattributes[5]</a> file.</p> </dd> <dt class="hdlist1" id="Documentation/git-var.txt-GITCONFIGSYSTEM"> GIT_CONFIG_SYSTEM </dt> <dd> <p>The path to the system configuration file, if one is enabled.</p> </dd> <dt class="hdlist1" id="Documentation/git-var.txt-GITCONFIGGLOBAL"> GIT_CONFIG_GLOBAL </dt> <dd> <p>The path to the global (per-user) configuration files, if any.</p> </dd> </dl> </div> <p>Most path values contain only one value. However, some can contain multiple values, which are separated by newlines, and are listed in order from highest to lowest priority. Callers should be prepared for any such path value to contain multiple items.</p> <p>Note that paths are printed even if they do not exist, but not if they are disabled by other environment variables.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-commit-tree">git-commit-tree[1]</a> <a href="git-tag">git-tag[1]</a> <a href="git-config">git-config[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-var" class="_attribution-link">https://git-scm.com/docs/git-var</a> + </p> +</div> diff --git a/devdocs/git/git-verify-commit.html b/devdocs/git/git-verify-commit.html new file mode 100644 index 00000000..caa893b4 --- /dev/null +++ b/devdocs/git/git-verify-commit.html @@ -0,0 +1,6 @@ +<h1>git-verify-commit</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-verify-commit - Check the GPG signature of commits</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git verify-commit [-v | --verbose] [--raw] <commit>…</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Validates the GPG signature created by <code>git commit -S</code>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-verify-commit.txt---raw"> --raw </dt> <dd> <p>Print the raw gpg status output to standard error instead of the normal human-readable output.</p> </dd> <dt class="hdlist1" id="Documentation/git-verify-commit.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-verify-commit.txt---verbose"> --verbose </dt> <dd> <p>Print the contents of the commit object before validating it.</p> </dd> <dt class="hdlist1" id="Documentation/git-verify-commit.txt-ltcommitgt82308203"> <commit>… </dt> <dd> <p>SHA-1 identifiers of Git commit objects.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-verify-commit" class="_attribution-link">https://git-scm.com/docs/git-verify-commit</a> + </p> +</div> diff --git a/devdocs/git/git-verify-pack.html b/devdocs/git/git-verify-pack.html new file mode 100644 index 00000000..df9a5cba --- /dev/null +++ b/devdocs/git/git-verify-pack.html @@ -0,0 +1,6 @@ +<h1>git-verify-pack</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-verify-pack - Validate packed Git archive files</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git verify-pack [-v | --verbose] [-s | --stat-only] [--] <pack>.idx…</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Reads given idx file for packed Git archive created with the <code>git pack-objects</code> command and verifies the idx file and the corresponding pack file.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-verify-pack.txt-ltpackgtidx82308203"> <pack>.idx … </dt> <dd> <p>The idx files to verify.</p> </dd> <dt class="hdlist1" id="Documentation/git-verify-pack.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-verify-pack.txt---verbose"> --verbose </dt> <dd> <p>After verifying the pack, show the list of objects contained in the pack and a histogram of delta chain length.</p> </dd> <dt class="hdlist1" id="Documentation/git-verify-pack.txt--s"> -s </dt> <dt class="hdlist1" id="Documentation/git-verify-pack.txt---stat-only"> --stat-only </dt> <dd> <p>Do not verify the pack contents; only show the histogram of delta chain length. With <code>--verbose</code>, the list of objects is also shown.</p> </dd> <dt class="hdlist1" id="Documentation/git-verify-pack.txt---"> -- </dt> <dd> <p>Do not interpret any more arguments as options.</p> </dd> </dl> </div> </div> <h2 id="_output_format">Output format</h2> <div class="sectionbody"> <p>When specifying the -v option the format used is:</p> <div class="literalblock"> <div class="content"> <pre>SHA-1 type size size-in-packfile offset-in-packfile</pre> </div> </div> <p>for objects that are not deltified in the pack, and</p> <div class="literalblock"> <div class="content"> <pre>SHA-1 type size size-in-packfile offset-in-packfile depth base-SHA-1</pre> </div> </div> <p>for objects that are deltified.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-verify-pack" class="_attribution-link">https://git-scm.com/docs/git-verify-pack</a> + </p> +</div> diff --git a/devdocs/git/git-verify-tag.html b/devdocs/git/git-verify-tag.html new file mode 100644 index 00000000..7c2d0d9f --- /dev/null +++ b/devdocs/git/git-verify-tag.html @@ -0,0 +1,6 @@ +<h1>git-verify-tag</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-verify-tag - Check the GPG signature of tags</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git verify-tag [-v | --verbose] [--format=<format>] [--raw] <tag>…</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Validates the gpg signature created by <code>git tag</code>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-verify-tag.txt---raw"> --raw </dt> <dd> <p>Print the raw gpg status output to standard error instead of the normal human-readable output.</p> </dd> <dt class="hdlist1" id="Documentation/git-verify-tag.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-verify-tag.txt---verbose"> --verbose </dt> <dd> <p>Print the contents of the tag object before validating it.</p> </dd> <dt class="hdlist1" id="Documentation/git-verify-tag.txt-lttaggt82308203"> <tag>… </dt> <dd> <p>SHA-1 identifiers of Git tag objects.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-verify-tag" class="_attribution-link">https://git-scm.com/docs/git-verify-tag</a> + </p> +</div> diff --git a/devdocs/git/git-version.html b/devdocs/git/git-version.html new file mode 100644 index 00000000..516c82c0 --- /dev/null +++ b/devdocs/git/git-version.html @@ -0,0 +1,6 @@ +<h1>git-version</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-version - Display version information about Git</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git version [--build-options]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>With no options given, the version of <code>git</code> is printed on the standard output.</p> <p>Note that <code>git --version</code> is identical to <code>git version</code> because the former is internally converted into the latter.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-version.txt---build-options"> --build-options </dt> <dd> <p>Include additional information about how git was built for diagnostic purposes.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-version" class="_attribution-link">https://git-scm.com/docs/git-version</a> + </p> +</div> diff --git a/devdocs/git/git-web--browse.html b/devdocs/git/git-web--browse.html new file mode 100644 index 00000000..819075e6 --- /dev/null +++ b/devdocs/git/git-web--browse.html @@ -0,0 +1,14 @@ +<h1>git-web--browse</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-web—browse - Git helper script to launch a web browser</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git web--browse [<options>] (<URL>|<file>)…</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This script tries, as much as possible, to display the URLs and FILEs that are passed as arguments, as HTML pages in new tabs on an already opened web browser.</p> <p>The following browsers (or commands) are currently supported:</p> <div class="ulist"> <ul> <li> <p>firefox (this is the default under X Window when not using KDE)</p> </li> <li> <p>iceweasel</p> </li> <li> <p>seamonkey</p> </li> <li> <p>iceape</p> </li> <li> <p>chromium (also supported as chromium-browser)</p> </li> <li> <p>google-chrome (also supported as chrome)</p> </li> <li> <p>konqueror (this is the default under KDE, see <code>Note about konqueror</code> below)</p> </li> <li> <p>opera</p> </li> <li> <p>w3m (this is the default outside graphical environments)</p> </li> <li> <p>elinks</p> </li> <li> <p>links</p> </li> <li> <p>lynx</p> </li> <li> <p>dillo</p> </li> <li> <p>open (this is the default under Mac OS X GUI)</p> </li> <li> <p>start (this is the default under MinGW)</p> </li> <li> <p>cygstart (this is the default under Cygwin)</p> </li> <li> <p>xdg-open</p> </li> </ul> </div> <p>Custom commands may also be specified.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-web--browse.txt--bltbrowsergt"> -b <browser> </dt> <dt class="hdlist1" id="Documentation/git-web--browse.txt---browserltbrowsergt"> --browser=<browser> </dt> <dd> <p>Use the specified browser. It must be in the list of supported browsers.</p> </dd> <dt class="hdlist1" id="Documentation/git-web--browse.txt--tltbrowsergt"> -t <browser> </dt> <dt class="hdlist1" id="Documentation/git-web--browse.txt---toolltbrowsergt"> --tool=<browser> </dt> <dd> <p>Same as above.</p> </dd> <dt class="hdlist1" id="Documentation/git-web--browse.txt--cltconfvargt"> -c <conf.var> </dt> <dt class="hdlist1" id="Documentation/git-web--browse.txt---configltconfvargt"> --config=<conf.var> </dt> <dd> <p>CONF.VAR is looked up in the Git config files. If it’s set, then its value specifies the browser that should be used.</p> </dd> </dl> </div> </div> <h2 id="_configuration_variables">Configuration variables</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_conf_var_from_c_option_and_web_browser"> +CONF.VAR (from -c option) and web.browser</h3> <p>The web browser can be specified using a configuration variable passed with the -c (or --config) command-line option, or the <code>web.browser</code> configuration variable if the former is not used.</p> </div> <div class="sect2"> <h3 id="_browser_tool_path"> +browser.<tool>.path</h3> <p>You can explicitly provide a full path to your preferred browser by setting the configuration variable <code>browser.<tool>.path</code>. For example, you can configure the absolute path to firefox by setting <code>browser.firefox.path</code>. Otherwise, <code>git web--browse</code> assumes the tool is available in PATH.</p> </div> <div class="sect2"> <h3 id="_browser_tool_cmd"> +browser.<tool>.cmd</h3> <p>When the browser, specified by options or configuration variables, is not among the supported ones, then the corresponding <code>browser.<tool>.cmd</code> configuration variable will be looked up. If this variable exists then <code>git web--browse</code> will treat the specified tool as a custom command and will use a shell eval to run the command with the URLs passed as arguments.</p> </div> </div> <h2 id="_note_about_konqueror">Note about konqueror</h2> <div class="sectionbody"> <p>When <code>konqueror</code> is specified by a command-line option or a configuration variable, we launch <code>kfmclient</code> to try to open the HTML man page on an already opened konqueror in a new tab if possible.</p> <p>For consistency, we also try such a trick if <code>browser.konqueror.path</code> is set to something like <code>A_PATH_TO/konqueror</code>. That means we will try to launch <code>A_PATH_TO/kfmclient</code> instead.</p> <p>If you really want to use <code>konqueror</code>, then you can use something like the following:</p> <div class="listingblock"> <div class="content"> <pre> [web] + browser = konq + + [browser "konq"] + cmd = A_PATH_TO/konqueror</pre> </div> </div> <div class="sect2"> <h3 id="_note_about_git_config_global"> +Note about git-config --global</h3> <p>Note that these configuration variables should probably be set using the <code>--global</code> flag, for example like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config --global web.browser firefox</pre> </div> </div> <p>as they are probably more user specific than repository specific. See <a href="git-config">git-config[1]</a> for more information about this.</p> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-web--browse" class="_attribution-link">https://git-scm.com/docs/git-web--browse</a> + </p> +</div> diff --git a/devdocs/git/git-whatchanged.html b/devdocs/git/git-whatchanged.html new file mode 100644 index 00000000..6ea4cf0e --- /dev/null +++ b/devdocs/git/git-whatchanged.html @@ -0,0 +1,6 @@ +<h1>git-whatchanged</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-whatchanged - Show logs with differences each commit introduces</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git whatchanged <option>…</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Shows commit logs and diff output each commit introduces.</p> <p>New users are encouraged to use <a href="git-log">git-log[1]</a> instead. The <code>whatchanged</code> command is essentially the same as <a href="git-log">git-log[1]</a> but defaults to showing the raw format diff output and skipping merges.</p> <p>The command is primarily kept for historical reasons; fingers of many people who learned Git long before <code>git log</code> was invented by reading the Linux kernel mailing list are trained to type it.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-whatchanged.txt-codegitwhatchanged-pv2612includescsidriversscsicode"> <code>git whatchanged -p v2.6.12.. include/scsi drivers/scsi</code> </dt> <dd> <p>Show as patches the commits since version <code>v2.6.12</code> that changed any file in the include/scsi or drivers/scsi subdirectories</p> </dd> <dt class="hdlist1" id="Documentation/git-whatchanged.txt-codegitwhatchanged--since2weeksago--gitkcode"> <code>git whatchanged --since="2 weeks ago" -- gitk</code> </dt> <dd> <p>Show the changes during the last two weeks to the file <code>gitk</code>. The "--" is necessary to avoid confusion with the <strong>branch</strong> named <code>gitk</code></p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-whatchanged" class="_attribution-link">https://git-scm.com/docs/git-whatchanged</a> + </p> +</div> diff --git a/devdocs/git/git-worktree.html b/devdocs/git/git-worktree.html new file mode 100644 index 00000000..a2aeaabc --- /dev/null +++ b/devdocs/git/git-worktree.html @@ -0,0 +1,63 @@ +<h1>git-worktree</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-worktree - Manage multiple working trees</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git worktree add [-f] [--detach] [--checkout] [--lock [--reason <string>]] + [--orphan] [(-b | -B) <new-branch>] <path> [<commit-ish>] +git worktree list [-v | --porcelain [-z]] +git worktree lock [--reason <string>] <worktree> +git worktree move <worktree> <new-path> +git worktree prune [-n] [-v] [--expire <expire>] +git worktree remove [-f] <worktree> +git worktree repair [<path>…] +git worktree unlock <worktree></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Manage multiple working trees attached to the same repository.</p> <p>A git repository can support multiple working trees, allowing you to check out more than one branch at a time. With <code>git worktree add</code> a new working tree is associated with the repository, along with additional metadata that differentiates that working tree from others in the same repository. The working tree, along with this metadata, is called a "worktree".</p> <p>This new worktree is called a "linked worktree" as opposed to the "main worktree" prepared by <a href="git-init">git-init[1]</a> or <a href="git-clone">git-clone[1]</a>. A repository has one main worktree (if it’s not a bare repository) and zero or more linked worktrees. When you are done with a linked worktree, remove it with <code>git worktree remove</code>.</p> <p>In its simplest form, <code>git worktree add <path></code> automatically creates a new branch whose name is the final component of <code><path></code>, which is convenient if you plan to work on a new topic. For instance, <code>git +worktree add ../hotfix</code> creates new branch <code>hotfix</code> and checks it out at path <code>../hotfix</code>. To instead work on an existing branch in a new worktree, use <code>git worktree add <path> <branch></code>. On the other hand, if you just plan to make some experimental changes or do testing without disturbing existing development, it is often convenient to create a <code>throwaway</code> worktree not associated with any branch. For instance, <code>git worktree add -d <path></code> creates a new worktree with a detached <code>HEAD</code> at the same commit as the current branch.</p> <p>If a working tree is deleted without using <code>git worktree remove</code>, then its associated administrative files, which reside in the repository (see "DETAILS" below), will eventually be removed automatically (see <code>gc.worktreePruneExpire</code> in <a href="git-config">git-config[1]</a>), or you can run <code>git worktree prune</code> in the main or any linked worktree to clean up any stale administrative files.</p> <p>If the working tree for a linked worktree is stored on a portable device or network share which is not always mounted, you can prevent its administrative files from being pruned by issuing the <code>git worktree lock</code> command, optionally specifying <code>--reason</code> to explain why the worktree is locked.</p> </div> <h2 id="_commands">Commands</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-worktree.txt-addltpathgtltcommit-ishgt"> add <path> [<commit-ish>] </dt> <dd> <p>Create a worktree at <code><path></code> and checkout <code><commit-ish></code> into it. The new worktree is linked to the current repository, sharing everything except per-worktree files such as <code>HEAD</code>, <code>index</code>, etc. As a convenience, <code><commit-ish></code> may be a bare "<code>-</code>", which is synonymous with <code>@{-1}</code>.</p> <p>If <code><commit-ish></code> is a branch name (call it <code><branch></code>) and is not found, and neither <code>-b</code> nor <code>-B</code> nor <code>--detach</code> are used, but there does exist a tracking branch in exactly one remote (call it <code><remote></code>) with a matching name, treat as equivalent to:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git worktree add --track -b <branch> <path> <remote>/<branch></pre> </div> </div> <p>If the branch exists in multiple remotes and one of them is named by the <code>checkout.defaultRemote</code> configuration variable, we’ll use that one for the purposes of disambiguation, even if the <code><branch></code> isn’t unique across all remotes. Set it to e.g. <code>checkout.defaultRemote=origin</code> to always checkout remote branches from there if <code><branch></code> is ambiguous but exists on the <code>origin</code> remote. See also <code>checkout.defaultRemote</code> in <a href="git-config">git-config[1]</a>.</p> <p>If <code><commit-ish></code> is omitted and neither <code>-b</code> nor <code>-B</code> nor <code>--detach</code> used, then, as a convenience, the new worktree is associated with a branch (call it <code><branch></code>) named after <code>$(basename <path>)</code>. If <code><branch></code> doesn’t exist, a new branch based on <code>HEAD</code> is automatically created as if <code>-b <branch></code> was given. If <code><branch></code> does exist, it will be checked out in the new worktree, if it’s not checked out anywhere else, otherwise the command will refuse to create the worktree (unless <code>--force</code> is used).</p> <p>If <code><commit-ish></code> is omitted, neither <code>--detach</code>, or <code>--orphan</code> is used, and there are no valid local branches (or remote branches if <code>--guess-remote</code> is specified) then, as a convenience, the new worktree is associated with a new unborn branch named <code><branch></code> (after <code>$(basename <path>)</code> if neither <code>-b</code> or <code>-B</code> is used) as if <code>--orphan</code> was passed to the command. In the event the repository has a remote and <code>--guess-remote</code> is used, but no remote or local branches exist, then the command fails with a warning reminding the user to fetch from their remote first (or override by using <code>-f/--force</code>).</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt-list"> list </dt> <dd> <p>List details of each worktree. The main worktree is listed first, followed by each of the linked worktrees. The output details include whether the worktree is bare, the revision currently checked out, the branch currently checked out (or "detached HEAD" if none), "locked" if the worktree is locked, "prunable" if the worktree can be pruned by the <code>prune</code> command.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt-lock"> lock </dt> <dd> <p>If a worktree is on a portable device or network share which is not always mounted, lock it to prevent its administrative files from being pruned automatically. This also prevents it from being moved or deleted. Optionally, specify a reason for the lock with <code>--reason</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt-move"> move </dt> <dd> <p>Move a worktree to a new location. Note that the main worktree or linked worktrees containing submodules cannot be moved with this command. (The <code>git worktree repair</code> command, however, can reestablish the connection with linked worktrees if you move the main worktree manually.)</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt-prune"> prune </dt> <dd> <p>Prune worktree information in <code>$GIT_DIR/worktrees</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt-remove"> remove </dt> <dd> <p>Remove a worktree. Only clean worktrees (no untracked files and no modification in tracked files) can be removed. Unclean worktrees or ones with submodules can be removed with <code>--force</code>. The main worktree cannot be removed.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt-repairltpathgt82308203"> repair [<path>…] </dt> <dd> <p>Repair worktree administrative files, if possible, if they have become corrupted or outdated due to external factors.</p> <p>For instance, if the main worktree (or bare repository) is moved, linked worktrees will be unable to locate it. Running <code>repair</code> in the main worktree will reestablish the connection from linked worktrees back to the main worktree.</p> <p>Similarly, if the working tree for a linked worktree is moved without using <code>git worktree move</code>, the main worktree (or bare repository) will be unable to locate it. Running <code>repair</code> within the recently-moved worktree will reestablish the connection. If multiple linked worktrees are moved, running <code>repair</code> from any worktree with each tree’s new <code><path></code> as an argument, will reestablish the connection to all the specified paths.</p> <p>If both the main worktree and linked worktrees have been moved manually, then running <code>repair</code> in the main worktree and specifying the new <code><path></code> of each linked worktree will reestablish all connections in both directions.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt-unlock"> unlock </dt> <dd> <p>Unlock a worktree, allowing it to be pruned, moved or deleted.</p> </dd> </dl> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-worktree.txt--f"> -f </dt> <dt class="hdlist1" id="Documentation/git-worktree.txt---force"> --force </dt> <dd> <p>By default, <code>add</code> refuses to create a new worktree when <code><commit-ish></code> is a branch name and is already checked out by another worktree, or if <code><path></code> is already assigned to some worktree but is missing (for instance, if <code><path></code> was deleted manually). This option overrides these safeguards. To add a missing but locked worktree path, specify <code>--force</code> twice.</p> <p><code>move</code> refuses to move a locked worktree unless <code>--force</code> is specified twice. If the destination is already assigned to some other worktree but is missing (for instance, if <code><new-path></code> was deleted manually), then <code>--force</code> allows the move to proceed; use <code>--force</code> twice if the destination is locked.</p> <p><code>remove</code> refuses to remove an unclean worktree unless <code>--force</code> is used. To remove a locked worktree, specify <code>--force</code> twice.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt--bltnew-branchgt"> -b <new-branch> </dt> <dt class="hdlist1" id="Documentation/git-worktree.txt--Bltnew-branchgt"> -B <new-branch> </dt> <dd> <p>With <code>add</code>, create a new branch named <code><new-branch></code> starting at <code><commit-ish></code>, and check out <code><new-branch></code> into the new worktree. If <code><commit-ish></code> is omitted, it defaults to <code>HEAD</code>. By default, <code>-b</code> refuses to create a new branch if it already exists. <code>-B</code> overrides this safeguard, resetting <code><new-branch></code> to <code><commit-ish></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt--d"> -d </dt> <dt class="hdlist1" id="Documentation/git-worktree.txt---detach"> --detach </dt> <dd> <p>With <code>add</code>, detach <code>HEAD</code> in the new worktree. See "DETACHED HEAD" in <a href="git-checkout">git-checkout[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt---no-checkout"> --[no-]checkout </dt> <dd> <p>By default, <code>add</code> checks out <code><commit-ish></code>, however, <code>--no-checkout</code> can be used to suppress checkout in order to make customizations, such as configuring sparse-checkout. See "Sparse checkout" in <a href="git-read-tree">git-read-tree[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt---no-guess-remote"> --[no-]guess-remote </dt> <dd> <p>With <code>worktree add <path></code>, without <code><commit-ish></code>, instead of creating a new branch from <code>HEAD</code>, if there exists a tracking branch in exactly one remote matching the basename of <code><path></code>, base the new branch on the remote-tracking branch, and mark the remote-tracking branch as "upstream" from the new branch.</p> <p>This can also be set up as the default behaviour by using the <code>worktree.guessRemote</code> config option.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt---no-track"> --[no-]track </dt> <dd> <p>When creating a new branch, if <code><commit-ish></code> is a branch, mark it as "upstream" from the new branch. This is the default if <code><commit-ish></code> is a remote-tracking branch. See <code>--track</code> in <a href="git-branch">git-branch[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt---lock"> --lock </dt> <dd> <p>Keep the worktree locked after creation. This is the equivalent of <code>git worktree lock</code> after <code>git worktree add</code>, but without a race condition.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt--n"> -n </dt> <dt class="hdlist1" id="Documentation/git-worktree.txt---dry-run"> --dry-run </dt> <dd> <p>With <code>prune</code>, do not remove anything; just report what it would remove.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt---orphan"> --orphan </dt> <dd> <p>With <code>add</code>, make the new worktree and index empty, associating the worktree with a new unborn branch named <code><new-branch></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt---porcelain"> --porcelain </dt> <dd> <p>With <code>list</code>, output in an easy-to-parse format for scripts. This format will remain stable across Git versions and regardless of user configuration. It is recommended to combine this with <code>-z</code>. See below for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt--z"> -z </dt> <dd> <p>Terminate each line with a NUL rather than a newline when <code>--porcelain</code> is specified with <code>list</code>. This makes it possible to parse the output when a worktree path contains a newline character.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt--q"> -q </dt> <dt class="hdlist1" id="Documentation/git-worktree.txt---quiet"> --quiet </dt> <dd> <p>With <code>add</code>, suppress feedback messages.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git-worktree.txt---verbose"> --verbose </dt> <dd> <p>With <code>prune</code>, report all removals.</p> <p>With <code>list</code>, output additional information about worktrees (see below).</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt---expirelttimegt"> --expire <time> </dt> <dd> <p>With <code>prune</code>, only expire unused worktrees older than <code><time></code>.</p> <p>With <code>list</code>, annotate missing worktrees as prunable if they are older than <code><time></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt---reasonltstringgt"> --reason <string> </dt> <dd> <p>With <code>lock</code> or with <code>add --lock</code>, an explanation why the worktree is locked.</p> </dd> <dt class="hdlist1" id="Documentation/git-worktree.txt-ltworktreegt"> <worktree> </dt> <dd> <p>Worktrees can be identified by path, either relative or absolute.</p> <p>If the last path components in the worktree’s path is unique among worktrees, it can be used to identify a worktree. For example if you only have two worktrees, at <code>/abc/def/ghi</code> and <code>/abc/def/ggg</code>, then <code>ghi</code> or <code>def/ghi</code> is enough to point to the former worktree.</p> </dd> </dl> </div> </div> <h2 id="_refs">Refs</h2> <div class="sectionbody"> <p>When using multiple worktrees, some refs are shared between all worktrees, but others are specific to an individual worktree. One example is <code>HEAD</code>, which is different for each worktree. This section is about the sharing rules and how to access refs of one worktree from another.</p> <p>In general, all pseudo refs are per-worktree and all refs starting with <code>refs/</code> are shared. Pseudo refs are ones like <code>HEAD</code> which are directly under <code>$GIT_DIR</code> instead of inside <code>$GIT_DIR/refs</code>. There are exceptions, however: refs inside <code>refs/bisect</code>, <code>refs/worktree</code> and <code>refs/rewritten</code> are not shared.</p> <p>Refs that are per-worktree can still be accessed from another worktree via two special paths, <code>main-worktree</code> and <code>worktrees</code>. The former gives access to per-worktree refs of the main worktree, while the latter to all linked worktrees.</p> <p>For example, <code>main-worktree/HEAD</code> or <code>main-worktree/refs/bisect/good</code> resolve to the same value as the main worktree’s <code>HEAD</code> and <code>refs/bisect/good</code> respectively. Similarly, <code>worktrees/foo/HEAD</code> or <code>worktrees/bar/refs/bisect/bad</code> are the same as <code>$GIT_COMMON_DIR/worktrees/foo/HEAD</code> and <code>$GIT_COMMON_DIR/worktrees/bar/refs/bisect/bad</code>.</p> <p>To access refs, it’s best not to look inside <code>$GIT_DIR</code> directly. Instead use commands such as <a href="git-rev-parse">git-rev-parse[1]</a> or <a href="git-update-ref">git-update-ref[1]</a> which will handle refs correctly.</p> </div> <h2 id="_configuration_file">Configuration file</h2> <div class="sectionbody"> <p>By default, the repository <code>config</code> file is shared across all worktrees. If the config variables <code>core.bare</code> or <code>core.worktree</code> are present in the common config file and <code>extensions.worktreeConfig</code> is disabled, then they will be applied to the main worktree only.</p> <p>In order to have worktree-specific configuration, you can turn on the <code>worktreeConfig</code> extension, e.g.:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config extensions.worktreeConfig true</pre> </div> </div> <p>In this mode, specific configuration stays in the path pointed by <code>git +rev-parse --git-path config.worktree</code>. You can add or update configuration in this file with <code>git config --worktree</code>. Older Git versions will refuse to access repositories with this extension.</p> <p>Note that in this file, the exception for <code>core.bare</code> and <code>core.worktree</code> is gone. If they exist in <code>$GIT_DIR/config</code>, you must move them to the <code>config.worktree</code> of the main worktree. You may also take this opportunity to review and move other configuration that you do not want to share to all worktrees:</p> <div class="ulist"> <ul> <li> <p><code>core.worktree</code> should never be shared.</p> </li> <li> <p><code>core.bare</code> should not be shared if the value is <code>core.bare=true</code>.</p> </li> <li> <p><code>core.sparseCheckout</code> should not be shared, unless you are sure you always use sparse checkout for all worktrees.</p> </li> </ul> </div> <p>See the documentation of <code>extensions.worktreeConfig</code> in <a href="git-config">git-config[1]</a> for more details.</p> </div> <h2 id="_details">Details</h2> <div class="sectionbody"> <p>Each linked worktree has a private sub-directory in the repository’s <code>$GIT_DIR/worktrees</code> directory. The private sub-directory’s name is usually the base name of the linked worktree’s path, possibly appended with a number to make it unique. For example, when <code>$GIT_DIR=/path/main/.git</code> the command <code>git worktree add /path/other/test-next next</code> creates the linked worktree in <code>/path/other/test-next</code> and also creates a <code>$GIT_DIR/worktrees/test-next</code> directory (or <code>$GIT_DIR/worktrees/test-next1</code> if <code>test-next</code> is already taken).</p> <p>Within a linked worktree, <code>$GIT_DIR</code> is set to point to this private directory (e.g. <code>/path/main/.git/worktrees/test-next</code> in the example) and <code>$GIT_COMMON_DIR</code> is set to point back to the main worktree’s <code>$GIT_DIR</code> (e.g. <code>/path/main/.git</code>). These settings are made in a <code>.git</code> file located at the top directory of the linked worktree.</p> <p>Path resolution via <code>git rev-parse --git-path</code> uses either <code>$GIT_DIR</code> or <code>$GIT_COMMON_DIR</code> depending on the path. For example, in the linked worktree <code>git rev-parse --git-path HEAD</code> returns <code>/path/main/.git/worktrees/test-next/HEAD</code> (not <code>/path/other/test-next/.git/HEAD</code> or <code>/path/main/.git/HEAD</code>) while <code>git +rev-parse --git-path refs/heads/master</code> uses <code>$GIT_COMMON_DIR</code> and returns <code>/path/main/.git/refs/heads/master</code>, since refs are shared across all worktrees, except <code>refs/bisect</code>, <code>refs/worktree</code> and <code>refs/rewritten</code>.</p> <p>See <a href="gitrepository-layout">gitrepository-layout[5]</a> for more information. The rule of thumb is do not make any assumption about whether a path belongs to <code>$GIT_DIR</code> or <code>$GIT_COMMON_DIR</code> when you need to directly access something inside <code>$GIT_DIR</code>. Use <code>git rev-parse --git-path</code> to get the final path.</p> <p>If you manually move a linked worktree, you need to update the <code>gitdir</code> file in the entry’s directory. For example, if a linked worktree is moved to <code>/newpath/test-next</code> and its <code>.git</code> file points to <code>/path/main/.git/worktrees/test-next</code>, then update <code>/path/main/.git/worktrees/test-next/gitdir</code> to reference <code>/newpath/test-next</code> instead. Better yet, run <code>git worktree repair</code> to reestablish the connection automatically.</p> <p>To prevent a <code>$GIT_DIR/worktrees</code> entry from being pruned (which can be useful in some situations, such as when the entry’s worktree is stored on a portable device), use the <code>git worktree lock</code> command, which adds a file named <code>locked</code> to the entry’s directory. The file contains the reason in plain text. For example, if a linked worktree’s <code>.git</code> file points to <code>/path/main/.git/worktrees/test-next</code> then a file named <code>/path/main/.git/worktrees/test-next/locked</code> will prevent the <code>test-next</code> entry from being pruned. See <a href="gitrepository-layout">gitrepository-layout[5]</a> for details.</p> <p>When <code>extensions.worktreeConfig</code> is enabled, the config file <code>.git/worktrees/<id>/config.worktree</code> is read after <code>.git/config</code> is.</p> </div> <h2 id="_list_output_format">List output format</h2> <div class="sectionbody"> <p>The <code>worktree list</code> command has two output formats. The default format shows the details on a single line with columns. For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git worktree list +/path/to/bare-source (bare) +/path/to/linked-worktree abcd1234 [master] +/path/to/other-linked-worktree 1234abc (detached HEAD)</pre> </div> </div> <p>The command also shows annotations for each worktree, according to its state. These annotations are:</p> <div class="ulist"> <ul> <li> <p><code>locked</code>, if the worktree is locked.</p> </li> <li> <p><code>prunable</code>, if the worktree can be pruned via <code>git worktree prune</code>.</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git worktree list +/path/to/linked-worktree abcd1234 [master] +/path/to/locked-worktree acbd5678 (brancha) locked +/path/to/prunable-worktree 5678abc (detached HEAD) prunable</pre> </div> </div> <p>For these annotations, a reason might also be available and this can be seen using the verbose mode. The annotation is then moved to the next line indented followed by the additional information.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git worktree list --verbose +/path/to/linked-worktree abcd1234 [master] +/path/to/locked-worktree-no-reason abcd5678 (detached HEAD) locked +/path/to/locked-worktree-with-reason 1234abcd (brancha) + locked: worktree path is mounted on a portable device +/path/to/prunable-worktree 5678abc1 (detached HEAD) + prunable: gitdir file points to non-existent location</pre> </div> </div> <p>Note that the annotation is moved to the next line if the additional information is available, otherwise it stays on the same line as the worktree itself.</p> <div class="sect2"> <h3 id="_porcelain_format"> +Porcelain Format</h3> <p>The porcelain format has a line per attribute. If <code>-z</code> is given then the lines are terminated with NUL rather than a newline. Attributes are listed with a label and value separated by a single space. Boolean attributes (like <code>bare</code> and <code>detached</code>) are listed as a label only, and are present only if the value is true. Some attributes (like <code>locked</code>) can be listed as a label only or with a value depending upon whether a reason is available. The first attribute of a worktree is always <code>worktree</code>, an empty line indicates the end of the record. For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git worktree list --porcelain +worktree /path/to/bare-source +bare + +worktree /path/to/linked-worktree +HEAD abcd1234abcd1234abcd1234abcd1234abcd1234 +branch refs/heads/master + +worktree /path/to/other-linked-worktree +HEAD 1234abc1234abc1234abc1234abc1234abc1234a +detached + +worktree /path/to/linked-worktree-locked-no-reason +HEAD 5678abc5678abc5678abc5678abc5678abc5678c +branch refs/heads/locked-no-reason +locked + +worktree /path/to/linked-worktree-locked-with-reason +HEAD 3456def3456def3456def3456def3456def3456b +branch refs/heads/locked-with-reason +locked reason why is locked + +worktree /path/to/linked-worktree-prunable +HEAD 1233def1234def1234def1234def1234def1234b +detached +prunable gitdir file points to non-existent location</pre> </div> </div> <p>Unless <code>-z</code> is used any "unusual" characters in the lock reason such as newlines are escaped and the entire reason is quoted as explained for the configuration variable <code>core.quotePath</code> (see <a href="git-config">git-config[1]</a>). For Example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git worktree list --porcelain +... +locked "reason\nwhy is locked" +...</pre> </div> </div> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>You are in the middle of a refactoring session and your boss comes in and demands that you fix something immediately. You might typically use <a href="git-stash">git-stash[1]</a> to store your changes away temporarily, however, your working tree is in such a state of disarray (with new, moved, and removed files, and other bits and pieces strewn around) that you don’t want to risk disturbing any of it. Instead, you create a temporary linked worktree to make the emergency fix, remove it when done, and then resume your earlier refactoring session.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git worktree add -b emergency-fix ../temp master +$ pushd ../temp +# ... hack hack hack ... +$ git commit -a -m 'emergency fix for boss' +$ popd +$ git worktree remove ../temp</pre> </div> </div> </div> <h2 id="_bugs">Bugs</h2> <div class="sectionbody"> <p>Multiple checkout in general is still experimental, and the support for submodules is incomplete. It is NOT recommended to make multiple checkouts of a superproject.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-worktree" class="_attribution-link">https://git-scm.com/docs/git-worktree</a> + </p> +</div> diff --git a/devdocs/git/git-write-tree.html b/devdocs/git/git-write-tree.html new file mode 100644 index 00000000..b032689e --- /dev/null +++ b/devdocs/git/git-write-tree.html @@ -0,0 +1,6 @@ +<h1>git-write-tree</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git-write-tree - Create a tree object from the current index</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git write-tree [--missing-ok] [--prefix=<prefix>/]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Creates a tree object using the current index. The name of the new tree object is printed to standard output.</p> <p>The index must be in a fully merged state.</p> <p>Conceptually, <code>git write-tree</code> sync()s the current index contents into a set of tree files. In order to have that match what is actually in your directory right now, you need to have done a <code>git update-index</code> phase before you did the <code>git write-tree</code>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-write-tree.txt---missing-ok"> --missing-ok </dt> <dd> <p>Normally <code>git write-tree</code> ensures that the objects referenced by the directory exist in the object database. This option disables this check.</p> </dd> <dt class="hdlist1" id="Documentation/git-write-tree.txt---prefixltprefixgt"> --prefix=<prefix>/ </dt> <dd> <p>Writes a tree object that represents a subdirectory <code><prefix></code>. This can be used to write the tree object for a subproject that is in the named subdirectory.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git-write-tree" class="_attribution-link">https://git-scm.com/docs/git-write-tree</a> + </p> +</div> diff --git a/devdocs/git/git.html b/devdocs/git/git.html new file mode 100644 index 00000000..a25dd38d --- /dev/null +++ b/devdocs/git/git.html @@ -0,0 +1,39 @@ +<h1>git</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>git - the stupid content tracker</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>] + [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] + [-p|--paginate|-P|--no-pager] [--no-replace-objects] [--bare] + [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>] + [--config-env=<name>=<envvar>] <command> [<args>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.</p> <p>See <a href="gittutorial">gittutorial[7]</a> to get started, then see <a href="giteveryday">giteveryday[7]</a> for a useful minimum set of commands. The <a href="user-manual">Git User’s Manual</a> has a more in-depth introduction.</p> <p>After you mastered the basic concepts, you can come back to this page to learn what commands Git offers. You can learn more about individual Git commands with "git help command". <a href="gitcli">gitcli[7]</a> manual page gives you an overview of the command-line command syntax.</p> <p>A formatted and hyperlinked copy of the latest Git documentation can be viewed at <a href="https://git.github.io/htmldocs/git.html" class="bare">https://git.github.io/htmldocs/git.html</a> or <a href="index" class="bare">https://git-scm.com/docs</a>.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt--v"> -v </dt> <dt class="hdlist1" id="Documentation/git.txt---version"> --version </dt> <dd> <p>Prints the Git suite version that the <code>git</code> program came from.</p> <p>This option is internally converted to <code>git version ...</code> and accepts the same options as the <a href="git-version">git-version[1]</a> command. If <code>--help</code> is also given, it takes precedence over <code>--version</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt--h"> -h </dt> <dt class="hdlist1" id="Documentation/git.txt---help"> --help </dt> <dd> <p>Prints the synopsis and a list of the most commonly used commands. If the option <code>--all</code> or <code>-a</code> is given then all available commands are printed. If a Git command is named this option will bring up the manual page for that command.</p> <p>Other options are available to control how the manual page is displayed. See <a href="git-help">git-help[1]</a> for more information, because <code>git --help ...</code> is converted internally into <code>git +help ...</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt--Cltpathgt"> -C <path> </dt> <dd> <p>Run as if git was started in <code><path></code> instead of the current working directory. When multiple <code>-C</code> options are given, each subsequent non-absolute <code>-C <path></code> is interpreted relative to the preceding <code>-C +<path></code>. If <code><path></code> is present but empty, e.g. <code>-C ""</code>, then the current working directory is left unchanged.</p> <p>This option affects options that expect path name like <code>--git-dir</code> and <code>--work-tree</code> in that their interpretations of the path names would be made relative to the working directory caused by the <code>-C</code> option. For example the following invocations are equivalent:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell">git --git-dir=a.git --work-tree=b -C c status +git --git-dir=c/a.git --work-tree=c/b status</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/git.txt--cltnamegtltvaluegt"> -c <name>=<value> </dt> <dd> <p>Pass a configuration parameter to the command. The value given will override values from configuration files. The <name> is expected in the same format as listed by <code>git config</code> (subkeys separated by dots).</p> <p>Note that omitting the <code>=</code> in <code>git -c foo.bar ...</code> is allowed and sets <code>foo.bar</code> to the boolean true value (just like <code>[foo]bar</code> would in a config file). Including the equals but with an empty value (like <code>git -c +foo.bar= ...</code>) sets <code>foo.bar</code> to the empty string which <code>git config +--type=bool</code> will convert to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---config-envltnamegtltenvvargt"> --config-env=<name>=<envvar> </dt> <dd> <p>Like <code>-c <name>=<value></code>, give configuration variable <code><name></code> a value, where <envvar> is the name of an environment variable from which to retrieve the value. Unlike <code>-c</code> there is no shortcut for directly setting the value to an empty string, instead the environment variable itself must be set to the empty string. It is an error if the <code><envvar></code> does not exist in the environment. <code><envvar></code> may not contain an equals sign to avoid ambiguity with <code><name></code> containing one.</p> <p>This is useful for cases where you want to pass transitory configuration options to git, but are doing so on operating systems where other processes might be able to read your command line (e.g. <code>/proc/self/cmdline</code>), but not your environment (e.g. <code>/proc/self/environ</code>). That behavior is the default on Linux, but may not be on your system.</p> <p>Note that this might add security for variables such as <code>http.extraHeader</code> where the sensitive information is part of the value, but not e.g. <code>url.<base>.insteadOf</code> where the sensitive information can be part of the key.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---exec-pathltpathgt"> --exec-path[=<path>] </dt> <dd> <p>Path to wherever your core Git programs are installed. This can also be controlled by setting the GIT_EXEC_PATH environment variable. If no path is given, <code>git</code> will print the current setting and then exit.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---html-path"> --html-path </dt> <dd> <p>Print the path, without trailing slash, where Git’s HTML documentation is installed and exit.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---man-path"> --man-path </dt> <dd> <p>Print the manpath (see <code>man(1)</code>) for the man pages for this version of Git and exit.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---info-path"> --info-path </dt> <dd> <p>Print the path where the Info files documenting this version of Git are installed and exit.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt--p"> -p </dt> <dt class="hdlist1" id="Documentation/git.txt---paginate"> --paginate </dt> <dd> <p>Pipe all output into <code>less</code> (or if set, $PAGER) if standard output is a terminal. This overrides the <code>pager.<cmd></code> configuration options (see the "Configuration Mechanism" section below).</p> </dd> <dt class="hdlist1" id="Documentation/git.txt--P"> -P </dt> <dt class="hdlist1" id="Documentation/git.txt---no-pager"> --no-pager </dt> <dd> <p>Do not pipe Git output into a pager.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---git-dirltpathgt"> --git-dir=<path> </dt> <dd> <p>Set the path to the repository (".git" directory). This can also be controlled by setting the <code>GIT_DIR</code> environment variable. It can be an absolute path or relative path to current working directory.</p> <p>Specifying the location of the ".git" directory using this option (or <code>GIT_DIR</code> environment variable) turns off the repository discovery that tries to find a directory with ".git" subdirectory (which is how the repository and the top-level of the working tree are discovered), and tells Git that you are at the top level of the working tree. If you are not at the top-level directory of the working tree, you should tell Git where the top-level of the working tree is, with the <code>--work-tree=<path></code> option (or <code>GIT_WORK_TREE</code> environment variable)</p> <p>If you just want to run git as if it was started in <code><path></code> then use <code>git -C <path></code>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---work-treeltpathgt"> --work-tree=<path> </dt> <dd> <p>Set the path to the working tree. It can be an absolute path or a path relative to the current working directory. This can also be controlled by setting the GIT_WORK_TREE environment variable and the core.worktree configuration variable (see core.worktree in <a href="git-config">git-config[1]</a> for a more detailed discussion).</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---namespaceltpathgt"> --namespace=<path> </dt> <dd> <p>Set the Git namespace. See <a href="gitnamespaces">gitnamespaces[7]</a> for more details. Equivalent to setting the <code>GIT_NAMESPACE</code> environment variable.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---bare"> --bare </dt> <dd> <p>Treat the repository as a bare repository. If GIT_DIR environment is not set, it is set to the current working directory.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---no-replace-objects"> --no-replace-objects </dt> <dd> <p>Do not use replacement refs to replace Git objects. See <a href="git-replace">git-replace[1]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---literal-pathspecs"> --literal-pathspecs </dt> <dd> <p>Treat pathspecs literally (i.e. no globbing, no pathspec magic). This is equivalent to setting the <code>GIT_LITERAL_PATHSPECS</code> environment variable to <code>1</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---glob-pathspecs"> --glob-pathspecs </dt> <dd> <p>Add "glob" magic to all pathspec. This is equivalent to setting the <code>GIT_GLOB_PATHSPECS</code> environment variable to <code>1</code>. Disabling globbing on individual pathspecs can be done using pathspec magic ":(literal)"</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---noglob-pathspecs"> --noglob-pathspecs </dt> <dd> <p>Add "literal" magic to all pathspec. This is equivalent to setting the <code>GIT_NOGLOB_PATHSPECS</code> environment variable to <code>1</code>. Enabling globbing on individual pathspecs can be done using pathspec magic ":(glob)"</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---icase-pathspecs"> --icase-pathspecs </dt> <dd> <p>Add "icase" magic to all pathspec. This is equivalent to setting the <code>GIT_ICASE_PATHSPECS</code> environment variable to <code>1</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---no-optional-locks"> --no-optional-locks </dt> <dd> <p>Do not perform optional operations that require locks. This is equivalent to setting the <code>GIT_OPTIONAL_LOCKS</code> to <code>0</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---list-cmdsgroupgroup82308203"> --list-cmds=group[,group…] </dt> <dd> <p>List commands by group. This is an internal/experimental option and may change or be removed in the future. Supported groups are: builtins, parseopt (builtin commands that use parse-options), main (all commands in libexec directory), others (all other commands in <code>$PATH</code> that have git- prefix), list-<category> (see categories in command-list.txt), nohelpers (exclude helper commands), alias and config (retrieve command list from config variable completion.commands)</p> </dd> <dt class="hdlist1" id="Documentation/git.txt---attr-sourcelttree-ishgt"> --attr-source=<tree-ish> </dt> <dd> <p>Read gitattributes from <tree-ish> instead of the worktree. See <a href="gitattributes">gitattributes[5]</a>. This is equivalent to setting the <code>GIT_ATTR_SOURCE</code> environment variable.</p> </dd> </dl> </div> </div> <h2 id="_git_commands">Git commands</h2> <div class="sectionbody"> <p>We divide Git into high level ("porcelain") commands and low level ("plumbing") commands.</p> </div> <h2 id="_high_level_commands_porcelain">High-level commands (porcelain)</h2> <div class="sectionbody"> <p>We separate the porcelain commands into the main commands and some ancillary user utilities.</p> <div class="sect2"> <h3 id="_main_porcelain_commands"> +Main porcelain commands</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-addgit-add1a"> <a href="git-add">git-add[1]</a> </dt> <dd> <p>Add file contents to the index</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-amgit-am1a"> <a href="git-am">git-am[1]</a> </dt> <dd> <p>Apply a series of patches from a mailbox</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-archivegit-archive1a"> <a href="git-archive">git-archive[1]</a> </dt> <dd> <p>Create an archive of files from a named tree</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-bisectgit-bisect1a"> <a href="git-bisect">git-bisect[1]</a> </dt> <dd> <p>Use binary search to find the commit that introduced a bug</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-branchgit-branch1a"> <a href="git-branch">git-branch[1]</a> </dt> <dd> <p>List, create, or delete branches</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-bundlegit-bundle1a"> <a href="git-bundle">git-bundle[1]</a> </dt> <dd> <p>Move objects and refs by archive</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-checkoutgit-checkout1a"> <a href="git-checkout">git-checkout[1]</a> </dt> <dd> <p>Switch branches or restore working tree files</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-cherry-pickgit-cherry-pick1a"> <a href="git-cherry-pick">git-cherry-pick[1]</a> </dt> <dd> <p>Apply the changes introduced by some existing commits</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-citoolgit-citool1a"> <a href="git-citool">git-citool[1]</a> </dt> <dd> <p>Graphical alternative to git-commit</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-cleangit-clean1a"> <a href="git-clean">git-clean[1]</a> </dt> <dd> <p>Remove untracked files from the working tree</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-clonegit-clone1a"> <a href="git-clone">git-clone[1]</a> </dt> <dd> <p>Clone a repository into a new directory</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-commitgit-commit1a"> <a href="git-commit">git-commit[1]</a> </dt> <dd> <p>Record changes to the repository</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-describegit-describe1a"> <a href="git-describe">git-describe[1]</a> </dt> <dd> <p>Give an object a human readable name based on an available ref</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-diffgit-diff1a"> <a href="git-diff">git-diff[1]</a> </dt> <dd> <p>Show changes between commits, commit and working tree, etc</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-fetchgit-fetch1a"> <a href="git-fetch">git-fetch[1]</a> </dt> <dd> <p>Download objects and refs from another repository</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-format-patchgit-format-patch1a"> <a href="git-format-patch">git-format-patch[1]</a> </dt> <dd> <p>Prepare patches for e-mail submission</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-gcgit-gc1a"> <a href="git-gc">git-gc[1]</a> </dt> <dd> <p>Cleanup unnecessary files and optimize the local repository</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-grepgit-grep1a"> <a href="git-grep">git-grep[1]</a> </dt> <dd> <p>Print lines matching a pattern</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-guigit-gui1a"> <a href="git-gui">git-gui[1]</a> </dt> <dd> <p>A portable graphical interface to Git</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-initgit-init1a"> <a href="git-init">git-init[1]</a> </dt> <dd> <p>Create an empty Git repository or reinitialize an existing one</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-loggit-log1a"> <a href="git-log">git-log[1]</a> </dt> <dd> <p>Show commit logs</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-maintenancegit-maintenance1a"> <a href="git-maintenance">git-maintenance[1]</a> </dt> <dd> <p>Run tasks to optimize Git repository data</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-mergegit-merge1a"> <a href="git-merge">git-merge[1]</a> </dt> <dd> <p>Join two or more development histories together</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-mvgit-mv1a"> <a href="git-mv">git-mv[1]</a> </dt> <dd> <p>Move or rename a file, a directory, or a symlink</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-notesgit-notes1a"> <a href="git-notes">git-notes[1]</a> </dt> <dd> <p>Add or inspect object notes</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-pullgit-pull1a"> <a href="git-pull">git-pull[1]</a> </dt> <dd> <p>Fetch from and integrate with another repository or a local branch</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-pushgit-push1a"> <a href="git-push">git-push[1]</a> </dt> <dd> <p>Update remote refs along with associated objects</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-range-diffgit-range-diff1a"> <a href="git-range-diff">git-range-diff[1]</a> </dt> <dd> <p>Compare two commit ranges (e.g. two versions of a branch)</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-rebasegit-rebase1a"> <a href="git-rebase">git-rebase[1]</a> </dt> <dd> <p>Reapply commits on top of another base tip</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-resetgit-reset1a"> <a href="git-reset">git-reset[1]</a> </dt> <dd> <p>Reset current HEAD to the specified state</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-restoregit-restore1a"> <a href="git-restore">git-restore[1]</a> </dt> <dd> <p>Restore working tree files</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-revertgit-revert1a"> <a href="git-revert">git-revert[1]</a> </dt> <dd> <p>Revert some existing commits</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-rmgit-rm1a"> <a href="git-rm">git-rm[1]</a> </dt> <dd> <p>Remove files from the working tree and from the index</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-shortloggit-shortlog1a"> <a href="git-shortlog">git-shortlog[1]</a> </dt> <dd> <p>Summarize <code>git log</code> output</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-showgit-show1a"> <a href="git-show">git-show[1]</a> </dt> <dd> <p>Show various types of objects</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-sparse-checkoutgit-sparse-checkout1a"> <a href="git-sparse-checkout">git-sparse-checkout[1]</a> </dt> <dd> <p>Reduce your working tree to a subset of tracked files</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-stashgit-stash1a"> <a href="git-stash">git-stash[1]</a> </dt> <dd> <p>Stash the changes in a dirty working directory away</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-statusgit-status1a"> <a href="git-status">git-status[1]</a> </dt> <dd> <p>Show the working tree status</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-submodulegit-submodule1a"> <a href="git-submodule">git-submodule[1]</a> </dt> <dd> <p>Initialize, update or inspect submodules</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-switchgit-switch1a"> <a href="git-switch">git-switch[1]</a> </dt> <dd> <p>Switch branches</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-taggit-tag1a"> <a href="git-tag">git-tag[1]</a> </dt> <dd> <p>Create, list, delete or verify a tag object signed with GPG</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-worktreegit-worktree1a"> <a href="git-worktree">git-worktree[1]</a> </dt> <dd> <p>Manage multiple working trees</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitkgitk1a"> <a href="gitk">gitk[1]</a> </dt> <dd> <p>The Git repository browser</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsscalarscalar1a"> <a href="scalar">scalar[1]</a> </dt> <dd> <p>A tool for managing large Git repositories</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_ancillary_commands"> +Ancillary Commands</h3> <p>Manipulators:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-configgit-config1a"> <a href="git-config">git-config[1]</a> </dt> <dd> <p>Get and set repository or global options</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-fast-exportgit-fast-export1a"> <a href="git-fast-export">git-fast-export[1]</a> </dt> <dd> <p>Git data exporter</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-fast-importgit-fast-import1a"> <a href="git-fast-import">git-fast-import[1]</a> </dt> <dd> <p>Backend for fast Git data importers</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-filter-branchgit-filter-branch1a"> <a href="git-filter-branch">git-filter-branch[1]</a> </dt> <dd> <p>Rewrite branches</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-mergetoolgit-mergetool1a"> <a href="git-mergetool">git-mergetool[1]</a> </dt> <dd> <p>Run merge conflict resolution tools to resolve merge conflicts</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-pack-refsgit-pack-refs1a"> <a href="git-pack-refs">git-pack-refs[1]</a> </dt> <dd> <p>Pack heads and tags for efficient repository access</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-prunegit-prune1a"> <a href="git-prune">git-prune[1]</a> </dt> <dd> <p>Prune all unreachable objects from the object database</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-refloggit-reflog1a"> <a href="git-reflog">git-reflog[1]</a> </dt> <dd> <p>Manage reflog information</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-remotegit-remote1a"> <a href="git-remote">git-remote[1]</a> </dt> <dd> <p>Manage set of tracked repositories</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-repackgit-repack1a"> <a href="git-repack">git-repack[1]</a> </dt> <dd> <p>Pack unpacked objects in a repository</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-replacegit-replace1a"> <a href="git-replace">git-replace[1]</a> </dt> <dd> <p>Create, list, delete refs to replace objects</p> </dd> </dl> </div> <p>Interrogators:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-annotategit-annotate1a"> <a href="git-annotate">git-annotate[1]</a> </dt> <dd> <p>Annotate file lines with commit information</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-blamegit-blame1a"> <a href="git-blame">git-blame[1]</a> </dt> <dd> <p>Show what revision and author last modified each line of a file</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-bugreportgit-bugreport1a"> <a href="git-bugreport">git-bugreport[1]</a> </dt> <dd> <p>Collect information for user to file a bug report</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-count-objectsgit-count-objects1a"> <a href="git-count-objects">git-count-objects[1]</a> </dt> <dd> <p>Count unpacked number of objects and their disk consumption</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-diagnosegit-diagnose1a"> <a href="git-diagnose">git-diagnose[1]</a> </dt> <dd> <p>Generate a zip archive of diagnostic information</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-difftoolgit-difftool1a"> <a href="git-difftool">git-difftool[1]</a> </dt> <dd> <p>Show changes using common diff tools</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-fsckgit-fsck1a"> <a href="git-fsck">git-fsck[1]</a> </dt> <dd> <p>Verifies the connectivity and validity of the objects in the database</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-helpgit-help1a"> <a href="git-help">git-help[1]</a> </dt> <dd> <p>Display help information about Git</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-instawebgit-instaweb1a"> <a href="git-instaweb">git-instaweb[1]</a> </dt> <dd> <p>Instantly browse your working repository in gitweb</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-merge-treegit-merge-tree1a"> <a href="git-merge-tree">git-merge-tree[1]</a> </dt> <dd> <p>Perform merge without touching index or working tree</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-rereregit-rerere1a"> <a href="git-rerere">git-rerere[1]</a> </dt> <dd> <p>Reuse recorded resolution of conflicted merges</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-show-branchgit-show-branch1a"> <a href="git-show-branch">git-show-branch[1]</a> </dt> <dd> <p>Show branches and their commits</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-verify-commitgit-verify-commit1a"> <a href="git-verify-commit">git-verify-commit[1]</a> </dt> <dd> <p>Check the GPG signature of commits</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-verify-taggit-verify-tag1a"> <a href="git-verify-tag">git-verify-tag[1]</a> </dt> <dd> <p>Check the GPG signature of tags</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-versiongit-version1a"> <a href="git-version">git-version[1]</a> </dt> <dd> <p>Display version information about Git</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-whatchangedgit-whatchanged1a"> <a href="git-whatchanged">git-whatchanged[1]</a> </dt> <dd> <p>Show logs with differences each commit introduces</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitwebgitweb1a"> <a href="gitweb">gitweb[1]</a> </dt> <dd> <p>Git web interface (web frontend to Git repositories)</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_interacting_with_others"> +Interacting with Others</h3> <p>These commands are to interact with foreign SCM and with other people via patch over e-mail.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-archimportgit-archimport1a"> <a href="git-archimport">git-archimport[1]</a> </dt> <dd> <p>Import a GNU Arch repository into Git</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-cvsexportcommitgit-cvsexportcommit1a"> <a href="git-cvsexportcommit">git-cvsexportcommit[1]</a> </dt> <dd> <p>Export a single commit to a CVS checkout</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-cvsimportgit-cvsimport1a"> <a href="git-cvsimport">git-cvsimport[1]</a> </dt> <dd> <p>Salvage your data out of another SCM people love to hate</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-cvsservergit-cvsserver1a"> <a href="git-cvsserver">git-cvsserver[1]</a> </dt> <dd> <p>A CVS server emulator for Git</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-imap-sendgit-imap-send1a"> <a href="git-imap-send">git-imap-send[1]</a> </dt> <dd> <p>Send a collection of patches from stdin to an IMAP folder</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-p4git-p41a"> <a href="git-p4">git-p4[1]</a> </dt> <dd> <p>Import from and submit to Perforce repositories</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-quiltimportgit-quiltimport1a"> <a href="git-quiltimport">git-quiltimport[1]</a> </dt> <dd> <p>Applies a quilt patchset onto the current branch</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-request-pullgit-request-pull1a"> <a href="git-request-pull">git-request-pull[1]</a> </dt> <dd> <p>Generates a summary of pending changes</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-send-emailgit-send-email1a"> <a href="git-send-email">git-send-email[1]</a> </dt> <dd> <p>Send a collection of patches as emails</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-svngit-svn1a"> <a href="git-svn">git-svn[1]</a> </dt> <dd> <p>Bidirectional operation between a Subversion repository and Git</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_reset_restore_and_revert"> +Reset, restore and revert</h3> <p>There are three commands with similar names: <code>git reset</code>, <code>git restore</code> and <code>git revert</code>.</p> <div class="ulist"> <ul> <li> <p><a href="git-revert">git-revert[1]</a> is about making a new commit that reverts the changes made by other commits.</p> </li> <li> <p><a href="git-restore">git-restore[1]</a> is about restoring files in the working tree from either the index or another commit. This command does not update your branch. The command can also be used to restore files in the index from another commit.</p> </li> <li> <p><a href="git-reset">git-reset[1]</a> is about updating your branch, moving the tip in order to add or remove commits from the branch. This operation changes the commit history.</p> <p><code>git reset</code> can also be used to restore the index, overlapping with <code>git restore</code>.</p> </li> </ul> </div> </div> </div> <h2 id="_low_level_commands_plumbing">Low-level commands (plumbing)</h2> <div class="sectionbody"> <p>Although Git includes its own porcelain layer, its low-level commands are sufficient to support development of alternative porcelains. Developers of such porcelains might start by reading about <a href="git-update-index">git-update-index[1]</a> and <a href="git-read-tree">git-read-tree[1]</a>.</p> <p>The interface (input, output, set of options and the semantics) to these low-level commands are meant to be a lot more stable than Porcelain level commands, because these commands are primarily for scripted use. The interface to Porcelain commands on the other hand are subject to change in order to improve the end user experience.</p> <p>The following description divides the low-level commands into commands that manipulate objects (in the repository, index, and working tree), commands that interrogate and compare objects, and commands that move objects and references between repositories.</p> <div class="sect2"> <h3 id="_manipulation_commands"> +Manipulation commands</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-applygit-apply1a"> <a href="git-apply">git-apply[1]</a> </dt> <dd> <p>Apply a patch to files and/or to the index</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-checkout-indexgit-checkout-index1a"> <a href="git-checkout-index">git-checkout-index[1]</a> </dt> <dd> <p>Copy files from the index to the working tree</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-commit-graphgit-commit-graph1a"> <a href="git-commit-graph">git-commit-graph[1]</a> </dt> <dd> <p>Write and verify Git commit-graph files</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-commit-treegit-commit-tree1a"> <a href="git-commit-tree">git-commit-tree[1]</a> </dt> <dd> <p>Create a new commit object</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-hash-objectgit-hash-object1a"> <a href="git-hash-object">git-hash-object[1]</a> </dt> <dd> <p>Compute object ID and optionally create an object from a file</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-index-packgit-index-pack1a"> <a href="git-index-pack">git-index-pack[1]</a> </dt> <dd> <p>Build pack index file for an existing packed archive</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-merge-filegit-merge-file1a"> <a href="git-merge-file">git-merge-file[1]</a> </dt> <dd> <p>Run a three-way file merge</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-merge-indexgit-merge-index1a"> <a href="git-merge-index">git-merge-index[1]</a> </dt> <dd> <p>Run a merge for files needing merging</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-mktaggit-mktag1a"> <a href="git-mktag">git-mktag[1]</a> </dt> <dd> <p>Creates a tag object with extra validation</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-mktreegit-mktree1a"> <a href="git-mktree">git-mktree[1]</a> </dt> <dd> <p>Build a tree-object from ls-tree formatted text</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-multi-pack-indexgit-multi-pack-index1a"> <a href="git-multi-pack-index">git-multi-pack-index[1]</a> </dt> <dd> <p>Write and verify multi-pack-indexes</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-pack-objectsgit-pack-objects1a"> <a href="git-pack-objects">git-pack-objects[1]</a> </dt> <dd> <p>Create a packed archive of objects</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-prune-packedgit-prune-packed1a"> <a href="git-prune-packed">git-prune-packed[1]</a> </dt> <dd> <p>Remove extra objects that are already in pack files</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-read-treegit-read-tree1a"> <a href="git-read-tree">git-read-tree[1]</a> </dt> <dd> <p>Reads tree information into the index</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-symbolic-refgit-symbolic-ref1a"> <a href="git-symbolic-ref">git-symbolic-ref[1]</a> </dt> <dd> <p>Read, modify and delete symbolic refs</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-unpack-objectsgit-unpack-objects1a"> <a href="git-unpack-objects">git-unpack-objects[1]</a> </dt> <dd> <p>Unpack objects from a packed archive</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-update-indexgit-update-index1a"> <a href="git-update-index">git-update-index[1]</a> </dt> <dd> <p>Register file contents in the working tree to the index</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-update-refgit-update-ref1a"> <a href="git-update-ref">git-update-ref[1]</a> </dt> <dd> <p>Update the object name stored in a ref safely</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-write-treegit-write-tree1a"> <a href="git-write-tree">git-write-tree[1]</a> </dt> <dd> <p>Create a tree object from the current index</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_interrogation_commands"> +Interrogation commands</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-cat-filegit-cat-file1a"> <a href="git-cat-file">git-cat-file[1]</a> </dt> <dd> <p>Provide contents or details of repository objects</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-cherrygit-cherry1a"> <a href="git-cherry">git-cherry[1]</a> </dt> <dd> <p>Find commits yet to be applied to upstream</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-diff-filesgit-diff-files1a"> <a href="git-diff-files">git-diff-files[1]</a> </dt> <dd> <p>Compares files in the working tree and the index</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-diff-indexgit-diff-index1a"> <a href="git-diff-index">git-diff-index[1]</a> </dt> <dd> <p>Compare a tree to the working tree or index</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-diff-treegit-diff-tree1a"> <a href="git-diff-tree">git-diff-tree[1]</a> </dt> <dd> <p>Compares the content and mode of blobs found via two tree objects</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-for-each-refgit-for-each-ref1a"> <a href="git-for-each-ref">git-for-each-ref[1]</a> </dt> <dd> <p>Output information on each ref</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-for-each-repogit-for-each-repo1a"> <a href="git-for-each-repo">git-for-each-repo[1]</a> </dt> <dd> <p>Run a Git command on a list of repositories</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-get-tar-commit-idgit-get-tar-commit-id1a"> <a href="git-get-tar-commit-id">git-get-tar-commit-id[1]</a> </dt> <dd> <p>Extract commit ID from an archive created using git-archive</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-ls-filesgit-ls-files1a"> <a href="git-ls-files">git-ls-files[1]</a> </dt> <dd> <p>Show information about files in the index and the working tree</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-ls-remotegit-ls-remote1a"> <a href="git-ls-remote">git-ls-remote[1]</a> </dt> <dd> <p>List references in a remote repository</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-ls-treegit-ls-tree1a"> <a href="git-ls-tree">git-ls-tree[1]</a> </dt> <dd> <p>List the contents of a tree object</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-merge-basegit-merge-base1a"> <a href="git-merge-base">git-merge-base[1]</a> </dt> <dd> <p>Find as good common ancestors as possible for a merge</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-name-revgit-name-rev1a"> <a href="git-name-rev">git-name-rev[1]</a> </dt> <dd> <p>Find symbolic names for given revs</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-pack-redundantgit-pack-redundant1a"> <a href="git-pack-redundant">git-pack-redundant[1]</a> </dt> <dd> <p>Find redundant pack files</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-rev-listgit-rev-list1a"> <a href="git-rev-list">git-rev-list[1]</a> </dt> <dd> <p>Lists commit objects in reverse chronological order</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-rev-parsegit-rev-parse1a"> <a href="git-rev-parse">git-rev-parse[1]</a> </dt> <dd> <p>Pick out and massage parameters</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-show-indexgit-show-index1a"> <a href="git-show-index">git-show-index[1]</a> </dt> <dd> <p>Show packed archive index</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-show-refgit-show-ref1a"> <a href="git-show-ref">git-show-ref[1]</a> </dt> <dd> <p>List references in a local repository</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-unpack-filegit-unpack-file1a"> <a href="git-unpack-file">git-unpack-file[1]</a> </dt> <dd> <p>Creates a temporary file with a blob’s contents</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-vargit-var1a"> <a href="git-var">git-var[1]</a> </dt> <dd> <p>Show a Git logical variable</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-verify-packgit-verify-pack1a"> <a href="git-verify-pack">git-verify-pack[1]</a> </dt> <dd> <p>Validate packed Git archive files</p> </dd> </dl> </div> <p>In general, the interrogate commands do not touch the files in the working tree.</p> </div> <div class="sect2"> <h3 id="_syncing_repositories"> +Syncing repositories</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-daemongit-daemon1a"> <a href="git-daemon">git-daemon[1]</a> </dt> <dd> <p>A really simple server for Git repositories</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-fetch-packgit-fetch-pack1a"> <a href="git-fetch-pack">git-fetch-pack[1]</a> </dt> <dd> <p>Receive missing objects from another repository</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-http-backendgit-http-backend1a"> <a href="git-http-backend">git-http-backend[1]</a> </dt> <dd> <p>Server side implementation of Git over HTTP</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-send-packgit-send-pack1a"> <a href="git-send-pack">git-send-pack[1]</a> </dt> <dd> <p>Push objects over Git protocol to another repository</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-update-server-infogit-update-server-info1a"> <a href="git-update-server-info">git-update-server-info[1]</a> </dt> <dd> <p>Update auxiliary info file to help dumb servers</p> </dd> </dl> </div> <p>The following are helper commands used by the above; end users typically do not use them directly.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-http-fetchgit-http-fetch1a"> <a href="git-http-fetch">git-http-fetch[1]</a> </dt> <dd> <p>Download from a remote Git repository via HTTP</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-http-pushgit-http-push1a"> <a href="git-http-push">git-http-push[1]</a> </dt> <dd> <p>Push objects over HTTP/DAV to another repository</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-receive-packgit-receive-pack1a"> <a href="git-receive-pack">git-receive-pack[1]</a> </dt> <dd> <p>Receive what is pushed into the repository</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-shellgit-shell1a"> <a href="git-shell">git-shell[1]</a> </dt> <dd> <p>Restricted login shell for Git-only SSH access</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-upload-archivegit-upload-archive1a"> <a href="git-upload-archive">git-upload-archive[1]</a> </dt> <dd> <p>Send archive back to git-archive</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-upload-packgit-upload-pack1a"> <a href="git-upload-pack">git-upload-pack[1]</a> </dt> <dd> <p>Send objects packed back to git-fetch-pack</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_internal_helper_commands"> +Internal helper commands</h3> <p>These are internal helper commands used by other commands; end users typically do not use them directly.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-check-attrgit-check-attr1a"> <a href="git-check-attr">git-check-attr[1]</a> </dt> <dd> <p>Display gitattributes information</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-check-ignoregit-check-ignore1a"> <a href="git-check-ignore">git-check-ignore[1]</a> </dt> <dd> <p>Debug gitignore / exclude files</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-check-mailmapgit-check-mailmap1a"> <a href="git-check-mailmap">git-check-mailmap[1]</a> </dt> <dd> <p>Show canonical names and email addresses of contacts</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-check-ref-formatgit-check-ref-format1a"> <a href="git-check-ref-format">git-check-ref-format[1]</a> </dt> <dd> <p>Ensures that a reference name is well formed</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-columngit-column1a"> <a href="git-column">git-column[1]</a> </dt> <dd> <p>Display data in columns</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-credentialgit-credential1a"> <a href="git-credential">git-credential[1]</a> </dt> <dd> <p>Retrieve and store user credentials</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-credential-cachegit-credential-cache1a"> <a href="git-credential-cache">git-credential-cache[1]</a> </dt> <dd> <p>Helper to temporarily store passwords in memory</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-credential-storegit-credential-store1a"> <a href="git-credential-store">git-credential-store[1]</a> </dt> <dd> <p>Helper to store credentials on disk</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-fmt-merge-msggit-fmt-merge-msg1a"> <a href="git-fmt-merge-msg">git-fmt-merge-msg[1]</a> </dt> <dd> <p>Produce a merge commit message</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-hookgit-hook1a"> <a href="git-hook">git-hook[1]</a> </dt> <dd> <p>Run git hooks</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-interpret-trailersgit-interpret-trailers1a"> <a href="git-interpret-trailers">git-interpret-trailers[1]</a> </dt> <dd> <p>Add or parse structured information in commit messages</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-mailinfogit-mailinfo1a"> <a href="git-mailinfo">git-mailinfo[1]</a> </dt> <dd> <p>Extracts patch and authorship from a single e-mail message</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-mailsplitgit-mailsplit1a"> <a href="git-mailsplit">git-mailsplit[1]</a> </dt> <dd> <p>Simple UNIX mbox splitter program</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-merge-one-filegit-merge-one-file1a"> <a href="git-merge-one-file">git-merge-one-file[1]</a> </dt> <dd> <p>The standard helper program to use with git-merge-index</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-patch-idgit-patch-id1a"> <a href="git-patch-id">git-patch-id[1]</a> </dt> <dd> <p>Compute unique ID for a patch</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-sh-i18ngit-sh-i18n1a"> <a href="git-sh-i18n">git-sh-i18n[1]</a> </dt> <dd> <p>Git’s i18n setup code for shell scripts</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-sh-setupgit-sh-setup1a"> <a href="git-sh-setup">git-sh-setup[1]</a> </dt> <dd> <p>Common Git shell script setup code</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgit-stripspacegit-stripspace1a"> <a href="git-stripspace">git-stripspace[1]</a> </dt> <dd> <p>Remove unnecessary whitespace</p> </dd> </dl> </div> </div> </div> <h2 id="_guides">Guides</h2> <div class="sectionbody"> <p>The following documentation pages are guides about Git concepts.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitcore-tutorialgitcore-tutorial7a"> <a href="gitcore-tutorial">gitcore-tutorial[7]</a> </dt> <dd> <p>A Git core tutorial for developers</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitcredentialsgitcredentials7a"> <a href="gitcredentials">gitcredentials[7]</a> </dt> <dd> <p>Providing usernames and passwords to Git</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitcvs-migrationgitcvs-migration7a"> <a href="gitcvs-migration">gitcvs-migration[7]</a> </dt> <dd> <p>Git for CVS users</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitdiffcoregitdiffcore7a"> <a href="gitdiffcore">gitdiffcore[7]</a> </dt> <dd> <p>Tweaking diff output</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgiteverydaygiteveryday7a"> <a href="giteveryday">giteveryday[7]</a> </dt> <dd> <p>A useful minimum set of commands for Everyday Git</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitfaqgitfaq7a"> <a href="gitfaq">gitfaq[7]</a> </dt> <dd> <p>Frequently asked questions about using Git</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitglossarygitglossary7a"> <a href="gitglossary">gitglossary[7]</a> </dt> <dd> <p>A Git Glossary</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitnamespacesgitnamespaces7a"> <a href="gitnamespaces">gitnamespaces[7]</a> </dt> <dd> <p>Git namespaces</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitremote-helpersgitremote-helpers7a"> <a href="gitremote-helpers">gitremote-helpers[7]</a> </dt> <dd> <p>Helper programs to interact with remote repositories</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitsubmodulesgitsubmodules7a"> <a href="gitsubmodules">gitsubmodules[7]</a> </dt> <dd> <p>Mounting one repository inside another</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgittutorialgittutorial7a"> <a href="gittutorial">gittutorial[7]</a> </dt> <dd> <p>A tutorial introduction to Git</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgittutorial-2gittutorial-27a"> <a href="gittutorial-2">gittutorial-2[7]</a> </dt> <dd> <p>A tutorial introduction to Git: part two</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitworkflowsgitworkflows7a"> <a href="gitworkflows">gitworkflows[7]</a> </dt> <dd> <p>An overview of recommended workflows with Git</p> </dd> </dl> </div> </div> <h2 id="_repository_command_and_file_interfaces">Repository, command and file interfaces</h2> <div class="sectionbody"> <p>This documentation discusses repository and command interfaces which users are expected to interact with directly. See <code>--user-formats</code> in <a href="git-help">git-help[1]</a> for more details on the criteria.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitattributesgitattributes5a"> <a href="gitattributes">gitattributes[5]</a> </dt> <dd> <p>Defining attributes per path</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitcligitcli7a"> <a href="gitcli">gitcli[7]</a> </dt> <dd> <p>Git command-line interface and conventions</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgithooksgithooks5a"> <a href="githooks">githooks[5]</a> </dt> <dd> <p>Hooks used by Git</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitignoregitignore5a"> <a href="gitignore">gitignore[5]</a> </dt> <dd> <p>Specifies intentionally untracked files to ignore</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitmailmapgitmailmap5a"> <a href="gitmailmap">gitmailmap[5]</a> </dt> <dd> <p>Map author/committer names and/or E-Mail addresses</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitmodulesgitmodules5a"> <a href="gitmodules">gitmodules[5]</a> </dt> <dd> <p>Defining submodule properties</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitrepository-layoutgitrepository-layout5a"> <a href="gitrepository-layout">gitrepository-layout[5]</a> </dt> <dd> <p>Git Repository Layout</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitrevisionsgitrevisions7a"> <a href="gitrevisions">gitrevisions[7]</a> </dt> <dd> <p>Specifying revisions and ranges for Git</p> </dd> </dl> </div> </div> <h2 id="_file_formats_protocols_and_other_developer_interfaces">File formats, protocols and other developer interfaces</h2> <div class="sectionbody"> <p>This documentation discusses file formats, over-the-wire protocols and other git developer interfaces. See <code>--developer-interfaces</code> in <a href="git-help">git-help[1]</a>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitformat-bundlegitformat-bundle5a"> <a href="gitformat-bundle">gitformat-bundle[5]</a> </dt> <dd> <p>The bundle file format</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitformat-chunkgitformat-chunk5a"> <a href="gitformat-chunk">gitformat-chunk[5]</a> </dt> <dd> <p>Chunk-based file formats</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitformat-commit-graphgitformat-commit-graph5a"> <a href="gitformat-commit-graph">gitformat-commit-graph[5]</a> </dt> <dd> <p>Git commit-graph format</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitformat-indexgitformat-index5a"> <a href="gitformat-index">gitformat-index[5]</a> </dt> <dd> <p>Git index format</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitformat-packgitformat-pack5a"> <a href="gitformat-pack">gitformat-pack[5]</a> </dt> <dd> <p>Git pack format</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitformat-signaturegitformat-signature5a"> <a href="gitformat-signature">gitformat-signature[5]</a> </dt> <dd> <p>Git cryptographic signature formats</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitprotocol-capabilitiesgitprotocol-capabilities5a"> <a href="gitprotocol-capabilities">gitprotocol-capabilities[5]</a> </dt> <dd> <p>Protocol v0 and v1 capabilities</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitprotocol-commongitprotocol-common5a"> <a href="gitprotocol-common">gitprotocol-common[5]</a> </dt> <dd> <p>Things common to various protocols</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitprotocol-httpgitprotocol-http5a"> <a href="gitprotocol-http">gitprotocol-http[5]</a> </dt> <dd> <p>Git HTTP-based protocols</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitprotocol-packgitprotocol-pack5a"> <a href="gitprotocol-pack">gitprotocol-pack[5]</a> </dt> <dd> <p>How packs are transferred over-the-wire</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ahrefdocsgitprotocol-v2gitprotocol-v25a"> <a href="gitprotocol-v2">gitprotocol-v2[5]</a> </dt> <dd> <p>Git Wire Protocol, Version 2</p> </dd> </dl> </div> </div> <h2 id="_configuration_mechanism">Configuration mechanism</h2> <div class="sectionbody"> <p>Git uses a simple text format to store customizations that are per repository and are per user. Such a configuration file may look like this:</p> <div class="listingblock"> <div class="content"> <pre># +# A '#' or ';' character indicates a comment. +# + +; core variables +[core] + ; Don't trust file modes + filemode = false + +; user identity +[user] + name = "Junio C Hamano" + email = "gitster@pobox.com"</pre> </div> </div> <p>Various commands read from the configuration file and adjust their operation accordingly. See <a href="git-config">git-config[1]</a> for a list and more details about the configuration mechanism.</p> </div> <h2 id="_identifier_terminology">Identifier terminology</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-ltobjectgt"> <object> </dt> <dd> <p>Indicates the object name for any type of object.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ltblobgt"> <blob> </dt> <dd> <p>Indicates a blob object name.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-lttreegt"> <tree> </dt> <dd> <p>Indicates a tree object name.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ltcommitgt"> <commit> </dt> <dd> <p>Indicates a commit object name.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-lttree-ishgt"> <tree-ish> </dt> <dd> <p>Indicates a tree, commit or tag object name. A command that takes a <tree-ish> argument ultimately wants to operate on a <tree> object but automatically dereferences <commit> and <tag> objects that point at a <tree>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ltcommit-ishgt"> <commit-ish> </dt> <dd> <p>Indicates a commit or tag object name. A command that takes a <commit-ish> argument ultimately wants to operate on a <commit> object but automatically dereferences <tag> objects that point at a <commit>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-lttypegt"> <type> </dt> <dd> <p>Indicates that an object type is required. Currently one of: <code>blob</code>, <code>tree</code>, <code>commit</code>, or <code>tag</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ltfilegt"> <file> </dt> <dd> <p>Indicates a filename - almost always relative to the root of the tree structure <code>GIT_INDEX_FILE</code> describes.</p> </dd> </dl> </div> </div> <h2 id="_symbolic_identifiers">Symbolic identifiers</h2> <div class="sectionbody"> <p>Any Git command accepting any <object> can also use the following symbolic notation:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-HEAD"> HEAD </dt> <dd> <p>indicates the head of the current branch.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-lttaggt"> <tag> </dt> <dd> <p>a valid tag <code>name</code> (i.e. a <code>refs/tags/<tag></code> reference).</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ltheadgt"> <head> </dt> <dd> <p>a valid head <code>name</code> (i.e. a <code>refs/heads/<head></code> reference).</p> </dd> </dl> </div> <p>For a more complete list of ways to spell object names, see "SPECIFYING REVISIONS" section in <a href="gitrevisions">gitrevisions[7]</a>.</p> </div> <h2 id="_filedirectory_structure">File/directory structure</h2> <div class="sectionbody"> <p>Please see the <a href="gitrepository-layout">gitrepository-layout[5]</a> document.</p> <p>Read <a href="githooks">githooks[5]</a> for more details about each hook.</p> <p>Higher level SCMs may provide and manage additional information in the <code>$GIT_DIR</code>.</p> </div> <h2 id="_terminology">Terminology</h2> <div class="sectionbody"> <p>Please see <a href="gitglossary">gitglossary[7]</a>.</p> </div> <h2 id="_environment_variables">Environment variables</h2> <div class="sectionbody"> <p>Various Git commands pay attention to environment variables and change their behavior. The environment variables marked as "Boolean" take their values the same way as Boolean valued configuration variables, e.g. "true", "yes", "on" and positive numbers are taken as "yes".</p> <p>Here are the variables:</p> <div class="sect2"> <h3 id="_the_git_repository"> +The Git Repository</h3> <p>These environment variables apply to <code>all</code> core Git commands. Nb: it is worth noting that they may be used/overridden by SCMS sitting above Git so take care if using a foreign front-end.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-codeGITINDEXFILEcode"> <code>GIT_INDEX_FILE</code> </dt> <dd> <p>This environment variable specifies an alternate index file. If not specified, the default of <code>$GIT_DIR/index</code> is used.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITINDEXVERSIONcode"> <code>GIT_INDEX_VERSION</code> </dt> <dd> <p>This environment variable specifies what index version is used when writing the index file out. It won’t affect existing index files. By default index file version 2 or 3 is used. See <a href="git-update-index">git-update-index[1]</a> for more information.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITOBJECTDIRECTORYcode"> <code>GIT_OBJECT_DIRECTORY</code> </dt> <dd> <p>If the object storage directory is specified via this environment variable then the sha1 directories are created underneath - otherwise the default <code>$GIT_DIR/objects</code> directory is used.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITALTERNATEOBJECTDIRECTORIEScode"> <code>GIT_ALTERNATE_OBJECT_DIRECTORIES</code> </dt> <dd> <p>Due to the immutable nature of Git objects, old objects can be archived into shared, read-only directories. This variable specifies a ":" separated (on Windows ";" separated) list of Git object directories which can be used to search for Git objects. New objects will not be written to these directories.</p> <p>Entries that begin with <code>"</code> (double-quote) will be interpreted as C-style quoted paths, removing leading and trailing double-quotes and respecting backslash escapes. E.g., the value <code>"path-with-\"-and-:-in-it":vanilla-path</code> has two paths: <code>path-with-"-and-:-in-it</code> and <code>vanilla-path</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITDIRcode"> <code>GIT_DIR</code> </dt> <dd> <p>If the <code>GIT_DIR</code> environment variable is set then it specifies a path to use instead of the default <code>.git</code> for the base of the repository. The <code>--git-dir</code> command-line option also sets this value.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITWORKTREEcode"> <code>GIT_WORK_TREE</code> </dt> <dd> <p>Set the path to the root of the working tree. This can also be controlled by the <code>--work-tree</code> command-line option and the core.worktree configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITNAMESPACEcode"> <code>GIT_NAMESPACE</code> </dt> <dd> <p>Set the Git namespace; see <a href="gitnamespaces">gitnamespaces[7]</a> for details. The <code>--namespace</code> command-line option also sets this value.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITCEILINGDIRECTORIEScode"> <code>GIT_CEILING_DIRECTORIES</code> </dt> <dd> <p>This should be a colon-separated list of absolute paths. If set, it is a list of directories that Git should not chdir up into while looking for a repository directory (useful for excluding slow-loading network directories). It will not exclude the current working directory or a GIT_DIR set on the command line or in the environment. Normally, Git has to read the entries in this list and resolve any symlink that might be present in order to compare them with the current directory. However, if even this access is slow, you can add an empty entry to the list to tell Git that the subsequent entries are not symlinks and needn’t be resolved; e.g., <code>GIT_CEILING_DIRECTORIES=/maybe/symlink::/very/slow/non/symlink</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITDISCOVERYACROSSFILESYSTEMcode"> <code>GIT_DISCOVERY_ACROSS_FILESYSTEM</code> </dt> <dd> <p>When run in a directory that does not have ".git" repository directory, Git tries to find such a directory in the parent directories to find the top of the working tree, but by default it does not cross filesystem boundaries. This Boolean environment variable can be set to true to tell Git not to stop at filesystem boundaries. Like <code>GIT_CEILING_DIRECTORIES</code>, this will not affect an explicit repository directory set via <code>GIT_DIR</code> or on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITCOMMONDIRcode"> <code>GIT_COMMON_DIR</code> </dt> <dd> <p>If this variable is set to a path, non-worktree files that are normally in $GIT_DIR will be taken from this path instead. Worktree-specific files such as HEAD or index are taken from $GIT_DIR. See <a href="gitrepository-layout">gitrepository-layout[5]</a> and <a href="git-worktree">git-worktree[1]</a> for details. This variable has lower precedence than other path variables such as GIT_INDEX_FILE, GIT_OBJECT_DIRECTORY…</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITDEFAULTHASHcode"> <code>GIT_DEFAULT_HASH</code> </dt> <dd> <p>If this variable is set, the default hash algorithm for new repositories will be set to this value. This value is ignored when cloning and the setting of the remote repository is always used. The default is "sha1". See <code>--object-format</code> in <a href="git-init">git-init[1]</a>.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_git_commits"> +Git Commits</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-codeGITAUTHORNAMEcode"> <code>GIT_AUTHOR_NAME</code> </dt> <dd> <p>The human-readable name used in the author identity when creating commit or tag objects, or when writing reflogs. Overrides the <code>user.name</code> and <code>author.name</code> configuration settings.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITAUTHOREMAILcode"> <code>GIT_AUTHOR_EMAIL</code> </dt> <dd> <p>The email address used in the author identity when creating commit or tag objects, or when writing reflogs. Overrides the <code>user.email</code> and <code>author.email</code> configuration settings.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITAUTHORDATEcode"> <code>GIT_AUTHOR_DATE</code> </dt> <dd> <p>The date used for the author identity when creating commit or tag objects, or when writing reflogs. See <a href="git-commit">git-commit[1]</a> for valid formats.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITCOMMITTERNAMEcode"> <code>GIT_COMMITTER_NAME</code> </dt> <dd> <p>The human-readable name used in the committer identity when creating commit or tag objects, or when writing reflogs. Overrides the <code>user.name</code> and <code>committer.name</code> configuration settings.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITCOMMITTEREMAILcode"> <code>GIT_COMMITTER_EMAIL</code> </dt> <dd> <p>The email address used in the author identity when creating commit or tag objects, or when writing reflogs. Overrides the <code>user.email</code> and <code>committer.email</code> configuration settings.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITCOMMITTERDATEcode"> <code>GIT_COMMITTER_DATE</code> </dt> <dd> <p>The date used for the committer identity when creating commit or tag objects, or when writing reflogs. See <a href="git-commit">git-commit[1]</a> for valid formats.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeEMAILcode"> <code>EMAIL</code> </dt> <dd> <p>The email address used in the author and committer identities if no other relevant environment variable or configuration setting has been set.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_git_diffs"> +Git Diffs</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-codeGITDIFFOPTScode"> <code>GIT_DIFF_OPTS</code> </dt> <dd> <p>Only valid setting is "--unified=??" or "-u??" to set the number of context lines shown when a unified diff is created. This takes precedence over any "-U" or "--unified" option value passed on the Git diff command line.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITEXTERNALDIFFcode"> <code>GIT_EXTERNAL_DIFF</code> </dt> <dd> <p>When the environment variable <code>GIT_EXTERNAL_DIFF</code> is set, the program named by it is called to generate diffs, and Git does not use its builtin diff machinery. For a path that is added, removed, or modified, <code>GIT_EXTERNAL_DIFF</code> is called with 7 parameters:</p> <div class="literalblock"> <div class="content"> <pre>path old-file old-hex old-mode new-file new-hex new-mode</pre> </div> </div> <p>where:</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ltoldnewgt-file"> <old|new>-file </dt> <dd> <p>are files GIT_EXTERNAL_DIFF can use to read the contents of <old|new>,</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ltoldnewgt-hex"> <old|new>-hex </dt> <dd> <p>are the 40-hexdigit SHA-1 hashes,</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-ltoldnewgt-mode"> <old|new>-mode </dt> <dd> <p>are the octal representation of the file modes.</p> <p>The file parameters can point at the user’s working file (e.g. <code>new-file</code> in "git-diff-files"), <code>/dev/null</code> (e.g. <code>old-file</code> when a new file is added), or a temporary file (e.g. <code>old-file</code> in the index). <code>GIT_EXTERNAL_DIFF</code> should not worry about unlinking the temporary file — it is removed when <code>GIT_EXTERNAL_DIFF</code> exits.</p> <p>For a path that is unmerged, <code>GIT_EXTERNAL_DIFF</code> is called with 1 parameter, <path>.</p> <p>For each path <code>GIT_EXTERNAL_DIFF</code> is called, two environment variables, <code>GIT_DIFF_PATH_COUNTER</code> and <code>GIT_DIFF_PATH_TOTAL</code> are set.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITDIFFPATHCOUNTERcode"> <code>GIT_DIFF_PATH_COUNTER</code> </dt> <dd> <p>A 1-based counter incremented by one for every path.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITDIFFPATHTOTALcode"> <code>GIT_DIFF_PATH_TOTAL</code> </dt> <dd> <p>The total number of paths.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_other"> +other</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git.txt-codeGITMERGEVERBOSITYcode"> <code>GIT_MERGE_VERBOSITY</code> </dt> <dd> <p>A number controlling the amount of output shown by the recursive merge strategy. Overrides merge.verbosity. See <a href="git-merge">git-merge[1]</a></p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITPAGERcode"> <code>GIT_PAGER</code> </dt> <dd> <p>This environment variable overrides <code>$PAGER</code>. If it is set to an empty string or to the value "cat", Git will not launch a pager. See also the <code>core.pager</code> option in <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITPROGRESSDELAYcode"> <code>GIT_PROGRESS_DELAY</code> </dt> <dd> <p>A number controlling how many seconds to delay before showing optional progress indicators. Defaults to 2.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITEDITORcode"> <code>GIT_EDITOR</code> </dt> <dd> <p>This environment variable overrides <code>$EDITOR</code> and <code>$VISUAL</code>. It is used by several Git commands when, on interactive mode, an editor is to be launched. See also <a href="git-var">git-var[1]</a> and the <code>core.editor</code> option in <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITSEQUENCEEDITORcode"> <code>GIT_SEQUENCE_EDITOR</code> </dt> <dd> <p>This environment variable overrides the configured Git editor when editing the todo list of an interactive rebase. See also <a href="git-rebase">git-rebase[1]</a> and the <code>sequence.editor</code> option in <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITSSHcode"> <code>GIT_SSH</code> </dt> <dt class="hdlist1" id="Documentation/git.txt-codeGITSSHCOMMANDcode"> <code>GIT_SSH_COMMAND</code> </dt> <dd> <p>If either of these environment variables is set then <code>git fetch</code> and <code>git push</code> will use the specified command instead of <code>ssh</code> when they need to connect to a remote system. The command-line parameters passed to the configured command are determined by the ssh variant. See <code>ssh.variant</code> option in <a href="git-config">git-config[1]</a> for details.</p> <p><code>$GIT_SSH_COMMAND</code> takes precedence over <code>$GIT_SSH</code>, and is interpreted by the shell, which allows additional arguments to be included. <code>$GIT_SSH</code> on the other hand must be just the path to a program (which can be a wrapper shell script, if additional arguments are needed).</p> <p>Usually it is easier to configure any desired options through your personal <code>.ssh/config</code> file. Please consult your ssh documentation for further details.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITSSHVARIANTcode"> <code>GIT_SSH_VARIANT</code> </dt> <dd> <p>If this environment variable is set, it overrides Git’s autodetection whether <code>GIT_SSH</code>/<code>GIT_SSH_COMMAND</code>/<code>core.sshCommand</code> refer to OpenSSH, plink or tortoiseplink. This variable overrides the config setting <code>ssh.variant</code> that serves the same purpose.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITSSLNOVERIFYcode"> <code>GIT_SSL_NO_VERIFY</code> </dt> <dd> <p>Setting and exporting this environment variable to any value tells Git not to verify the SSL certificate when fetching or pushing over HTTPS.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITATTRSOURCEcode"> <code>GIT_ATTR_SOURCE</code> </dt> <dd> <p>Sets the treeish that gitattributes will be read from.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITASKPASScode"> <code>GIT_ASKPASS</code> </dt> <dd> <p>If this environment variable is set, then Git commands which need to acquire passwords or passphrases (e.g. for HTTP or IMAP authentication) will call this program with a suitable prompt as command-line argument and read the password from its STDOUT. See also the <code>core.askPass</code> option in <a href="git-config">git-config[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTERMINALPROMPTcode"> <code>GIT_TERMINAL_PROMPT</code> </dt> <dd> <p>If this Boolean environment variable is set to false, git will not prompt on the terminal (e.g., when asking for HTTP authentication).</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITCONFIGGLOBALcode"> <code>GIT_CONFIG_GLOBAL</code> </dt> <dt class="hdlist1" id="Documentation/git.txt-codeGITCONFIGSYSTEMcode"> <code>GIT_CONFIG_SYSTEM</code> </dt> <dd> <p>Take the configuration from the given files instead from global or system-level configuration files. If <code>GIT_CONFIG_SYSTEM</code> is set, the system config file defined at build time (usually <code>/etc/gitconfig</code>) will not be read. Likewise, if <code>GIT_CONFIG_GLOBAL</code> is set, neither <code>$HOME/.gitconfig</code> nor <code>$XDG_CONFIG_HOME/git/config</code> will be read. Can be set to <code>/dev/null</code> to skip reading configuration files of the respective level.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITCONFIGNOSYSTEMcode"> <code>GIT_CONFIG_NOSYSTEM</code> </dt> <dd> <p>Whether to skip reading settings from the system-wide <code>$(prefix)/etc/gitconfig</code> file. This Boolean environment variable can be used along with <code>$HOME</code> and <code>$XDG_CONFIG_HOME</code> to create a predictable environment for a picky script, or you can set it to true to temporarily avoid using a buggy <code>/etc/gitconfig</code> file while waiting for someone with sufficient permissions to fix it.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITFLUSHcode"> <code>GIT_FLUSH</code> </dt> <dd> <p>If this Boolean environment variable is set to true, then commands such as <code>git blame</code> (in incremental mode), <code>git rev-list</code>, <code>git log</code>, <code>git check-attr</code> and <code>git check-ignore</code> will force a flush of the output stream after each record have been flushed. If this variable is set to false, the output of these commands will be done using completely buffered I/O. If this environment variable is not set, Git will choose buffered or record-oriented flushing based on whether stdout appears to be redirected to a file or not.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTRACEcode"> <code>GIT_TRACE</code> </dt> <dd> <p>Enables general trace messages, e.g. alias expansion, built-in command execution and external command execution.</p> <p>If this variable is set to "1", "2" or "true" (comparison is case insensitive), trace messages will be printed to stderr.</p> <p>If the variable is set to an integer value greater than 2 and lower than 10 (strictly) then Git will interpret this value as an open file descriptor and will try to write the trace messages into this file descriptor.</p> <p>Alternatively, if the variable is set to an absolute path (starting with a <code>/</code> character), Git will interpret this as a file path and will try to append the trace messages to it.</p> <p>Unsetting the variable, or setting it to empty, "0" or "false" (case insensitive) disables trace messages.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTRACEFSMONITORcode"> <code>GIT_TRACE_FSMONITOR</code> </dt> <dd> <p>Enables trace messages for the filesystem monitor extension. See <code>GIT_TRACE</code> for available trace output options.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTRACEPACKACCESScode"> <code>GIT_TRACE_PACK_ACCESS</code> </dt> <dd> <p>Enables trace messages for all accesses to any packs. For each access, the pack file name and an offset in the pack is recorded. This may be helpful for troubleshooting some pack-related performance problems. See <code>GIT_TRACE</code> for available trace output options.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTRACEPACKETcode"> <code>GIT_TRACE_PACKET</code> </dt> <dd> <p>Enables trace messages for all packets coming in or out of a given program. This can help with debugging object negotiation or other protocol issues. Tracing is turned off at a packet starting with "PACK" (but see <code>GIT_TRACE_PACKFILE</code> below). See <code>GIT_TRACE</code> for available trace output options.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTRACEPACKFILEcode"> <code>GIT_TRACE_PACKFILE</code> </dt> <dd> <p>Enables tracing of packfiles sent or received by a given program. Unlike other trace output, this trace is verbatim: no headers, and no quoting of binary data. You almost certainly want to direct into a file (e.g., <code>GIT_TRACE_PACKFILE=/tmp/my.pack</code>) rather than displaying it on the terminal or mixing it with other trace output.</p> <p>Note that this is currently only implemented for the client side of clones and fetches.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTRACEPERFORMANCEcode"> <code>GIT_TRACE_PERFORMANCE</code> </dt> <dd> <p>Enables performance related trace messages, e.g. total execution time of each Git command. See <code>GIT_TRACE</code> for available trace output options.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTRACEREFScode"> <code>GIT_TRACE_REFS</code> </dt> <dd> <p>Enables trace messages for operations on the ref database. See <code>GIT_TRACE</code> for available trace output options.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTRACESETUPcode"> <code>GIT_TRACE_SETUP</code> </dt> <dd> <p>Enables trace messages printing the .git, working tree and current working directory after Git has completed its setup phase. See <code>GIT_TRACE</code> for available trace output options.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTRACESHALLOWcode"> <code>GIT_TRACE_SHALLOW</code> </dt> <dd> <p>Enables trace messages that can help debugging fetching / cloning of shallow repositories. See <code>GIT_TRACE</code> for available trace output options.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTRACECURLcode"> <code>GIT_TRACE_CURL</code> </dt> <dd> <p>Enables a curl full trace dump of all incoming and outgoing data, including descriptive information, of the git transport protocol. This is similar to doing curl <code>--trace-ascii</code> on the command line. See <code>GIT_TRACE</code> for available trace output options.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTRACECURLNODATAcode"> <code>GIT_TRACE_CURL_NO_DATA</code> </dt> <dd> <p>When a curl trace is enabled (see <code>GIT_TRACE_CURL</code> above), do not dump data (that is, only dump info lines and headers).</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTRACE2code"> <code>GIT_TRACE2</code> </dt> <dd> <p>Enables more detailed trace messages from the "trace2" library. Output from <code>GIT_TRACE2</code> is a simple text-based format for human readability.</p> <p>If this variable is set to "1", "2" or "true" (comparison is case insensitive), trace messages will be printed to stderr.</p> <p>If the variable is set to an integer value greater than 2 and lower than 10 (strictly) then Git will interpret this value as an open file descriptor and will try to write the trace messages into this file descriptor.</p> <p>Alternatively, if the variable is set to an absolute path (starting with a <code>/</code> character), Git will interpret this as a file path and will try to append the trace messages to it. If the path already exists and is a directory, the trace messages will be written to files (one per process) in that directory, named according to the last component of the SID and an optional counter (to avoid filename collisions).</p> <p>In addition, if the variable is set to <code>af_unix:[<socket_type>:]<absolute-pathname></code>, Git will try to open the path as a Unix Domain Socket. The socket type can be either <code>stream</code> or <code>dgram</code>.</p> <p>Unsetting the variable, or setting it to empty, "0" or "false" (case insensitive) disables trace messages.</p> <p>See <a href="api-trace2">Trace2 documentation</a> for full details.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTRACE2EVENTcode"> <code>GIT_TRACE2_EVENT</code> </dt> <dd> <p>This setting writes a JSON-based format that is suited for machine interpretation. See <code>GIT_TRACE2</code> for available trace output options and <a href="api-trace2">Trace2 documentation</a> for full details.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTRACE2PERFcode"> <code>GIT_TRACE2_PERF</code> </dt> <dd> <p>In addition to the text-based messages available in <code>GIT_TRACE2</code>, this setting writes a column-based format for understanding nesting regions. See <code>GIT_TRACE2</code> for available trace output options and <a href="api-trace2">Trace2 documentation</a> for full details.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITTRACEREDACTcode"> <code>GIT_TRACE_REDACT</code> </dt> <dd> <p>By default, when tracing is activated, Git redacts the values of cookies, the "Authorization:" header, the "Proxy-Authorization:" header and packfile URIs. Set this Boolean environment variable to false to prevent this redaction.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITLITERALPATHSPECScode"> <code>GIT_LITERAL_PATHSPECS</code> </dt> <dd> <p>Setting this Boolean environment variable to true will cause Git to treat all pathspecs literally, rather than as glob patterns. For example, running <code>GIT_LITERAL_PATHSPECS=1 git log -- '*.c'</code> will search for commits that touch the path <code>*.c</code>, not any paths that the glob <code>*.c</code> matches. You might want this if you are feeding literal paths to Git (e.g., paths previously given to you by <code>git ls-tree</code>, <code>--raw</code> diff output, etc).</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITGLOBPATHSPECScode"> <code>GIT_GLOB_PATHSPECS</code> </dt> <dd> <p>Setting this Boolean environment variable to true will cause Git to treat all pathspecs as glob patterns (aka "glob" magic).</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITNOGLOBPATHSPECScode"> <code>GIT_NOGLOB_PATHSPECS</code> </dt> <dd> <p>Setting this Boolean environment variable to true will cause Git to treat all pathspecs as literal (aka "literal" magic).</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITICASEPATHSPECScode"> <code>GIT_ICASE_PATHSPECS</code> </dt> <dd> <p>Setting this Boolean environment variable to true will cause Git to treat all pathspecs as case-insensitive.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITREFLOGACTIONcode"> <code>GIT_REFLOG_ACTION</code> </dt> <dd> <p>When a ref is updated, reflog entries are created to keep track of the reason why the ref was updated (which is typically the name of the high-level command that updated the ref), in addition to the old and new values of the ref. A scripted Porcelain command can use set_reflog_action helper function in <code>git-sh-setup</code> to set its name to this variable when it is invoked as the top level command by the end user, to be recorded in the body of the reflog.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITREFPARANOIAcode"> <code>GIT_REF_PARANOIA</code> </dt> <dd> <p>If this Boolean environment variable is set to false, ignore broken or badly named refs when iterating over lists of refs. Normally Git will try to include any such refs, which may cause some operations to fail. This is usually preferable, as potentially destructive operations (e.g., <a href="git-prune">git-prune[1]</a>) are better off aborting rather than ignoring broken refs (and thus considering the history they point to as not worth saving). The default value is <code>1</code> (i.e., be paranoid about detecting and aborting all operations). You should not normally need to set this to <code>0</code>, but it may be useful when trying to salvage data from a corrupted repository.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITCOMMITGRAPHPARANOIAcode"> <code>GIT_COMMIT_GRAPH_PARANOIA</code> </dt> <dd> <p>When loading a commit object from the commit-graph, Git performs an existence check on the object in the object database. This is done to avoid issues with stale commit-graphs that contain references to already-deleted commits, but comes with a performance penalty.</p> <p>The default is "false", which disables the aforementioned behavior. Setting this to "true" enables the existence check so that stale commits will never be returned from the commit-graph at the cost of performance.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITALLOWPROTOCOLcode"> <code>GIT_ALLOW_PROTOCOL</code> </dt> <dd> <p>If set to a colon-separated list of protocols, behave as if <code>protocol.allow</code> is set to <code>never</code>, and each of the listed protocols has <code>protocol.<name>.allow</code> set to <code>always</code> (overriding any existing configuration). See the description of <code>protocol.allow</code> in <a href="git-config">git-config[1]</a> for more details.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITPROTOCOLFROMUSERcode"> <code>GIT_PROTOCOL_FROM_USER</code> </dt> <dd> <p>Set this Boolean environment variable to false to prevent protocols used by fetch/push/clone which are configured to the <code>user</code> state. This is useful to restrict recursive submodule initialization from an untrusted repository or for programs which feed potentially-untrusted URLS to git commands. See <a href="git-config">git-config[1]</a> for more details.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITPROTOCOLcode"> <code>GIT_PROTOCOL</code> </dt> <dd> <p>For internal use only. Used in handshaking the wire protocol. Contains a colon <code>:</code> separated list of keys with optional values <code>key[=value]</code>. Presence of unknown keys and values must be ignored.</p> <p>Note that servers may need to be configured to allow this variable to pass over some transports. It will be propagated automatically when accessing local repositories (i.e., <code>file://</code> or a filesystem path), as well as over the <code>git://</code> protocol. For git-over-http, it should work automatically in most configurations, but see the discussion in <a href="git-http-backend">git-http-backend[1]</a>. For git-over-ssh, the ssh server may need to be configured to allow clients to pass this variable (e.g., by using <code>AcceptEnv GIT_PROTOCOL</code> with OpenSSH).</p> <p>This configuration is optional. If the variable is not propagated, then clients will fall back to the original "v0" protocol (but may miss out on some performance improvements or features). This variable currently only affects clones and fetches; it is not yet used for pushes (but may be in the future).</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITOPTIONALLOCKScode"> <code>GIT_OPTIONAL_LOCKS</code> </dt> <dd> <p>If this Boolean environment variable is set to false, Git will complete any requested operation without performing any optional sub-operations that require taking a lock. For example, this will prevent <code>git status</code> from refreshing the index as a side effect. This is useful for processes running in the background which do not want to cause lock contention with other operations on the repository. Defaults to <code>1</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITREDIRECTSTDINcode"> <code>GIT_REDIRECT_STDIN</code> </dt> <dt class="hdlist1" id="Documentation/git.txt-codeGITREDIRECTSTDOUTcode"> <code>GIT_REDIRECT_STDOUT</code> </dt> <dt class="hdlist1" id="Documentation/git.txt-codeGITREDIRECTSTDERRcode"> <code>GIT_REDIRECT_STDERR</code> </dt> <dd> <p>Windows-only: allow redirecting the standard input/output/error handles to paths specified by the environment variables. This is particularly useful in multi-threaded applications where the canonical way to pass standard handles via <code>CreateProcess()</code> is not an option because it would require the handles to be marked inheritable (and consequently <strong>every</strong> spawned process would inherit them, possibly blocking regular Git operations). The primary intended use case is to use named pipes for communication (e.g. <code>\\.\pipe\my-git-stdin-123</code>).</p> <p>Two special values are supported: <code>off</code> will simply close the corresponding standard handle, and if <code>GIT_REDIRECT_STDERR</code> is <code>2>&1</code>, standard error will be redirected to the same handle as standard output.</p> </dd> <dt class="hdlist1" id="Documentation/git.txt-codeGITPRINTSHA1ELLIPSIScodedeprecated"> <code>GIT_PRINT_SHA1_ELLIPSIS</code> (deprecated) </dt> <dd> <p>If set to <code>yes</code>, print an ellipsis following an (abbreviated) SHA-1 value. This affects indications of detached HEADs (<a href="git-checkout">git-checkout[1]</a>) and the raw diff output (<a href="git-diff">git-diff[1]</a>). Printing an ellipsis in the cases mentioned is no longer considered adequate and support for it is likely to be removed in the foreseeable future (along with the variable).</p> </dd> </dl> </div> </div> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>More detail on the following is available from the <a href="user-manual#git-concepts">Git concepts chapter of the user-manual</a> and <a href="gitcore-tutorial">gitcore-tutorial[7]</a>.</p> <p>A Git project normally consists of a working directory with a ".git" subdirectory at the top level. The .git directory contains, among other things, a compressed object database representing the complete history of the project, an "index" file which links that history to the current contents of the working tree, and named pointers into that history such as tags and branch heads.</p> <p>The object database contains objects of three main types: blobs, which hold file data; trees, which point to blobs and other trees to build up directory hierarchies; and commits, which each reference a single tree and some number of parent commits.</p> <p>The commit, equivalent to what other systems call a "changeset" or "version", represents a step in the project’s history, and each parent represents an immediately preceding step. Commits with more than one parent represent merges of independent lines of development.</p> <p>All objects are named by the SHA-1 hash of their contents, normally written as a string of 40 hex digits. Such names are globally unique. The entire history leading up to a commit can be vouched for by signing just that commit. A fourth object type, the tag, is provided for this purpose.</p> <p>When first created, objects are stored in individual files, but for efficiency may later be compressed together into "pack files".</p> <p>Named pointers called refs mark interesting points in history. A ref may contain the SHA-1 name of an object or the name of another ref (the latter is called a "symbolic ref"). Refs with names beginning <code>refs/head/</code> contain the SHA-1 name of the most recent commit (or "head") of a branch under development. SHA-1 names of tags of interest are stored under <code>refs/tags/</code>. A symbolic ref named <code>HEAD</code> contains the name of the currently checked-out branch.</p> <p>The index file is initialized with a list of all paths and, for each path, a blob object and a set of attributes. The blob object represents the contents of the file as of the head of the current branch. The attributes (last modified time, size, etc.) are taken from the corresponding file in the working tree. Subsequent changes to the working tree can be found by comparing these attributes. The index may be updated with new content, and new commits may be created from the content stored in the index.</p> <p>The index is also capable of storing multiple entries (called "stages") for a given pathname. These stages are used to hold the various unmerged version of a file when a merge is in progress.</p> </div> <h2 id="_further_documentation">Further documentation</h2> <div class="sectionbody"> <p>See the references in the "description" section to get started using Git. The following is probably more detail than necessary for a first-time user.</p> <p>The <a href="user-manual#git-concepts">Git concepts chapter of the user-manual</a> and <a href="gitcore-tutorial">gitcore-tutorial[7]</a> both provide introductions to the underlying Git architecture.</p> <p>See <a href="gitworkflows">gitworkflows[7]</a> for an overview of recommended workflows.</p> <p>See also the <a href="howto-index">howto</a> documents for some useful examples.</p> <p>The internals are documented in the <a href="api-index">Git API documentation</a>.</p> <p>Users migrating from CVS may also want to read <a href="gitcvs-migration">gitcvs-migration[7]</a>.</p> </div> <h2 id="_authors">Authors</h2> <div class="sectionbody"> <p>Git was started by Linus Torvalds, and is currently maintained by Junio C Hamano. Numerous contributions have come from the Git mailing list <<a href="mailto:git@vger.kernel.org">git@vger.kernel.org</a>>. <a href="https://openhub.net/p/git/contributors/summary" class="bare">https://openhub.net/p/git/contributors/summary</a> gives you a more complete list of contributors.</p> <p>If you have a clone of git.git itself, the output of <a href="git-shortlog">git-shortlog[1]</a> and <a href="git-blame">git-blame[1]</a> can show you the authors for specific parts of the project.</p> </div> <h2 id="_reporting_bugs">Reporting bugs</h2> <div class="sectionbody"> <p>Report bugs to the Git mailing list <<a href="mailto:git@vger.kernel.org">git@vger.kernel.org</a>> where the development and maintenance is primarily done. You do not have to be subscribed to the list to send a message there. See the list archive at <a href="https://lore.kernel.org/git" class="bare">https://lore.kernel.org/git</a> for previous bug reports and other discussions.</p> <p>Issues which are security relevant should be disclosed privately to the Git Security mailing list <<a href="mailto:git-security@googlegroups.com">git-security@googlegroups.com</a>>.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gittutorial">gittutorial[7]</a>, <a href="gittutorial-2">gittutorial-2[7]</a>, <a href="giteveryday">giteveryday[7]</a>, <a href="gitcvs-migration">gitcvs-migration[7]</a>, <a href="gitglossary">gitglossary[7]</a>, <a href="gitcore-tutorial">gitcore-tutorial[7]</a>, <a href="gitcli">gitcli[7]</a>, <a href="user-manual">The Git User’s Manual</a>, <a href="gitworkflows">gitworkflows[7]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/git.html" class="_attribution-link">https://git-scm.com/docs/git.html</a> + </p> +</div> diff --git a/devdocs/git/gitattributes.html b/devdocs/git/gitattributes.html new file mode 100644 index 00000000..cac9839d --- /dev/null +++ b/devdocs/git/gitattributes.html @@ -0,0 +1,138 @@ +<h1>gitattributes</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitattributes - Defining attributes per path</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>$GIT_DIR/info/attributes, .gitattributes</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>A <code>gitattributes</code> file is a simple text file that gives <code>attributes</code> to pathnames.</p> <p>Each line in <code>gitattributes</code> file is of form:</p> <div class="literalblock"> <div class="content"> <pre>pattern attr1 attr2 ...</pre> </div> </div> <p>That is, a pattern followed by an attributes list, separated by whitespaces. Leading and trailing whitespaces are ignored. Lines that begin with <code>#</code> are ignored. Patterns that begin with a double quote are quoted in C style. When the pattern matches the path in question, the attributes listed on the line are given to the path.</p> <p>Each attribute can be in one of these states for a given path:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitattributes.txt-Set"> Set </dt> <dd> <p>The path has the attribute with special value "true"; this is specified by listing only the name of the attribute in the attribute list.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-Unset"> Unset </dt> <dd> <p>The path has the attribute with special value "false"; this is specified by listing the name of the attribute prefixed with a dash <code>-</code> in the attribute list.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-Settoavalue"> Set to a value </dt> <dd> <p>The path has the attribute with specified string value; this is specified by listing the name of the attribute followed by an equal sign <code>=</code> and its value in the attribute list.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-Unspecified"> Unspecified </dt> <dd> <p>No pattern matches the path, and nothing says if the path has or does not have the attribute, the attribute for the path is said to be Unspecified.</p> </dd> </dl> </div> <p>When more than one pattern matches the path, a later line overrides an earlier line. This overriding is done per attribute.</p> <p>The rules by which the pattern matches paths are the same as in <code>.gitignore</code> files (see <a href="gitignore">gitignore[5]</a>), with a few exceptions:</p> <div class="ulist"> <ul> <li> <p>negative patterns are forbidden</p> </li> <li> <p>patterns that match a directory do not recursively match paths inside that directory (so using the trailing-slash <code>path/</code> syntax is pointless in an attributes file; use <code>path/**</code> instead)</p> </li> </ul> </div> <p>When deciding what attributes are assigned to a path, Git consults <code>$GIT_DIR/info/attributes</code> file (which has the highest precedence), <code>.gitattributes</code> file in the same directory as the path in question, and its parent directories up to the toplevel of the work tree (the further the directory that contains <code>.gitattributes</code> is from the path in question, the lower its precedence). Finally global and system-wide files are considered (they have the lowest precedence).</p> <p>When the <code>.gitattributes</code> file is missing from the work tree, the path in the index is used as a fall-back. During checkout process, <code>.gitattributes</code> in the index is used and then the file in the working tree is used as a fall-back.</p> <p>If you wish to affect only a single repository (i.e., to assign attributes to files that are particular to one user’s workflow for that repository), then attributes should be placed in the <code>$GIT_DIR/info/attributes</code> file. Attributes which should be version-controlled and distributed to other repositories (i.e., attributes of interest to all users) should go into <code>.gitattributes</code> files. Attributes that should affect all repositories for a single user should be placed in a file specified by the <code>core.attributesFile</code> configuration option (see <a href="git-config">git-config[1]</a>). Its default value is $XDG_CONFIG_HOME/git/attributes. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/attributes is used instead. Attributes for all users on a system should be placed in the <code>$(prefix)/etc/gitattributes</code> file.</p> <p>Sometimes you would need to override a setting of an attribute for a path to <code>Unspecified</code> state. This can be done by listing the name of the attribute prefixed with an exclamation point <code>!</code>.</p> </div> <h2 id="_effects">Effects</h2> <div class="sectionbody"> <p>Certain operations by Git can be influenced by assigning particular attributes to a path. Currently, the following operations are attributes-aware.</p> <div class="sect2"> <h3 id="_checking_out_and_checking_in"> +Checking-out and checking-in</h3> <p>These attributes affect how the contents stored in the repository are copied to the working tree files when commands such as <code>git switch</code>, <code>git checkout</code> and <code>git merge</code> run. They also affect how Git stores the contents you prepare in the working tree in the repository upon <code>git add</code> and <code>git commit</code>.</p> <div class="sect3"> <h4 id="_text"> +<code>text</code> +</h4> <p>This attribute marks the path as a text file, which enables end-of-line conversion: When a matching file is added to the index, the file’s line endings are normalized to LF in the index. Conversely, when the file is copied from the index to the working directory, its line endings may be converted from LF to CRLF depending on the <code>eol</code> attribute, the Git config, and the platform (see explanation of <code>eol</code> below).</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitattributes.txt-Set-1"> Set </dt> <dd> <p>Setting the <code>text</code> attribute on a path enables end-of-line conversion on checkin and checkout as described above. Line endings are normalized to LF in the index every time the file is checked in, even if the file was previously added to Git with CRLF line endings.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-Unset-1"> Unset </dt> <dd> <p>Unsetting the <code>text</code> attribute on a path tells Git not to attempt any end-of-line conversion upon checkin or checkout.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-Settostringvalueauto"> Set to string value "auto" </dt> <dd> <p>When <code>text</code> is set to "auto", Git decides by itself whether the file is text or binary. If it is text and the file was not already in Git with CRLF endings, line endings are converted on checkin and checkout as described above. Otherwise, no conversion is done on checkin or checkout.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-Unspecified-1"> Unspecified </dt> <dd> <p>If the <code>text</code> attribute is unspecified, Git uses the <code>core.autocrlf</code> configuration variable to determine if the file should be converted.</p> </dd> </dl> </div> <p>Any other value causes Git to act as if <code>text</code> has been left unspecified.</p> </div> <div class="sect3"> <h4 id="_eol"> +<code>eol</code> +</h4> <p>This attribute marks a path to use a specific line-ending style in the working tree when it is checked out. It has effect only if <code>text</code> or <code>text=auto</code> is set (see above), but specifying <code>eol</code> automatically sets <code>text</code> if <code>text</code> was left unspecified.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitattributes.txt-Settostringvaluecrlf"> Set to string value "crlf" </dt> <dd> <p>This setting converts the file’s line endings in the working directory to CRLF when the file is checked out.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-Settostringvaluelf"> Set to string value "lf" </dt> <dd> <p>This setting uses the same line endings in the working directory as in the index when the file is checked out.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-Unspecified-1-1"> Unspecified </dt> <dd> <p>If the <code>eol</code> attribute is unspecified for a file, its line endings in the working directory are determined by the <code>core.autocrlf</code> or <code>core.eol</code> configuration variable (see the definitions of those options in <a href="git-config">git-config[1]</a>). If <code>text</code> is set but neither of those variables is, the default is <code>eol=crlf</code> on Windows and <code>eol=lf</code> on all other platforms.</p> </dd> </dl> </div> </div> <div class="sect3"> <h4 id="_backwards_compatibility_with_crlf_attribute"> +Backwards compatibility with <code>crlf</code> attribute</h4> <p>For backwards compatibility, the <code>crlf</code> attribute is interpreted as follows:</p> <div class="listingblock"> <div class="content"> <pre>crlf text +-crlf -text +crlf=input eol=lf</pre> </div> </div> </div> <div class="sect3"> <h4 id="_end_of_line_conversion"> +End-of-line conversion</h4> <p>While Git normally leaves file contents alone, it can be configured to normalize line endings to LF in the repository and, optionally, to convert them to CRLF when files are checked out.</p> <p>If you simply want to have CRLF line endings in your working directory regardless of the repository you are working with, you can set the config variable "core.autocrlf" without using any attributes.</p> <div class="listingblock"> <div class="content"> <pre>[core] + autocrlf = true</pre> </div> </div> <p>This does not force normalization of text files, but does ensure that text files that you introduce to the repository have their line endings normalized to LF when they are added, and that files that are already normalized in the repository stay normalized.</p> <p>If you want to ensure that text files that any contributor introduces to the repository have their line endings normalized, you can set the <code>text</code> attribute to "auto" for <code>all</code> files.</p> <div class="listingblock"> <div class="content"> <pre>* text=auto</pre> </div> </div> <p>The attributes allow a fine-grained control, how the line endings are converted. Here is an example that will make Git normalize .txt, .vcproj and .sh files, ensure that .vcproj files have CRLF and .sh files have LF in the working directory, and prevent .jpg files from being normalized regardless of their content.</p> <div class="listingblock"> <div class="content"> <pre>* text=auto +*.txt text +*.vcproj text eol=crlf +*.sh text eol=lf +*.jpg -text</pre> </div> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> When <code>text=auto</code> conversion is enabled in a cross-platform project using push and pull to a central repository the text files containing CRLFs should be normalized. </td> </tr> </table> </div> <p>From a clean working directory:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ echo "* text=auto" >.gitattributes +$ git add --renormalize . +$ git status # Show files that will be normalized +$ git commit -m "Introduce end-of-line normalization"</pre> </div> </div> <p>If any files that should not be normalized show up in <code>git status</code>, unset their <code>text</code> attribute before running <code>git add -u</code>.</p> <div class="listingblock"> <div class="content"> <pre>manual.pdf -text</pre> </div> </div> <p>Conversely, text files that Git does not detect can have normalization enabled manually.</p> <div class="listingblock"> <div class="content"> <pre>weirdchars.txt text</pre> </div> </div> <p>If <code>core.safecrlf</code> is set to "true" or "warn", Git verifies if the conversion is reversible for the current setting of <code>core.autocrlf</code>. For "true", Git rejects irreversible conversions; for "warn", Git only prints a warning but accepts an irreversible conversion. The safety triggers to prevent such a conversion done to the files in the work tree, but there are a few exceptions. Even though…</p> <div class="ulist"> <ul> <li> <p><code>git add</code> itself does not touch the files in the work tree, the next checkout would, so the safety triggers;</p> </li> <li> <p><code>git apply</code> to update a text file with a patch does touch the files in the work tree, but the operation is about text files and CRLF conversion is about fixing the line ending inconsistencies, so the safety does not trigger;</p> </li> <li> <p><code>git diff</code> itself does not touch the files in the work tree, it is often run to inspect the changes you intend to next <code>git add</code>. To catch potential problems early, safety triggers.</p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_working_tree_encoding"> +<code>working-tree-encoding</code> +</h4> <p>Git recognizes files encoded in ASCII or one of its supersets (e.g. UTF-8, ISO-8859-1, …) as text files. Files encoded in certain other encodings (e.g. UTF-16) are interpreted as binary and consequently built-in Git text processing tools (e.g. <code>git diff</code>) as well as most Git web front ends do not visualize the contents of these files by default.</p> <p>In these cases you can tell Git the encoding of a file in the working directory with the <code>working-tree-encoding</code> attribute. If a file with this attribute is added to Git, then Git re-encodes the content from the specified encoding to UTF-8. Finally, Git stores the UTF-8 encoded content in its internal data structure (called "the index"). On checkout the content is re-encoded back to the specified encoding.</p> <p>Please note that using the <code>working-tree-encoding</code> attribute may have a number of pitfalls:</p> <div class="ulist"> <ul> <li> <p>Alternative Git implementations (e.g. JGit or libgit2) and older Git versions (as of March 2018) do not support the <code>working-tree-encoding</code> attribute. If you decide to use the <code>working-tree-encoding</code> attribute in your repository, then it is strongly recommended to ensure that all clients working with the repository support it.</p> <p>For example, Microsoft Visual Studio resources files (<code>*.rc</code>) or PowerShell script files (<code>*.ps1</code>) are sometimes encoded in UTF-16. If you declare <code>*.ps1</code> as files as UTF-16 and you add <code>foo.ps1</code> with a <code>working-tree-encoding</code> enabled Git client, then <code>foo.ps1</code> will be stored as UTF-8 internally. A client without <code>working-tree-encoding</code> support will checkout <code>foo.ps1</code> as UTF-8 encoded file. This will typically cause trouble for the users of this file.</p> <p>If a Git client that does not support the <code>working-tree-encoding</code> attribute adds a new file <code>bar.ps1</code>, then <code>bar.ps1</code> will be stored "as-is" internally (in this example probably as UTF-16). A client with <code>working-tree-encoding</code> support will interpret the internal contents as UTF-8 and try to convert it to UTF-16 on checkout. That operation will fail and cause an error.</p> </li> <li> <p>Reencoding content to non-UTF encodings can cause errors as the conversion might not be UTF-8 round trip safe. If you suspect your encoding to not be round trip safe, then add it to <code>core.checkRoundtripEncoding</code> to make Git check the round trip encoding (see <a href="git-config">git-config[1]</a>). SHIFT-JIS (Japanese character set) is known to have round trip issues with UTF-8 and is checked by default.</p> </li> <li> <p>Reencoding content requires resources that might slow down certain Git operations (e.g <code>git checkout</code> or <code>git add</code>).</p> </li> </ul> </div> <p>Use the <code>working-tree-encoding</code> attribute only if you cannot store a file in UTF-8 encoding and if you want Git to be able to process the content as text.</p> <p>As an example, use the following attributes if your <code>*.ps1</code> files are UTF-16 encoded with byte order mark (BOM) and you want Git to perform automatic line ending conversion based on your platform.</p> <div class="listingblock"> <div class="content"> <pre>*.ps1 text working-tree-encoding=UTF-16</pre> </div> </div> <p>Use the following attributes if your <code>*.ps1</code> files are UTF-16 little endian encoded without BOM and you want Git to use Windows line endings in the working directory (use <code>UTF-16LE-BOM</code> instead of <code>UTF-16LE</code> if you want UTF-16 little endian with BOM). Please note, it is highly recommended to explicitly define the line endings with <code>eol</code> if the <code>working-tree-encoding</code> attribute is used to avoid ambiguity.</p> <div class="listingblock"> <div class="content"> <pre>*.ps1 text working-tree-encoding=UTF-16LE eol=CRLF</pre> </div> </div> <p>You can get a list of all available encodings on your platform with the following command:</p> <div class="listingblock"> <div class="content"> <pre>iconv --list</pre> </div> </div> <p>If you do not know the encoding of a file, then you can use the <code>file</code> command to guess the encoding:</p> <div class="listingblock"> <div class="content"> <pre>file foo.ps1</pre> </div> </div> </div> <div class="sect3"> <h4 id="_ident"> +<code>ident</code> +</h4> <p>When the attribute <code>ident</code> is set for a path, Git replaces <code>$Id$</code> in the blob object with <code>$Id:</code>, followed by the 40-character hexadecimal blob object name, followed by a dollar sign <code>$</code> upon checkout. Any byte sequence that begins with <code>$Id:</code> and ends with <code>$</code> in the worktree file is replaced with <code>$Id$</code> upon check-in.</p> </div> <div class="sect3"> <h4 id="_filter"> +<code>filter</code> +</h4> <p>A <code>filter</code> attribute can be set to a string value that names a filter driver specified in the configuration.</p> <p>A filter driver consists of a <code>clean</code> command and a <code>smudge</code> command, either of which can be left unspecified. Upon checkout, when the <code>smudge</code> command is specified, the command is fed the blob object from its standard input, and its standard output is used to update the worktree file. Similarly, the <code>clean</code> command is used to convert the contents of worktree file upon checkin. By default these commands process only a single blob and terminate. If a long running <code>process</code> filter is used in place of <code>clean</code> and/or <code>smudge</code> filters, then Git can process all blobs with a single filter command invocation for the entire life of a single Git command, for example <code>git add --all</code>. If a long running <code>process</code> filter is configured then it always takes precedence over a configured single blob filter. See section below for the description of the protocol used to communicate with a <code>process</code> filter.</p> <p>One use of the content filtering is to massage the content into a shape that is more convenient for the platform, filesystem, and the user to use. For this mode of operation, the key phrase here is "more convenient" and not "turning something unusable into usable". In other words, the intent is that if someone unsets the filter driver definition, or does not have the appropriate filter program, the project should still be usable.</p> <p>Another use of the content filtering is to store the content that cannot be directly used in the repository (e.g. a UUID that refers to the true content stored outside Git, or an encrypted content) and turn it into a usable form upon checkout (e.g. download the external content, or decrypt the encrypted content).</p> <p>These two filters behave differently, and by default, a filter is taken as the former, massaging the contents into more convenient shape. A missing filter driver definition in the config, or a filter driver that exits with a non-zero status, is not an error but makes the filter a no-op passthru.</p> <p>You can declare that a filter turns a content that by itself is unusable into a usable content by setting the filter.<driver>.required configuration variable to <code>true</code>.</p> <p>Note: Whenever the clean filter is changed, the repo should be renormalized: $ git add --renormalize .</p> <p>For example, in .gitattributes, you would assign the <code>filter</code> attribute for paths.</p> <div class="listingblock"> <div class="content"> <pre>*.c filter=indent</pre> </div> </div> <p>Then you would define a "filter.indent.clean" and "filter.indent.smudge" configuration in your .git/config to specify a pair of commands to modify the contents of C programs when the source files are checked in ("clean" is run) and checked out (no change is made because the command is "cat").</p> <div class="listingblock"> <div class="content"> <pre>[filter "indent"] + clean = indent + smudge = cat</pre> </div> </div> <p>For best results, <code>clean</code> should not alter its output further if it is run twice ("clean→clean" should be equivalent to "clean"), and multiple <code>smudge</code> commands should not alter <code>clean</code>'s output ("smudge→smudge→clean" should be equivalent to "clean"). See the section on merging below.</p> <p>The "indent" filter is well-behaved in this regard: it will not modify input that is already correctly indented. In this case, the lack of a smudge filter means that the clean filter <code>must</code> accept its own output without modifying it.</p> <p>If a filter <code>must</code> succeed in order to make the stored contents usable, you can declare that the filter is <code>required</code>, in the configuration:</p> <div class="listingblock"> <div class="content"> <pre>[filter "crypt"] + clean = openssl enc ... + smudge = openssl enc -d ... + required</pre> </div> </div> <p>Sequence "%f" on the filter command line is replaced with the name of the file the filter is working on. A filter might use this in keyword substitution. For example:</p> <div class="listingblock"> <div class="content"> <pre>[filter "p4"] + clean = git-p4-filter --clean %f + smudge = git-p4-filter --smudge %f</pre> </div> </div> <p>Note that "%f" is the name of the path that is being worked on. Depending on the version that is being filtered, the corresponding file on disk may not exist, or may have different contents. So, smudge and clean commands should not try to access the file on disk, but only act as filters on the content provided to them on standard input.</p> </div> <div class="sect3"> <h4 id="_long_running_filter_process"> +Long Running Filter Process</h4> <p>If the filter command (a string value) is defined via <code>filter.<driver>.process</code> then Git can process all blobs with a single filter invocation for the entire life of a single Git command. This is achieved by using the long-running process protocol (described in technical/long-running-process-protocol.txt).</p> <p>When Git encounters the first file that needs to be cleaned or smudged, it starts the filter and performs the handshake. In the handshake, the welcome message sent by Git is "git-filter-client", only version 2 is supported, and the supported capabilities are "clean", "smudge", and "delay".</p> <p>Afterwards Git sends a list of "key=value" pairs terminated with a flush packet. The list will contain at least the filter command (based on the supported capabilities) and the pathname of the file to filter relative to the repository root. Right after the flush packet Git sends the content split in zero or more pkt-line packets and a flush packet to terminate content. Please note, that the filter must not send any response before it received the content and the final flush packet. Also note that the "value" of a "key=value" pair can contain the "=" character whereas the key would never contain that character.</p> <div class="listingblock"> <div class="content"> <pre>packet: git> command=smudge +packet: git> pathname=path/testfile.dat +packet: git> 0000 +packet: git> CONTENT +packet: git> 0000</pre> </div> </div> <p>The filter is expected to respond with a list of "key=value" pairs terminated with a flush packet. If the filter does not experience problems then the list must contain a "success" status. Right after these packets the filter is expected to send the content in zero or more pkt-line packets and a flush packet at the end. Finally, a second list of "key=value" pairs terminated with a flush packet is expected. The filter can change the status in the second list or keep the status as is with an empty list. Please note that the empty list must be terminated with a flush packet regardless.</p> <div class="listingblock"> <div class="content"> <pre>packet: git< status=success +packet: git< 0000 +packet: git< SMUDGED_CONTENT +packet: git< 0000 +packet: git< 0000 # empty list, keep "status=success" unchanged!</pre> </div> </div> <p>If the result content is empty then the filter is expected to respond with a "success" status and a flush packet to signal the empty content.</p> <div class="listingblock"> <div class="content"> <pre>packet: git< status=success +packet: git< 0000 +packet: git< 0000 # empty content! +packet: git< 0000 # empty list, keep "status=success" unchanged!</pre> </div> </div> <p>In case the filter cannot or does not want to process the content, it is expected to respond with an "error" status.</p> <div class="listingblock"> <div class="content"> <pre>packet: git< status=error +packet: git< 0000</pre> </div> </div> <p>If the filter experiences an error during processing, then it can send the status "error" after the content was (partially or completely) sent.</p> <div class="listingblock"> <div class="content"> <pre>packet: git< status=success +packet: git< 0000 +packet: git< HALF_WRITTEN_ERRONEOUS_CONTENT +packet: git< 0000 +packet: git< status=error +packet: git< 0000</pre> </div> </div> <p>In case the filter cannot or does not want to process the content as well as any future content for the lifetime of the Git process, then it is expected to respond with an "abort" status at any point in the protocol.</p> <div class="listingblock"> <div class="content"> <pre>packet: git< status=abort +packet: git< 0000</pre> </div> </div> <p>Git neither stops nor restarts the filter process in case the "error"/"abort" status is set. However, Git sets its exit code according to the <code>filter.<driver>.required</code> flag, mimicking the behavior of the <code>filter.<driver>.clean</code> / <code>filter.<driver>.smudge</code> mechanism.</p> <p>If the filter dies during the communication or does not adhere to the protocol then Git will stop the filter process and restart it with the next file that needs to be processed. Depending on the <code>filter.<driver>.required</code> flag Git will interpret that as error.</p> </div> <div class="sect3"> <h4 id="_delay"> +Delay</h4> <p>If the filter supports the "delay" capability, then Git can send the flag "can-delay" after the filter command and pathname. This flag denotes that the filter can delay filtering the current blob (e.g. to compensate network latencies) by responding with no content but with the status "delayed" and a flush packet.</p> <div class="listingblock"> <div class="content"> <pre>packet: git> command=smudge +packet: git> pathname=path/testfile.dat +packet: git> can-delay=1 +packet: git> 0000 +packet: git> CONTENT +packet: git> 0000 +packet: git< status=delayed +packet: git< 0000</pre> </div> </div> <p>If the filter supports the "delay" capability then it must support the "list_available_blobs" command. If Git sends this command, then the filter is expected to return a list of pathnames representing blobs that have been delayed earlier and are now available. The list must be terminated with a flush packet followed by a "success" status that is also terminated with a flush packet. If no blobs for the delayed paths are available, yet, then the filter is expected to block the response until at least one blob becomes available. The filter can tell Git that it has no more delayed blobs by sending an empty list. As soon as the filter responds with an empty list, Git stops asking. All blobs that Git has not received at this point are considered missing and will result in an error.</p> <div class="listingblock"> <div class="content"> <pre>packet: git> command=list_available_blobs +packet: git> 0000 +packet: git< pathname=path/testfile.dat +packet: git< pathname=path/otherfile.dat +packet: git< 0000 +packet: git< status=success +packet: git< 0000</pre> </div> </div> <p>After Git received the pathnames, it will request the corresponding blobs again. These requests contain a pathname and an empty content section. The filter is expected to respond with the smudged content in the usual way as explained above.</p> <div class="listingblock"> <div class="content"> <pre>packet: git> command=smudge +packet: git> pathname=path/testfile.dat +packet: git> 0000 +packet: git> 0000 # empty content! +packet: git< status=success +packet: git< 0000 +packet: git< SMUDGED_CONTENT +packet: git< 0000 +packet: git< 0000 # empty list, keep "status=success" unchanged!</pre> </div> </div> </div> <div class="sect3"> <h4 id="_example"> +Example</h4> <p>A long running filter demo implementation can be found in <code>contrib/long-running-filter/example.pl</code> located in the Git core repository. If you develop your own long running filter process then the <code>GIT_TRACE_PACKET</code> environment variables can be very helpful for debugging (see <a href="git">git[1]</a>).</p> <p>Please note that you cannot use an existing <code>filter.<driver>.clean</code> or <code>filter.<driver>.smudge</code> command with <code>filter.<driver>.process</code> because the former two use a different inter process communication protocol than the latter one.</p> </div> <div class="sect3"> <h4 id="_interaction_between_checkincheckout_attributes"> +Interaction between checkin/checkout attributes</h4> <p>In the check-in codepath, the worktree file is first converted with <code>filter</code> driver (if specified and corresponding driver defined), then the result is processed with <code>ident</code> (if specified), and then finally with <code>text</code> (again, if specified and applicable).</p> <p>In the check-out codepath, the blob content is first converted with <code>text</code>, and then <code>ident</code> and fed to <code>filter</code>.</p> </div> <div class="sect3"> <h4 id="_merging_branches_with_differing_checkincheckout_attributes"> +Merging branches with differing checkin/checkout attributes</h4> <p>If you have added attributes to a file that cause the canonical repository format for that file to change, such as adding a clean/smudge filter or text/eol/ident attributes, merging anything where the attribute is not in place would normally cause merge conflicts.</p> <p>To prevent these unnecessary merge conflicts, Git can be told to run a virtual check-out and check-in of all three stages of a file when resolving a three-way merge by setting the <code>merge.renormalize</code> configuration variable. This prevents changes caused by check-in conversion from causing spurious merge conflicts when a converted file is merged with an unconverted file.</p> <p>As long as a "smudge→clean" results in the same output as a "clean" even on files that are already smudged, this strategy will automatically resolve all filter-related conflicts. Filters that do not act in this way may cause additional merge conflicts that must be resolved manually.</p> </div> </div> <div class="sect2"> <h3 id="_generating_diff_text"> +Generating diff text</h3> <div class="sect3"> <h4 id="_diff"> +<code>diff</code> +</h4> <p>The attribute <code>diff</code> affects how Git generates diffs for particular files. It can tell Git whether to generate a textual patch for the path or to treat the path as a binary file. It can also affect what line is shown on the hunk header <code>@@ -k,l +n,m @@</code> line, tell Git to use an external command to generate the diff, or ask Git to convert binary files to a text format before generating the diff.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitattributes.txt-Set-1-1"> Set </dt> <dd> <p>A path to which the <code>diff</code> attribute is set is treated as text, even when they contain byte values that normally never appear in text files, such as NUL.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-Unset-1-1"> Unset </dt> <dd> <p>A path to which the <code>diff</code> attribute is unset will generate <code>Binary files differ</code> (or a binary patch, if binary patches are enabled).</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-Unspecified-1-1-1"> Unspecified </dt> <dd> <p>A path to which the <code>diff</code> attribute is unspecified first gets its contents inspected, and if it looks like text and is smaller than core.bigFileThreshold, it is treated as text. Otherwise it would generate <code>Binary files differ</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-String"> String </dt> <dd> <p>Diff is shown using the specified diff driver. Each driver may specify one or more options, as described in the following section. The options for the diff driver "foo" are defined by the configuration variables in the "diff.foo" section of the Git config file.</p> </dd> </dl> </div> </div> <div class="sect3"> <h4 id="_defining_an_external_diff_driver"> +Defining an external diff driver</h4> <p>The definition of a diff driver is done in <code>gitconfig</code>, not <code>gitattributes</code> file, so strictly speaking this manual page is a wrong place to talk about it. However…</p> <p>To define an external diff driver <code>jcdiff</code>, add a section to your <code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p> <div class="listingblock"> <div class="content"> <pre>[diff "jcdiff"] + command = j-c-diff</pre> </div> </div> <p>When Git needs to show you a diff for the path with <code>diff</code> attribute set to <code>jcdiff</code>, it calls the command you specified with the above configuration, i.e. <code>j-c-diff</code>, with 7 parameters, just like <code>GIT_EXTERNAL_DIFF</code> program is called. See <a href="git">git[1]</a> for details.</p> </div> <div class="sect3"> <h4 id="_setting_the_internal_diff_algorithm"> +Setting the internal diff algorithm</h4> <p>The diff algorithm can be set through the <code>diff.algorithm</code> config key, but sometimes it may be helpful to set the diff algorithm per path. For example, one may want to use the <code>minimal</code> diff algorithm for .json files, and the <code>histogram</code> for .c files, and so on without having to pass in the algorithm through the command line each time.</p> <p>First, in <code>.gitattributes</code>, assign the <code>diff</code> attribute for paths.</p> <div class="listingblock"> <div class="content"> <pre>*.json diff=<name></pre> </div> </div> <p>Then, define a "diff.<name>.algorithm" configuration to specify the diff algorithm, choosing from <code>myers</code>, <code>patience</code>, <code>minimal</code>, or <code>histogram</code>.</p> <div class="listingblock"> <div class="content"> <pre>[diff "<name>"] + algorithm = histogram</pre> </div> </div> <p>This diff algorithm applies to user facing diff output like git-diff(1), git-show(1) and is used for the <code>--stat</code> output as well. The merge machinery will not use the diff algorithm set through this method.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> If <code>diff.<name>.command</code> is defined for path with the <code>diff=<name></code> attribute, it is executed as an external diff driver (see above), and adding <code>diff.<name>.algorithm</code> has no effect, as the algorithm is not passed to the external diff driver. </td> </tr> </table> </div> </div> <div class="sect3"> <h4 id="_defining_a_custom_hunk_header"> +Defining a custom hunk-header</h4> <p>Each group of changes (called a "hunk") in the textual diff output is prefixed with a line of the form:</p> <div class="literalblock"> <div class="content"> <pre>@@ -k,l +n,m @@ TEXT</pre> </div> </div> <p>This is called a <code>hunk header</code>. The "TEXT" portion is by default a line that begins with an alphabet, an underscore or a dollar sign; this matches what GNU <code>diff -p</code> output uses. This default selection however is not suited for some contents, and you can use a customized pattern to make a selection.</p> <p>First, in .gitattributes, you would assign the <code>diff</code> attribute for paths.</p> <div class="listingblock"> <div class="content"> <pre>*.tex diff=tex</pre> </div> </div> <p>Then, you would define a "diff.tex.xfuncname" configuration to specify a regular expression that matches a line that you would want to appear as the hunk header "TEXT". Add a section to your <code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p> <div class="listingblock"> <div class="content"> <pre>[diff "tex"] + xfuncname = "^(\\\\(sub)*section\\{.*)$"</pre> </div> </div> <p>Note. A single level of backslashes are eaten by the configuration file parser, so you would need to double the backslashes; the pattern above picks a line that begins with a backslash, and zero or more occurrences of <code>sub</code> followed by <code>section</code> followed by open brace, to the end of line.</p> <p>There are a few built-in patterns to make this easier, and <code>tex</code> is one of them, so you do not have to write the above in your configuration file (you still need to enable this with the attribute mechanism, via <code>.gitattributes</code>). The following built in patterns are available:</p> <div class="ulist"> <ul> <li> <p><code>ada</code> suitable for source code in the Ada language.</p> </li> <li> <p><code>bash</code> suitable for source code in the Bourne-Again SHell language. Covers a superset of POSIX shell function definitions.</p> </li> <li> <p><code>bibtex</code> suitable for files with BibTeX coded references.</p> </li> <li> <p><code>cpp</code> suitable for source code in the C and C++ languages.</p> </li> <li> <p><code>csharp</code> suitable for source code in the C# language.</p> </li> <li> <p><code>css</code> suitable for cascading style sheets.</p> </li> <li> <p><code>dts</code> suitable for devicetree (DTS) files.</p> </li> <li> <p><code>elixir</code> suitable for source code in the Elixir language.</p> </li> <li> <p><code>fortran</code> suitable for source code in the Fortran language.</p> </li> <li> <p><code>fountain</code> suitable for Fountain documents.</p> </li> <li> <p><code>golang</code> suitable for source code in the Go language.</p> </li> <li> <p><code>html</code> suitable for HTML/XHTML documents.</p> </li> <li> <p><code>java</code> suitable for source code in the Java language.</p> </li> <li> <p><code>kotlin</code> suitable for source code in the Kotlin language.</p> </li> <li> <p><code>markdown</code> suitable for Markdown documents.</p> </li> <li> <p><code>matlab</code> suitable for source code in the MATLAB and Octave languages.</p> </li> <li> <p><code>objc</code> suitable for source code in the Objective-C language.</p> </li> <li> <p><code>pascal</code> suitable for source code in the Pascal/Delphi language.</p> </li> <li> <p><code>perl</code> suitable for source code in the Perl language.</p> </li> <li> <p><code>php</code> suitable for source code in the PHP language.</p> </li> <li> <p><code>python</code> suitable for source code in the Python language.</p> </li> <li> <p><code>ruby</code> suitable for source code in the Ruby language.</p> </li> <li> <p><code>rust</code> suitable for source code in the Rust language.</p> </li> <li> <p><code>scheme</code> suitable for source code in the Scheme language.</p> </li> <li> <p><code>tex</code> suitable for source code for LaTeX documents.</p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_customizing_word_diff"> +Customizing word diff</h4> <p>You can customize the rules that <code>git diff --word-diff</code> uses to split words in a line, by specifying an appropriate regular expression in the "diff.*.wordRegex" configuration variable. For example, in TeX a backslash followed by a sequence of letters forms a command, but several such commands can be run together without intervening whitespace. To separate them, use a regular expression in your <code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p> <div class="listingblock"> <div class="content"> <pre>[diff "tex"] + wordRegex = "\\\\[a-zA-Z]+|[{}]|\\\\.|[^\\{}[:space:]]+"</pre> </div> </div> <p>A built-in pattern is provided for all languages listed in the previous section.</p> </div> <div class="sect3"> <h4 id="_performing_text_diffs_of_binary_files"> +Performing text diffs of binary files</h4> <p>Sometimes it is desirable to see the diff of a text-converted version of some binary files. For example, a word processor document can be converted to an ASCII text representation, and the diff of the text shown. Even though this conversion loses some information, the resulting diff is useful for human viewing (but cannot be applied directly).</p> <p>The <code>textconv</code> config option is used to define a program for performing such a conversion. The program should take a single argument, the name of a file to convert, and produce the resulting text on stdout.</p> <p>For example, to show the diff of the exif information of a file instead of the binary information (assuming you have the exif tool installed), add the following section to your <code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file):</p> <div class="listingblock"> <div class="content"> <pre>[diff "jpg"] + textconv = exif</pre> </div> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> The text conversion is generally a one-way conversion; in this example, we lose the actual image contents and focus just on the text data. This means that diffs generated by textconv are <em>not</em> suitable for applying. For this reason, only <code>git diff</code> and the <code>git log</code> family of commands (i.e., log, whatchanged, show) will perform text conversion. <code>git +format-patch</code> will never generate this output. If you want to send somebody a text-converted diff of a binary file (e.g., because it quickly conveys the changes you have made), you should generate it separately and send it as a comment <em>in addition to</em> the usual binary diff that you might send. </td> </tr> </table> </div> <p>Because text conversion can be slow, especially when doing a large number of them with <code>git log -p</code>, Git provides a mechanism to cache the output and use it in future diffs. To enable caching, set the "cachetextconv" variable in your diff driver’s config. For example:</p> <div class="listingblock"> <div class="content"> <pre>[diff "jpg"] + textconv = exif + cachetextconv = true</pre> </div> </div> <p>This will cache the result of running "exif" on each blob indefinitely. If you change the textconv config variable for a diff driver, Git will automatically invalidate the cache entries and re-run the textconv filter. If you want to invalidate the cache manually (e.g., because your version of "exif" was updated and now produces better output), you can remove the cache manually with <code>git update-ref -d refs/notes/textconv/jpg</code> (where "jpg" is the name of the diff driver, as in the example above).</p> </div> <div class="sect3"> <h4 id="_choosing_textconv_versus_external_diff"> +Choosing textconv versus external diff</h4> <p>If you want to show differences between binary or specially-formatted blobs in your repository, you can choose to use either an external diff command, or to use textconv to convert them to a diff-able text format. Which method you choose depends on your exact situation.</p> <p>The advantage of using an external diff command is flexibility. You are not bound to find line-oriented changes, nor is it necessary for the output to resemble unified diff. You are free to locate and report changes in the most appropriate way for your data format.</p> <p>A textconv, by comparison, is much more limiting. You provide a transformation of the data into a line-oriented text format, and Git uses its regular diff tools to generate the output. There are several advantages to choosing this method:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Ease of use. It is often much simpler to write a binary to text transformation than it is to perform your own diff. In many cases, existing programs can be used as textconv filters (e.g., exif, odt2txt).</p> </li> <li> <p>Git diff features. By performing only the transformation step yourself, you can still utilize many of Git’s diff features, including colorization, word-diff, and combined diffs for merges.</p> </li> <li> <p>Caching. Textconv caching can speed up repeated diffs, such as those you might trigger by running <code>git log -p</code>.</p> </li> </ol> </div> </div> <div class="sect3"> <h4 id="_marking_files_as_binary"> +Marking files as binary</h4> <p>Git usually guesses correctly whether a blob contains text or binary data by examining the beginning of the contents. However, sometimes you may want to override its decision, either because a blob contains binary data later in the file, or because the content, while technically composed of text characters, is opaque to a human reader. For example, many postscript files contain only ASCII characters, but produce noisy and meaningless diffs.</p> <p>The simplest way to mark a file as binary is to unset the diff attribute in the <code>.gitattributes</code> file:</p> <div class="listingblock"> <div class="content"> <pre>*.ps -diff</pre> </div> </div> <p>This will cause Git to generate <code>Binary files differ</code> (or a binary patch, if binary patches are enabled) instead of a regular diff.</p> <p>However, one may also want to specify other diff driver attributes. For example, you might want to use <code>textconv</code> to convert postscript files to an ASCII representation for human viewing, but otherwise treat them as binary files. You cannot specify both <code>-diff</code> and <code>diff=ps</code> attributes. The solution is to use the <code>diff.*.binary</code> config option:</p> <div class="listingblock"> <div class="content"> <pre>[diff "ps"] + textconv = ps2ascii + binary = true</pre> </div> </div> </div> </div> <div class="sect2"> <h3 id="_performing_a_three_way_merge"> +Performing a three-way merge</h3> <div class="sect3"> <h4 id="_merge"> +<code>merge</code> +</h4> <p>The attribute <code>merge</code> affects how three versions of a file are merged when a file-level merge is necessary during <code>git merge</code>, and other commands such as <code>git revert</code> and <code>git cherry-pick</code>.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitattributes.txt-Set-1-1-1"> Set </dt> <dd> <p>Built-in 3-way merge driver is used to merge the contents in a way similar to <code>merge</code> command of <code>RCS</code> suite. This is suitable for ordinary text files.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-Unset-1-1-1"> Unset </dt> <dd> <p>Take the version from the current branch as the tentative merge result, and declare that the merge has conflicts. This is suitable for binary files that do not have a well-defined merge semantics.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-Unspecified-1-1-1-1"> Unspecified </dt> <dd> <p>By default, this uses the same built-in 3-way merge driver as is the case when the <code>merge</code> attribute is set. However, the <code>merge.default</code> configuration variable can name different merge driver to be used with paths for which the <code>merge</code> attribute is unspecified.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-String-1"> String </dt> <dd> <p>3-way merge is performed using the specified custom merge driver. The built-in 3-way merge driver can be explicitly specified by asking for "text" driver; the built-in "take the current branch" driver can be requested with "binary".</p> </dd> </dl> </div> </div> <div class="sect3"> <h4 id="_built_in_merge_drivers"> +Built-in merge drivers</h4> <p>There are a few built-in low-level merge drivers defined that can be asked for via the <code>merge</code> attribute.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitattributes.txt-text"> text </dt> <dd> <p>Usual 3-way file level merge for text files. Conflicted regions are marked with conflict markers <code><<<<<<<</code>, <code>=======</code> and <code>>>>>>>></code>. The version from your branch appears before the <code>=======</code> marker, and the version from the merged branch appears after the <code>=======</code> marker.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-binary"> binary </dt> <dd> <p>Keep the version from your branch in the work tree, but leave the path in the conflicted state for the user to sort out.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-union"> union </dt> <dd> <p>Run 3-way file level merge for text files, but take lines from both versions, instead of leaving conflict markers. This tends to leave the added lines in the resulting file in random order and the user should verify the result. Do not use this if you do not understand the implications.</p> </dd> </dl> </div> </div> <div class="sect3"> <h4 id="_defining_a_custom_merge_driver"> +Defining a custom merge driver</h4> <p>The definition of a merge driver is done in the <code>.git/config</code> file, not in the <code>gitattributes</code> file, so strictly speaking this manual page is a wrong place to talk about it. However…</p> <p>To define a custom merge driver <code>filfre</code>, add a section to your <code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p> <div class="listingblock"> <div class="content"> <pre>[merge "filfre"] + name = feel-free merge driver + driver = filfre %O %A %B %L %P + recursive = binary</pre> </div> </div> <p>The <code>merge.*.name</code> variable gives the driver a human-readable name.</p> <p>The <code>merge.*.driver</code> variable’s value is used to construct a command to run to merge ancestor’s version (<code>%O</code>), current version (<code>%A</code>) and the other branches' version (<code>%B</code>). These three tokens are replaced with the names of temporary files that hold the contents of these versions when the command line is built. Additionally, %L will be replaced with the conflict marker size (see below).</p> <p>The merge driver is expected to leave the result of the merge in the file named with <code>%A</code> by overwriting it, and exit with zero status if it managed to merge them cleanly, or non-zero if there were conflicts. When the driver crashes (e.g. killed by SEGV), it is expected to exit with non-zero status that are higher than 128, and in such a case, the merge results in a failure (which is different from producing a conflict).</p> <p>The <code>merge.*.recursive</code> variable specifies what other merge driver to use when the merge driver is called for an internal merge between common ancestors, when there are more than one. When left unspecified, the driver itself is used for both internal merge and the final merge.</p> <p>The merge driver can learn the pathname in which the merged result will be stored via placeholder <code>%P</code>.</p> </div> <div class="sect3"> <h4 id="_conflict_marker_size"> +<code>conflict-marker-size</code> +</h4> <p>This attribute controls the length of conflict markers left in the work tree file during a conflicted merge. Only a positive integer has a meaningful effect.</p> <p>For example, this line in <code>.gitattributes</code> can be used to tell the merge machinery to leave much longer (instead of the usual 7-character-long) conflict markers when merging the file <code>Documentation/git-merge.txt</code> results in a conflict.</p> <div class="listingblock"> <div class="content"> <pre>Documentation/git-merge.txt conflict-marker-size=32</pre> </div> </div> </div> </div> <div class="sect2"> <h3 id="_checking_whitespace_errors"> +Checking whitespace errors</h3> <div class="sect3"> <h4 id="_whitespace"> +<code>whitespace</code> +</h4> <p>The <code>core.whitespace</code> configuration variable allows you to define what <code>diff</code> and <code>apply</code> should consider whitespace errors for all paths in the project (See <a href="git-config">git-config[1]</a>). This attribute gives you finer control per path.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitattributes.txt-Set-1-1-1-1"> Set </dt> <dd> <p>Notice all types of potential whitespace errors known to Git. The tab width is taken from the value of the <code>core.whitespace</code> configuration variable.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-Unset-1-1-1-1"> Unset </dt> <dd> <p>Do not notice anything as error.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-Unspecified-1-1-1-1-1"> Unspecified </dt> <dd> <p>Use the value of the <code>core.whitespace</code> configuration variable to decide what to notice as error.</p> </dd> <dt class="hdlist1" id="Documentation/gitattributes.txt-String-1-1"> String </dt> <dd> <p>Specify a comma separated list of common whitespace problems to notice in the same format as the <code>core.whitespace</code> configuration variable.</p> </dd> </dl> </div> </div> </div> <div class="sect2"> <h3 id="_creating_an_archive"> +Creating an archive</h3> <div class="sect3"> <h4 id="_export_ignore"> +<code>export-ignore</code> +</h4> <p>Files and directories with the attribute <code>export-ignore</code> won’t be added to archive files.</p> </div> <div class="sect3"> <h4 id="_export_subst"> +<code>export-subst</code> +</h4> <p>If the attribute <code>export-subst</code> is set for a file then Git will expand several placeholders when adding this file to an archive. The expansion depends on the availability of a commit ID, i.e., if <a href="git-archive">git-archive[1]</a> has been given a tree instead of a commit or a tag then no replacement will be done. The placeholders are the same as those for the option <code>--pretty=format:</code> of <a href="git-log">git-log[1]</a>, except that they need to be wrapped like this: <code>$Format:PLACEHOLDERS$</code> in the file. E.g. the string <code>$Format:%H$</code> will be replaced by the commit hash. However, only one <code>%(describe)</code> placeholder is expanded per archive to avoid denial-of-service attacks.</p> </div> </div> <div class="sect2"> <h3 id="_packing_objects"> +Packing objects</h3> <div class="sect3"> <h4 id="_delta"> +<code>delta</code> +</h4> <p>Delta compression will not be attempted for blobs for paths with the attribute <code>delta</code> set to false.</p> </div> </div> <div class="sect2"> <h3 id="_viewing_files_in_gui_tools"> +Viewing files in GUI tools</h3> <div class="sect3"> <h4 id="_encoding"> +<code>encoding</code> +</h4> <p>The value of this attribute specifies the character encoding that should be used by GUI tools (e.g. <a href="gitk">gitk[1]</a> and <a href="git-gui">git-gui[1]</a>) to display the contents of the relevant file. Note that due to performance considerations <a href="gitk">gitk[1]</a> does not use this attribute unless you manually enable per-file encodings in its options.</p> <p>If this attribute is not set or has an invalid value, the value of the <code>gui.encoding</code> configuration variable is used instead (See <a href="git-config">git-config[1]</a>).</p> </div> </div> </div> <h2 id="_using_macro_attributes">Using macro attributes</h2> <div class="sectionbody"> <p>You do not want any end-of-line conversions applied to, nor textual diffs produced for, any binary file you track. You would need to specify e.g.</p> <div class="listingblock"> <div class="content"> <pre>*.jpg -text -diff</pre> </div> </div> <p>but that may become cumbersome, when you have many attributes. Using macro attributes, you can define an attribute that, when set, also sets or unsets a number of other attributes at the same time. The system knows a built-in macro attribute, <code>binary</code>:</p> <div class="listingblock"> <div class="content"> <pre>*.jpg binary</pre> </div> </div> <p>Setting the "binary" attribute also unsets the "text" and "diff" attributes as above. Note that macro attributes can only be "Set", though setting one might have the effect of setting or unsetting other attributes or even returning other attributes to the "Unspecified" state.</p> </div> <h2 id="_defining_macro_attributes">Defining macro attributes</h2> <div class="sectionbody"> <p>Custom macro attributes can be defined only in top-level gitattributes files (<code>$GIT_DIR/info/attributes</code>, the <code>.gitattributes</code> file at the top level of the working tree, or the global or system-wide gitattributes files), not in <code>.gitattributes</code> files in working tree subdirectories. The built-in macro attribute "binary" is equivalent to:</p> <div class="listingblock"> <div class="content"> <pre>[attr]binary -diff -merge -text</pre> </div> </div> </div> <h2 id="_notes">Notes</h2> <div class="sectionbody"> <p>Git does not follow symbolic links when accessing a <code>.gitattributes</code> file in the working tree. This keeps behavior consistent when the file is accessed from the index or a tree versus from the filesystem.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>If you have these three <code>gitattributes</code> file:</p> <div class="listingblock"> <div class="content"> <pre>(in $GIT_DIR/info/attributes) + +a* foo !bar -baz + +(in .gitattributes) +abc foo bar baz + +(in t/.gitattributes) +ab* merge=filfre +abc -foo -bar +*.c frotz</pre> </div> </div> <p>the attributes given to path <code>t/abc</code> are computed as follows:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>By examining <code>t/.gitattributes</code> (which is in the same directory as the path in question), Git finds that the first line matches. <code>merge</code> attribute is set. It also finds that the second line matches, and attributes <code>foo</code> and <code>bar</code> are unset.</p> </li> <li> <p>Then it examines <code>.gitattributes</code> (which is in the parent directory), and finds that the first line matches, but <code>t/.gitattributes</code> file already decided how <code>merge</code>, <code>foo</code> and <code>bar</code> attributes should be given to this path, so it leaves <code>foo</code> and <code>bar</code> unset. Attribute <code>baz</code> is set.</p> </li> <li> <p>Finally it examines <code>$GIT_DIR/info/attributes</code>. This file is used to override the in-tree settings. The first line is a match, and <code>foo</code> is set, <code>bar</code> is reverted to unspecified state, and <code>baz</code> is unset.</p> </li> </ol> </div> <p>As the result, the attributes assignment to <code>t/abc</code> becomes:</p> <div class="listingblock"> <div class="content"> <pre>foo set to true +bar unspecified +baz set to false +merge set to string value "filfre" +frotz unspecified</pre> </div> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-check-attr">git-check-attr[1]</a>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitattributes" class="_attribution-link">https://git-scm.com/docs/gitattributes</a> + </p> +</div> diff --git a/devdocs/git/gitcli.html b/devdocs/git/gitcli.html new file mode 100644 index 00000000..809bd74c --- /dev/null +++ b/devdocs/git/gitcli.html @@ -0,0 +1,27 @@ +<h1>gitcli</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitcli - Git command-line interface and conventions</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>gitcli</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This manual describes the convention used throughout Git CLI.</p> <p>Many commands take revisions (most often "commits", but sometimes "tree-ish", depending on the context and command) and paths as their arguments. Here are the rules:</p> <div class="ulist"> <ul> <li> <p>Options come first and then args. A subcommand may take dashed options (which may take their own arguments, e.g. "--max-parents 2") and arguments. You SHOULD give dashed options first and then arguments. Some commands may accept dashed options after you have already given non-option arguments (which may make the command ambiguous), but you should not rely on it (because eventually we may find a way to fix these ambiguities by enforcing the "options then args" rule).</p> </li> <li> <p>Revisions come first and then paths. E.g. in <code>git diff v1.0 v2.0 arch/x86 include/asm-x86</code>, <code>v1.0</code> and <code>v2.0</code> are revisions and <code>arch/x86</code> and <code>include/asm-x86</code> are paths.</p> </li> <li> <p>When an argument can be misunderstood as either a revision or a path, they can be disambiguated by placing <code>--</code> between them. E.g. <code>git diff -- HEAD</code> is, "I have a file called HEAD in my work tree. Please show changes between the version I staged in the index and what I have in the work tree for that file", not "show the difference between the HEAD commit and the work tree as a whole". You can say <code>git diff HEAD --</code> to ask for the latter.</p> </li> <li> <p>Without disambiguating <code>--</code>, Git makes a reasonable guess, but errors out and asks you to disambiguate when ambiguous. E.g. if you have a file called HEAD in your work tree, <code>git diff HEAD</code> is ambiguous, and you have to say either <code>git diff HEAD --</code> or <code>git diff -- HEAD</code> to disambiguate.</p> </li> <li> <p>Because <code>--</code> disambiguates revisions and paths in some commands, it cannot be used for those commands to separate options and revisions. You can use <code>--end-of-options</code> for this (it also works for commands that do not distinguish between revisions in paths, in which case it is simply an alias for <code>--</code>).</p> <p>When writing a script that is expected to handle random user-input, it is a good practice to make it explicit which arguments are which by placing disambiguating <code>--</code> at appropriate places.</p> </li> <li> <p>Many commands allow wildcards in paths, but you need to protect them from getting globbed by the shell. These two mean different things:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git restore *.c +$ git restore \*.c</pre> </div> </div> <p>The former lets your shell expand the fileglob, and you are asking the dot-C files in your working tree to be overwritten with the version in the index. The latter passes the <code>*.c</code> to Git, and you are asking the paths in the index that match the pattern to be checked out to your working tree. After running <code>git add hello.c; rm hello.c</code>, you will <code>not</code> see <code>hello.c</code> in your working tree with the former, but with the latter you will.</p> </li> <li> <p>Just as the filesystem <code>.</code> (period) refers to the current directory, using a <code>.</code> as a repository name in Git (a dot-repository) is a relative path and means your current repository.</p> </li> </ul> </div> <p>Here are the rules regarding the "flags" that you should follow when you are scripting Git:</p> <div class="ulist"> <ul> <li> <p>It’s preferred to use the non-dashed form of Git commands, which means that you should prefer <code>git foo</code> to <code>git-foo</code>.</p> </li> <li> <p>Splitting short options to separate words (prefer <code>git foo -a -b</code> to <code>git foo -ab</code>, the latter may not even work).</p> </li> <li> <p>When a command-line option takes an argument, use the <code>stuck</code> form. In other words, write <code>git foo -oArg</code> instead of <code>git foo -o Arg</code> for short options, and <code>git foo --long-opt=Arg</code> instead of <code>git foo --long-opt Arg</code> for long options. An option that takes optional option-argument must be written in the <code>stuck</code> form.</p> </li> <li> <p>When you give a revision parameter to a command, make sure the parameter is not ambiguous with a name of a file in the work tree. E.g. do not write <code>git log -1 HEAD</code> but write <code>git log -1 HEAD --</code>; the former will not work if you happen to have a file called <code>HEAD</code> in the work tree.</p> </li> <li> <p>Many commands allow a long option <code>--option</code> to be abbreviated only to their unique prefix (e.g. if there is no other option whose name begins with <code>opt</code>, you may be able to spell <code>--opt</code> to invoke the <code>--option</code> flag), but you should fully spell them out when writing your scripts; later versions of Git may introduce a new option whose name shares the same prefix, e.g. <code>--optimize</code>, to make a short prefix that used to be unique no longer unique.</p> </li> </ul> </div> </div> <h2 id="_enhanced_option_parser">Enhanced option parser</h2> <div class="sectionbody"> <p>From the Git 1.5.4 series and further, many Git commands (not all of them at the time of the writing though) come with an enhanced option parser.</p> <p>Here is a list of the facilities provided by this option parser.</p> <div class="sect2"> <h3 id="_magic_options"> +Magic Options</h3> <p>Commands which have the enhanced option parser activated all understand a couple of magic command-line options:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitcli.txt--h"> -h </dt> <dd> <p>gives a pretty printed usage of the command.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git describe -h +usage: git describe [<options>] <commit-ish>* + or: git describe [<options>] --dirty + + --contains find the tag that comes after the commit + --debug debug search strategy on stderr + --all use any ref + --tags use any tag, even unannotated + --long always use long format + --abbrev[=<n>] use <n> digits to display SHA-1s</pre> </div> </div> <p>Note that some subcommand (e.g. <code>git grep</code>) may behave differently when there are things on the command line other than <code>-h</code>, but <code>git +subcmd -h</code> without anything else on the command line is meant to consistently give the usage.</p> </dd> <dt class="hdlist1" id="Documentation/gitcli.txt---help-all"> --help-all </dt> <dd> <p>Some Git commands take options that are only used for plumbing or that are deprecated, and such options are hidden from the default usage. This option gives the full list of options.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_negating_options"> +Negating options</h3> <p>Options with long option names can be negated by prefixing <code>--no-</code>. For example, <code>git branch</code> has the option <code>--track</code> which is <code>on</code> by default. You can use <code>--no-track</code> to override that behaviour. The same goes for <code>--color</code> and <code>--no-color</code>.</p> </div> <div class="sect2"> <h3 id="_aggregating_short_options"> +Aggregating short options</h3> <p>Commands that support the enhanced option parser allow you to aggregate short options. This means that you can for example use <code>git rm -rf</code> or <code>git clean -fdx</code>.</p> </div> <div class="sect2"> <h3 id="_abbreviating_long_options"> +Abbreviating long options</h3> <p>Commands that support the enhanced option parser accepts unique prefix of a long option as if it is fully spelled out, but use this with a caution. For example, <code>git commit --amen</code> behaves as if you typed <code>git commit --amend</code>, but that is true only until a later version of Git introduces another option that shares the same prefix, e.g. <code>git commit --amenity</code> option.</p> </div> <div class="sect2"> <h3 id="_separating_argument_from_the_option"> +Separating argument from the option</h3> <p>You can write the mandatory option parameter to an option as a separate word on the command line. That means that all the following uses work:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git foo --long-opt=Arg +$ git foo --long-opt Arg +$ git foo -oArg +$ git foo -o Arg</pre> </div> </div> <p>However, this is <strong>NOT</strong> allowed for switches with an optional value, where the <code>stuck</code> form must be used:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git describe --abbrev HEAD # correct +$ git describe --abbrev=10 HEAD # correct +$ git describe --abbrev 10 HEAD # NOT WHAT YOU MEANT</pre> </div> </div> </div> </div> <h2 id="_notes_on_frequently_confused_options">Notes on frequently confused options</h2> <div class="sectionbody"> <p>Many commands that can work on files in the working tree and/or in the index can take <code>--cached</code> and/or <code>--index</code> options. Sometimes people incorrectly think that, because the index was originally called cache, these two are synonyms. They are <strong>not</strong> — these two options mean very different things.</p> <div class="ulist"> <ul> <li> <p>The <code>--cached</code> option is used to ask a command that usually works on files in the working tree to <strong>only</strong> work with the index. For example, <code>git grep</code>, when used without a commit to specify from which commit to look for strings in, usually works on files in the working tree, but with the <code>--cached</code> option, it looks for strings in the index.</p> </li> <li> <p>The <code>--index</code> option is used to ask a command that usually works on files in the working tree to <strong>also</strong> affect the index. For example, <code>git stash apply</code> usually merges changes recorded in a stash entry to the working tree, but with the <code>--index</code> option, it also merges changes to the index as well.</p> </li> </ul> </div> <p><code>git apply</code> command can be used with <code>--cached</code> and <code>--index</code> (but not at the same time). Usually the command only affects the files in the working tree, but with <code>--index</code>, it patches both the files and their index entries, and with <code>--cached</code>, it modifies only the index entries.</p> <p>See also <a href="https://lore.kernel.org/git/7v64clg5u9.fsf@assigned-by-dhcp.cox.net/" class="bare">https://lore.kernel.org/git/7v64clg5u9.fsf@assigned-by-dhcp.cox.net/</a> and <a href="https://lore.kernel.org/git/7vy7ej9g38.fsf@gitster.siamese.dyndns.org/" class="bare">https://lore.kernel.org/git/7vy7ej9g38.fsf@gitster.siamese.dyndns.org/</a> for further information.</p> <p>Some other commands that also work on files in the working tree and/or in the index can take <code>--staged</code> and/or <code>--worktree</code>.</p> <div class="ulist"> <ul> <li> <p><code>--staged</code> is exactly like <code>--cached</code>, which is used to ask a command to only work on the index, not the working tree.</p> </li> <li> <p><code>--worktree</code> is the opposite, to ask a command to work on the working tree only, not the index.</p> </li> <li> <p>The two options can be specified together to ask a command to work on both the index and the working tree.</p> </li> </ul> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitcli" class="_attribution-link">https://git-scm.com/docs/gitcli</a> + </p> +</div> diff --git a/devdocs/git/gitcore-tutorial.html b/devdocs/git/gitcore-tutorial.html new file mode 100644 index 00000000..c08b93ab --- /dev/null +++ b/devdocs/git/gitcore-tutorial.html @@ -0,0 +1,147 @@ +<h1>gitcore-tutorial</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitcore-tutorial - A Git core tutorial for developers</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>git *</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This tutorial explains how to use the "core" Git commands to set up and work with a Git repository.</p> <p>If you just need to use Git as a revision control system you may prefer to start with "A Tutorial Introduction to Git" (<a href="gittutorial">gittutorial[7]</a>) or <a href="user-manual">the Git User Manual</a>.</p> <p>However, an understanding of these low-level tools can be helpful if you want to understand Git’s internals.</p> <p>The core Git is often called "plumbing", with the prettier user interfaces on top of it called "porcelain". You may not want to use the plumbing directly very often, but it can be good to know what the plumbing does when the porcelain isn’t flushing.</p> <p>Back when this document was originally written, many porcelain commands were shell scripts. For simplicity, it still uses them as examples to illustrate how plumbing is fit together to form the porcelain commands. The source tree includes some of these scripts in contrib/examples/ for reference. Although these are not implemented as shell scripts anymore, the description of what the plumbing layer commands do is still valid.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> Deeper technical details are often marked as Notes, which you can skip on your first reading. </td> </tr> </table> </div> </div> <h2 id="_creating_a_git_repository">Creating a git repository</h2> <div class="sectionbody"> <p>Creating a new Git repository couldn’t be easier: all Git repositories start out empty, and the only thing you need to do is find yourself a subdirectory that you want to use as a working tree - either an empty one for a totally new project, or an existing working tree that you want to import into Git.</p> <p>For our first example, we’re going to start a totally new repository from scratch, with no pre-existing files, and we’ll call it <code>git-tutorial</code>. To start up, create a subdirectory for it, change into that subdirectory, and initialize the Git infrastructure with <code>git init</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ mkdir git-tutorial +$ cd git-tutorial +$ git init</pre> </div> </div> <p>to which Git will reply</p> <div class="listingblock"> <div class="content"> <pre>Initialized empty Git repository in .git/</pre> </div> </div> <p>which is just Git’s way of saying that you haven’t been doing anything strange, and that it will have created a local <code>.git</code> directory setup for your new project. You will now have a <code>.git</code> directory, and you can inspect that with <code>ls</code>. For your new empty project, it should show you three entries, among other things:</p> <div class="ulist"> <ul> <li> <p>a file called <code>HEAD</code>, that has <code>ref: refs/heads/master</code> in it. This is similar to a symbolic link and points at <code>refs/heads/master</code> relative to the <code>HEAD</code> file.</p> <p>Don’t worry about the fact that the file that the <code>HEAD</code> link points to doesn’t even exist yet — you haven’t created the commit that will start your <code>HEAD</code> development branch yet.</p> </li> <li> <p>a subdirectory called <code>objects</code>, which will contain all the objects of your project. You should never have any real reason to look at the objects directly, but you might want to know that these objects are what contains all the real <code>data</code> in your repository.</p> </li> <li> <p>a subdirectory called <code>refs</code>, which contains references to objects.</p> </li> </ul> </div> <p>In particular, the <code>refs</code> subdirectory will contain two other subdirectories, named <code>heads</code> and <code>tags</code> respectively. They do exactly what their names imply: they contain references to any number of different <code>heads</code> of development (aka <code>branches</code>), and to any <code>tags</code> that you have created to name specific versions in your repository.</p> <p>One note: the special <code>master</code> head is the default branch, which is why the <code>.git/HEAD</code> file was created points to it even if it doesn’t yet exist. Basically, the <code>HEAD</code> link is supposed to always point to the branch you are working on right now, and you always start out expecting to work on the <code>master</code> branch.</p> <p>However, this is only a convention, and you can name your branches anything you want, and don’t have to ever even <code>have</code> a <code>master</code> branch. A number of the Git tools will assume that <code>.git/HEAD</code> is valid, though.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> An <em>object</em> is identified by its 160-bit SHA-1 hash, aka <em>object name</em>, and a reference to an object is always the 40-byte hex representation of that SHA-1 name. The files in the <code>refs</code> subdirectory are expected to contain these hex references (usually with a final <code>\n</code> at the end), and you should thus expect to see a number of 41-byte files containing these references in these <code>refs</code> subdirectories when you actually start populating your tree. </td> </tr> </table> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> An advanced user may want to take a look at <a href="gitrepository-layout">gitrepository-layout[5]</a> after finishing this tutorial. </td> </tr> </table> </div> <p>You have now created your first Git repository. Of course, since it’s empty, that’s not very useful, so let’s start populating it with data.</p> </div> <h2 id="_populating_a_git_repository">Populating a git repository</h2> <div class="sectionbody"> <p>We’ll keep this simple and stupid, so we’ll start off with populating a few trivial files just to get a feel for it.</p> <p>Start off with just creating any random files that you want to maintain in your Git repository. We’ll start off with a few bad examples, just to get a feel for how this works:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ echo "Hello World" >hello +$ echo "Silly example" >example</pre> </div> </div> <p>you have now created two files in your working tree (aka <code>working directory</code>), but to actually check in your hard work, you will have to go through two steps:</p> <div class="ulist"> <ul> <li> <p>fill in the <code>index</code> file (aka <code>cache</code>) with the information about your working tree state.</p> </li> <li> <p>commit that index file as an object.</p> </li> </ul> </div> <p>The first step is trivial: when you want to tell Git about any changes to your working tree, you use the <code>git update-index</code> program. That program normally just takes a list of filenames you want to update, but to avoid trivial mistakes, it refuses to add new entries to the index (or remove existing ones) unless you explicitly tell it that you’re adding a new entry with the <code>--add</code> flag (or removing an entry with the <code>--remove</code>) flag.</p> <p>So to populate the index with the two files you just created, you can do</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git update-index --add hello example</pre> </div> </div> <p>and you have now told Git to track those two files.</p> <p>In fact, as you did that, if you now look into your object directory, you’ll notice that Git will have added two new objects to the object database. If you did exactly the steps above, you should now be able to do</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ ls .git/objects/??/*</pre> </div> </div> <p>and see two files:</p> <div class="listingblock"> <div class="content"> <pre>.git/objects/55/7db03de997c86a4a028e1ebd3a1ceb225be238 +.git/objects/f2/4c74a2e500f5ee1332c86b94199f52b1d1d962</pre> </div> </div> <p>which correspond with the objects with names of <code>557db...</code> and <code>f24c7...</code> respectively.</p> <p>If you want to, you can use <code>git cat-file</code> to look at those objects, but you’ll have to use the object name, not the filename of the object:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cat-file -t 557db03de997c86a4a028e1ebd3a1ceb225be238</pre> </div> </div> <p>where the <code>-t</code> tells <code>git cat-file</code> to tell you what the "type" of the object is. Git will tell you that you have a "blob" object (i.e., just a regular file), and you can see the contents with</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cat-file blob 557db03</pre> </div> </div> <p>which will print out "Hello World". The object <code>557db03</code> is nothing more than the contents of your file <code>hello</code>.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> Don’t confuse that object with the file <code>hello</code> itself. The object is literally just those specific <strong>contents</strong> of the file, and however much you later change the contents in file <code>hello</code>, the object we just looked at will never change. Objects are immutable. </td> </tr> </table> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> The second example demonstrates that you can abbreviate the object name to only the first several hexadecimal digits in most places. </td> </tr> </table> </div> <p>Anyway, as we mentioned previously, you normally never actually take a look at the objects themselves, and typing long 40-character hex names is not something you’d normally want to do. The above digression was just to show that <code>git update-index</code> did something magical, and actually saved away the contents of your files into the Git object database.</p> <p>Updating the index did something else too: it created a <code>.git/index</code> file. This is the index that describes your current working tree, and something you should be very aware of. Again, you normally never worry about the index file itself, but you should be aware of the fact that you have not actually really "checked in" your files into Git so far, you’ve only <strong>told</strong> Git about them.</p> <p>However, since Git knows about them, you can now start using some of the most basic Git commands to manipulate the files or look at their status.</p> <p>In particular, let’s not even check in the two files into Git yet, we’ll start off by adding another line to <code>hello</code> first:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ echo "It's a new day for git" >>hello</pre> </div> </div> <p>and you can now, since you told Git about the previous state of <code>hello</code>, ask Git what has changed in the tree compared to your old index, using the <code>git diff-files</code> command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff-files</pre> </div> </div> <p>Oops. That wasn’t very readable. It just spit out its own internal version of a <code>diff</code>, but that internal version really just tells you that it has noticed that "hello" has been modified, and that the old object contents it had have been replaced with something else.</p> <p>To make it readable, we can tell <code>git diff-files</code> to output the differences as a patch, using the <code>-p</code> flag:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff-files -p +diff --git a/hello b/hello +index 557db03..263414f 100644 +--- a/hello ++++ b/hello +@@ -1 +1,2 @@ + Hello World ++It's a new day for git</pre> </div> </div> <p>i.e. the diff of the change we caused by adding another line to <code>hello</code>.</p> <p>In other words, <code>git diff-files</code> always shows us the difference between what is recorded in the index, and what is currently in the working tree. That’s very useful.</p> <p>A common shorthand for <code>git diff-files -p</code> is to just write <code>git +diff</code>, which will do the same thing.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff +diff --git a/hello b/hello +index 557db03..263414f 100644 +--- a/hello ++++ b/hello +@@ -1 +1,2 @@ + Hello World ++It's a new day for git</pre> </div> </div> </div> <h2 id="_committing_git_state">Committing git state</h2> <div class="sectionbody"> <p>Now, we want to go to the next stage in Git, which is to take the files that Git knows about in the index, and commit them as a real tree. We do that in two phases: creating a <code>tree</code> object, and committing that <code>tree</code> object as a <code>commit</code> object together with an explanation of what the tree was all about, along with information of how we came to that state.</p> <p>Creating a tree object is trivial, and is done with <code>git write-tree</code>. There are no options or other input: <code>git write-tree</code> will take the current index state, and write an object that describes that whole index. In other words, we’re now tying together all the different filenames with their contents (and their permissions), and we’re creating the equivalent of a Git "directory" object:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git write-tree</pre> </div> </div> <p>and this will just output the name of the resulting tree, in this case (if you have done exactly as I’ve described) it should be</p> <div class="listingblock"> <div class="content"> <pre>8988da15d077d4829fc51d8544c097def6644dbb</pre> </div> </div> <p>which is another incomprehensible object name. Again, if you want to, you can use <code>git cat-file -t 8988d...</code> to see that this time the object is not a "blob" object, but a "tree" object (you can also use <code>git cat-file</code> to actually output the raw object contents, but you’ll see mainly a binary mess, so that’s less interesting).</p> <p>However — normally you’d never use <code>git write-tree</code> on its own, because normally you always commit a tree into a commit object using the <code>git commit-tree</code> command. In fact, it’s easier to not actually use <code>git write-tree</code> on its own at all, but to just pass its result in as an argument to <code>git commit-tree</code>.</p> <p><code>git commit-tree</code> normally takes several arguments — it wants to know what the <code>parent</code> of a commit was, but since this is the first commit ever in this new repository, and it has no parents, we only need to pass in the object name of the tree. However, <code>git commit-tree</code> also wants to get a commit message on its standard input, and it will write out the resulting object name for the commit to its standard output.</p> <p>And this is where we create the <code>.git/refs/heads/master</code> file which is pointed at by <code>HEAD</code>. This file is supposed to contain the reference to the top-of-tree of the master branch, and since that’s exactly what <code>git commit-tree</code> spits out, we can do this all with a sequence of simple shell commands:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ tree=$(git write-tree) +$ commit=$(echo 'Initial commit' | git commit-tree $tree) +$ git update-ref HEAD $commit</pre> </div> </div> <p>In this case this creates a totally new commit that is not related to anything else. Normally you do this only <strong>once</strong> for a project ever, and all later commits will be parented on top of an earlier commit.</p> <p>Again, normally you’d never actually do this by hand. There is a helpful script called <code>git commit</code> that will do all of this for you. So you could have just written <code>git commit</code> instead, and it would have done the above magic scripting for you.</p> </div> <h2 id="_making_a_change">Making a change</h2> <div class="sectionbody"> <p>Remember how we did the <code>git update-index</code> on file <code>hello</code> and then we changed <code>hello</code> afterward, and could compare the new state of <code>hello</code> with the state we saved in the index file?</p> <p>Further, remember how I said that <code>git write-tree</code> writes the contents of the <strong>index</strong> file to the tree, and thus what we just committed was in fact the <strong>original</strong> contents of the file <code>hello</code>, not the new ones. We did that on purpose, to show the difference between the index state, and the state in the working tree, and how they don’t have to match, even when we commit things.</p> <p>As before, if we do <code>git diff-files -p</code> in our git-tutorial project, we’ll still see the same difference we saw last time: the index file hasn’t changed by the act of committing anything. However, now that we have committed something, we can also learn to use a new command: <code>git diff-index</code>.</p> <p>Unlike <code>git diff-files</code>, which showed the difference between the index file and the working tree, <code>git diff-index</code> shows the differences between a committed <strong>tree</strong> and either the index file or the working tree. In other words, <code>git diff-index</code> wants a tree to be diffed against, and before we did the commit, we couldn’t do that, because we didn’t have anything to diff against.</p> <p>But now we can do</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff-index -p HEAD</pre> </div> </div> <p>(where <code>-p</code> has the same meaning as it did in <code>git diff-files</code>), and it will show us the same difference, but for a totally different reason. Now we’re comparing the working tree not against the index file, but against the tree we just wrote. It just so happens that those two are obviously the same, so we get the same result.</p> <p>Again, because this is a common operation, you can also just shorthand it with</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff HEAD</pre> </div> </div> <p>which ends up doing the above for you.</p> <p>In other words, <code>git diff-index</code> normally compares a tree against the working tree, but when given the <code>--cached</code> flag, it is told to instead compare against just the index cache contents, and ignore the current working tree state entirely. Since we just wrote the index file to HEAD, doing <code>git diff-index --cached -p HEAD</code> should thus return an empty set of differences, and that’s exactly what it does.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> <p><code>git diff-index</code> really always uses the index for its comparisons, and saying that it compares a tree against the working tree is thus not strictly accurate. In particular, the list of files to compare (the "meta-data") <strong>always</strong> comes from the index file, regardless of whether the <code>--cached</code> flag is used or not. The <code>--cached</code> flag really only determines whether the file <strong>contents</strong> to be compared come from the working tree or not.</p> <p>This is not hard to understand, as soon as you realize that Git simply never knows (or cares) about files that it is not told about explicitly. Git will never go <strong>looking</strong> for files to compare, it expects you to tell it what the files are, and that’s what the index is there for.</p> </td> </tr> </table> </div> <p>However, our next step is to commit the <strong>change</strong> we did, and again, to understand what’s going on, keep in mind the difference between "working tree contents", "index file" and "committed tree". We have changes in the working tree that we want to commit, and we always have to work through the index file, so the first thing we need to do is to update the index cache:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git update-index hello</pre> </div> </div> <p>(note how we didn’t need the <code>--add</code> flag this time, since Git knew about the file already).</p> <p>Note what happens to the different <code>git diff-*</code> versions here. After we’ve updated <code>hello</code> in the index, <code>git diff-files -p</code> now shows no differences, but <code>git diff-index -p HEAD</code> still <strong>does</strong> show that the current state is different from the state we committed. In fact, now <code>git diff-index</code> shows the same difference whether we use the <code>--cached</code> flag or not, since now the index is coherent with the working tree.</p> <p>Now, since we’ve updated <code>hello</code> in the index, we can commit the new version. We could do it by writing the tree by hand again, and committing the tree (this time we’d have to use the <code>-p HEAD</code> flag to tell commit that the HEAD was the <strong>parent</strong> of the new commit, and that this wasn’t an initial commit any more), but you’ve done that once already, so let’s just use the helpful script this time:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit</pre> </div> </div> <p>which starts an editor for you to write the commit message and tells you a bit about what you have done.</p> <p>Write whatever message you want, and all the lines that start with <code>#</code> will be pruned out, and the rest will be used as the commit message for the change. If you decide you don’t want to commit anything after all at this point (you can continue to edit things and update the index), you can just leave an empty message. Otherwise <code>git commit</code> will commit the change for you.</p> <p>You’ve now made your first real Git commit. And if you’re interested in looking at what <code>git commit</code> really does, feel free to investigate: it’s a few very simple shell scripts to generate the helpful (?) commit message headers, and a few one-liners that actually do the commit itself (<code>git commit</code>).</p> </div> <h2 id="_inspecting_changes">Inspecting changes</h2> <div class="sectionbody"> <p>While creating changes is useful, it’s even more useful if you can tell later what changed. The most useful command for this is another of the <code>diff</code> family, namely <code>git diff-tree</code>.</p> <p><code>git diff-tree</code> can be given two arbitrary trees, and it will tell you the differences between them. Perhaps even more commonly, though, you can give it just a single commit object, and it will figure out the parent of that commit itself, and show the difference directly. Thus, to get the same diff that we’ve already seen several times, we can now do</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff-tree -p HEAD</pre> </div> </div> <p>(again, <code>-p</code> means to show the difference as a human-readable patch), and it will show what the last commit (in <code>HEAD</code>) actually changed.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> <p>Here is an ASCII art by Jon Loeliger that illustrates how various <code>diff-*</code> commands compare things.</p> <div class="literalblock"> <div class="content"> <pre> diff-tree + +----+ + | | + | | + V V + +-----------+ + | Object DB | + | Backing | + | Store | + +-----------+ + ^ ^ + | | + | | diff-index --cached + | | +diff-index | V + | +-----------+ + | | Index | + | | "cache" | + | +-----------+ + | ^ + | | + | | diff-files + | | + V V + +-----------+ + | Working | + | Directory | + +-----------+</pre> </div> </div> </td> </tr> </table> </div> <p>More interestingly, you can also give <code>git diff-tree</code> the <code>--pretty</code> flag, which tells it to also show the commit message and author and date of the commit, and you can tell it to show a whole series of diffs. Alternatively, you can tell it to be "silent", and not show the diffs at all, but just show the actual commit message.</p> <p>In fact, together with the <code>git rev-list</code> program (which generates a list of revisions), <code>git diff-tree</code> ends up being a veritable fount of changes. You can emulate <code>git log</code>, <code>git log -p</code>, etc. with a trivial script that pipes the output of <code>git rev-list</code> to <code>git diff-tree --stdin</code>, which was exactly how early versions of <code>git log</code> were implemented.</p> </div> <h2 id="_tagging_a_version">Tagging a version</h2> <div class="sectionbody"> <p>In Git, there are two kinds of tags, a "light" one, and an "annotated tag".</p> <p>A "light" tag is technically nothing more than a branch, except we put it in the <code>.git/refs/tags/</code> subdirectory instead of calling it a <code>head</code>. So the simplest form of tag involves nothing more than</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git tag my-first-tag</pre> </div> </div> <p>which just writes the current <code>HEAD</code> into the <code>.git/refs/tags/my-first-tag</code> file, after which point you can then use this symbolic name for that particular state. You can, for example, do</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff my-first-tag</pre> </div> </div> <p>to diff your current state against that tag which at this point will obviously be an empty diff, but if you continue to develop and commit stuff, you can use your tag as an "anchor-point" to see what has changed since you tagged it.</p> <p>An "annotated tag" is actually a real Git object, and contains not only a pointer to the state you want to tag, but also a small tag name and message, along with optionally a PGP signature that says that yes, you really did that tag. You create these annotated tags with either the <code>-a</code> or <code>-s</code> flag to <code>git tag</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git tag -s <tagname></pre> </div> </div> <p>which will sign the current <code>HEAD</code> (but you can also give it another argument that specifies the thing to tag, e.g., you could have tagged the current <code>mybranch</code> point by using <code>git tag <tagname> mybranch</code>).</p> <p>You normally only do signed tags for major releases or things like that, while the light-weight tags are useful for any marking you want to do — any time you decide that you want to remember a certain point, just create a private tag for it, and you have a nice symbolic name for the state at that point.</p> </div> <h2 id="_copying_repositories">Copying repositories</h2> <div class="sectionbody"> <p>Git repositories are normally totally self-sufficient and relocatable. Unlike CVS, for example, there is no separate notion of "repository" and "working tree". A Git repository normally <strong>is</strong> the working tree, with the local Git information hidden in the <code>.git</code> subdirectory. There is nothing else. What you see is what you got.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> You can tell Git to split the Git internal information from the directory that it tracks, but we’ll ignore that for now: it’s not how normal projects work, and it’s really only meant for special uses. So the mental model of "the Git information is always tied directly to the working tree that it describes" may not be technically 100% accurate, but it’s a good model for all normal use. </td> </tr> </table> </div> <p>This has two implications:</p> <div class="ulist"> <ul> <li> <p>if you grow bored with the tutorial repository you created (or you’ve made a mistake and want to start all over), you can just do simple</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ rm -rf git-tutorial</pre> </div> </div> <p>and it will be gone. There’s no external repository, and there’s no history outside the project you created.</p> </li> <li> <p>if you want to move or duplicate a Git repository, you can do so. There is <code>git clone</code> command, but if all you want to do is just to create a copy of your repository (with all the full history that went along with it), you can do so with a regular <code>cp -a git-tutorial new-git-tutorial</code>.</p> <p>Note that when you’ve moved or copied a Git repository, your Git index file (which caches various information, notably some of the "stat" information for the files involved) will likely need to be refreshed. So after you do a <code>cp -a</code> to create a new copy, you’ll want to do</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git update-index --refresh</pre> </div> </div> <p>in the new repository to make sure that the index file is up to date.</p> </li> </ul> </div> <p>Note that the second point is true even across machines. You can duplicate a remote Git repository with <strong>any</strong> regular copy mechanism, be it <code>scp</code>, <code>rsync</code> or <code>wget</code>.</p> <p>When copying a remote repository, you’ll want to at a minimum update the index cache when you do this, and especially with other peoples' repositories you often want to make sure that the index cache is in some known state (you don’t know <strong>what</strong> they’ve done and not yet checked in), so usually you’ll precede the <code>git update-index</code> with a</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git read-tree --reset HEAD +$ git update-index --refresh</pre> </div> </div> <p>which will force a total index re-build from the tree pointed to by <code>HEAD</code>. It resets the index contents to <code>HEAD</code>, and then the <code>git update-index</code> makes sure to match up all index entries with the checked-out files. If the original repository had uncommitted changes in its working tree, <code>git update-index --refresh</code> notices them and tells you they need to be updated.</p> <p>The above can also be written as simply</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git reset</pre> </div> </div> <p>and in fact a lot of the common Git command combinations can be scripted with the <code>git xyz</code> interfaces. You can learn things by just looking at what the various git scripts do. For example, <code>git reset</code> used to be the above two lines implemented in <code>git reset</code>, but some things like <code>git status</code> and <code>git commit</code> are slightly more complex scripts around the basic Git commands.</p> <p>Many (most?) public remote repositories will not contain any of the checked out files or even an index file, and will <strong>only</strong> contain the actual core Git files. Such a repository usually doesn’t even have the <code>.git</code> subdirectory, but has all the Git files directly in the repository.</p> <p>To create your own local live copy of such a "raw" Git repository, you’d first create your own subdirectory for the project, and then copy the raw repository contents into the <code>.git</code> directory. For example, to create your own copy of the Git repository, you’d do the following</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ mkdir my-git +$ cd my-git +$ rsync -rL rsync://rsync.kernel.org/pub/scm/git/git.git/ .git</pre> </div> </div> <p>followed by</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git read-tree HEAD</pre> </div> </div> <p>to populate the index. However, now you have populated the index, and you have all the Git internal files, but you will notice that you don’t actually have any of the working tree files to work on. To get those, you’d check them out with</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout-index -u -a</pre> </div> </div> <p>where the <code>-u</code> flag means that you want the checkout to keep the index up to date (so that you don’t have to refresh it afterward), and the <code>-a</code> flag means "check out all files" (if you have a stale copy or an older version of a checked out tree you may also need to add the <code>-f</code> flag first, to tell <code>git checkout-index</code> to <strong>force</strong> overwriting of any old files).</p> <p>Again, this can all be simplified with</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git clone git://git.kernel.org/pub/scm/git/git.git/ my-git +$ cd my-git +$ git checkout</pre> </div> </div> <p>which will end up doing all of the above for you.</p> <p>You have now successfully copied somebody else’s (mine) remote repository, and checked it out.</p> </div> <h2 id="_creating_a_new_branch">Creating a new branch</h2> <div class="sectionbody"> <p>Branches in Git are really nothing more than pointers into the Git object database from within the <code>.git/refs/</code> subdirectory, and as we already discussed, the <code>HEAD</code> branch is nothing but a symlink to one of these object pointers.</p> <p>You can at any time create a new branch by just picking an arbitrary point in the project history, and just writing the SHA-1 name of that object into a file under <code>.git/refs/heads/</code>. You can use any filename you want (and indeed, subdirectories), but the convention is that the "normal" branch is called <code>master</code>. That’s just a convention, though, and nothing enforces it.</p> <p>To show that as an example, let’s go back to the git-tutorial repository we used earlier, and create a branch in it. You do that by simply just saying that you want to check out a new branch:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -c mybranch</pre> </div> </div> <p>will create a new branch based at the current <code>HEAD</code> position, and switch to it.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> <p>If you make the decision to start your new branch at some other point in the history than the current <code>HEAD</code>, you can do so by just telling <code>git switch</code> what the base of the checkout would be. In other words, if you have an earlier tag or branch, you’d just do</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -c mybranch earlier-commit</pre> </div> </div> <p>and it would create the new branch <code>mybranch</code> at the earlier commit, and check out the state at that time.</p> </td> </tr> </table> </div> <p>You can always just jump back to your original <code>master</code> branch by doing</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch master</pre> </div> </div> <p>(or any other branch-name, for that matter) and if you forget which branch you happen to be on, a simple</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat .git/HEAD</pre> </div> </div> <p>will tell you where it’s pointing. To get the list of branches you have, you can say</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch</pre> </div> </div> <p>which used to be nothing more than a simple script around <code>ls .git/refs/heads</code>. There will be an asterisk in front of the branch you are currently on.</p> <p>Sometimes you may wish to create a new branch <code>without</code> actually checking it out and switching to it. If so, just use the command</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch <branchname> [startingpoint]</pre> </div> </div> <p>which will simply <code>create</code> the branch, but will not do anything further. You can then later — once you decide that you want to actually develop on that branch — switch to that branch with a regular <code>git switch</code> with the branchname as the argument.</p> </div> <h2 id="_merging_two_branches">Merging two branches</h2> <div class="sectionbody"> <p>One of the ideas of having a branch is that you do some (possibly experimental) work in it, and eventually merge it back to the main branch. So assuming you created the above <code>mybranch</code> that started out being the same as the original <code>master</code> branch, let’s make sure we’re in that branch, and do some work there.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch mybranch +$ echo "Work, work, work" >>hello +$ git commit -m "Some work." -i hello</pre> </div> </div> <p>Here, we just added another line to <code>hello</code>, and we used a shorthand for doing both <code>git update-index hello</code> and <code>git commit</code> by just giving the filename directly to <code>git commit</code>, with an <code>-i</code> flag (it tells Git to <code>include</code> that file in addition to what you have done to the index file so far when making the commit). The <code>-m</code> flag is to give the commit log message from the command line.</p> <p>Now, to make it a bit more interesting, let’s assume that somebody else does some work in the original branch, and simulate that by going back to the master branch, and editing the same file differently there:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch master</pre> </div> </div> <p>Here, take a moment to look at the contents of <code>hello</code>, and notice how they don’t contain the work we just did in <code>mybranch</code> — because that work hasn’t happened in the <code>master</code> branch at all. Then do</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ echo "Play, play, play" >>hello +$ echo "Lots of fun" >>example +$ git commit -m "Some fun." -i hello example</pre> </div> </div> <p>since the master branch is obviously in a much better mood.</p> <p>Now, you’ve got two branches, and you decide that you want to merge the work done. Before we do that, let’s introduce a cool graphical tool that helps you view what’s going on:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ gitk --all</pre> </div> </div> <p>will show you graphically both of your branches (that’s what the <code>--all</code> means: normally it will just show you your current <code>HEAD</code>) and their histories. You can also see exactly how they came to be from a common source.</p> <p>Anyway, let’s exit <code>gitk</code> (<code>^Q</code> or the File menu), and decide that we want to merge the work we did on the <code>mybranch</code> branch into the <code>master</code> branch (which is currently our <code>HEAD</code> too). To do that, there’s a nice script called <code>git merge</code>, which wants to know which branches you want to resolve and what the merge is all about:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git merge -m "Merge work in mybranch" mybranch</pre> </div> </div> <p>where the first argument is going to be used as the commit message if the merge can be resolved automatically.</p> <p>Now, in this case we’ve intentionally created a situation where the merge will need to be fixed up by hand, though, so Git will do as much of it as it can automatically (which in this case is just merge the <code>example</code> file, which had no differences in the <code>mybranch</code> branch), and say:</p> <div class="listingblock"> <div class="content"> <pre> Auto-merging hello + CONFLICT (content): Merge conflict in hello + Automatic merge failed; fix conflicts and then commit the result.</pre> </div> </div> <p>It tells you that it did an "Automatic merge", which failed due to conflicts in <code>hello</code>.</p> <p>Not to worry. It left the (trivial) conflict in <code>hello</code> in the same form you should already be well used to if you’ve ever used CVS, so let’s just open <code>hello</code> in our editor (whatever that may be), and fix it up somehow. I’d suggest just making it so that <code>hello</code> contains all four lines:</p> <div class="listingblock"> <div class="content"> <pre>Hello World +It's a new day for git +Play, play, play +Work, work, work</pre> </div> </div> <p>and once you’re happy with your manual merge, just do a</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit -i hello</pre> </div> </div> <p>which will very loudly warn you that you’re now committing a merge (which is correct, so never mind), and you can write a small merge message about your adventures in <code>git merge</code>-land.</p> <p>After you’re done, start up <code>gitk --all</code> to see graphically what the history looks like. Notice that <code>mybranch</code> still exists, and you can switch to it, and continue to work with it if you want to. The <code>mybranch</code> branch will not contain the merge, but next time you merge it from the <code>master</code> branch, Git will know how you merged it, so you’ll not have to do <code>that</code> merge again.</p> <p>Another useful tool, especially if you do not always work in X-Window environment, is <code>git show-branch</code>.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show-branch --topo-order --more=1 master mybranch +* [master] Merge work in mybranch + ! [mybranch] Some work. +-- +- [master] Merge work in mybranch +*+ [mybranch] Some work. +* [master^] Some fun.</pre> </div> </div> <p>The first two lines indicate that it is showing the two branches with the titles of their top-of-the-tree commits, you are currently on <code>master</code> branch (notice the asterisk <code>*</code> character), and the first column for the later output lines is used to show commits contained in the <code>master</code> branch, and the second column for the <code>mybranch</code> branch. Three commits are shown along with their titles. All of them have non blank characters in the first column (<code>*</code> shows an ordinary commit on the current branch, <code>-</code> is a merge commit), which means they are now part of the <code>master</code> branch. Only the "Some work" commit has the plus <code>+</code> character in the second column, because <code>mybranch</code> has not been merged to incorporate these commits from the master branch. The string inside brackets before the commit log message is a short name you can use to name the commit. In the above example, <code>master</code> and <code>mybranch</code> are branch heads. <code>master^</code> is the first parent of <code>master</code> branch head. Please see <a href="gitrevisions">gitrevisions[7]</a> if you want to see more complex cases.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> Without the <em>--more=1</em> option, <em>git show-branch</em> would not output the <em>[master^]</em> commit, as <em>[mybranch]</em> commit is a common ancestor of both <em>master</em> and <em>mybranch</em> tips. Please see <a href="git-show-branch">git-show-branch[1]</a> for details. </td> </tr> </table> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> If there were more commits on the <em>master</em> branch after the merge, the merge commit itself would not be shown by <em>git show-branch</em> by default. You would need to provide <code>--sparse</code> option to make the merge commit visible in this case. </td> </tr> </table> </div> <p>Now, let’s pretend you are the one who did all the work in <code>mybranch</code>, and the fruit of your hard work has finally been merged to the <code>master</code> branch. Let’s go back to <code>mybranch</code>, and run <code>git merge</code> to get the "upstream changes" back to your branch.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch mybranch +$ git merge -m "Merge upstream changes." master</pre> </div> </div> <p>This outputs something like this (the actual commit object names would be different)</p> <div class="listingblock"> <div class="content"> <pre>Updating from ae3a2da... to a80b4aa.... +Fast-forward (no commit created; -m option ignored) + example | 1 + + hello | 1 + + 2 files changed, 2 insertions(+)</pre> </div> </div> <p>Because your branch did not contain anything more than what had already been merged into the <code>master</code> branch, the merge operation did not actually do a merge. Instead, it just updated the top of the tree of your branch to that of the <code>master</code> branch. This is often called <code>fast-forward</code> merge.</p> <p>You can run <code>gitk --all</code> again to see how the commit ancestry looks like, or run <code>show-branch</code>, which tells you this.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show-branch master mybranch +! [master] Merge work in mybranch + * [mybranch] Merge work in mybranch +-- +-- [master] Merge work in mybranch</pre> </div> </div> </div> <h2 id="_merging_external_work">Merging external work</h2> <div class="sectionbody"> <p>It’s usually much more common that you merge with somebody else than merging with your own branches, so it’s worth pointing out that Git makes that very easy too, and in fact, it’s not that different from doing a <code>git merge</code>. In fact, a remote merge ends up being nothing more than "fetch the work from a remote repository into a temporary tag" followed by a <code>git merge</code>.</p> <p>Fetching from a remote repository is done by, unsurprisingly, <code>git fetch</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch <remote-repository></pre> </div> </div> <p>One of the following transports can be used to name the repository to download from:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitcore-tutorial.txt-SSH"> SSH </dt> <dd> <p><code>remote.machine:/path/to/repo.git/</code> or</p> <p><code>ssh://remote.machine/path/to/repo.git/</code></p> <p>This transport can be used for both uploading and downloading, and requires you to have a log-in privilege over <code>ssh</code> to the remote machine. It finds out the set of objects the other side lacks by exchanging the head commits both ends have and transfers (close to) minimum set of objects. It is by far the most efficient way to exchange Git objects between repositories.</p> </dd> <dt class="hdlist1" id="Documentation/gitcore-tutorial.txt-Localdirectory"> Local directory </dt> <dd> <p><code>/path/to/repo.git/</code></p> <p>This transport is the same as SSH transport but uses <code>sh</code> to run both ends on the local machine instead of running other end on the remote machine via <code>ssh</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitcore-tutorial.txt-GitNative"> Git Native </dt> <dd> <p><code>git://remote.machine/path/to/repo.git/</code></p> <p>This transport was designed for anonymous downloading. Like SSH transport, it finds out the set of objects the downstream side lacks and transfers (close to) minimum set of objects.</p> </dd> <dt class="hdlist1" id="Documentation/gitcore-tutorial.txt-HTTPS"> HTTP(S) </dt> <dd> <p><code>http://remote.machine/path/to/repo.git/</code></p> <p>Downloader from http and https URL first obtains the topmost commit object name from the remote site by looking at the specified refname under <code>repo.git/refs/</code> directory, and then tries to obtain the commit object by downloading from <code>repo.git/objects/xx/xxx...</code> using the object name of that commit object. Then it reads the commit object to find out its parent commits and the associate tree object; it repeats this process until it gets all the necessary objects. Because of this behavior, they are sometimes also called <code>commit walkers</code>.</p> <p>The <code>commit walkers</code> are sometimes also called <code>dumb transports</code>, because they do not require any Git aware smart server like Git Native transport does. Any stock HTTP server that does not even support directory index would suffice. But you must prepare your repository with <code>git update-server-info</code> to help dumb transport downloaders.</p> </dd> </dl> </div> <p>Once you fetch from the remote repository, you <code>merge</code> that with your current branch.</p> <p>However — it’s such a common thing to <code>fetch</code> and then immediately <code>merge</code>, that it’s called <code>git pull</code>, and you can simply do</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git pull <remote-repository></pre> </div> </div> <p>and optionally give a branch-name for the remote end as a second argument.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> You could do without using any branches at all, by keeping as many local repositories as you would like to have branches, and merging between them with <em>git pull</em>, just like you merge between branches. The advantage of this approach is that it lets you keep a set of files for each <code>branch</code> checked out and you may find it easier to switch back and forth if you juggle multiple lines of development simultaneously. Of course, you will pay the price of more disk usage to hold multiple working trees, but disk space is cheap these days. </td> </tr> </table> </div> <p>It is likely that you will be pulling from the same remote repository from time to time. As a short hand, you can store the remote repository URL in the local repository’s config file like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config remote.linus.url https://git.kernel.org/pub/scm/git/git.git/</pre> </div> </div> <p>and use the "linus" keyword with <code>git pull</code> instead of the full URL.</p> <p>Examples.</p> <div class="olist arabic"> <ol class="arabic"> <li> <p><code>git pull linus</code></p> </li> <li> <p><code>git pull linus tag v0.99.1</code></p> </li> </ol> </div> <p>the above are equivalent to:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p><code>git pull http://www.kernel.org/pub/scm/git/git.git/ HEAD</code></p> </li> <li> <p><code>git pull http://www.kernel.org/pub/scm/git/git.git/ tag v0.99.1</code></p> </li> </ol> </div> </div> <h2 id="_how_does_the_merge_work">How does the merge work?</h2> <div class="sectionbody"> <p>We said this tutorial shows what plumbing does to help you cope with the porcelain that isn’t flushing, but we so far did not talk about how the merge really works. If you are following this tutorial the first time, I’d suggest to skip to "Publishing your work" section and come back here later.</p> <p>OK, still with me? To give us an example to look at, let’s go back to the earlier repository with "hello" and "example" file, and bring ourselves back to the pre-merge state:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show-branch --more=2 master mybranch +! [master] Merge work in mybranch + * [mybranch] Merge work in mybranch +-- +-- [master] Merge work in mybranch ++* [master^2] Some work. ++* [master^] Some fun.</pre> </div> </div> <p>Remember, before running <code>git merge</code>, our <code>master</code> head was at "Some fun." commit, while our <code>mybranch</code> head was at "Some work." commit.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -C mybranch master^2 +$ git switch master +$ git reset --hard master^</pre> </div> </div> <p>After rewinding, the commit structure should look like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show-branch +* [master] Some fun. + ! [mybranch] Some work. +-- +* [master] Some fun. + + [mybranch] Some work. +*+ [master^] Initial commit</pre> </div> </div> <p>Now we are ready to experiment with the merge by hand.</p> <p><code>git merge</code> command, when merging two branches, uses 3-way merge algorithm. First, it finds the common ancestor between them. The command it uses is <code>git merge-base</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ mb=$(git merge-base HEAD mybranch)</pre> </div> </div> <p>The command writes the commit object name of the common ancestor to the standard output, so we captured its output to a variable, because we will be using it in the next step. By the way, the common ancestor commit is the "Initial commit" commit in this case. You can tell it by:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git name-rev --name-only --tags $mb +my-first-tag</pre> </div> </div> <p>After finding out a common ancestor commit, the second step is this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git read-tree -m -u $mb HEAD mybranch</pre> </div> </div> <p>This is the same <code>git read-tree</code> command we have already seen, but it takes three trees, unlike previous examples. This reads the contents of each tree into different <code>stage</code> in the index file (the first tree goes to stage 1, the second to stage 2, etc.). After reading three trees into three stages, the paths that are the same in all three stages are <code>collapsed</code> into stage 0. Also paths that are the same in two of three stages are collapsed into stage 0, taking the SHA-1 from either stage 2 or stage 3, whichever is different from stage 1 (i.e. only one side changed from the common ancestor).</p> <p>After <code>collapsing</code> operation, paths that are different in three trees are left in non-zero stages. At this point, you can inspect the index file with this command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-files --stage +100644 7f8b141b65fdcee47321e399a2598a235a032422 0 example +100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1 hello +100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2 hello +100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello</pre> </div> </div> <p>In our example of only two files, we did not have unchanged files so only <code>example</code> resulted in collapsing. But in real-life large projects, when only a small number of files change in one commit, this <code>collapsing</code> tends to trivially merge most of the paths fairly quickly, leaving only a handful of real changes in non-zero stages.</p> <p>To look at only non-zero stages, use <code>--unmerged</code> flag:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-files --unmerged +100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1 hello +100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2 hello +100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello</pre> </div> </div> <p>The next step of merging is to merge these three versions of the file, using 3-way merge. This is done by giving <code>git merge-one-file</code> command as one of the arguments to <code>git merge-index</code> command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git merge-index git-merge-one-file hello +Auto-merging hello +ERROR: Merge conflict in hello +fatal: merge program failed</pre> </div> </div> <p><code>git merge-one-file</code> script is called with parameters to describe those three versions, and is responsible to leave the merge results in the working tree. It is a fairly straightforward shell script, and eventually calls <code>merge</code> program from RCS suite to perform a file-level 3-way merge. In this case, <code>merge</code> detects conflicts, and the merge result with conflict marks is left in the working tree.. This can be seen if you run <code>ls-files +--stage</code> again at this point:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-files --stage +100644 7f8b141b65fdcee47321e399a2598a235a032422 0 example +100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1 hello +100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2 hello +100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello</pre> </div> </div> <p>This is the state of the index file and the working file after <code>git merge</code> returns control back to you, leaving the conflicting merge for you to resolve. Notice that the path <code>hello</code> is still unmerged, and what you see with <code>git diff</code> at this point is differences since stage 2 (i.e. your version).</p> </div> <h2 id="_publishing_your_work">Publishing your work</h2> <div class="sectionbody"> <p>So, we can use somebody else’s work from a remote repository, but how can <strong>you</strong> prepare a repository to let other people pull from it?</p> <p>You do your real work in your working tree that has your primary repository hanging under it as its <code>.git</code> subdirectory. You <strong>could</strong> make that repository accessible remotely and ask people to pull from it, but in practice that is not the way things are usually done. A recommended way is to have a public repository, make it reachable by other people, and when the changes you made in your primary working tree are in good shape, update the public repository from it. This is often called <code>pushing</code>.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> This public repository could further be mirrored, and that is how Git repositories at <code>kernel.org</code> are managed. </td> </tr> </table> </div> <p>Publishing the changes from your local (private) repository to your remote (public) repository requires a write privilege on the remote machine. You need to have an SSH account there to run a single command, <code>git-receive-pack</code>.</p> <p>First, you need to create an empty repository on the remote machine that will house your public repository. This empty repository will be populated and be kept up to date by pushing into it later. Obviously, this repository creation needs to be done only once.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> <em>git push</em> uses a pair of commands, <em>git send-pack</em> on your local machine, and <em>git-receive-pack</em> on the remote machine. The communication between the two over the network internally uses an SSH connection. </td> </tr> </table> </div> <p>Your private repository’s Git directory is usually <code>.git</code>, but your public repository is often named after the project name, i.e. <code><project>.git</code>. Let’s create such a public repository for project <code>my-git</code>. After logging into the remote machine, create an empty directory:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ mkdir my-git.git</pre> </div> </div> <p>Then, make that directory into a Git repository by running <code>git init</code>, but this time, since its name is not the usual <code>.git</code>, we do things slightly differently:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ GIT_DIR=my-git.git git init</pre> </div> </div> <p>Make sure this directory is available for others you want your changes to be pulled via the transport of your choice. Also you need to make sure that you have the <code>git-receive-pack</code> program on the <code>$PATH</code>.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> Many installations of sshd do not invoke your shell as the login shell when you directly run programs; what this means is that if your login shell is <em>bash</em>, only <code>.bashrc</code> is read and not <code>.bash_profile</code>. As a workaround, make sure <code>.bashrc</code> sets up <code>$PATH</code> so that you can run <em>git-receive-pack</em> program. </td> </tr> </table> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> If you plan to publish this repository to be accessed over http, you should do <code>mv my-git.git/hooks/post-update.sample +my-git.git/hooks/post-update</code> at this point. This makes sure that every time you push into this repository, <code>git update-server-info</code> is run. </td> </tr> </table> </div> <p>Your "public repository" is now ready to accept your changes. Come back to the machine you have your private repository. From there, run this command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git push <public-host>:/path/to/my-git.git master</pre> </div> </div> <p>This synchronizes your public repository to match the named branch head (i.e. <code>master</code> in this case) and objects reachable from them in your current repository.</p> <p>As a real example, this is how I update my public Git repository. Kernel.org mirror network takes care of the propagation to other publicly visible machines:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git push master.kernel.org:/pub/scm/git/git.git/</pre> </div> </div> </div> <h2 id="_packing_your_repository">Packing your repository</h2> <div class="sectionbody"> <p>Earlier, we saw that one file under <code>.git/objects/??/</code> directory is stored for each Git object you create. This representation is efficient to create atomically and safely, but not so convenient to transport over the network. Since Git objects are immutable once they are created, there is a way to optimize the storage by "packing them together". The command</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git repack</pre> </div> </div> <p>will do it for you. If you followed the tutorial examples, you would have accumulated about 17 objects in <code>.git/objects/??/</code> directories by now. <code>git repack</code> tells you how many objects it packed, and stores the packed file in the <code>.git/objects/pack</code> directory.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> You will see two files, <code>pack-*.pack</code> and <code>pack-*.idx</code>, in <code>.git/objects/pack</code> directory. They are closely related to each other, and if you ever copy them by hand to a different repository for whatever reason, you should make sure you copy them together. The former holds all the data from the objects in the pack, and the latter holds the index for random access. </td> </tr> </table> </div> <p>If you are paranoid, running <code>git verify-pack</code> command would detect if you have a corrupt pack, but do not worry too much. Our programs are always perfect ;-).</p> <p>Once you have packed objects, you do not need to leave the unpacked objects that are contained in the pack file anymore.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git prune-packed</pre> </div> </div> <p>would remove them for you.</p> <p>You can try running <code>find .git/objects -type f</code> before and after you run <code>git prune-packed</code> if you are curious. Also <code>git +count-objects</code> would tell you how many unpacked objects are in your repository and how much space they are consuming.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> <code>git pull</code> is slightly cumbersome for HTTP transport, as a packed repository may contain relatively few objects in a relatively large pack. If you expect many HTTP pulls from your public repository you might want to repack & prune often, or never. </td> </tr> </table> </div> <p>If you run <code>git repack</code> again at this point, it will say "Nothing new to pack.". Once you continue your development and accumulate the changes, running <code>git repack</code> again will create a new pack, that contains objects created since you packed your repository the last time. We recommend that you pack your project soon after the initial import (unless you are starting your project from scratch), and then run <code>git repack</code> every once in a while, depending on how active your project is.</p> <p>When a repository is synchronized via <code>git push</code> and <code>git pull</code> objects packed in the source repository are usually stored unpacked in the destination. While this allows you to use different packing strategies on both ends, it also means you may need to repack both repositories every once in a while.</p> </div> <h2 id="_working_with_others">Working with others</h2> <div class="sectionbody"> <p>Although Git is a truly distributed system, it is often convenient to organize your project with an informal hierarchy of developers. Linux kernel development is run this way. There is a nice illustration (page 17, "Merges to Mainline") in <a href="https://web.archive.org/web/20120915203609/http://www.xenotime.net/linux/mentor/linux-mentoring-2006.pdf">Randy Dunlap’s presentation</a>.</p> <p>It should be stressed that this hierarchy is purely <strong>informal</strong>. There is nothing fundamental in Git that enforces the "chain of patch flow" this hierarchy implies. You do not have to pull from only one remote repository.</p> <p>A recommended workflow for a "project lead" goes like this:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Prepare your primary repository on your local machine. Your work is done there.</p> </li> <li> <p>Prepare a public repository accessible to others.</p> <p>If other people are pulling from your repository over dumb transport protocols (HTTP), you need to keep this repository <code>dumb transport friendly</code>. After <code>git init</code>, <code>$GIT_DIR/hooks/post-update.sample</code> copied from the standard templates would contain a call to <code>git update-server-info</code> but you need to manually enable the hook with <code>mv post-update.sample post-update</code>. This makes sure <code>git update-server-info</code> keeps the necessary files up to date.</p> </li> <li> <p>Push into the public repository from your primary repository.</p> </li> <li> <p><code>git repack</code> the public repository. This establishes a big pack that contains the initial set of objects as the baseline, and possibly <code>git prune</code> if the transport used for pulling from your repository supports packed repositories.</p> </li> <li> <p>Keep working in your primary repository. Your changes include modifications of your own, patches you receive via e-mails, and merges resulting from pulling the "public" repositories of your "subsystem maintainers".</p> <p>You can repack this private repository whenever you feel like.</p> </li> <li> <p>Push your changes to the public repository, and announce it to the public.</p> </li> <li> <p>Every once in a while, <code>git repack</code> the public repository. Go back to step 5. and continue working.</p> </li> </ol> </div> <p>A recommended work cycle for a "subsystem maintainer" who works on that project and has an own "public repository" goes like this:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Prepare your work repository, by running <code>git clone</code> on the public repository of the "project lead". The URL used for the initial cloning is stored in the remote.origin.url configuration variable.</p> </li> <li> <p>Prepare a public repository accessible to others, just like the "project lead" person does.</p> </li> <li> <p>Copy over the packed files from "project lead" public repository to your public repository, unless the "project lead" repository lives on the same machine as yours. In the latter case, you can use <code>objects/info/alternates</code> file to point at the repository you are borrowing from.</p> </li> <li> <p>Push into the public repository from your primary repository. Run <code>git repack</code>, and possibly <code>git prune</code> if the transport used for pulling from your repository supports packed repositories.</p> </li> <li> <p>Keep working in your primary repository. Your changes include modifications of your own, patches you receive via e-mails, and merges resulting from pulling the "public" repositories of your "project lead" and possibly your "sub-subsystem maintainers".</p> <p>You can repack this private repository whenever you feel like.</p> </li> <li> <p>Push your changes to your public repository, and ask your "project lead" and possibly your "sub-subsystem maintainers" to pull from it.</p> </li> <li> <p>Every once in a while, <code>git repack</code> the public repository. Go back to step 5. and continue working.</p> </li> </ol> </div> <p>A recommended work cycle for an "individual developer" who does not have a "public" repository is somewhat different. It goes like this:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Prepare your work repository, by <code>git clone</code> the public repository of the "project lead" (or a "subsystem maintainer", if you work on a subsystem). The URL used for the initial cloning is stored in the remote.origin.url configuration variable.</p> </li> <li> <p>Do your work in your repository on <code>master</code> branch.</p> </li> <li> <p>Run <code>git fetch origin</code> from the public repository of your upstream every once in a while. This does only the first half of <code>git pull</code> but does not merge. The head of the public repository is stored in <code>.git/refs/remotes/origin/master</code>.</p> </li> <li> <p>Use <code>git cherry origin</code> to see which ones of your patches were accepted, and/or use <code>git rebase origin</code> to port your unmerged changes forward to the updated upstream.</p> </li> <li> <p>Use <code>git format-patch origin</code> to prepare patches for e-mail submission to your upstream and send it out. Go back to step 2. and continue.</p> </li> </ol> </div> </div> <h2 id="_working_with_others_shared_repository_style">Working with others, shared repository style</h2> <div class="sectionbody"> <p>If you are coming from a CVS background, the style of cooperation suggested in the previous section may be new to you. You do not have to worry. Git supports the "shared public repository" style of cooperation you are probably more familiar with as well.</p> <p>See <a href="gitcvs-migration">gitcvs-migration[7]</a> for the details.</p> </div> <h2 id="_bundling_your_work_together">Bundling your work together</h2> <div class="sectionbody"> <p>It is likely that you will be working on more than one thing at a time. It is easy to manage those more-or-less independent tasks using branches with Git.</p> <p>We have already seen how branches work previously, with "fun and work" example using two branches. The idea is the same if there are more than two branches. Let’s say you started out from "master" head, and have some new code in the "master" branch, and two independent fixes in the "commit-fix" and "diff-fix" branches:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show-branch +! [commit-fix] Fix commit message normalization. + ! [diff-fix] Fix rename detection. + * [master] Release candidate #1 +--- + + [diff-fix] Fix rename detection. + + [diff-fix~1] Better common substring algorithm. ++ [commit-fix] Fix commit message normalization. + * [master] Release candidate #1 +++* [diff-fix~2] Pretty-print messages.</pre> </div> </div> <p>Both fixes are tested well, and at this point, you want to merge in both of them. You could merge in <code>diff-fix</code> first and then <code>commit-fix</code> next, like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git merge -m "Merge fix in diff-fix" diff-fix +$ git merge -m "Merge fix in commit-fix" commit-fix</pre> </div> </div> <p>Which would result in:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show-branch +! [commit-fix] Fix commit message normalization. + ! [diff-fix] Fix rename detection. + * [master] Merge fix in commit-fix +--- + - [master] Merge fix in commit-fix ++ * [commit-fix] Fix commit message normalization. + - [master~1] Merge fix in diff-fix + +* [diff-fix] Fix rename detection. + +* [diff-fix~1] Better common substring algorithm. + * [master~2] Release candidate #1 +++* [master~3] Pretty-print messages.</pre> </div> </div> <p>However, there is no particular reason to merge in one branch first and the other next, when what you have are a set of truly independent changes (if the order mattered, then they are not independent by definition). You could instead merge those two branches into the current branch at once. First let’s undo what we just did and start over. We would want to get the master branch before these two merges by resetting it to <code>master~2</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git reset --hard master~2</pre> </div> </div> <p>You can make sure <code>git show-branch</code> matches the state before those two <code>git merge</code> you just did. Then, instead of running two <code>git merge</code> commands in a row, you would merge these two branch heads (this is known as <code>making an Octopus</code>):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git merge commit-fix diff-fix +$ git show-branch +! [commit-fix] Fix commit message normalization. + ! [diff-fix] Fix rename detection. + * [master] Octopus merge of branches 'diff-fix' and 'commit-fix' +--- + - [master] Octopus merge of branches 'diff-fix' and 'commit-fix' ++ * [commit-fix] Fix commit message normalization. + +* [diff-fix] Fix rename detection. + +* [diff-fix~1] Better common substring algorithm. + * [master~1] Release candidate #1 +++* [master~2] Pretty-print messages.</pre> </div> </div> <p>Note that you should not do Octopus just because you can. An octopus is a valid thing to do and often makes it easier to view the commit history if you are merging more than two independent changes at the same time. However, if you have merge conflicts with any of the branches you are merging in and need to hand resolve, that is an indication that the development happened in those branches were not independent after all, and you should merge two at a time, documenting how you resolved the conflicts, and the reason why you preferred changes made in one side over the other. Otherwise it would make the project history harder to follow, not easier.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gittutorial">gittutorial[7]</a>, <a href="gittutorial-2">gittutorial-2[7]</a>, <a href="gitcvs-migration">gitcvs-migration[7]</a>, <a href="git-help">git-help[1]</a>, <a href="giteveryday">giteveryday[7]</a>, <a href="user-manual">The Git User’s Manual</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitcore-tutorial" class="_attribution-link">https://git-scm.com/docs/gitcore-tutorial</a> + </p> +</div> diff --git a/devdocs/git/gitcredentials.html b/devdocs/git/gitcredentials.html new file mode 100644 index 00000000..698eeb44 --- /dev/null +++ b/devdocs/git/gitcredentials.html @@ -0,0 +1,35 @@ +<h1>gitcredentials</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitcredentials - Providing usernames and passwords to Git</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="listingblock"> <div class="content"> <pre data-language="shell">git config credential.https://example.com.username myusername +git config credential.helper "$helper $options"</pre> </div> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Git will sometimes need credentials from the user in order to perform operations; for example, it may need to ask for a username and password in order to access a remote repository over HTTP. Some remotes accept a personal access token or OAuth access token as a password. This manual describes the mechanisms Git uses to request these credentials, as well as some features to avoid inputting these credentials repeatedly.</p> </div> <h2 id="_requesting_credentials">Requesting credentials</h2> <div class="sectionbody"> <p>Without any credential helpers defined, Git will try the following strategies to ask the user for usernames and passwords:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>If the <code>GIT_ASKPASS</code> environment variable is set, the program specified by the variable is invoked. A suitable prompt is provided to the program on the command line, and the user’s input is read from its standard output.</p> </li> <li> <p>Otherwise, if the <code>core.askPass</code> configuration variable is set, its value is used as above.</p> </li> <li> <p>Otherwise, if the <code>SSH_ASKPASS</code> environment variable is set, its value is used as above.</p> </li> <li> <p>Otherwise, the user is prompted on the terminal.</p> </li> </ol> </div> </div> <h2 id="_avoiding_repetition">Avoiding repetition</h2> <div class="sectionbody"> <p>It can be cumbersome to input the same credentials over and over. Git provides two methods to reduce this annoyance:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Static configuration of usernames for a given authentication context.</p> </li> <li> <p>Credential helpers to cache or store passwords, or to interact with a system password wallet or keychain.</p> </li> </ol> </div> <p>The first is simple and appropriate if you do not have secure storage available for a password. It is generally configured by adding this to your config:</p> <div class="listingblock"> <div class="content"> <pre>[credential "https://example.com"] + username = me</pre> </div> </div> <p>Credential helpers, on the other hand, are external programs from which Git can request both usernames and passwords; they typically interface with secure storage provided by the OS or other programs. Alternatively, a credential-generating helper might generate credentials for certain servers via some API.</p> <p>To use a helper, you must first select one to use. Git currently includes the following helpers:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitcredentials.txt-cache"> cache </dt> <dd> <p>Cache credentials in memory for a short period of time. See <a href="git-credential-cache">git-credential-cache[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/gitcredentials.txt-store"> store </dt> <dd> <p>Store credentials indefinitely on disk. See <a href="git-credential-store">git-credential-store[1]</a> for details.</p> </dd> </dl> </div> <p>You may also have third-party helpers installed; search for <code>credential-*</code> in the output of <code>git help -a</code>, and consult the documentation of individual helpers. Once you have selected a helper, you can tell Git to use it by putting its name into the credential.helper variable.</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Find a helper.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git help -a | grep credential- +credential-foo</pre> </div> </div> </li> <li> <p>Read its description.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git help credential-foo</pre> </div> </div> </li> <li> <p>Tell Git to use it.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config --global credential.helper foo</pre> </div> </div> </li> </ol> </div> <div class="sect2"> <h3 id="_available_helpers"> +Available helpers</h3> <p>The community maintains a comprehensive list of Git credential helpers at <a href="https://git-scm.com/doc/credential-helpers" class="bare">https://git-scm.com/doc/credential-helpers</a>.</p> </div> <div class="sect2"> <h3 id="_oauth"> +OAuth</h3> <p>An alternative to inputting passwords or personal access tokens is to use an OAuth credential helper. Initial authentication opens a browser window to the host. Subsequent authentication happens in the background. Many popular Git hosts support OAuth.</p> </div> </div> <h2 id="_credential_contexts">Credential contexts</h2> <div class="sectionbody"> <p>Git considers each credential to have a context defined by a URL. This context is used to look up context-specific configuration, and is passed to any helpers, which may use it as an index into secure storage.</p> <p>For instance, imagine we are accessing <code>https://example.com/foo.git</code>. When Git looks into a config file to see if a section matches this context, it will consider the two a match if the context is a more-specific subset of the pattern in the config file. For example, if you have this in your config file:</p> <div class="listingblock"> <div class="content"> <pre>[credential "https://example.com"] + username = foo</pre> </div> </div> <p>then we will match: both protocols are the same, both hosts are the same, and the "pattern" URL does not care about the path component at all. However, this context would not match:</p> <div class="listingblock"> <div class="content"> <pre>[credential "https://kernel.org"] + username = foo</pre> </div> </div> <p>because the hostnames differ. Nor would it match <code>foo.example.com</code>; Git compares hostnames exactly, without considering whether two hosts are part of the same domain. Likewise, a config entry for <code>http://example.com</code> would not match: Git compares the protocols exactly. However, you may use wildcards in the domain name and other pattern matching techniques as with the <code>http.<URL>.*</code> options.</p> <p>If the "pattern" URL does include a path component, then this too must match exactly: the context <code>https://example.com/bar/baz.git</code> will match a config entry for <code>https://example.com/bar/baz.git</code> (in addition to matching the config entry for <code>https://example.com</code>) but will not match a config entry for <code>https://example.com/bar</code>.</p> </div> <h2 id="_configuration_options">Configuration options</h2> <div class="sectionbody"> <p>Options for a credential context can be configured either in <code>credential.*</code> (which applies to all credentials), or <code>credential.<URL>.*</code>, where <URL> matches the context as described above.</p> <p>The following options are available in either location:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitcredentials.txt-helper"> helper </dt> <dd> <p>The name of an external credential helper, and any associated options. If the helper name is not an absolute path, then the string <code>git +credential-</code> is prepended. The resulting string is executed by the shell (so, for example, setting this to <code>foo --option=bar</code> will execute <code>git credential-foo --option=bar</code> via the shell. See the manual of specific helpers for examples of their use.</p> <p>If there are multiple instances of the <code>credential.helper</code> configuration variable, each helper will be tried in turn, and may provide a username, password, or nothing. Once Git has acquired both a username and a non-expired password, no more helpers will be tried.</p> <p>If <code>credential.helper</code> is configured to the empty string, this resets the helper list to empty (so you may override a helper set by a lower-priority config file by configuring the empty-string helper, followed by whatever set of helpers you would like).</p> </dd> <dt class="hdlist1" id="Documentation/gitcredentials.txt-username"> username </dt> <dd> <p>A default username, if one is not provided in the URL.</p> </dd> <dt class="hdlist1" id="Documentation/gitcredentials.txt-useHttpPath"> useHttpPath </dt> <dd> <p>By default, Git does not consider the "path" component of an http URL to be worth matching via external helpers. This means that a credential stored for <code>https://example.com/foo.git</code> will also be used for <code>https://example.com/bar.git</code>. If you do want to distinguish these cases, set this option to <code>true</code>.</p> </dd> </dl> </div> </div> <h2 id="_custom_helpers">Custom helpers</h2> <div class="sectionbody"> <p>You can write your own custom helpers to interface with any system in which you keep credentials.</p> <p>Credential helpers are programs executed by Git to fetch or save credentials from and to long-term storage (where "long-term" is simply longer than a single Git process; e.g., credentials may be stored in-memory for a few minutes, or indefinitely on disk).</p> <p>Each helper is specified by a single string in the configuration variable <code>credential.helper</code> (and others, see <a href="git-config">git-config[1]</a>). The string is transformed by Git into a command to be executed using these rules:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>If the helper string begins with "!", it is considered a shell snippet, and everything after the "!" becomes the command.</p> </li> <li> <p>Otherwise, if the helper string begins with an absolute path, the verbatim helper string becomes the command.</p> </li> <li> <p>Otherwise, the string "git credential-" is prepended to the helper string, and the result becomes the command.</p> </li> </ol> </div> <p>The resulting command then has an "operation" argument appended to it (see below for details), and the result is executed by the shell.</p> <p>Here are some example specifications:</p> <div class="listingblock"> <div class="content"> <pre># run "git credential-foo" +[credential] + helper = foo + +# same as above, but pass an argument to the helper +[credential] + helper = "foo --bar=baz" + +# the arguments are parsed by the shell, so use shell +# quoting if necessary +[credential] + helper = "foo --bar='whitespace arg'" + +# you can also use an absolute path, which will not use the git wrapper +[credential] + helper = "/path/to/my/helper --with-arguments" + +# or you can specify your own shell snippet +[credential "https://example.com"] + username = your_user + helper = "!f() { test \"$1\" = get && echo \"password=$(cat $HOME/.secret)\"; }; f"</pre> </div> </div> <p>Generally speaking, rule (3) above is the simplest for users to specify. Authors of credential helpers should make an effort to assist their users by naming their program "git-credential-$NAME", and putting it in the <code>$PATH</code> or <code>$GIT_EXEC_PATH</code> during installation, which will allow a user to enable it with <code>git config credential.helper $NAME</code>.</p> <p>When a helper is executed, it will have one "operation" argument appended to its command line, which is one of:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitcredentials.txt-codegetcode"> <code>get</code> </dt> <dd> <p>Return a matching credential, if any exists.</p> </dd> <dt class="hdlist1" id="Documentation/gitcredentials.txt-codestorecode"> <code>store</code> </dt> <dd> <p>Store the credential, if applicable to the helper.</p> </dd> <dt class="hdlist1" id="Documentation/gitcredentials.txt-codeerasecode"> <code>erase</code> </dt> <dd> <p>Remove matching credentials, if any, from the helper’s storage.</p> </dd> </dl> </div> <p>The details of the credential will be provided on the helper’s stdin stream. The exact format is the same as the input/output format of the <code>git credential</code> plumbing command (see the section <code>INPUT/OUTPUT +FORMAT</code> in <a href="git-credential">git-credential[1]</a> for a detailed specification).</p> <p>For a <code>get</code> operation, the helper should produce a list of attributes on stdout in the same format (see <a href="git-credential">git-credential[1]</a> for common attributes). A helper is free to produce a subset, or even no values at all if it has nothing useful to provide. Any provided attributes will overwrite those already known about by Git’s credential subsystem. Unrecognised attributes are silently discarded.</p> <p>While it is possible to override all attributes, well behaving helpers should refrain from doing so for any attribute other than username and password.</p> <p>If a helper outputs a <code>quit</code> attribute with a value of <code>true</code> or <code>1</code>, no further helpers will be consulted, nor will the user be prompted (if no credential has been provided, the operation will then fail).</p> <p>Similarly, no more helpers will be consulted once both username and password had been provided.</p> <p>For a <code>store</code> or <code>erase</code> operation, the helper’s output is ignored.</p> <p>If a helper fails to perform the requested operation or needs to notify the user of a potential issue, it may write to stderr.</p> <p>If it does not support the requested operation (e.g., a read-only store or generator), it should silently ignore the request.</p> <p>If a helper receives any other operation, it should silently ignore the request. This leaves room for future operations to be added (older helpers will just ignore the new requests).</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitcredentials" class="_attribution-link">https://git-scm.com/docs/gitcredentials</a> + </p> +</div> diff --git a/devdocs/git/gitcvs-migration.html b/devdocs/git/gitcvs-migration.html new file mode 100644 index 00000000..34b6df5c --- /dev/null +++ b/devdocs/git/gitcvs-migration.html @@ -0,0 +1,11 @@ +<h1>gitcvs-migration</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitcvs-migration - Git for CVS users</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git cvsimport *</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Git differs from CVS in that every working tree contains a repository with a full copy of the project history, and no repository is inherently more important than any other. However, you can emulate the CVS model by designating a single shared repository which people can synchronize with; this document explains how to do that.</p> <p>Some basic familiarity with Git is required. Having gone through <a href="gittutorial">gittutorial[7]</a> and <a href="gitglossary">gitglossary[7]</a> should be sufficient.</p> </div> <h2 id="_developing_against_a_shared_repository">Developing against a shared repository</h2> <div class="sectionbody"> <p>Suppose a shared repository is set up in /pub/repo.git on the host foo.com. Then as an individual committer you can clone the shared repository over ssh with:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git clone foo.com:/pub/repo.git/ my-project +$ cd my-project</pre> </div> </div> <p>and hack away. The equivalent of <code>cvs update</code> is</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git pull origin</pre> </div> </div> <p>which merges in any work that others might have done since the clone operation. If there are uncommitted changes in your working tree, commit them first before running git pull.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> <p>The <code>pull</code> command knows where to get updates from because of certain configuration variables that were set by the first <code>git clone</code> command; see <code>git config -l</code> and the <a href="git-config">git-config[1]</a> man page for details.</p> </td> </tr> </table> </div> <p>You can update the shared repository with your changes by first committing your changes, and then using the <code>git push</code> command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git push origin master</pre> </div> </div> <p>to "push" those commits to the shared repository. If someone else has updated the repository more recently, <code>git push</code>, like <code>cvs commit</code>, will complain, in which case you must pull any changes before attempting the push again.</p> <p>In the <code>git push</code> command above we specify the name of the remote branch to update (<code>master</code>). If we leave that out, <code>git push</code> tries to update any branches in the remote repository that have the same name as a branch in the local repository. So the last <code>push</code> can be done with either of:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git push origin +$ git push foo.com:/pub/project.git/</pre> </div> </div> <p>as long as the shared repository does not have any branches other than <code>master</code>.</p> </div> <h2 id="_setting_up_a_shared_repository">Setting up a shared repository</h2> <div class="sectionbody"> <p>We assume you have already created a Git repository for your project, possibly created from scratch or from a tarball (see <a href="gittutorial">gittutorial[7]</a>), or imported from an already existing CVS repository (see the next section).</p> <p>Assume your existing repo is at /home/alice/myproject. Create a new "bare" repository (a repository without a working tree) and fetch your project into it:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ mkdir /pub/my-repo.git +$ cd /pub/my-repo.git +$ git --bare init --shared +$ git --bare fetch /home/alice/myproject master:master</pre> </div> </div> <p>Next, give every team member read/write access to this repository. One easy way to do this is to give all the team members ssh access to the machine where the repository is hosted. If you don’t want to give them a full shell on the machine, there is a restricted shell which only allows users to do Git pushes and pulls; see <a href="git-shell">git-shell[1]</a>.</p> <p>Put all the committers in the same group, and make the repository writable by that group:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ chgrp -R $group /pub/my-repo.git</pre> </div> </div> <p>Make sure committers have a umask of at most 027, so that the directories they create are writable and searchable by other group members.</p> </div> <h2 id="_importing_a_cvs_archive">Importing a cvs archive</h2> <div class="sectionbody"> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> These instructions use the <code>git-cvsimport</code> script which ships with git, but other importers may provide better results. See the note in <a href="git-cvsimport">git-cvsimport[1]</a> for other options. </td> </tr> </table> </div> <p>First, install version 2.1 or higher of cvsps from <a href="https://github.com/andreyvit/cvsps">https://github.com/andreyvit/cvsps</a> and make sure it is in your path. Then cd to a checked out CVS working directory of the project you are interested in and run <a href="git-cvsimport">git-cvsimport[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cvsimport -C <destination> <module></pre> </div> </div> <p>This puts a Git archive of the named CVS module in the directory <destination>, which will be created if necessary.</p> <p>The import checks out from CVS every revision of every file. Reportedly cvsimport can average some twenty revisions per second, so for a medium-sized project this should not take more than a couple of minutes. Larger projects or remote repositories may take longer.</p> <p>The main trunk is stored in the Git branch named <code>origin</code>, and additional CVS branches are stored in Git branches with the same names. The most recent version of the main trunk is also left checked out on the <code>master</code> branch, so you can start adding your own changes right away.</p> <p>The import is incremental, so if you call it again next month it will fetch any CVS updates that have been made in the meantime. For this to work, you must not modify the imported branches; instead, create new branches for your own changes, and merge in the imported branches as necessary.</p> <p>If you want a shared repository, you will need to make a bare clone of the imported directory, as described above. Then treat the imported directory as another development clone for purposes of merging incremental imports.</p> </div> <h2 id="_advanced_shared_repository_management">Advanced shared repository management</h2> <div class="sectionbody"> <p>Git allows you to specify scripts called "hooks" to be run at certain points. You can use these, for example, to send all commits to the shared repository to a mailing list. See <a href="githooks">githooks[5]</a>.</p> <p>You can enforce finer grained permissions using update hooks. See <a href="https://git-scm.com/docs/howto/update-hook-example">Controlling access to branches using update hooks</a>.</p> </div> <h2 id="_providing_cvs_access_to_a_git_repository">Providing cvs access to a git repository</h2> <div class="sectionbody"> <p>It is also possible to provide true CVS access to a Git repository, so that developers can still use CVS; see <a href="git-cvsserver">git-cvsserver[1]</a> for details.</p> </div> <h2 id="_alternative_development_models">Alternative development models</h2> <div class="sectionbody"> <p>CVS users are accustomed to giving a group of developers commit access to a common repository. As we’ve seen, this is also possible with Git. However, the distributed nature of Git allows other development models, and you may want to first consider whether one of them might be a better fit for your project.</p> <p>For example, you can choose a single person to maintain the project’s primary public repository. Other developers then clone this repository and each work in their own clone. When they have a series of changes that they’re happy with, they ask the maintainer to pull from the branch containing the changes. The maintainer reviews their changes and pulls them into the primary repository, which other developers pull from as necessary to stay coordinated. The Linux kernel and other projects use variants of this model.</p> <p>With a small group, developers may just pull changes from each other’s repositories without the need for a central maintainer.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gittutorial">gittutorial[7]</a>, <a href="gittutorial-2">gittutorial-2[7]</a>, <a href="gitcore-tutorial">gitcore-tutorial[7]</a>, <a href="gitglossary">gitglossary[7]</a>, <a href="giteveryday">giteveryday[7]</a>, <a href="user-manual">The Git User’s Manual</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitcvs-migration" class="_attribution-link">https://git-scm.com/docs/gitcvs-migration</a> + </p> +</div> diff --git a/devdocs/git/gitdiffcore.html b/devdocs/git/gitdiffcore.html new file mode 100644 index 00000000..5a099c43 --- /dev/null +++ b/devdocs/git/gitdiffcore.html @@ -0,0 +1,18 @@ +<h1>gitdiffcore</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitdiffcore - Tweaking diff output</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git diff *</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>The diff commands <code>git diff-index</code>, <code>git diff-files</code>, and <code>git diff-tree</code> can be told to manipulate differences they find in unconventional ways before showing <code>diff</code> output. The manipulation is collectively called "diffcore transformation". This short note describes what they are and how to use them to produce <code>diff</code> output that is easier to understand than the conventional kind.</p> </div> <h2 id="_the_chain_of_operation">The chain of operation</h2> <div class="sectionbody"> <p>The <code>git diff-*</code> family works by first comparing two sets of files:</p> <div class="ulist"> <ul> <li> <p><code>git diff-index</code> compares contents of a "tree" object and the working directory (when <code>--cached</code> flag is not used) or a "tree" object and the index file (when <code>--cached</code> flag is used);</p> </li> <li> <p><code>git diff-files</code> compares contents of the index file and the working directory;</p> </li> <li> <p><code>git diff-tree</code> compares contents of two "tree" objects;</p> </li> </ul> </div> <p>In all of these cases, the commands themselves first optionally limit the two sets of files by any pathspecs given on their command-lines, and compare corresponding paths in the two resulting sets of files.</p> <p>The pathspecs are used to limit the world diff operates in. They remove the filepairs outside the specified sets of pathnames. E.g. If the input set of filepairs included:</p> <div class="listingblock"> <div class="content"> <pre>:100644 100644 bcd1234... 0123456... M junkfile</pre> </div> </div> <p>but the command invocation was <code>git diff-files myfile</code>, then the junkfile entry would be removed from the list because only "myfile" is under consideration.</p> <p>The result of comparison is passed from these commands to what is internally called "diffcore", in a format similar to what is output when the -p option is not used. E.g.</p> <div class="listingblock"> <div class="content"> <pre>in-place edit :100644 100644 bcd1234... 0123456... M file0 +create :000000 100644 0000000... 1234567... A file4 +delete :100644 000000 1234567... 0000000... D file5 +unmerged :000000 000000 0000000... 0000000... U file6</pre> </div> </div> <p>The diffcore mechanism is fed a list of such comparison results (each of which is called "filepair", although at this point each of them talks about a single file), and transforms such a list into another list. There are currently 5 such transformations:</p> <div class="ulist"> <ul> <li> <p>diffcore-break</p> </li> <li> <p>diffcore-rename</p> </li> <li> <p>diffcore-merge-broken</p> </li> <li> <p>diffcore-pickaxe</p> </li> <li> <p>diffcore-order</p> </li> <li> <p>diffcore-rotate</p> </li> </ul> </div> <p>These are applied in sequence. The set of filepairs <code>git diff-*</code> commands find are used as the input to diffcore-break, and the output from diffcore-break is used as the input to the next transformation. The final result is then passed to the output routine and generates either diff-raw format (see Output format sections of the manual for <code>git diff-*</code> commands) or diff-patch format.</p> </div> <h2 id="_diffcore_break_for_splitting_up_complete_rewrites">Diffcore-break: for splitting up complete rewrites</h2> <div class="sectionbody"> <p>The second transformation in the chain is diffcore-break, and is controlled by the -B option to the <code>git diff-*</code> commands. This is used to detect a filepair that represents "complete rewrite" and break such filepair into two filepairs that represent delete and create. E.g. If the input contained this filepair:</p> <div class="listingblock"> <div class="content"> <pre>:100644 100644 bcd1234... 0123456... M file0</pre> </div> </div> <p>and if it detects that the file "file0" is completely rewritten, it changes it to:</p> <div class="listingblock"> <div class="content"> <pre>:100644 000000 bcd1234... 0000000... D file0 +:000000 100644 0000000... 0123456... A file0</pre> </div> </div> <p>For the purpose of breaking a filepair, diffcore-break examines the extent of changes between the contents of the files before and after modification (i.e. the contents that have "bcd1234…" and "0123456…" as their SHA-1 content ID, in the above example). The amount of deletion of original contents and insertion of new material are added together, and if it exceeds the "break score", the filepair is broken into two. The break score defaults to 50% of the size of the smaller of the original and the result (i.e. if the edit shrinks the file, the size of the result is used; if the edit lengthens the file, the size of the original is used), and can be customized by giving a number after "-B" option (e.g. "-B75" to tell it to use 75%).</p> </div> <h2 id="_diffcore_rename_for_detecting_renames_and_copies">Diffcore-rename: for detecting renames and copies</h2> <div class="sectionbody"> <p>This transformation is used to detect renames and copies, and is controlled by the -M option (to detect renames) and the -C option (to detect copies as well) to the <code>git diff-*</code> commands. If the input contained these filepairs:</p> <div class="listingblock"> <div class="content"> <pre>:100644 000000 0123456... 0000000... D fileX +:000000 100644 0000000... 0123456... A file0</pre> </div> </div> <p>and the contents of the deleted file fileX is similar enough to the contents of the created file file0, then rename detection merges these filepairs and creates:</p> <div class="listingblock"> <div class="content"> <pre>:100644 100644 0123456... 0123456... R100 fileX file0</pre> </div> </div> <p>When the "-C" option is used, the original contents of modified files, and deleted files (and also unmodified files, if the "--find-copies-harder" option is used) are considered as candidates of the source files in rename/copy operation. If the input were like these filepairs, that talk about a modified file fileY and a newly created file file0:</p> <div class="listingblock"> <div class="content"> <pre>:100644 100644 0123456... 1234567... M fileY +:000000 100644 0000000... bcd3456... A file0</pre> </div> </div> <p>the original contents of fileY and the resulting contents of file0 are compared, and if they are similar enough, they are changed to:</p> <div class="listingblock"> <div class="content"> <pre>:100644 100644 0123456... 1234567... M fileY +:100644 100644 0123456... bcd3456... C100 fileY file0</pre> </div> </div> <p>In both rename and copy detection, the same "extent of changes" algorithm used in diffcore-break is used to determine if two files are "similar enough", and can be customized to use a similarity score different from the default of 50% by giving a number after the "-M" or "-C" option (e.g. "-M8" to tell it to use 8/10 = 80%).</p> <p>Note that when rename detection is on but both copy and break detection are off, rename detection adds a preliminary step that first checks if files are moved across directories while keeping their filename the same. If there is a file added to a directory whose contents are sufficiently similar to a file with the same name that got deleted from a different directory, it will mark them as renames and exclude them from the later quadratic step (the one that pairwise compares all unmatched files to find the "best" matches, determined by the highest content similarity). So, for example, if a deleted docs/ext.txt and an added docs/config/ext.txt are similar enough, they will be marked as a rename and prevent an added docs/ext.md that may be even more similar to the deleted docs/ext.txt from being considered as the rename destination in the later step. For this reason, the preliminary "match same filename" step uses a bit higher threshold to mark a file pair as a rename and stop considering other candidates for better matches. At most, one comparison is done per file in this preliminary pass; so if there are several remaining ext.txt files throughout the directory hierarchy after exact rename detection, this preliminary step may be skipped for those files.</p> <p>Note. When the "-C" option is used with <code>--find-copies-harder</code> option, <code>git diff-*</code> commands feed unmodified filepairs to diffcore mechanism as well as modified ones. This lets the copy detector consider unmodified files as copy source candidates at the expense of making it slower. Without <code>--find-copies-harder</code>, <code>git diff-*</code> commands can detect copies only if the file that was copied happened to have been modified in the same changeset.</p> </div> <h2 id="_diffcore_merge_broken_for_putting_complete_rewrites_back_together">Diffcore-merge-broken: for putting complete rewrites back together</h2> <div class="sectionbody"> <p>This transformation is used to merge filepairs broken by diffcore-break, and not transformed into rename/copy by diffcore-rename, back into a single modification. This always runs when diffcore-break is used.</p> <p>For the purpose of merging broken filepairs back, it uses a different "extent of changes" computation from the ones used by diffcore-break and diffcore-rename. It counts only the deletion from the original, and does not count insertion. If you removed only 10 lines from a 100-line document, even if you added 910 new lines to make a new 1000-line document, you did not do a complete rewrite. diffcore-break breaks such a case in order to help diffcore-rename to consider such filepairs as a candidate of rename/copy detection, but if filepairs broken that way were not matched with other filepairs to create rename/copy, then this transformation merges them back into the original "modification".</p> <p>The "extent of changes" parameter can be tweaked from the default 80% (that is, unless more than 80% of the original material is deleted, the broken pairs are merged back into a single modification) by giving a second number to -B option, like these:</p> <div class="ulist"> <ul> <li> <p>-B50/60 (give 50% "break score" to diffcore-break, use 60% for diffcore-merge-broken).</p> </li> <li> <p>-B/60 (the same as above, since diffcore-break defaults to 50%).</p> </li> </ul> </div> <p>Note that earlier implementation left a broken pair as separate creation and deletion patches. This was an unnecessary hack, and the latest implementation always merges all the broken pairs back into modifications, but the resulting patch output is formatted differently for easier review in case of such a complete rewrite by showing the entire contents of the old version prefixed with <code>-</code>, followed by the entire contents of the new version prefixed with <code>+</code>.</p> </div> <h2 id="_diffcore_pickaxe_for_detecting_additiondeletion_of_specified_string">Diffcore-pickaxe: for detecting addition/deletion of specified string</h2> <div class="sectionbody"> <p>This transformation limits the set of filepairs to those that change specified strings between the preimage and the postimage in a certain way. -S<block of text> and -G<regular expression> options are used to specify different ways these strings are sought.</p> <p>"-S<block of text>" detects filepairs whose preimage and postimage have different number of occurrences of the specified block of text. By definition, it will not detect in-file moves. Also, when a changeset moves a file wholesale without affecting the interesting string, diffcore-rename kicks in as usual, and <code>-S</code> omits the filepair (since the number of occurrences of that string didn’t change in that rename-detected filepair). When used with <code>--pickaxe-regex</code>, treat the <block of text> as an extended POSIX regular expression to match, instead of a literal string.</p> <p>"-G<regular expression>" (mnemonic: grep) detects filepairs whose textual diff has an added or a deleted line that matches the given regular expression. This means that it will detect in-file (or what rename-detection considers the same file) moves, which is noise. The implementation runs diff twice and greps, and this can be quite expensive. To speed things up, binary files without textconv filters will be ignored.</p> <p>When <code>-S</code> or <code>-G</code> are used without <code>--pickaxe-all</code>, only filepairs that match their respective criterion are kept in the output. When <code>--pickaxe-all</code> is used, if even one filepair matches their respective criterion in a changeset, the entire changeset is kept. This behavior is designed to make reviewing changes in the context of the whole changeset easier.</p> </div> <h2 id="_diffcore_order_for_sorting_the_output_based_on_filenames">Diffcore-order: for sorting the output based on filenames</h2> <div class="sectionbody"> <p>This is used to reorder the filepairs according to the user’s (or project’s) taste, and is controlled by the -O option to the <code>git diff-*</code> commands.</p> <p>This takes a text file each of whose lines is a shell glob pattern. Filepairs that match a glob pattern on an earlier line in the file are output before ones that match a later line, and filepairs that do not match any glob pattern are output last.</p> <p>As an example, a typical orderfile for the core Git probably would look like this:</p> <div class="listingblock"> <div class="content"> <pre>README +Makefile +Documentation +*.h +*.c +t</pre> </div> </div> </div> <h2 id="_diffcore_rotate_for_changing_at_which_path_output_starts">Diffcore-rotate: for changing at which path output starts</h2> <div class="sectionbody"> <p>This transformation takes one pathname, and rotates the set of filepairs so that the filepair for the given pathname comes first, optionally discarding the paths that come before it. This is used to implement the <code>--skip-to</code> and the <code>--rotate-to</code> options. It is an error when the specified pathname is not in the set of filepairs, but it is not useful to error out when used with "git log" family of commands, because it is unreasonable to expect that a given path would be modified by each and every commit shown by the "git log" command. For this reason, when used with "git log", the filepair that sorts the same as, or the first one that sorts after, the given pathname is where the output starts.</p> <p>Use of this transformation combined with diffcore-order will produce unexpected results, as the input to this transformation is likely not sorted when diffcore-order is in effect.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-diff">git-diff[1]</a>, <a href="git-diff-files">git-diff-files[1]</a>, <a href="git-diff-index">git-diff-index[1]</a>, <a href="git-diff-tree">git-diff-tree[1]</a>, <a href="git-format-patch">git-format-patch[1]</a>, <a href="git-log">git-log[1]</a>, <a href="gitglossary">gitglossary[7]</a>, <a href="user-manual">The Git User’s Manual</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitdiffcore" class="_attribution-link">https://git-scm.com/docs/gitdiffcore</a> + </p> +</div> diff --git a/devdocs/git/giteveryday.html b/devdocs/git/giteveryday.html new file mode 100644 index 00000000..ca564a7e --- /dev/null +++ b/devdocs/git/giteveryday.html @@ -0,0 +1,129 @@ +<h1>giteveryday</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>giteveryday - A useful minimum set of commands for Everyday Git</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>Everyday Git With 20 Commands Or So</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Git users can broadly be grouped into four categories for the purposes of describing here a small set of useful commands for everyday Git.</p> <div class="ulist"> <ul> <li> <p><a href="#STANDALONE">Individual Developer (Standalone)</a> commands are essential for anybody who makes a commit, even for somebody who works alone.</p> </li> <li> <p>If you work with other people, you will need commands listed in the <a href="#PARTICIPANT">Individual Developer (Participant)</a> section as well.</p> </li> <li> <p>People who play the <a href="#INTEGRATOR">Integrator</a> role need to learn some more commands in addition to the above.</p> </li> <li> <p><a href="#ADMINISTRATION">Repository Administration</a> commands are for system administrators who are responsible for the care and feeding of Git repositories.</p> </li> </ul> </div> </div> <h2 id="_individual_developer_standalone">Individual developer (standalone)</h2> <div class="sectionbody"> <p>A standalone individual developer does not exchange patches with other people, and works alone in a single repository, using the following commands.</p> <div class="ulist"> <ul> <li> <p><a href="git-init">git-init[1]</a> to create a new repository.</p> </li> <li> <p><a href="git-log">git-log[1]</a> to see what happened.</p> </li> <li> <p><a href="git-switch">git-switch[1]</a> and <a href="git-branch">git-branch[1]</a> to switch branches.</p> </li> <li> <p><a href="git-add">git-add[1]</a> to manage the index file.</p> </li> <li> <p><a href="git-diff">git-diff[1]</a> and <a href="git-status">git-status[1]</a> to see what you are in the middle of doing.</p> </li> <li> <p><a href="git-commit">git-commit[1]</a> to advance the current branch.</p> </li> <li> <p><a href="git-restore">git-restore[1]</a> to undo changes.</p> </li> <li> <p><a href="git-merge">git-merge[1]</a> to merge between local branches.</p> </li> <li> <p><a href="git-rebase">git-rebase[1]</a> to maintain topic branches.</p> </li> <li> <p><a href="git-tag">git-tag[1]</a> to mark a known point.</p> </li> </ul> </div> <div class="sect2"> <h3 id="_examples"> +Examples</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/giteveryday.txt-Useatarballasastartingpointforanewrepository"> Use a tarball as a starting point for a new repository. </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ tar zxf frotz.tar.gz +$ cd frotz +$ git init +$ git add . (1) +$ git commit -m "import of frotz source tree." +$ git tag v2.43 (2)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>add everything under the current directory.</p> </li> <li> <p>make a lightweight, unannotated tag.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/giteveryday.txt-Createatopicbranchanddevelop"> Create a topic branch and develop. </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -c alsa-audio (1) +$ edit/compile/test +$ git restore curses/ux_audio_oss.c (2) +$ git add curses/ux_audio_alsa.c (3) +$ edit/compile/test +$ git diff HEAD (4) +$ git commit -a -s (5) +$ edit/compile/test +$ git diff HEAD^ (6) +$ git commit -a --amend (7) +$ git switch master (8) +$ git merge alsa-audio (9) +$ git log --since='3 days ago' (10) +$ git log v2.43.. curses/ (11)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>create a new topic branch.</p> </li> <li> <p>revert your botched changes in <code>curses/ux_audio_oss.c</code>.</p> </li> <li> <p>you need to tell Git if you added a new file; removal and modification will be caught if you do <code>git commit -a</code> later.</p> </li> <li> <p>to see what changes you are committing.</p> </li> <li> <p>commit everything, as you have tested, with your sign-off.</p> </li> <li> <p>look at all your changes including the previous commit.</p> </li> <li> <p>amend the previous commit, adding all your new changes, using your original message.</p> </li> <li> <p>switch to the master branch.</p> </li> <li> <p>merge a topic branch into your master branch.</p> </li> <li> <p>review commit logs; other forms to limit output can be combined and include <code>-10</code> (to show up to 10 commits), <code>--until=2005-12-10</code>, etc.</p> </li> <li> <p>view only the changes that touch what’s in <code>curses/</code> directory, since <code>v2.43</code> tag.</p> </li> </ol> </div> </dd> </dl> </div> </div> </div> <h2 id="_individual_developer_participant">Individual developer (participant)</h2> <div class="sectionbody"> <p>A developer working as a participant in a group project needs to learn how to communicate with others, and uses these commands in addition to the ones needed by a standalone developer.</p> <div class="ulist"> <ul> <li> <p><a href="git-clone">git-clone[1]</a> from the upstream to prime your local repository.</p> </li> <li> <p><a href="git-pull">git-pull[1]</a> and <a href="git-fetch">git-fetch[1]</a> from "origin" to keep up-to-date with the upstream.</p> </li> <li> <p><a href="git-push">git-push[1]</a> to shared repository, if you adopt CVS style shared repository workflow.</p> </li> <li> <p><a href="git-format-patch">git-format-patch[1]</a> to prepare e-mail submission, if you adopt Linux kernel-style public forum workflow.</p> </li> <li> <p><a href="git-send-email">git-send-email[1]</a> to send your e-mail submission without corruption by your MUA.</p> </li> <li> <p><a href="git-request-pull">git-request-pull[1]</a> to create a summary of changes for your upstream to pull.</p> </li> </ul> </div> <div class="sect2"> <h3 id="_examples_2"> +Examples</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/giteveryday.txt-ClonetheupstreamandworkonitFeedchangestoupstream"> Clone the upstream and work on it. Feed changes to upstream. </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git clone git://git.kernel.org/pub/scm/.../torvalds/linux-2.6 my2.6 +$ cd my2.6 +$ git switch -c mine master (1) +$ edit/compile/test; git commit -a -s (2) +$ git format-patch master (3) +$ git send-email --to="person <email@example.com>" 00*.patch (4) +$ git switch master (5) +$ git pull (6) +$ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 (7) +$ git ls-remote --heads http://git.kernel.org/.../jgarzik/libata-dev.git (8) +$ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL (9) +$ git reset --hard ORIG_HEAD (10) +$ git gc (11)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>checkout a new branch <code>mine</code> from master.</p> </li> <li> <p>repeat as needed.</p> </li> <li> <p>extract patches from your branch, relative to master,</p> </li> <li> <p>and email them.</p> </li> <li> <p>return to <code>master</code>, ready to see what’s new</p> </li> <li> <p><code>git pull</code> fetches from <code>origin</code> by default and merges into the current branch.</p> </li> <li> <p>immediately after pulling, look at the changes done upstream since last time we checked, only in the area we are interested in.</p> </li> <li> <p>check the branch names in an external repository (if not known).</p> </li> <li> <p>fetch from a specific branch <code>ALL</code> from a specific repository and merge it.</p> </li> <li> <p>revert the pull.</p> </li> <li> <p>garbage collect leftover objects from reverted pull.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/giteveryday.txt-Pushintoanotherrepository"> Push into another repository. </dt> <dd> <div class="listingblock"> <div class="content"> <pre>satellite$ git clone mothership:frotz frotz (1) +satellite$ cd frotz +satellite$ git config --get-regexp '^(remote|branch)\.' (2) +remote.origin.url mothership:frotz +remote.origin.fetch refs/heads/*:refs/remotes/origin/* +branch.master.remote origin +branch.master.merge refs/heads/master +satellite$ git config remote.origin.push \ + +refs/heads/*:refs/remotes/satellite/* (3) +satellite$ edit/compile/test/commit +satellite$ git push origin (4) + +mothership$ cd frotz +mothership$ git switch master +mothership$ git merge satellite/master (5)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>mothership machine has a frotz repository under your home directory; clone from it to start a repository on the satellite machine.</p> </li> <li> <p>clone sets these configuration variables by default. It arranges <code>git pull</code> to fetch and store the branches of mothership machine to local <code>remotes/origin/*</code> remote-tracking branches.</p> </li> <li> <p>arrange <code>git push</code> to push all local branches to their corresponding branch of the mothership machine.</p> </li> <li> <p>push will stash all our work away on <code>remotes/satellite/*</code> remote-tracking branches on the mothership machine. You could use this as a back-up method. Likewise, you can pretend that mothership "fetched" from you (useful when access is one sided).</p> </li> <li> <p>on mothership machine, merge the work done on the satellite machine into the master branch.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/giteveryday.txt-Branchoffofaspecifictag"> Branch off of a specific tag. </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -c private2.6.14 v2.6.14 (1) +$ edit/compile/test; git commit -a +$ git checkout master +$ git cherry-pick v2.6.14..private2.6.14 (2)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>create a private branch based on a well known (but somewhat behind) tag.</p> </li> <li> <p>forward port all changes in <code>private2.6.14</code> branch to <code>master</code> branch without a formal "merging". Or longhand<br> <code>git format-patch -k -m --stdout v2.6.14..private2.6.14 | + git am -3 -k</code></p> </li> </ol> </div> </dd> </dl> </div> <p>An alternate participant submission mechanism is using the <code>git request-pull</code> or pull-request mechanisms (e.g. as used on GitHub (www.github.com) to notify your upstream of your contribution.</p> </div> </div> <h2 id="_integrator">Integrator</h2> <div class="sectionbody"> <p>A fairly central person acting as the integrator in a group project receives changes made by others, reviews and integrates them and publishes the result for others to use, using these commands in addition to the ones needed by participants.</p> <p>This section can also be used by those who respond to <code>git +request-pull</code> or pull-request on GitHub (www.github.com) to integrate the work of others into their history. A sub-area lieutenant for a repository will act both as a participant and as an integrator.</p> <div class="ulist"> <ul> <li> <p><a href="git-am">git-am[1]</a> to apply patches e-mailed in from your contributors.</p> </li> <li> <p><a href="git-pull">git-pull[1]</a> to merge from your trusted lieutenants.</p> </li> <li> <p><a href="git-format-patch">git-format-patch[1]</a> to prepare and send suggested alternative to contributors.</p> </li> <li> <p><a href="git-revert">git-revert[1]</a> to undo botched commits.</p> </li> <li> <p><a href="git-push">git-push[1]</a> to publish the bleeding edge.</p> </li> </ul> </div> <div class="sect2"> <h3 id="_examples_3"> +Examples</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/giteveryday.txt-Atypicalintegrator8217sGitday"> A typical integrator’s Git day. </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git status (1) +$ git branch --no-merged master (2) +$ mailx (3) +& s 2 3 4 5 ./+to-apply +& s 7 8 ./+hold-linus +& q +$ git switch -c topic/one master +$ git am -3 -i -s ./+to-apply (4) +$ compile/test +$ git switch -c hold/linus && git am -3 -i -s ./+hold-linus (5) +$ git switch topic/one && git rebase master (6) +$ git switch -C seen next (7) +$ git merge topic/one topic/two && git merge hold/linus (8) +$ git switch maint +$ git cherry-pick master~4 (9) +$ compile/test +$ git tag -s -m "GIT 0.99.9x" v0.99.9x (10) +$ git fetch ko && for branch in master maint next seen (11) + do + git show-branch ko/$branch $branch (12) + done +$ git push --follow-tags ko (13)</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>see what you were in the middle of doing, if anything.</p> </li> <li> <p>see which branches haven’t been merged into <code>master</code> yet. Likewise for any other integration branches e.g. <code>maint</code>, <code>next</code> and <code>seen</code>.</p> </li> <li> <p>read mails, save ones that are applicable, and save others that are not quite ready (other mail readers are available).</p> </li> <li> <p>apply them, interactively, with your sign-offs.</p> </li> <li> <p>create topic branch as needed and apply, again with sign-offs.</p> </li> <li> <p>rebase internal topic branch that has not been merged to the master or exposed as a part of a stable branch.</p> </li> <li> <p>restart <code>seen</code> every time from the next.</p> </li> <li> <p>and bundle topic branches still cooking.</p> </li> <li> <p>backport a critical fix.</p> </li> <li> <p>create a signed tag.</p> </li> <li> <p>make sure master was not accidentally rewound beyond that already pushed out.</p> </li> <li> <p>In the output from <code>git show-branch</code>, <code>master</code> should have everything <code>ko/master</code> has, and <code>next</code> should have everything <code>ko/next</code> has, etc.</p> </li> <li> <p>push out the bleeding edge, together with new tags that point into the pushed history.</p> </li> </ol> </div> </dd> </dl> </div> <p>In this example, the <code>ko</code> shorthand points at the Git maintainer’s repository at kernel.org, and looks like this:</p> <div class="listingblock"> <div class="content"> <pre>(in .git/config) +[remote "ko"] + url = kernel.org:/pub/scm/git/git.git + fetch = refs/heads/*:refs/remotes/ko/* + push = refs/heads/master + push = refs/heads/next + push = +refs/heads/seen + push = refs/heads/maint</pre> </div> </div> </div> </div> <h2 id="_repository_administration">Repository administration</h2> <div class="sectionbody"> <p>A repository administrator uses the following tools to set up and maintain access to the repository by developers.</p> <div class="ulist"> <ul> <li> <p><a href="git-daemon">git-daemon[1]</a> to allow anonymous download from repository.</p> </li> <li> <p><a href="git-shell">git-shell[1]</a> can be used as a <code>restricted login shell</code> for shared central repository users.</p> </li> <li> <p><a href="git-http-backend">git-http-backend[1]</a> provides a server side implementation of Git-over-HTTP ("Smart http") allowing both fetch and push services.</p> </li> <li> <p><a href="gitweb">gitweb[1]</a> provides a web front-end to Git repositories, which can be set-up using the <a href="git-instaweb">git-instaweb[1]</a> script.</p> </li> </ul> </div> <p><a href="https://git-scm.com/docs/howto/update-hook-example">update hook howto</a> has a good example of managing a shared central repository.</p> <p>In addition there are a number of other widely deployed hosting, browsing and reviewing solutions such as:</p> <div class="ulist"> <ul> <li> <p>gitolite, gerrit code review, cgit and others.</p> </li> </ul> </div> <div class="sect2"> <h3 id="_examples_4"> +Examples</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/giteveryday.txt-Weassumethefollowinginetcservices"> We assume the following in /etc/services </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ grep 9418 /etc/services +git 9418/tcp # Git Version Control System</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/giteveryday.txt-Rungit-daemontoservepubscmfrominetd"> Run git-daemon to serve /pub/scm from inetd. </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ grep git /etc/inetd.conf +git stream tcp nowait nobody \ + /usr/bin/git-daemon git-daemon --inetd --export-all /pub/scm</pre> </div> </div> <p>The actual configuration line should be on one line.</p> </dd> <dt class="hdlist1" id="Documentation/giteveryday.txt-Rungit-daemontoservepubscmfromxinetd"> Run git-daemon to serve /pub/scm from xinetd. </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat /etc/xinetd.d/git-daemon +# default: off +# description: The Git server offers access to Git repositories +service git +{ + disable = no + type = UNLISTED + port = 9418 + socket_type = stream + wait = no + user = nobody + server = /usr/bin/git-daemon + server_args = --inetd --export-all --base-path=/pub/scm + log_on_failure += USERID +}</pre> </div> </div> <p>Check your xinetd(8) documentation and setup, this is from a Fedora system. Others might be different.</p> </dd> <dt class="hdlist1" id="Documentation/giteveryday.txt-Givepushpullonlyaccesstodevelopersusinggit-over-ssh"> Give push/pull only access to developers using git-over-ssh. </dt> <dd> <p>e.g. those using: <code>$ git push/pull ssh://host.xz/pub/scm/project</code></p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ grep git /etc/passwd (1) +alice:x:1000:1000::/home/alice:/usr/bin/git-shell +bob:x:1001:1001::/home/bob:/usr/bin/git-shell +cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell +david:x:1003:1003::/home/david:/usr/bin/git-shell +$ grep git /etc/shells (2) +/usr/bin/git-shell</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>log-in shell is set to /usr/bin/git-shell, which does not allow anything but <code>git push</code> and <code>git pull</code>. The users require ssh access to the machine.</p> </li> <li> <p>in many distributions /etc/shells needs to list what is used as the login shell.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/giteveryday.txt-CVS-stylesharedrepository"> CVS-style shared repository. </dt> <dd> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ grep git /etc/group (1) +git:x:9418:alice,bob,cindy,david +$ cd /home/devo.git +$ ls -l (2) + lrwxrwxrwx 1 david git 17 Dec 4 22:40 HEAD -> refs/heads/master + drwxrwsr-x 2 david git 4096 Dec 4 22:40 branches + -rw-rw-r-- 1 david git 84 Dec 4 22:40 config + -rw-rw-r-- 1 david git 58 Dec 4 22:40 description + drwxrwsr-x 2 david git 4096 Dec 4 22:40 hooks + -rw-rw-r-- 1 david git 37504 Dec 4 22:40 index + drwxrwsr-x 2 david git 4096 Dec 4 22:40 info + drwxrwsr-x 4 david git 4096 Dec 4 22:40 objects + drwxrwsr-x 4 david git 4096 Nov 7 14:58 refs + drwxrwsr-x 2 david git 4096 Dec 4 22:40 remotes +$ ls -l hooks/update (3) + -r-xr-xr-x 1 david git 3536 Dec 4 22:40 update +$ cat info/allowed-users (4) +refs/heads/master alice\|cindy +refs/heads/doc-update bob +refs/tags/v[0-9]* david</pre> </div> </div> <div class="colist arabic"> <ol> <li> <p>place the developers into the same git group.</p> </li> <li> <p>and make the shared repository writable by the group.</p> </li> <li> <p>use update-hook example by Carl from Documentation/howto/ for branch policy control.</p> </li> <li> <p>alice and cindy can push into master, only bob can push into doc-update. david is the release manager and is the only person who can create and push version tags.</p> </li> </ol> </div> </dd> </dl> </div> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/giteveryday" class="_attribution-link">https://git-scm.com/docs/giteveryday</a> + </p> +</div> diff --git a/devdocs/git/gitfaq.html b/devdocs/git/gitfaq.html new file mode 100644 index 00000000..28bedcf8 --- /dev/null +++ b/devdocs/git/gitfaq.html @@ -0,0 +1,33 @@ +<h1>gitfaq</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitfaq - Frequently asked questions about using Git</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>gitfaq</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>The examples in this FAQ assume a standard POSIX shell, like <code>bash</code> or <code>dash</code>, and a user, A U Thor, who has the account <code>author</code> on the hosting provider <code>git.example.org</code>.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <div id="user-name" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-WhatshouldIputincodeusernamecode"> What should I put in <code>user.name</code>? </dt> <dd> <p>You should put your personal name, generally a form using a given name and family name. For example, the current maintainer of Git uses "Junio C Hamano". This will be the name portion that is stored in every commit you make.</p> <p>This configuration doesn’t have any effect on authenticating to remote services; for that, see <code>credential.username</code> in <a href="git-config">git-config[1]</a>.</p> </dd> </dl> </div> <div id="http-postbuffer" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-WhatdoescodehttppostBuffercodereallydo"> What does <code>http.postBuffer</code> really do? </dt> <dd> <p>This option changes the size of the buffer that Git uses when pushing data to a remote over HTTP or HTTPS. If the data is larger than this size, libcurl, which handles the HTTP support for Git, will use chunked transfer encoding since it isn’t known ahead of time what the size of the pushed data will be.</p> <p>Leaving this value at the default size is fine unless you know that either the remote server or a proxy in the middle doesn’t support HTTP/1.1 (which introduced the chunked transfer encoding) or is known to be broken with chunked data. This is often (erroneously) suggested as a solution for generic push problems, but since almost every server and proxy supports at least HTTP/1.1, raising this value usually doesn’t solve most push problems. A server or proxy that didn’t correctly support HTTP/1.1 and chunked transfer encoding wouldn’t be that useful on the Internet today, since it would break lots of traffic.</p> <p>Note that increasing this value will increase the memory used on every relevant push that Git does over HTTP or HTTPS, since the entire buffer is allocated regardless of whether or not it is all used. Thus, it’s best to leave it at the default unless you are sure you need a different value.</p> </dd> </dl> </div> <div id="configure-editor" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-HowdoIconfigureadifferenteditor"> How do I configure a different editor? </dt> <dd> <p>If you haven’t specified an editor specifically for Git, it will by default use the editor you’ve configured using the <code>VISUAL</code> or <code>EDITOR</code> environment variables, or if neither is specified, the system default (which is usually <code>vi</code>). Since some people find <code>vi</code> difficult to use or prefer a different editor, it may be desirable to change the editor used.</p> <p>If you want to configure a general editor for most programs which need one, you can edit your shell configuration (e.g., <code>~/.bashrc</code> or <code>~/.zshenv</code>) to contain a line setting the <code>EDITOR</code> or <code>VISUAL</code> environment variable to an appropriate value. For example, if you prefer the editor <code>nano</code>, then you could write the following:</p> <div class="listingblock"> <div class="content"> <pre>export VISUAL=nano</pre> </div> </div> <p>If you want to configure an editor specifically for Git, you can either set the <code>core.editor</code> configuration value or the <code>GIT_EDITOR</code> environment variable. You can see <a href="git-var">git-var[1]</a> for details on the order in which these options are consulted.</p> <p>Note that in all cases, the editor value will be passed to the shell, so any arguments containing spaces should be appropriately quoted. Additionally, if your editor normally detaches from the terminal when invoked, you should specify it with an argument that makes it not do that, or else Git will not see any changes. An example of a configuration addressing both of these issues on Windows would be the configuration <code>"C:\Program Files\Vim\gvim.exe" --nofork</code>, which quotes the filename with spaces and specifies the <code>--nofork</code> option to avoid backgrounding the process.</p> </dd> </dl> </div> </div> <h2 id="_credentials">Credentials</h2> <div class="sectionbody"> <div id="http-credentials" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-HowdoIspecifymycredentialswhenpushingoverHTTP"> How do I specify my credentials when pushing over HTTP? </dt> <dd> <p>The easiest way to do this is to use a credential helper via the <code>credential.helper</code> configuration. Most systems provide a standard choice to integrate with the system credential manager. For example, Git for Windows provides the <code>wincred</code> credential manager, macOS has the <code>osxkeychain</code> credential manager, and Unix systems with a standard desktop environment can use the <code>libsecret</code> credential manager. All of these store credentials in an encrypted store to keep your passwords or tokens secure.</p> <p>In addition, you can use the <code>store</code> credential manager which stores in a file in your home directory, or the <code>cache</code> credential manager, which does not permanently store your credentials, but does prevent you from being prompted for them for a certain period of time.</p> <p>You can also just enter your password when prompted. While it is possible to place the password (which must be percent-encoded) in the URL, this is not particularly secure and can lead to accidental exposure of credentials, so it is not recommended.</p> </dd> </dl> </div> <div id="http-credentials-environment" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-HowdoIreadapasswordortokenfromanenvironmentvariable"> How do I read a password or token from an environment variable? </dt> <dd> <p>The <code>credential.helper</code> configuration option can also take an arbitrary shell command that produces the credential protocol on standard output. This is useful when passing credentials into a container, for example.</p> <p>Such a shell command can be specified by starting the option value with an exclamation point. If your password or token were stored in the <code>GIT_TOKEN</code>, you could run the following command to set your credential helper:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config credential.helper \ + '!f() { echo username=author; echo "password=$GIT_TOKEN"; };f'</pre> </div> </div> </dd> </dl> </div> <div id="http-reset-credentials" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-HowdoIchangethepasswordortokenI8217vesavedinmycredentialmanager"> How do I change the password or token I’ve saved in my credential manager? </dt> <dd> <p>Usually, if the password or token is invalid, Git will erase it and prompt for a new one. However, there are times when this doesn’t always happen. To change the password or token, you can erase the existing credentials and then Git will prompt for new ones. To erase credentials, use a syntax like the following (substituting your username and the hostname):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ echo url=https://author@git.example.org | git credential reject</pre> </div> </div> </dd> </dl> </div> <div id="multiple-accounts-http" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-HowdoIusemultipleaccountswiththesamehostingproviderusingHTTP"> How do I use multiple accounts with the same hosting provider using HTTP? </dt> <dd> <p>Usually the easiest way to distinguish between these accounts is to use the username in the URL. For example, if you have the accounts <code>author</code> and <code>committer</code> on <code>git.example.org</code>, you can use the URLs <a href="https://author@git.example.org/org1/project1.git" class="bare">https://author@git.example.org/org1/project1.git</a> and <a href="https://committer@git.example.org/org2/project2.git" class="bare">https://committer@git.example.org/org2/project2.git</a>. This way, when you use a credential helper, it will automatically try to look up the correct credentials for your account. If you already have a remote set up, you can change the URL with something like <code>git remote set-url +origin https://author@git.example.org/org1/project1.git</code> (see <a href="git-remote">git-remote[1]</a> for details).</p> </dd> </dl> </div> <div id="multiple-accounts-ssh" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-HowdoIusemultipleaccountswiththesamehostingproviderusingSSH"> How do I use multiple accounts with the same hosting provider using SSH? </dt> <dd> <p>With most hosting providers that support SSH, a single key pair uniquely identifies a user. Therefore, to use multiple accounts, it’s necessary to create a key pair for each account. If you’re using a reasonably modern OpenSSH version, you can create a new key pair with something like <code>ssh-keygen -t ed25519 -f ~/.ssh/id_committer</code>. You can then register the public key (in this case, <code>~/.ssh/id_committer.pub</code>; note the <code>.pub</code>) with the hosting provider.</p> <p>Most hosting providers use a single SSH account for pushing; that is, all users push to the <code>git</code> account (e.g., <code>git@git.example.org</code>). If that’s the case for your provider, you can set up multiple aliases in SSH to make it clear which key pair to use. For example, you could write something like the following in <code>~/.ssh/config</code>, substituting the proper private key file:</p> <div class="listingblock"> <div class="content"> <pre># This is the account for author on git.example.org. +Host example_author + HostName git.example.org + User git + # This is the key pair registered for author with git.example.org. + IdentityFile ~/.ssh/id_author + IdentitiesOnly yes +# This is the account for committer on git.example.org. +Host example_committer + HostName git.example.org + User git + # This is the key pair registered for committer with git.example.org. + IdentityFile ~/.ssh/id_committer + IdentitiesOnly yes</pre> </div> </div> <p>Then, you can adjust your push URL to use <code>git@example_author</code> or <code>git@example_committer</code> instead of <code>git@example.org</code> (e.g., <code>git remote set-url +git@example_author:org1/project1.git</code>).</p> </dd> </dl> </div> </div> <h2 id="_common_issues">Common issues</h2> <div class="sectionbody"> <div id="last-commit-amend" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-I8217vemadeamistakeinthelastcommitHowdoIchangeit"> I’ve made a mistake in the last commit. How do I change it? </dt> <dd> <p>You can make the appropriate change to your working tree, run <code>git add +<file></code> or <code>git rm <file></code>, as appropriate, to stage it, and then <code>git +commit --amend</code>. Your change will be included in the commit, and you’ll be prompted to edit the commit message again; if you wish to use the original message verbatim, you can use the <code>--no-edit</code> option to <code>git +commit</code> in addition, or just save and quit when your editor opens.</p> </dd> </dl> </div> <div id="undo-previous-change" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-I8217vemadeachangewithabugandit8217sbeenincludedinthemainbranchHowshouldIundoit"> I’ve made a change with a bug and it’s been included in the main branch. How should I undo it? </dt> <dd> <p>The usual way to deal with this is to use <code>git revert</code>. This preserves the history that the original change was made and was a valuable contribution, but also introduces a new commit that undoes those changes because the original had a problem. The commit message of the revert indicates the commit which was reverted and is usually edited to include an explanation as to why the revert was made.</p> </dd> </dl> </div> <div id="ignore-tracked-files" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-HowdoIignorechangestoatrackedfile"> How do I ignore changes to a tracked file? </dt> <dd> <p>Git doesn’t provide a way to do this. The reason is that if Git needs to overwrite this file, such as during a checkout, it doesn’t know whether the changes to the file are precious and should be kept, or whether they are irrelevant and can safely be destroyed. Therefore, it has to take the safe route and always preserve them.</p> <p>It’s tempting to try to use certain features of <code>git update-index</code>, namely the assume-unchanged and skip-worktree bits, but these don’t work properly for this purpose and shouldn’t be used this way.</p> <p>If your goal is to modify a configuration file, it can often be helpful to have a file checked into the repository which is a template or set of defaults which can then be copied alongside and modified as appropriate. This second, modified file is usually ignored to prevent accidentally committing it.</p> </dd> </dl> </div> <div id="files-in-gitignore-are-tracked" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-IaskedGittoignorevariousfilesyettheyarestilltracked"> I asked Git to ignore various files, yet they are still tracked </dt> <dd> <p>A <code>gitignore</code> file ensures that certain file(s) which are not tracked by Git remain untracked. However, sometimes particular file(s) may have been tracked before adding them into the <code>.gitignore</code>, hence they still remain tracked. To untrack and ignore files/patterns, use <code>git rm --cached <file/pattern></code> and add a pattern to <code>.gitignore</code> that matches the <file>. See <a href="gitignore">gitignore[5]</a> for details.</p> </dd> </dl> </div> <div id="fetching-and-pulling" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-HowdoIknowifIwanttodoafetchorapull"> How do I know if I want to do a fetch or a pull? </dt> <dd> <p>A fetch stores a copy of the latest changes from the remote repository, without modifying the working tree or current branch. You can then at your leisure inspect, merge, rebase on top of, or ignore the upstream changes. A pull consists of a fetch followed immediately by either a merge or rebase. See <a href="git-pull">git-pull[1]</a>.</p> </dd> </dl> </div> </div> <h2 id="_merging_and_rebasing">Merging and rebasing</h2> <div class="sectionbody"> <div id="long-running-squash-merge" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-Whatkindsofproblemscanoccurwhenmerginglong-livedbrancheswithsquashmerges"> What kinds of problems can occur when merging long-lived branches with squash merges? </dt> <dd> <p>In general, there are a variety of problems that can occur when using squash merges to merge two branches multiple times. These can include seeing extra commits in <code>git log</code> output, with a GUI, or when using the <code>...</code> notation to express a range, as well as the possibility of needing to re-resolve conflicts again and again.</p> <p>When Git does a normal merge between two branches, it considers exactly three points: the two branches and a third commit, called the <code>merge base</code>, which is usually the common ancestor of the commits. The result of the merge is the sum of the changes between the merge base and each head. When you merge two branches with a regular merge commit, this results in a new commit which will end up as a merge base when they’re merged again, because there is now a new common ancestor. Git doesn’t have to consider changes that occurred before the merge base, so you don’t have to re-resolve any conflicts you resolved before.</p> <p>When you perform a squash merge, a merge commit isn’t created; instead, the changes from one side are applied as a regular commit to the other side. This means that the merge base for these branches won’t have changed, and so when Git goes to perform its next merge, it considers all of the changes that it considered the last time plus the new changes. That means any conflicts may need to be re-resolved. Similarly, anything using the <code>...</code> notation in <code>git +diff</code>, <code>git log</code>, or a GUI will result in showing all of the changes since the original merge base.</p> <p>As a consequence, if you want to merge two long-lived branches repeatedly, it’s best to always use a regular merge commit.</p> </dd> </dl> </div> <div id="merge-two-revert-one" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-IfImakeachangeontwobranchesbutrevertitononewhydoesthemergeofthosebranchesincludethechange"> If I make a change on two branches but revert it on one, why does the merge of those branches include the change? </dt> <dd> <p>By default, when Git does a merge, it uses a strategy called the <code>ort</code> strategy, which does a fancy three-way merge. In such a case, when Git performs the merge, it considers exactly three points: the two heads and a third point, called the <code>merge base</code>, which is usually the common ancestor of those commits. Git does not consider the history or the individual commits that have happened on those branches at all.</p> <p>As a result, if both sides have a change and one side has reverted that change, the result is to include the change. This is because the code has changed on one side and there is no net change on the other, and in this scenario, Git adopts the change.</p> <p>If this is a problem for you, you can do a rebase instead, rebasing the branch with the revert onto the other branch. A rebase in this scenario will revert the change, because a rebase applies each individual commit, including the revert. Note that rebases rewrite history, so you should avoid rebasing published branches unless you’re sure you’re comfortable with that. See the NOTES section in <a href="git-rebase">git-rebase[1]</a> for more details.</p> </dd> </dl> </div> </div> <h2 id="_hooks">Hooks</h2> <div class="sectionbody"> <div id="restrict-with-hooks" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-HowdoIusehookstopreventusersfrommakingcertainchanges"> How do I use hooks to prevent users from making certain changes? </dt> <dd> <p>The only safe place to make these changes is on the remote repository (i.e., the Git server), usually in the <code>pre-receive</code> hook or in a continuous integration (CI) system. These are the locations in which policy can be enforced effectively.</p> <p>It’s common to try to use <code>pre-commit</code> hooks (or, for commit messages, <code>commit-msg</code> hooks) to check these things, which is great if you’re working as a solo developer and want the tooling to help you. However, using hooks on a developer machine is not effective as a policy control because a user can bypass these hooks with <code>--no-verify</code> without being noticed (among various other ways). Git assumes that the user is in control of their local repositories and doesn’t try to prevent this or tattle on the user.</p> <p>In addition, some advanced users find <code>pre-commit</code> hooks to be an impediment to workflows that use temporary commits to stage work in progress or that create fixup commits, so it’s better to push these kinds of checks to the server anyway.</p> </dd> </dl> </div> </div> <h2 id="_cross_platform_issues">Cross-platform issues</h2> <div class="sectionbody"> <div id="windows-text-binary" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-I8217monWindowsandmytextfilesaredetectedasbinary"> I’m on Windows and my text files are detected as binary. </dt> <dd> <p>Git works best when you store text files as UTF-8. Many programs on Windows support UTF-8, but some do not and only use the little-endian UTF-16 format, which Git detects as binary. If you can’t use UTF-8 with your programs, you can specify a working tree encoding that indicates which encoding your files should be checked out with, while still storing these files as UTF-8 in the repository. This allows tools like <a href="git-diff">git-diff[1]</a> to work as expected, while still allowing your tools to work.</p> <p>To do so, you can specify a <a href="gitattributes">gitattributes[5]</a> pattern with the <code>working-tree-encoding</code> attribute. For example, the following pattern sets all C files to use UTF-16LE-BOM, which is a common encoding on Windows:</p> <div class="listingblock"> <div class="content"> <pre>*.c working-tree-encoding=UTF-16LE-BOM</pre> </div> </div> <p>You will need to run <code>git add --renormalize</code> to have this take effect. Note that if you are making these changes on a project that is used across platforms, you’ll probably want to make it in a per-user configuration file or in the one in <code>$GIT_DIR/info/attributes</code>, since making it in a <code>.gitattributes</code> file in the repository will apply to all users of the repository.</p> <p>See the following entry for information about normalizing line endings as well, and see <a href="gitattributes">gitattributes[5]</a> for more information about attribute files.</p> </dd> </dl> </div> <div id="windows-diff-control-m" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-I8217monWindowsandgitdiffshowsmyfilesashavingacodeMcodeattheend"> I’m on Windows and git diff shows my files as having a <code>^M</code> at the end. </dt> <dd> <p>By default, Git expects files to be stored with Unix line endings. As such, the carriage return (<code>^M</code>) that is part of a Windows line ending is shown because it is considered to be trailing whitespace. Git defaults to showing trailing whitespace only on new lines, not existing ones.</p> <p>You can store the files in the repository with Unix line endings and convert them automatically to your platform’s line endings. To do that, set the configuration option <code>core.eol</code> to <code>native</code> and see the following entry for information about how to configure files as text or binary.</p> <p>You can also control this behavior with the <code>core.whitespace</code> setting if you don’t wish to remove the carriage returns from your line endings.</p> </dd> </dl> </div> <div id="always-modified-files-case" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-WhydoIhaveafilethat8217salwaysmodified"> Why do I have a file that’s always modified? </dt> <dd> <p>Internally, Git always stores file names as sequences of bytes and doesn’t perform any encoding or case folding. However, Windows and macOS by default both perform case folding on file names. As a result, it’s possible to end up with multiple files or directories whose names differ only in case. Git can handle this just fine, but the file system can store only one of these files, so when Git reads the other file to see its contents, it looks modified.</p> <p>It’s best to remove one of the files such that you only have one file. You can do this with commands like the following (assuming two files <code>AFile.txt</code> and <code>afile.txt</code>) on an otherwise clean working tree:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rm --cached AFile.txt +$ git commit -m 'Remove files conflicting in case' +$ git checkout .</pre> </div> </div> <p>This avoids touching the disk, but removes the additional file. Your project may prefer to adopt a naming convention, such as all-lowercase names, to avoid this problem from occurring again; such a convention can be checked using a <code>pre-receive</code> hook or as part of a continuous integration (CI) system.</p> <p>It is also possible for perpetually modified files to occur on any platform if a smudge or clean filter is in use on your system but a file was previously committed without running the smudge or clean filter. To fix this, run the following on an otherwise clean working tree:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git add --renormalize .</pre> </div> </div> </dd> </dl> </div> <div id="recommended-storage-settings" class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitfaq.txt-What8217stherecommendedwaytostorefilesinGit"> What’s the recommended way to store files in Git? </dt> <dd> <p>While Git can store and handle any file of any type, there are some settings that work better than others. In general, we recommend that text files be stored in UTF-8 without a byte-order mark (BOM) with LF (Unix-style) endings. We also recommend the use of UTF-8 (again, without BOM) in commit messages. These are the settings that work best across platforms and with tools such as <code>git diff</code> and <code>git merge</code>.</p> <p>Additionally, if you have a choice between storage formats that are text based or non-text based, we recommend storing files in the text format and, if necessary, transforming them into the other format. For example, a text-based SQL dump with one record per line will work much better for diffing and merging than an actual database file. Similarly, text-based formats such as Markdown and AsciiDoc will work better than binary formats such as Microsoft Word and PDF.</p> <p>Similarly, storing binary dependencies (e.g., shared libraries or JAR files) or build products in the repository is generally not recommended. Dependencies and build products are best stored on an artifact or package server with only references, URLs, and hashes stored in the repository.</p> <p>We also recommend setting a <a href="gitattributes">gitattributes[5]</a> file to explicitly mark which files are text and which are binary. If you want Git to guess, you can set the attribute <code>text=auto</code>. For example, the following might be appropriate in some projects:</p> <div class="listingblock"> <div class="content"> <pre># By default, guess. +* text=auto +# Mark all C files as text. +*.c text +# Mark all JPEG files as binary. +*.jpg binary</pre> </div> </div> <p>These settings help tools pick the right format for output such as patches and result in files being checked out in the appropriate line ending for the platform.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitfaq" class="_attribution-link">https://git-scm.com/docs/gitfaq</a> + </p> +</div> diff --git a/devdocs/git/gitformat-bundle.html b/devdocs/git/gitformat-bundle.html new file mode 100644 index 00000000..4d6cd2a5 --- /dev/null +++ b/devdocs/git/gitformat-bundle.html @@ -0,0 +1,25 @@ +<h1>gitformat-bundle</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitformat-bundle - The bundle file format</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content">*.bundle +*.bdl</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>The Git bundle format is a format that represents both refs and Git objects. A bundle is a header in a format similar to <a href="git-show-ref">git-show-ref[1]</a> followed by a pack in *.pack format.</p> <p>The format is created and read by the <a href="git-bundle">git-bundle[1]</a> command, and supported by e.g. <a href="git-fetch">git-fetch[1]</a> and <a href="git-clone">git-clone[1]</a>.</p> </div> <h2 id="_format">Format</h2> <div class="sectionbody"> <p>We will use ABNF notation to define the Git bundle format. See <a href="gitprotocol-common">gitprotocol-common[5]</a> for the details.</p> <p>A v2 bundle looks like this:</p> <div class="listingblock"> <div class="content"> <pre>bundle = signature *prerequisite *reference LF pack +signature = "# v2 git bundle" LF + +prerequisite = "-" obj-id SP comment LF +comment = *CHAR +reference = obj-id SP refname LF + +pack = ... ; packfile</pre> </div> </div> <p>A v3 bundle looks like this:</p> <div class="listingblock"> <div class="content"> <pre>bundle = signature *capability *prerequisite *reference LF pack +signature = "# v3 git bundle" LF + +capability = "@" key ["=" value] LF +prerequisite = "-" obj-id SP comment LF +comment = *CHAR +reference = obj-id SP refname LF +key = 1*(ALPHA / DIGIT / "-") +value = *(%01-09 / %0b-FF) + +pack = ... ; packfile</pre> </div> </div> </div> <h2 id="_semantics">Semantics</h2> <div class="sectionbody"> <p>A Git bundle consists of several parts.</p> <div class="ulist"> <ul> <li> <p>"Capabilities", which are only in the v3 format, indicate functionality that the bundle requires to be read properly.</p> </li> <li> <p>"Prerequisites" list the objects that are NOT included in the bundle and the reader of the bundle MUST already have, in order to use the data in the bundle. The objects stored in the bundle may refer to prerequisite objects and anything reachable from them (e.g. a tree object in the bundle can reference a blob that is reachable from a prerequisite) and/or expressed as a delta against prerequisite objects.</p> </li> <li> <p>"References" record the tips of the history graph, iow, what the reader of the bundle CAN "git fetch" from it.</p> </li> <li> <p>"Pack" is the pack data stream "git fetch" would send, if you fetch from a repository that has the references recorded in the "References" above into a repository that has references pointing at the objects listed in "Prerequisites" above.</p> </li> </ul> </div> <p>In the bundle format, there can be a comment following a prerequisite obj-id. This is a comment and it has no specific meaning. The writer of the bundle MAY put any string here. The reader of the bundle MUST ignore the comment.</p> <div class="sect2"> <h3 id="_note_on_shallow_clones_and_git_bundles"> +Note on shallow clones and Git bundles</h3> <p>Note that the prerequisites do not represent a shallow-clone boundary. The semantics of the prerequisites and the shallow-clone boundaries are different, and the Git bundle v2 format cannot represent a shallow clone repository.</p> </div> </div> <h2 id="_capabilities">Capabilities</h2> <div class="sectionbody"> <p>Because there is no opportunity for negotiation, unknown capabilities cause <code>git bundle</code> to abort.</p> <div class="ulist"> <ul> <li> <p><code>object-format</code> specifies the hash algorithm in use, and can take the same values as the <code>extensions.objectFormat</code> configuration value.</p> </li> <li> <p><code>filter</code> specifies an object filter as in the <code>--filter</code> option in <a href="git-rev-list">git-rev-list[1]</a>. The resulting pack-file must be marked as a <code>.promisor</code> pack-file after it is unbundled.</p> </li> </ul> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitformat-bundle" class="_attribution-link">https://git-scm.com/docs/gitformat-bundle</a> + </p> +</div> diff --git a/devdocs/git/gitformat-chunk.html b/devdocs/git/gitformat-chunk.html new file mode 100644 index 00000000..05107f3e --- /dev/null +++ b/devdocs/git/gitformat-chunk.html @@ -0,0 +1,11 @@ +<h1>gitformat-chunk</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitformat-chunk - Chunk-based file formats</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>Used by <a href="gitformat-commit-graph">gitformat-commit-graph[5]</a> and the "MIDX" format (see the pack format documentation in <a href="gitformat-pack">gitformat-pack[5]</a>).</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Some file formats in Git use a common concept of "chunks" to describe sections of the file. This allows structured access to a large file by scanning a small "table of contents" for the remaining data. This common format is used by the <code>commit-graph</code> and <code>multi-pack-index</code> files. See the <code>multi-pack-index</code> format in <a href="gitformat-pack">gitformat-pack[5]</a> and the <code>commit-graph</code> format in <a href="gitformat-commit-graph">gitformat-commit-graph[5]</a> for how they use the chunks to describe structured data.</p> <p>A chunk-based file format begins with some header information custom to that format. That header should include enough information to identify the file type, format version, and number of chunks in the file. From this information, that file can determine the start of the chunk-based region.</p> <p>The chunk-based region starts with a table of contents describing where each chunk starts and ends. This consists of (C+1) rows of 12 bytes each, where C is the number of chunks. Consider the following table:</p> <div class="literalblock"> <div class="content"> <pre>| Chunk ID (4 bytes) | Chunk Offset (8 bytes) | +|--------------------|------------------------| +| ID[0] | OFFSET[0] | +| ... | ... | +| ID[C] | OFFSET[C] | +| 0x0000 | OFFSET[C+1] |</pre> </div> </div> <p>Each row consists of a 4-byte chunk identifier (ID) and an 8-byte offset. Each integer is stored in network-byte order.</p> <p>The chunk identifier <code>ID[i]</code> is a label for the data stored within this file from <code>OFFSET[i]</code> (inclusive) to <code>OFFSET[i+1]</code> (exclusive). Thus, the size of the <code>i`th chunk is equal to the difference between `OFFSET[i+1]</code> and <code>OFFSET[i]</code>. This requires that the chunk data appears contiguously in the same order as the table of contents.</p> <p>The final entry in the table of contents must be four zero bytes. This confirms that the table of contents is ending and provides the offset for the end of the chunk-based data.</p> <p>Note: The chunk-based format expects that the file contains <code>at least</code> a trailing hash after <code>OFFSET[C+1]</code>.</p> <p>Functions for working with chunk-based file formats are declared in <code>chunk-format.h</code>. Using these methods provide extra checks that assist developers when creating new file formats.</p> </div> <h2 id="_writing_chunk_based_file_formats">Writing chunk-based file formats</h2> <div class="sectionbody"> <p>To write a chunk-based file format, create a <code>struct chunkfile</code> by calling <code>init_chunkfile()</code> and pass a <code>struct hashfile</code> pointer. The caller is responsible for opening the <code>hashfile</code> and writing header information so the file format is identifiable before the chunk-based format begins.</p> <p>Then, call <code>add_chunk()</code> for each chunk that is intended for writing. This populates the <code>chunkfile</code> with information about the order and size of each chunk to write. Provide a <code>chunk_write_fn</code> function pointer to perform the write of the chunk data upon request.</p> <p>Call <code>write_chunkfile()</code> to write the table of contents to the <code>hashfile</code> followed by each of the chunks. This will verify that each chunk wrote the expected amount of data so the table of contents is correct.</p> <p>Finally, call <code>free_chunkfile()</code> to clear the <code>struct chunkfile</code> data. The caller is responsible for finalizing the <code>hashfile</code> by writing the trailing hash and closing the file.</p> </div> <h2 id="_reading_chunk_based_file_formats">Reading chunk-based file formats</h2> <div class="sectionbody"> <p>To read a chunk-based file format, the file must be opened as a memory-mapped region. The chunk-format API expects that the entire file is mapped as a contiguous memory region.</p> <p>Initialize a <code>struct chunkfile</code> pointer with <code>init_chunkfile(NULL)</code>.</p> <p>After reading the header information from the beginning of the file, including the chunk count, call <code>read_table_of_contents()</code> to populate the <code>struct chunkfile</code> with the list of chunks, their offsets, and their sizes.</p> <p>Extract the data information for each chunk using <code>pair_chunk()</code> or <code>read_chunk()</code>:</p> <div class="ulist"> <ul> <li> <p><code>pair_chunk()</code> assigns a given pointer with the location inside the memory-mapped file corresponding to that chunk’s offset. If the chunk does not exist, then the pointer is not modified.</p> </li> <li> <p><code>read_chunk()</code> takes a <code>chunk_read_fn</code> function pointer and calls it with the appropriate initial pointer and size information. The function is not called if the chunk does not exist. Use this method to read chunks if you need to perform immediate parsing or if you need to execute logic based on the size of the chunk.</p> </li> </ul> </div> <p>After calling these methods, call <code>free_chunkfile()</code> to clear the <code>struct chunkfile</code> data. This will not close the memory-mapped region. Callers are expected to own that data for the timeframe the pointers into the region are needed.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>These file formats use the chunk-format API, and can be used as examples for future formats:</p> <div class="ulist"> <ul> <li> <p><strong>commit-graph:</strong> see <code>write_commit_graph_file()</code> and <code>parse_commit_graph()</code> in <code>commit-graph.c</code> for how the chunk-format API is used to write and parse the commit-graph file format documented in the commit-graph file format in <a href="gitformat-commit-graph">gitformat-commit-graph[5]</a>.</p> </li> <li> <p><strong>multi-pack-index:</strong> see <code>write_midx_internal()</code> and <code>load_multi_pack_index()</code> in <code>midx.c</code> for how the chunk-format API is used to write and parse the multi-pack-index file format documented in the multi-pack-index file format section of <a href="gitformat-pack">gitformat-pack[5]</a>.</p> </li> </ul> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitformat-chunk" class="_attribution-link">https://git-scm.com/docs/gitformat-chunk</a> + </p> +</div> diff --git a/devdocs/git/gitformat-commit-graph.html b/devdocs/git/gitformat-commit-graph.html new file mode 100644 index 00000000..38e6911f --- /dev/null +++ b/devdocs/git/gitformat-commit-graph.html @@ -0,0 +1,48 @@ +<h1>gitformat-commit-graph</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitformat-commit-graph - Git commit-graph format</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell-session">$GIT_DIR/objects/info/commit-graph +$GIT_DIR/objects/info/commit-graphs/*</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>The Git commit-graph stores a list of commit OIDs and some associated metadata, including:</p> <div class="ulist"> <ul> <li> <p>The generation number of the commit.</p> </li> <li> <p>The root tree OID.</p> </li> <li> <p>The commit date.</p> </li> <li> <p>The parents of the commit, stored using positional references within the graph file.</p> </li> <li> <p>The Bloom filter of the commit carrying the paths that were changed between the commit and its first parent, if requested.</p> </li> </ul> </div> <p>These positional references are stored as unsigned 32-bit integers corresponding to the array position within the list of commit OIDs. Due to some special constants we use to track parents, we can store at most (1 << 30) + (1 << 29) + (1 << 28) - 1 (around 1.8 billion) commits.</p> </div> <h2 id="_commit_graph_files_have_the_following_format">Commit-graph files have the following format:</h2> <div class="sectionbody"> <p>In order to allow extensions that add extra data to the graph, we organize the body into "chunks" and provide a binary lookup table at the beginning of the body. The header includes certain values, such as number of chunks and hash type.</p> <p>All multi-byte numbers are in network byte order.</p> <div class="sect2"> <h3 id="_header"> +HEADER:</h3> <div class="literalblock"> <div class="content"> <pre>4-byte signature: + The signature is: {'C', 'G', 'P', 'H'}</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>1-byte version number: + Currently, the only valid version is 1.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> 1-byte Hash Version + We infer the hash length (H) from this value: +1 => SHA-1 +2 => SHA-256 + If the hash type does not match the repository's hash algorithm, the + commit-graph file should be ignored with a warning presented to the + user.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>1-byte number (C) of "chunks"</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>1-byte number (B) of base commit-graphs + We infer the length (H*B) of the Base Graphs chunk + from this value.</pre> </div> </div> </div> <div class="sect2"> <h3 id="_chunk_lookup"> +CHUNK LOOKUP:</h3> <div class="literalblock"> <div class="content"> <pre>(C + 1) * 12 bytes listing the table of contents for the chunks: + First 4 bytes describe the chunk id. Value 0 is a terminating label. + Other 8 bytes provide the byte-offset in current file for chunk to + start. (Chunks are ordered contiguously in the file, so you can infer + the length using the next chunk position if necessary.) Each chunk + ID appears at most once.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The CHUNK LOOKUP matches the table of contents from +the chunk-based file format, see gitformat-chunk[5]</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The remaining data in the body is described one chunk at a time, and +these chunks may be given in any order. Chunks are required unless +otherwise specified.</pre> </div> </div> </div> <div class="sect2"> <h3 id="_chunk_data"> +CHUNK DATA:</h3> <div class="sect3"> <h4 id="_oid_fanout_id_o_i_d_f_256_4_bytes"> +OID Fanout (ID: {<em>O</em>, <em>I</em>, <em>D</em>, <em>F</em>}) (256 * 4 bytes)</h4> <div class="literalblock"> <div class="content"> <pre>The ith entry, F[i], stores the number of OIDs with first +byte at most i. Thus F[255] stores the total +number of commits (N).</pre> </div> </div> </div> <div class="sect3"> <h4 id="_oid_lookup_id_o_i_d_l_n_h_bytes"> +OID Lookup (ID: {<em>O</em>, <em>I</em>, <em>D</em>, <em>L</em>}) (N * H bytes)</h4> <div class="literalblock"> <div class="content"> <pre>The OIDs for all commits in the graph, sorted in ascending order.</pre> </div> </div> </div> <div class="sect3"> <h4 id="_commit_data_id_c_d_a_t_n_h_16_bytes"> +Commit Data (ID: {<em>C</em>, <em>D</em>, <em>A</em>, <em>T</em> }) (N * (H + 16) bytes)</h4> <div class="ulist"> <ul> <li> <p>The first H bytes are for the OID of the root tree.</p> </li> <li> <p>The next 8 bytes are for the positions of the first two parents of the ith commit. Stores value 0x70000000 if no parent in that position. If there are more than two parents, the second value has its most-significant bit on and the other bits store an array position into the Extra Edge List chunk.</p> </li> <li> <p>The next 8 bytes store the topological level (generation number v1) of the commit and the commit time in seconds since EPOCH. The generation number uses the higher 30 bits of the first 4 bytes, while the commit time uses the 32 bits of the second 4 bytes, along with the lowest 2 bits of the lowest byte, storing the 33rd and 34th bit of the commit time.</p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_generation_data_id_g_d_a_2_n_4_bytes_optional"> +Generation Data (ID: {<em>G</em>, <em>D</em>, <em>A</em>, <em>2</em> }) (N * 4 bytes) [Optional]</h4> <div class="ulist"> <ul> <li> <p>This list of 4-byte values store corrected commit date offsets for the commits, arranged in the same order as commit data chunk.</p> </li> <li> <p>If the corrected commit date offset cannot be stored within 31 bits, the value has its most-significant bit on and the other bits store the position of corrected commit date into the Generation Data Overflow chunk.</p> </li> <li> <p>Generation Data chunk is present only when commit-graph file is written by compatible versions of Git and in case of split commit-graph chains, the topmost layer also has Generation Data chunk.</p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_generation_data_overflow_id_g_d_o_2_optional"> +Generation Data Overflow (ID: {<em>G</em>, <em>D</em>, <em>O</em>, <em>2</em> }) [Optional]</h4> <div class="ulist"> <ul> <li> <p>This list of 8-byte values stores the corrected commit date offsets for commits with corrected commit date offsets that cannot be stored within 31 bits.</p> </li> <li> <p>Generation Data Overflow chunk is present only when Generation Data chunk is present and atleast one corrected commit date offset cannot be stored within 31 bits.</p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_extra_edge_list_id_e_d_g_e_optional"> +Extra Edge List (ID: {<em>E</em>, <em>D</em>, <em>G</em>, <em>E</em>}) [Optional]</h4> <div class="literalblock"> <div class="content"> <pre>This list of 4-byte values store the second through nth parents for +all octopus merges. The second parent value in the commit data stores +an array position within this list along with the most-significant bit +on. Starting at that array position, iterate through this list of commit +positions for the parents until reaching a value with the most-significant +bit on. The other bits correspond to the position of the last parent.</pre> </div> </div> </div> <div class="sect3"> <h4 id="_bloom_filter_index_id_b_i_d_x_n_4_bytes_optional"> +Bloom Filter Index (ID: {<em>B</em>, <em>I</em>, <em>D</em>, <em>X</em>}) (N * 4 bytes) [Optional]</h4> <div class="ulist"> <ul> <li> <p>The ith entry, BIDX[i], stores the number of bytes in all Bloom filters from commit 0 to commit i (inclusive) in lexicographic order. The Bloom filter for the i-th commit spans from BIDX[i-1] to BIDX[i] (plus header length), where BIDX[-1] is 0.</p> </li> <li> <p>The BIDX chunk is ignored if the BDAT chunk is not present.</p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_bloom_filter_data_id_b_d_a_t_optional"> +Bloom Filter Data (ID: {<em>B</em>, <em>D</em>, <em>A</em>, <em>T</em>}) [Optional]</h4> <div class="ulist"> <ul> <li> <p>It starts with header consisting of three unsigned 32-bit integers:</p> <div class="ulist"> <ul> <li> <p>Version of the hash algorithm being used. We currently only support value 1 which corresponds to the 32-bit version of the murmur3 hash implemented exactly as described in <a href="https://en.wikipedia.org/wiki/MurmurHash#Algorithm" class="bare">https://en.wikipedia.org/wiki/MurmurHash#Algorithm</a> and the double hashing technique using seed values 0x293ae76f and 0x7e646e2 as described in <a href="https://doi.org/10.1007/978-3-540-30494-4_26" class="bare">https://doi.org/10.1007/978-3-540-30494-4_26</a> "Bloom Filters in Probabilistic Verification"</p> </li> <li> <p>The number of times a path is hashed and hence the number of bit positions that cumulatively determine whether a file is present in the commit.</p> </li> <li> <p>The minimum number of bits <code>b</code> per entry in the Bloom filter. If the filter contains <code>n</code> entries, then the filter size is the minimum number of 64-bit words that contain n*b bits.</p> </li> </ul> </div> </li> <li> <p>The rest of the chunk is the concatenation of all the computed Bloom filters for the commits in lexicographic order.</p> </li> <li> <p>Note: Commits with no changes or more than 512 changes have Bloom filters of length one, with either all bits set to zero or one respectively.</p> </li> <li> <p>The BDAT chunk is present if and only if BIDX is present.</p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="_base_graphs_list_id_b_a_s_e_optional"> +Base Graphs List (ID: {<em>B</em>, <em>A</em>, <em>S</em>, <em>E</em>}) [Optional]</h4> <div class="literalblock"> <div class="content"> <pre>This list of H-byte hashes describe a set of B commit-graph files that +form a commit-graph chain. The graph position for the ith commit in this +file's OID Lookup chunk is equal to i plus the number of commits in all +base graphs. If B is non-zero, this chunk must exist.</pre> </div> </div> </div> </div> <div class="sect2"> <h3 id="_trailer"> +TRAILER:</h3> <div class="literalblock"> <div class="content"> <pre>H-byte HASH-checksum of all of the above.</pre> </div> </div> </div> </div> <h2 id="_historical_notes">Historical notes:</h2> <div class="sectionbody"> <p>The Generation Data (GDA2) and Generation Data Overflow (GDO2) chunks have the number <code>2</code> in their chunk IDs because a previous version of Git wrote possibly erroneous data in these chunks with the IDs "GDAT" and "GDOV". By changing the IDs, newer versions of Git will silently ignore those older chunks and write the new information without trusting the incorrect data.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitformat-commit-graph" class="_attribution-link">https://git-scm.com/docs/gitformat-commit-graph</a> + </p> +</div> diff --git a/devdocs/git/gitformat-index.html b/devdocs/git/gitformat-index.html new file mode 100644 index 00000000..b7702821 --- /dev/null +++ b/devdocs/git/gitformat-index.html @@ -0,0 +1,116 @@ +<h1>gitformat-index</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitformat-index - Git index format</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell-session">$GIT_DIR/index</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Git index format</p> </div> <h2 id="_the_git_index_file_has_the_following_format">The git index file has the following format</h2> <div class="sectionbody"> <div class="literalblock"> <div class="content"> <pre>All binary numbers are in network byte order. +In a repository using the traditional SHA-1, checksums and object IDs +(object names) mentioned below are all computed using SHA-1. Similarly, +in SHA-256 repositories, these values are computed using SHA-256. +Version 2 is described here unless stated otherwise.</pre> </div> </div> <div class="ulist"> <ul> <li> <p>A 12-byte header consisting of</p> <div class="literalblock"> <div class="content"> <pre>4-byte signature: + The signature is { 'D', 'I', 'R', 'C' } (stands for "dircache")</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>4-byte version number: + The current supported versions are 2, 3 and 4.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>32-bit number of index entries.</pre> </div> </div> </li> <li> <p>A number of sorted index entries (see below).</p> </li> <li> <p>Extensions</p> <div class="literalblock"> <div class="content"> <pre>Extensions are identified by signature. Optional extensions can +be ignored if Git does not understand them.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>4-byte extension signature. If the first byte is 'A'..'Z' the +extension is optional and can be ignored.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>32-bit size of the extension</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Extension data</pre> </div> </div> </li> <li> <p>Hash checksum over the content of the index file before this checksum.</p> </li> </ul> </div> </div> <h2 id="_index_entry">Index entry</h2> <div class="sectionbody"> <div class="literalblock"> <div class="content"> <pre>Index entries are sorted in ascending order on the name field, +interpreted as a string of unsigned bytes (i.e. memcmp() order, no +localization, no special casing of directory separator '/'). Entries +with the same name are sorted by their stage field.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>An index entry typically represents a file. However, if sparse-checkout +is enabled in cone mode (`core.sparseCheckoutCone` is enabled) and the +`extensions.sparseIndex` extension is enabled, then the index may +contain entries for directories outside of the sparse-checkout definition. +These entries have mode `040000`, include the `SKIP_WORKTREE` bit, and +the path ends in a directory separator.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>32-bit ctime seconds, the last time a file's metadata changed + this is stat(2) data</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>32-bit ctime nanosecond fractions + this is stat(2) data</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>32-bit mtime seconds, the last time a file's data changed + this is stat(2) data</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>32-bit mtime nanosecond fractions + this is stat(2) data</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>32-bit dev + this is stat(2) data</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>32-bit ino + this is stat(2) data</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>32-bit mode, split into (high to low bits)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>16-bit unused, must be zero</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>4-bit object type + valid values in binary are 1000 (regular file), 1010 (symbolic link) + and 1110 (gitlink)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>3-bit unused, must be zero</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>9-bit unix permission. Only 0755 and 0644 are valid for regular files. +Symbolic links and gitlinks have value 0 in this field.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>32-bit uid + this is stat(2) data</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>32-bit gid + this is stat(2) data</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>32-bit file size + This is the on-disk size from stat(2), truncated to 32-bit.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Object name for the represented object</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>A 16-bit 'flags' field split into (high to low bits)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>1-bit assume-valid flag</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>1-bit extended flag (must be zero in version 2)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>2-bit stage (during merge)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>12-bit name length if the length is less than 0xFFF; otherwise 0xFFF +is stored in this field.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>(Version 3 or later) A 16-bit field, only applicable if the +"extended flag" above is 1, split into (high to low bits).</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>1-bit reserved for future</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>1-bit skip-worktree flag (used by sparse checkout)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>1-bit intent-to-add flag (used by "git add -N")</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>13-bit unused, must be zero</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Entry path name (variable length) relative to top level directory + (without leading slash). '/' is used as path separator. The special + path components ".", ".." and ".git" (without quotes) are disallowed. + Trailing slash is also disallowed.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The exact encoding is undefined, but the '.' and '/' characters +are encoded in 7-bit ASCII and the encoding cannot contain a NUL +byte (iow, this is a UNIX pathname).</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>(Version 4) In version 4, the entry path name is prefix-compressed + relative to the path name for the previous entry (the very first + entry is encoded as if the path name for the previous entry is an + empty string). At the beginning of an entry, an integer N in the + variable width encoding (the same encoding as the offset is encoded + for OFS_DELTA pack entries; see gitformat-pack[5]) is stored, followed + by a NUL-terminated string S. Removing N bytes from the end of the + path name for the previous entry, and replacing it with the string S + yields the path name for this entry.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>1-8 nul bytes as necessary to pad the entry to a multiple of eight bytes +while keeping the name NUL-terminated.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>(Version 4) In version 4, the padding after the pathname does not +exist.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Interpretation of index entries in split index mode is completely +different. See below for details.</pre> </div> </div> </div> <h2 id="_extensions">Extensions</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_cache_tree"> +Cache tree</h3> <div class="literalblock"> <div class="content"> <pre>Since the index does not record entries for directories, the cache +entries cannot describe tree objects that already exist in the object +database for regions of the index that are unchanged from an existing +commit. The cache tree extension stores a recursive tree structure that +describes the trees that already exist and completely match sections of +the cache entries. This speeds up tree object generation from the index +for a new commit by only computing the trees that are "new" to that +commit. It also assists when comparing the index to another tree, such +as `HEAD^{tree}`, since sections of the index can be skipped when a tree +comparison demonstrates equality.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The recursive tree structure uses nodes that store a number of cache +entries, a list of subnodes, and an object ID (OID). The OID references +the existing tree for that node, if it is known to exist. The subnodes +correspond to subdirectories that themselves have cache tree nodes. The +number of cache entries corresponds to the number of cache entries in +the index that describe paths within that tree's directory.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The extension tracks the full directory structure in the cache tree +extension, but this is generally smaller than the full cache entry list.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>When a path is updated in index, Git invalidates all nodes of the +recursive cache tree corresponding to the parent directories of that +path. We store these tree nodes as being "invalid" by using "-1" as the +number of cache entries. Invalid nodes still store a span of index +entries, allowing Git to focus its efforts when reconstructing a full +cache tree.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The signature for this extension is { 'T', 'R', 'E', 'E' }.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>A series of entries fill the entire extension; each of which +consists of:</pre> </div> </div> <div class="ulist"> <ul> <li> <p>NUL-terminated path component (relative to its parent directory);</p> </li> <li> <p>ASCII decimal number of entries in the index that is covered by the tree this entry represents (entry_count);</p> </li> <li> <p>A space (ASCII 32);</p> </li> <li> <p>ASCII decimal number that represents the number of subtrees this tree has;</p> </li> <li> <p>A newline (ASCII 10); and</p> </li> <li> <p>Object name for the object that would result from writing this span of index as a tree.</p> <div class="literalblock"> <div class="content"> <pre>An entry can be in an invalidated state and is represented by having +a negative number in the entry_count field. In this case, there is no +object name and the next entry starts immediately after the newline. +When writing an invalid entry, -1 should always be used as entry_count.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The entries are written out in the top-down, depth-first order. The +first entry represents the root level of the repository, followed by the +first subtree--let's call this A--of the root level (with its name +relative to the root level), followed by the first subtree of A (with +its name relative to A), and so on. The specified number of subtrees +indicates when the current level of the recursive stack is complete.</pre> </div> </div> </li> </ul> </div> </div> <div class="sect2"> <h3 id="_resolve_undo"> +Resolve undo</h3> <div class="literalblock"> <div class="content"> <pre>A conflict is represented in the index as a set of higher stage entries. +When a conflict is resolved (e.g. with "git add path"), these higher +stage entries will be removed and a stage-0 entry with proper resolution +is added.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>When these higher stage entries are removed, they are saved in the +resolve undo extension, so that conflicts can be recreated (e.g. with +"git checkout -m"), in case users want to redo a conflict resolution +from scratch.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The signature for this extension is { 'R', 'E', 'U', 'C' }.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>A series of entries fill the entire extension; each of which +consists of:</pre> </div> </div> <div class="ulist"> <ul> <li> <p>NUL-terminated pathname the entry describes (relative to the root of the repository, i.e. full pathname);</p> </li> <li> <p>Three NUL-terminated ASCII octal numbers, entry mode of entries in stage 1 to 3 (a missing stage is represented by "0" in this field); and</p> </li> <li> <p>At most three object names of the entry in stages from 1 to 3 (nothing is written for a missing stage).</p> </li> </ul> </div> </div> <div class="sect2"> <h3 id="_split_index"> +Split index</h3> <div class="literalblock"> <div class="content"> <pre>In split index mode, the majority of index entries could be stored +in a separate file. This extension records the changes to be made on +top of that to produce the final index.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The signature for this extension is { 'l', 'i', 'n', 'k' }.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The extension consists of:</pre> </div> </div> <div class="ulist"> <ul> <li> <p>Hash of the shared index file. The shared index file path is $GIT_DIR/sharedindex.<hash>. If all bits are zero, the index does not require a shared index file.</p> </li> <li> <p>An ewah-encoded delete bitmap, each bit represents an entry in the shared index. If a bit is set, its corresponding entry in the shared index will be removed from the final index. Note, because a delete operation changes index entry positions, but we do need original positions in replace phase, it’s best to just mark entries for removal, then do a mass deletion after replacement.</p> </li> <li> <p>An ewah-encoded replace bitmap, each bit represents an entry in the shared index. If a bit is set, its corresponding entry in the shared index will be replaced with an entry in this index file. All replaced entries are stored in sorted order in this index. The first "1" bit in the replace bitmap corresponds to the first index entry, the second "1" bit to the second entry and so on. Replaced entries may have empty path names to save space.</p> <div class="literalblock"> <div class="content"> <pre>The remaining index entries after replaced ones will be added to the +final index. These added entries are also sorted by entry name then +stage.</pre> </div> </div> </li> </ul> </div> </div> </div> <h2 id="_untracked_cache">Untracked cache</h2> <div class="sectionbody"> <div class="literalblock"> <div class="content"> <pre>Untracked cache saves the untracked file list and necessary data to +verify the cache. The signature for this extension is { 'U', 'N', +'T', 'R' }.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The extension starts with</pre> </div> </div> <div class="ulist"> <ul> <li> <p>A sequence of NUL-terminated strings, preceded by the size of the sequence in variable width encoding. Each string describes the environment where the cache can be used.</p> </li> <li> <p>Stat data of $GIT_DIR/info/exclude. See "Index entry" section from ctime field until "file size".</p> </li> <li> <p>Stat data of core.excludesFile</p> </li> <li> <p>32-bit dir_flags (see struct dir_struct)</p> </li> <li> <p>Hash of $GIT_DIR/info/exclude. A null hash means the file does not exist.</p> </li> <li> <p>Hash of core.excludesFile. A null hash means the file does not exist.</p> </li> <li> <p>NUL-terminated string of per-dir exclude file name. This usually is ".gitignore".</p> </li> <li> <p>The number of following directory blocks, variable width encoding. If this number is zero, the extension ends here with a following NUL.</p> </li> <li> <p>A number of directory blocks in depth-first-search order, each consists of</p> </li> <li> <p>The number of untracked entries, variable width encoding.</p> </li> <li> <p>The number of sub-directory blocks, variable width encoding.</p> </li> <li> <p>The directory name terminated by NUL.</p> </li> <li> <p>A number of untracked file/dir names terminated by NUL.</p> </li> </ul> </div> <p>The remaining data of each directory block is grouped by type:</p> <div class="ulist"> <ul> <li> <p>An ewah bitmap, the n-th bit marks whether the n-th directory has valid untracked cache entries.</p> </li> <li> <p>An ewah bitmap, the n-th bit records "check-only" bit of read_directory_recursive() for the n-th directory.</p> </li> <li> <p>An ewah bitmap, the n-th bit indicates whether hash and stat data is valid for the n-th directory and exists in the next data.</p> </li> <li> <p>An array of stat data. The n-th data corresponds with the n-th "one" bit in the previous ewah bitmap.</p> </li> <li> <p>An array of hashes. The n-th hash corresponds with the n-th "one" bit in the previous ewah bitmap.</p> </li> <li> <p>One NUL.</p> </li> </ul> </div> </div> <h2 id="_file_system_monitor_cache">File system monitor cache</h2> <div class="sectionbody"> <div class="literalblock"> <div class="content"> <pre>The file system monitor cache tracks files for which the core.fsmonitor +hook has told us about changes. The signature for this extension is +{ 'F', 'S', 'M', 'N' }.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The extension starts with</pre> </div> </div> <div class="ulist"> <ul> <li> <p>32-bit version number: the current supported versions are 1 and 2.</p> </li> <li> <p>(Version 1) 64-bit time: the extension data reflects all changes through the given time which is stored as the nanoseconds elapsed since midnight, January 1, 1970.</p> </li> <li> <p>(Version 2) A null terminated string: an opaque token defined by the file system monitor application. The extension data reflects all changes relative to that token.</p> </li> <li> <p>32-bit bitmap size: the size of the CE_FSMONITOR_VALID bitmap.</p> </li> <li> <p>An ewah bitmap, the n-th bit indicates whether the n-th index entry is not CE_FSMONITOR_VALID.</p> </li> </ul> </div> </div> <h2 id="_end_of_index_entry">End of index entry</h2> <div class="sectionbody"> <div class="literalblock"> <div class="content"> <pre>The End of Index Entry (EOIE) is used to locate the end of the variable +length index entries and the beginning of the extensions. Code can take +advantage of this to quickly locate the index extensions without having +to parse through all of the index entries.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Because it must be able to be loaded before the variable length cache +entries and other index extensions, this extension must be written last. +The signature for this extension is { 'E', 'O', 'I', 'E' }.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The extension consists of:</pre> </div> </div> <div class="ulist"> <ul> <li> <p>32-bit offset to the end of the index entries</p> </li> <li> <p>Hash over the extension types and their sizes (but not their contents). E.g. if we have "TREE" extension that is N-bytes long, "REUC" extension that is M-bytes long, followed by "EOIE", then the hash would be:</p> <div class="literalblock"> <div class="content"> <pre>Hash("TREE" + <binary representation of N> + + "REUC" + <binary representation of M>)</pre> </div> </div> </li> </ul> </div> </div> <h2 id="_index_entry_offset_table">Index entry offset table</h2> <div class="sectionbody"> <div class="literalblock"> <div class="content"> <pre>The Index Entry Offset Table (IEOT) is used to help address the CPU +cost of loading the index by enabling multi-threading the process of +converting cache entries from the on-disk format to the in-memory format. +The signature for this extension is { 'I', 'E', 'O', 'T' }.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The extension consists of:</pre> </div> </div> <div class="ulist"> <ul> <li> <p>32-bit version (currently 1)</p> </li> <li> <p>A number of index offset entries each consisting of:</p> </li> <li> <p>32-bit offset from the beginning of the file to the first cache entry in this block of entries.</p> </li> <li> <p>32-bit count of cache entries in this block</p> </li> </ul> </div> </div> <h2 id="_sparse_directory_entries">Sparse directory entries</h2> <div class="sectionbody"> <div class="literalblock"> <div class="content"> <pre>When using sparse-checkout in cone mode, some entire directories within +the index can be summarized by pointing to a tree object instead of the +entire expanded list of paths within that tree. An index containing such +entries is a "sparse index". Index format versions 4 and less were not +implemented with such entries in mind. Thus, for these versions, an +index containing sparse directory entries will include this extension +with signature { 's', 'd', 'i', 'r' }. Like the split-index extension, +tools should avoid interacting with a sparse index unless they understand +this extension.</pre> </div> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitformat-index" class="_attribution-link">https://git-scm.com/docs/gitformat-index</a> + </p> +</div> diff --git a/devdocs/git/gitformat-pack.html b/devdocs/git/gitformat-pack.html new file mode 100644 index 00000000..0f78ba8e --- /dev/null +++ b/devdocs/git/gitformat-pack.html @@ -0,0 +1,141 @@ +<h1>gitformat-pack</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitformat-pack - Git pack format</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell-session">$GIT_DIR/objects/pack/pack-.{pack,idx} +$GIT_DIR/objects/pack/pack-.rev +$GIT_DIR/objects/pack/pack-*.mtimes +$GIT_DIR/objects/pack/multi-pack-index</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>The Git pack format is how Git stores most of its primary repository data. Over the lifetime of a repository, loose objects (if any) and smaller packs are consolidated into larger pack(s). See <a href="git-gc">git-gc[1]</a> and <a href="git-pack-objects">git-pack-objects[1]</a>.</p> <p>The pack format is also used over-the-wire, see e.g. <a href="gitprotocol-v2">gitprotocol-v2[5]</a>, as well as being a part of other container formats in the case of <a href="gitformat-bundle">gitformat-bundle[5]</a>.</p> </div> <h2 id="_checksums_and_object_ids">Checksums and object ids</h2> <div class="sectionbody"> <p>In a repository using the traditional SHA-1, pack checksums, index checksums, and object IDs (object names) mentioned below are all computed using SHA-1. Similarly, in SHA-256 repositories, these values are computed using SHA-256.</p> </div> <h2 id="_pack_pack_files_have_the_following_format">Pack-*.pack files have the following format:</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>A header appears at the beginning and consists of the following:</p> <div class="literalblock"> <div class="content"> <pre>4-byte signature: + The signature is: {'P', 'A', 'C', 'K'}</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> 4-byte version number (network byte order): +Git currently accepts version number 2 or 3 but + generates version 2 only.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>4-byte number of objects contained in the pack (network byte order)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Observation: we cannot have more than 4G versions ;-) and +more than 4G objects in a pack.</pre> </div> </div> </li> <li> <p>The header is followed by a number of object entries, each of which looks like this:</p> <div class="literalblock"> <div class="content"> <pre>(undeltified representation) +n-byte type and length (3-bit type, (n-1)*7+4-bit length) +compressed data</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> (deltified representation) + n-byte type and length (3-bit type, (n-1)*7+4-bit length) + base object name if OBJ_REF_DELTA or a negative relative +offset from the delta object's position in the pack if this +is an OBJ_OFS_DELTA object + compressed delta data</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Observation: the length of each object is encoded in a variable +length format and is not constrained to 32-bit or anything.</pre> </div> </div> </li> <li> <p>The trailer records a pack checksum of all of the above.</p> </li> </ul> </div> <div class="sect2"> <h3 id="_object_types"> +Object types</h3> <p>Valid object types are:</p> <div class="ulist"> <ul> <li> <p>OBJ_COMMIT (1)</p> </li> <li> <p>OBJ_TREE (2)</p> </li> <li> <p>OBJ_BLOB (3)</p> </li> <li> <p>OBJ_TAG (4)</p> </li> <li> <p>OBJ_OFS_DELTA (6)</p> </li> <li> <p>OBJ_REF_DELTA (7)</p> </li> </ul> </div> <p>Type 5 is reserved for future expansion. Type 0 is invalid.</p> </div> <div class="sect2"> <h3 id="_size_encoding"> +Size encoding</h3> <p>This document uses the following "size encoding" of non-negative integers: From each byte, the seven least significant bits are used to form the resulting integer. As long as the most significant bit is 1, this process continues; the byte with MSB 0 provides the last seven bits. The seven-bit chunks are concatenated. Later values are more significant.</p> <p>This size encoding should not be confused with the "offset encoding", which is also used in this document.</p> </div> <div class="sect2"> <h3 id="_deltified_representation"> +Deltified representation</h3> <p>Conceptually there are only four object types: commit, tree, tag and blob. However to save space, an object could be stored as a "delta" of another "base" object. These representations are assigned new types ofs-delta and ref-delta, which is only valid in a pack file.</p> <p>Both ofs-delta and ref-delta store the "delta" to be applied to another object (called <code>base object</code>) to reconstruct the object. The difference between them is, ref-delta directly encodes base object name. If the base object is in the same pack, ofs-delta encodes the offset of the base object in the pack instead.</p> <p>The base object could also be deltified if it’s in the same pack. Ref-delta can also refer to an object outside the pack (i.e. the so-called "thin pack"). When stored on disk however, the pack should be self contained to avoid cyclic dependency.</p> <p>The delta data starts with the size of the base object and the size of the object to be reconstructed. These sizes are encoded using the size encoding from above. The remainder of the delta data is a sequence of instructions to reconstruct the object from the base object. If the base object is deltified, it must be converted to canonical form first. Each instruction appends more and more data to the target object until it’s complete. There are two supported instructions so far: one for copying a byte range from the source object and one for inserting new data embedded in the instruction itself.</p> <p>Each instruction has variable length. Instruction type is determined by the seventh bit of the first octet. The following diagrams follow the convention in RFC 1951 (Deflate compressed data format).</p> <div class="sect3"> <h4 id="_instruction_to_copy_from_base_object"> +Instruction to copy from base object</h4> <div class="literalblock"> <div class="content"> <pre>+----------+---------+---------+---------+---------+-------+-------+-------+ +| 1xxxxxxx | offset1 | offset2 | offset3 | offset4 | size1 | size2 | size3 | ++----------+---------+---------+---------+---------+-------+-------+-------+</pre> </div> </div> <p>This is the instruction format to copy a byte range from the source object. It encodes the offset to copy from and the number of bytes to copy. Offset and size are in little-endian order.</p> <p>All offset and size bytes are optional. This is to reduce the instruction size when encoding small offsets or sizes. The first seven bits in the first octet determine which of the next seven octets is present. If bit zero is set, offset1 is present. If bit one is set offset2 is present and so on.</p> <p>Note that a more compact instruction does not change offset and size encoding. For example, if only offset2 is omitted like below, offset3 still contains bits 16-23. It does not become offset2 and contains bits 8-15 even if it’s right next to offset1.</p> <div class="literalblock"> <div class="content"> <pre>+----------+---------+---------+ +| 10000101 | offset1 | offset3 | ++----------+---------+---------+</pre> </div> </div> <p>In its most compact form, this instruction only takes up one byte (0x80) with both offset and size omitted, which will have default values zero. There is another exception: size zero is automatically converted to 0x10000.</p> </div> <div class="sect3"> <h4 id="_instruction_to_add_new_data"> +Instruction to add new data</h4> <div class="literalblock"> <div class="content"> <pre>+----------+============+ +| 0xxxxxxx | data | ++----------+============+</pre> </div> </div> <p>This is the instruction to construct the target object without the base object. The following data is appended to the target object. The first seven bits of the first octet determine the size of data in bytes. The size must be non-zero.</p> </div> <div class="sect3"> <h4 id="_reserved_instruction"> +Reserved instruction</h4> <div class="literalblock"> <div class="content"> <pre>+----------+============ +| 00000000 | ++----------+============</pre> </div> </div> <p>This is the instruction reserved for future expansion.</p> </div> </div> </div> <h2 id="_original_version_1_pack_idx_files_have_the_following_format">Original (version 1) pack-*.idx files have the following format:</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>The header consists of 256 4-byte network byte order integers. N-th entry of this table records the number of objects in the corresponding pack, the first byte of whose object name is less than or equal to N. This is called the <code>first-level fan-out</code> table.</p> </li> <li> <p>The header is followed by sorted 24-byte entries, one entry per object in the pack. Each entry is:</p> <div class="literalblock"> <div class="content"> <pre>4-byte network byte order integer, recording where the +object is stored in the packfile as the offset from the +beginning.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>one object name of the appropriate size.</pre> </div> </div> </li> <li> <p>The file is concluded with a trailer:</p> <div class="literalblock"> <div class="content"> <pre>A copy of the pack checksum at the end of the corresponding +packfile.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Index checksum of all of the above.</pre> </div> </div> </li> </ul> </div> <p>Pack Idx file:</p> <div class="literalblock"> <div class="content"> <pre> -- +--------------------------------+ +fanout | fanout[0] = 2 (for example) |-. +table +--------------------------------+ | + | fanout[1] | | + +--------------------------------+ | + | fanout[2] | | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | + | fanout[255] = total objects |---. + -- +--------------------------------+ | | +main | offset | | | +index | object name 00XXXXXXXXXXXXXXXX | | | +table +--------------------------------+ | | + | offset | | | + | object name 00XXXXXXXXXXXXXXXX | | | + +--------------------------------+<+ | + .-| offset | | + | | object name 01XXXXXXXXXXXXXXXX | | + | +--------------------------------+ | + | | offset | | + | | object name 01XXXXXXXXXXXXXXXX | | + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | + | | offset | | + | | object name FFXXXXXXXXXXXXXXXX | | + --| +--------------------------------+<--+ +trailer | | packfile checksum | + | +--------------------------------+ + | | idxfile checksum | + | +--------------------------------+ + .-------. + | +Pack file entry: <+</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> packed object header: +1-byte size extension bit (MSB) + type (next 3 bit) + size0 (lower 4-bit) + n-byte sizeN (as long as MSB is set, each 7-bit) + size0..sizeN form 4+7+7+..+7 bit integer, size0 + is the least significant part, and sizeN is the + most significant part. + packed object data: + If it is not DELTA, then deflated bytes (the size above + is the size before compression). +If it is REF_DELTA, then + base object name (the size above is the + size of the delta data that follows). + delta data, deflated. +If it is OFS_DELTA, then + n-byte offset (see below) interpreted as a negative + offset from the type-byte of the header of the + ofs-delta entry (the size above is the size of + the delta data that follows). + delta data, deflated.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> offset encoding: +n bytes with MSB set in all but the last one. +The offset is then the number constructed by +concatenating the lower 7 bit of each byte, and +for n >= 2 adding 2^7 + 2^14 + ... + 2^(7*(n-1)) +to the result.</pre> </div> </div> </div> <h2 id="_version_2_pack_idx_files_support_packs_larger_than_4_gib_and">Version 2 pack-*.idx files support packs larger than 4 gib, and</h2> <div class="sectionbody"> <div class="literalblock"> <div class="content"> <pre>have some other reorganizations. They have the format:</pre> </div> </div> <div class="ulist"> <ul> <li> <p>A 4-byte magic number <code>\377tOc</code> which is an unreasonable fanout[0] value.</p> </li> <li> <p>A 4-byte version number (= 2)</p> </li> <li> <p>A 256-entry fan-out table just like v1.</p> </li> <li> <p>A table of sorted object names. These are packed together without offset values to reduce the cache footprint of the binary search for a specific object name.</p> </li> <li> <p>A table of 4-byte CRC32 values of the packed object data. This is new in v2 so compressed data can be copied directly from pack to pack during repacking without undetected data corruption.</p> </li> <li> <p>A table of 4-byte offset values (in network byte order). These are usually 31-bit pack file offsets, but large offsets are encoded as an index into the next table with the msbit set.</p> </li> <li> <p>A table of 8-byte offset entries (empty for pack files less than 2 GiB). Pack files are organized with heavily used objects toward the front, so most object references should not need to refer to this table.</p> </li> <li> <p>The same trailer as a v1 pack file:</p> <div class="literalblock"> <div class="content"> <pre>A copy of the pack checksum at the end of the +corresponding packfile.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Index checksum of all of the above.</pre> </div> </div> </li> </ul> </div> </div> <h2 id="_pack_rev_files_have_the_format">Pack-*.rev files have the format:</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>A 4-byte magic number <code>0x52494458</code> (<code>RIDX</code>).</p> </li> <li> <p>A 4-byte version identifier (= 1).</p> </li> <li> <p>A 4-byte hash function identifier (= 1 for SHA-1, 2 for SHA-256).</p> </li> <li> <p>A table of index positions (one per packed object, num_objects in total, each a 4-byte unsigned integer in network order), sorted by their corresponding offsets in the packfile.</p> </li> <li> <p>A trailer, containing a:</p> <div class="literalblock"> <div class="content"> <pre>checksum of the corresponding packfile, and</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>a checksum of all of the above.</pre> </div> </div> </li> </ul> </div> <p>All 4-byte numbers are in network order.</p> </div> <h2 id="_pack_mtimes_files_have_the_format">Pack-*.mtimes files have the format:</h2> <div class="sectionbody"> <p>All 4-byte numbers are in network byte order.</p> <div class="ulist"> <ul> <li> <p>A 4-byte magic number <code>0x4d544d45</code> (<code>MTME</code>).</p> </li> <li> <p>A 4-byte version identifier (= 1).</p> </li> <li> <p>A 4-byte hash function identifier (= 1 for SHA-1, 2 for SHA-256).</p> </li> <li> <p>A table of 4-byte unsigned integers. The ith value is the modification time (mtime) of the ith object in the corresponding pack by lexicographic (index) order. The mtimes count standard epoch seconds.</p> </li> <li> <p>A trailer, containing a checksum of the corresponding packfile, and a checksum of all of the above (each having length according to the specified hash function).</p> </li> </ul> </div> </div> <h2 id="_multi_pack_index_midx_files_have_the_following_format">Multi-pack-index (midx) files have the following format:</h2> <div class="sectionbody"> <p>The multi-pack-index files refer to multiple pack-files and loose objects.</p> <p>In order to allow extensions that add extra data to the MIDX, we organize the body into "chunks" and provide a lookup table at the beginning of the body. The header includes certain length values, such as the number of packs, the number of base MIDX files, hash lengths and types.</p> <p>All 4-byte numbers are in network order.</p> <p>HEADER:</p> <div class="literalblock"> <div class="content"> <pre>4-byte signature: + The signature is: {'M', 'I', 'D', 'X'}</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>1-byte version number: + Git only writes or recognizes version 1.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>1-byte Object Id Version + We infer the length of object IDs (OIDs) from this value: + 1 => SHA-1 + 2 => SHA-256 + If the hash type does not match the repository's hash algorithm, + the multi-pack-index file should be ignored with a warning + presented to the user.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>1-byte number of "chunks"</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>1-byte number of base multi-pack-index files: + This value is currently always zero.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>4-byte number of pack files</pre> </div> </div> <p>CHUNK LOOKUP:</p> <div class="literalblock"> <div class="content"> <pre>(C + 1) * 12 bytes providing the chunk offsets: + First 4 bytes describe chunk id. Value 0 is a terminating label. + Other 8 bytes provide offset in current file for chunk to start. + (Chunks are provided in file-order, so you can infer the length + using the next chunk position if necessary.)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The CHUNK LOOKUP matches the table of contents from +the chunk-based file format, see gitformat-chunk[5].</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>The remaining data in the body is described one chunk at a time, and +these chunks may be given in any order. Chunks are required unless +otherwise specified.</pre> </div> </div> <p>CHUNK DATA:</p> <div class="literalblock"> <div class="content"> <pre>Packfile Names (ID: {'P', 'N', 'A', 'M'}) + Store the names of packfiles as a sequence of NUL-terminated + strings. There is no extra padding between the filenames, + and they are listed in lexicographic order. The chunk itself + is padded at the end with between 0 and 3 NUL bytes to make the + chunk size a multiple of 4 bytes.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>OID Fanout (ID: {'O', 'I', 'D', 'F'}) + The ith entry, F[i], stores the number of OIDs with first + byte at most i. Thus F[255] stores the total + number of objects.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>OID Lookup (ID: {'O', 'I', 'D', 'L'}) + The OIDs for all objects in the MIDX are stored in lexicographic + order in this chunk.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>Object Offsets (ID: {'O', 'O', 'F', 'F'}) + Stores two 4-byte values for every object. + 1: The pack-int-id for the pack storing this object. + 2: The offset within the pack. + If all offsets are less than 2^32, then the large offset chunk + will not exist and offsets are stored as in IDX v1. + If there is at least one offset value larger than 2^32-1, then + the large offset chunk must exist, and offsets larger than + 2^31-1 must be stored in it instead. If the large offset chunk + exists and the 31st bit is on, then removing that bit reveals + the row in the large offsets containing the 8-byte offset of + this object.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>[Optional] Object Large Offsets (ID: {'L', 'O', 'F', 'F'}) + 8-byte offsets into large packfiles.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>[Optional] Bitmap pack order (ID: {'R', 'I', 'D', 'X'}) + A list of MIDX positions (one per object in the MIDX, num_objects in + total, each a 4-byte unsigned integer in network byte order), sorted + according to their relative bitmap/pseudo-pack positions.</pre> </div> </div> <p>TRAILER:</p> <div class="literalblock"> <div class="content"> <pre>Index checksum of the above contents.</pre> </div> </div> </div> <h2 id="_multi_pack_index_reverse_indexes">Multi-pack-index reverse indexes</h2> <div class="sectionbody"> <p>Similar to the pack-based reverse index, the multi-pack index can also be used to generate a reverse index.</p> <p>Instead of mapping between offset, pack-, and index position, this reverse index maps between an object’s position within the MIDX, and that object’s position within a pseudo-pack that the MIDX describes (i.e., the ith entry of the multi-pack reverse index holds the MIDX position of ith object in pseudo-pack order).</p> <p>To clarify the difference between these orderings, consider a multi-pack reachability bitmap (which does not yet exist, but is what we are building towards here). Each bit needs to correspond to an object in the MIDX, and so we need an efficient mapping from bit position to MIDX position.</p> <p>One solution is to let bits occupy the same position in the oid-sorted index stored by the MIDX. But because oids are effectively random, their resulting reachability bitmaps would have no locality, and thus compress poorly. (This is the reason that single-pack bitmaps use the pack ordering, and not the .idx ordering, for the same purpose.)</p> <p>So we’d like to define an ordering for the whole MIDX based around pack ordering, which has far better locality (and thus compresses more efficiently). We can think of a pseudo-pack created by the concatenation of all of the packs in the MIDX. E.g., if we had a MIDX with three packs (a, b, c), with 10, 15, and 20 objects respectively, we can imagine an ordering of the objects like:</p> <div class="literalblock"> <div class="content"> <pre>|a,0|a,1|...|a,9|b,0|b,1|...|b,14|c,0|c,1|...|c,19|</pre> </div> </div> <p>where the ordering of the packs is defined by the MIDX’s pack list, and then the ordering of objects within each pack is the same as the order in the actual packfile.</p> <p>Given the list of packs and their counts of objects, you can naïvely reconstruct that pseudo-pack ordering (e.g., the object at position 27 must be (c,1) because packs "a" and "b" consumed 25 of the slots). But there’s a catch. Objects may be duplicated between packs, in which case the MIDX only stores one pointer to the object (and thus we’d want only one slot in the bitmap).</p> <p>Callers could handle duplicates themselves by reading objects in order of their bit-position, but that’s linear in the number of objects, and much too expensive for ordinary bitmap lookups. Building a reverse index solves this, since it is the logical inverse of the index, and that index has already removed duplicates. But, building a reverse index on the fly can be expensive. Since we already have an on-disk format for pack-based reverse indexes, let’s reuse it for the MIDX’s pseudo-pack, too.</p> <p>Objects from the MIDX are ordered as follows to string together the pseudo-pack. Let <code>pack(o)</code> return the pack from which <code>o</code> was selected by the MIDX, and define an ordering of packs based on their numeric ID (as stored by the MIDX). Let <code>offset(o)</code> return the object offset of <code>o</code> within <code>pack(o)</code>. Then, compare <code>o1</code> and <code>o2</code> as follows:</p> <div class="ulist"> <ul> <li> <p>If one of <code>pack(o1)</code> and <code>pack(o2)</code> is preferred and the other is not, then the preferred one sorts first.</p> <p>(This is a detail that allows the MIDX bitmap to determine which pack should be used by the pack-reuse mechanism, since it can ask the MIDX for the pack containing the object at bit position 0).</p> </li> <li> <p>If <code>pack(o1) ≠ pack(o2)</code>, then sort the two objects in descending order based on the pack ID.</p> </li> <li> <p>Otherwise, <code>pack(o1) = pack(o2)</code>, and the objects are sorted in pack-order (i.e., <code>o1</code> sorts ahead of <code>o2</code> exactly when <code>offset(o1) +< offset(o2)</code>).</p> </li> </ul> </div> <p>In short, a MIDX’s pseudo-pack is the de-duplicated concatenation of objects in packs stored by the MIDX, laid out in pack order, and the packs arranged in MIDX order (with the preferred pack coming first).</p> <p>The MIDX’s reverse index is stored in the optional <code>RIDX</code> chunk within the MIDX itself.</p> </div> <h2 id="_cruft_packs">Cruft packs</h2> <div class="sectionbody"> <p>The cruft packs feature offer an alternative to Git’s traditional mechanism of removing unreachable objects. This document provides an overview of Git’s pruning mechanism, and how a cruft pack can be used instead to accomplish the same.</p> <div class="sect2"> <h3 id="_background"> +Background</h3> <p>To remove unreachable objects from your repository, Git offers <code>git repack -Ad</code> (see <a href="git-repack">git-repack[1]</a>). Quoting from the documentation:</p> <div class="listingblock"> <div class="content"> <pre>[...] unreachable objects in a previous pack become loose, unpacked objects, +instead of being left in the old pack. [...] loose unreachable objects will be +pruned according to normal expiry rules with the next 'git gc' invocation.</pre> </div> </div> <p>Unreachable objects aren’t removed immediately, since doing so could race with an incoming push which may reference an object which is about to be deleted. Instead, those unreachable objects are stored as loose objects and stay that way until they are older than the expiration window, at which point they are removed by <a href="git-prune">git-prune[1]</a>.</p> <p>Git must store these unreachable objects loose in order to keep track of their per-object mtimes. If these unreachable objects were written into one big pack, then either freshening that pack (because an object contained within it was re-written) or creating a new pack of unreachable objects would cause the pack’s mtime to get updated, and the objects within it would never leave the expiration window. Instead, objects are stored loose in order to keep track of the individual object mtimes and avoid a situation where all cruft objects are freshened at once.</p> <p>This can lead to undesirable situations when a repository contains many unreachable objects which have not yet left the grace period. Having large directories in the shards of <code>.git/objects</code> can lead to decreased performance in the repository. But given enough unreachable objects, this can lead to inode starvation and degrade the performance of the whole system. Since we can never pack those objects, these repositories often take up a large amount of disk space, since we can only zlib compress them, but not store them in delta chains.</p> </div> <div class="sect2"> <h3 id="_cruft_packs_2"> +Cruft packs</h3> <p>A cruft pack eliminates the need for storing unreachable objects in a loose state by including the per-object mtimes in a separate file alongside a single pack containing all loose objects.</p> <p>A cruft pack is written by <code>git repack --cruft</code> when generating a new pack. <a href="git-pack-objects">git-pack-objects[1]</a>'s <code>--cruft</code> option. Note that <code>git repack --cruft</code> is a classic all-into-one repack, meaning that everything in the resulting pack is reachable, and everything else is unreachable. Once written, the <code>--cruft</code> option instructs <code>git repack</code> to generate another pack containing only objects not packed in the previous step (which equates to packing all unreachable objects together). This progresses as follows:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Enumerate every object, marking any object which is (a) not contained in a kept-pack, and (b) whose mtime is within the grace period as a traversal tip.</p> </li> <li> <p>Perform a reachability traversal based on the tips gathered in the previous step, adding every object along the way to the pack.</p> </li> <li> <p>Write the pack out, along with a <code>.mtimes</code> file that records the per-object timestamps.</p> </li> </ol> </div> <p>This mode is invoked internally by <a href="git-repack">git-repack[1]</a> when instructed to write a cruft pack. Crucially, the set of in-core kept packs is exactly the set of packs which will not be deleted by the repack; in other words, they contain all of the repository’s reachable objects.</p> <p>When a repository already has a cruft pack, <code>git repack --cruft</code> typically only adds objects to it. An exception to this is when <code>git repack</code> is given the <code>--cruft-expiration</code> option, which allows the generated cruft pack to omit expired objects instead of waiting for <a href="git-gc">git-gc[1]</a> to expire those objects later on.</p> <p>It is <a href="git-gc">git-gc[1]</a> that is typically responsible for removing expired unreachable objects.</p> </div> <div class="sect2"> <h3 id="_alternatives"> +Alternatives</h3> <p>Notable alternatives to this design include:</p> <div class="ulist"> <ul> <li> <p>The location of the per-object mtime data.</p> </li> </ul> </div> <p>On the location of mtime data, a new auxiliary file tied to the pack was chosen to avoid complicating the <code>.idx</code> format. If the <code>.idx</code> format were ever to gain support for optional chunks of data, it may make sense to consolidate the <code>.mtimes</code> format into the <code>.idx</code> itself.</p> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitformat-pack" class="_attribution-link">https://git-scm.com/docs/gitformat-pack</a> + </p> +</div> diff --git a/devdocs/git/gitformat-signature.html b/devdocs/git/gitformat-signature.html new file mode 100644 index 00000000..8db0a9c5 --- /dev/null +++ b/devdocs/git/gitformat-signature.html @@ -0,0 +1,123 @@ +<h1>gitformat-signature</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitformat-signature - Git cryptographic signature formats</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content"><[tag|commit] object header(s)> +<over-the-wire protocol></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Git uses cryptographic signatures in various places, currently objects (tags, commits, mergetags) and transactions (pushes). In every case, the command which is about to create an object or transaction determines a payload from that, calls an external program to obtain a detached signature for the payload (<code>gpg -bsa</code> in the case of PGP signatures), and embeds the signature into the object or transaction.</p> <p>Signatures begin with an "ASCII Armor" header line and end with a tail line, which differ depending on signature type (as selected by <code>gpg.format</code>, see <a href="git-config">git-config[1]</a>). These are, for <code>gpg.format</code> values:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitformat-signature.txt-codegpgcodePGP"> <code>gpg</code> (PGP) </dt> <dd> <p><code>-----BEGIN PGP SIGNATURE-----</code> and <code>-----END PGP SIGNATURE-----</code>. Or, if gpg is told to produce RFC1991 signatures, <code>-----BEGIN PGP MESSAGE-----</code> and <code>-----END PGP MESSAGE-----</code></p> </dd> <dt class="hdlist1" id="Documentation/gitformat-signature.txt-codesshcodeSSH"> <code>ssh</code> (SSH) </dt> <dd> <p><code>-----BEGIN SSH SIGNATURE-----</code> and <code>-----END SSH SIGNATURE-----</code></p> </dd> <dt class="hdlist1" id="Documentation/gitformat-signature.txt-codex509codeX509"> <code>x509</code> (X.509) </dt> <dd> <p><code>-----BEGIN SIGNED MESSAGE-----</code> and <code>-----END SIGNED MESSAGE-----</code></p> </dd> </dl> </div> <p>Signatures sometimes appear as a part of the normal payload (e.g. a signed tag has the signature block appended after the payload that the signature applies to), and sometimes appear in the value of an object header (e.g. a merge commit that merged a signed tag would have the entire tag contents on its "mergetag" header). In the case of the latter, the usual multi-line formatting rule for object headers applies. I.e. the second and subsequent lines are prefixed with a SP to signal that the line is continued from the previous line.</p> <p>This is even true for an originally empty line. In the following examples, the end of line that ends with a whitespace letter is highlighted with a <code>$</code> sign; if you are trying to recreate these example by hand, do not cut and paste them—they are there primarily to highlight extra whitespace at the end of some lines.</p> <p>The signed payload and the way the signature is embedded depends on the type of the object resp. transaction.</p> </div> <h2 id="_tag_signatures">Tag signatures</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>created by: <code>git tag -s</code></p> </li> <li> <p>payload: annotated tag object</p> </li> <li> <p>embedding: append the signature to the unsigned tag object</p> </li> <li> <p>example: tag <code>signedtag</code> with subject <code>signed tag</code></p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre>object 04b871796dc0420f8e7561a895b52484b701d51a +type commit +tag signedtag +tagger C O Mitter <committer@example.com> 1465981006 +0000 + +signed tag + +signed tag message body +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1 + +iQEcBAABAgAGBQJXYRhOAAoJEGEJLoW3InGJklkIAIcnhL7RwEb/+QeX9enkXhxn +rxfdqrvWd1K80sl2TOt8Bg/NYwrUBw/RWJ+sg/hhHp4WtvE1HDGHlkEz3y11Lkuh +8tSxS3qKTxXUGozyPGuE90sJfExhZlW4knIQ1wt/yWqM+33E9pN4hzPqLwyrdods +q8FWEqPPUbSJXoMbRPw04S5jrLtZSsUWbRYjmJCHzlhSfFWW4eFd37uquIaLUBS0 +rkC3Jrx7420jkIpgFcTI2s60uhSQLzgcCwdA2ukSYIRnjg/zDkj8+3h/GaROJ72x +lZyI6HWixKJkWw8lE9aAOD9TmTW9sFJwcVAzmAuFX2kUreDUKMZduGcoRYGpD7E= +=jpXa +-----END PGP SIGNATURE-----</pre> </div> </div> <div class="ulist"> <ul> <li> <p>verify with: <code>git verify-tag [-v]</code> or <code>git tag -v</code></p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre>gpg: Signature made Wed Jun 15 10:56:46 2016 CEST using RSA key ID B7227189 +gpg: Good signature from "Eris Discordia <discord@example.net>" +gpg: WARNING: This key is not certified with a trusted signature! +gpg: There is no indication that the signature belongs to the owner. +Primary key fingerprint: D4BE 2231 1AD3 131E 5EDA 29A4 6109 2E85 B722 7189 +object 04b871796dc0420f8e7561a895b52484b701d51a +type commit +tag signedtag +tagger C O Mitter <committer@example.com> 1465981006 +0000 + +signed tag + +signed tag message body</pre> </div> </div> </div> <h2 id="_commit_signatures">Commit signatures</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>created by: <code>git commit -S</code></p> </li> <li> <p>payload: commit object</p> </li> <li> <p>embedding: header entry <code>gpgsig</code> (content is preceded by a space)</p> </li> <li> <p>example: commit with subject <code>signed commit</code></p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre>tree eebfed94e75e7760540d1485c740902590a00332 +parent 04b871796dc0420f8e7561a895b52484b701d51a +author A U Thor <author@example.com> 1465981137 +0000 +committer C O Mitter <committer@example.com> 1465981137 +0000 +gpgsig -----BEGIN PGP SIGNATURE----- + Version: GnuPG v1 + $ + iQEcBAABAgAGBQJXYRjRAAoJEGEJLoW3InGJ3IwIAIY4SA6GxY3BjL60YyvsJPh/ + HRCJwH+w7wt3Yc/9/bW2F+gF72kdHOOs2jfv+OZhq0q4OAN6fvVSczISY/82LpS7 + DVdMQj2/YcHDT4xrDNBnXnviDO9G7am/9OE77kEbXrp7QPxvhjkicHNwy2rEflAA + zn075rtEERDHr8nRYiDh8eVrefSO7D+bdQ7gv+7GsYMsd2auJWi1dHOSfTr9HIF4 + HJhWXT9d2f8W+diRYXGh4X0wYiGg6na/soXc+vdtDYBzIxanRqjg8jCAeo1eOTk1 + EdTwhcTZlI0x5pvJ3H0+4hA2jtldVtmPM4OTB0cTrEWBad7XV6YgiyuII73Ve3I= + =jKHM + -----END PGP SIGNATURE----- + +signed commit + +signed commit message body</pre> </div> </div> <div class="ulist"> <ul> <li> <p>verify with: <code>git verify-commit [-v]</code> (or <code>git show --show-signature</code>)</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre>gpg: Signature made Wed Jun 15 10:58:57 2016 CEST using RSA key ID B7227189 +gpg: Good signature from "Eris Discordia <discord@example.net>" +gpg: WARNING: This key is not certified with a trusted signature! +gpg: There is no indication that the signature belongs to the owner. +Primary key fingerprint: D4BE 2231 1AD3 131E 5EDA 29A4 6109 2E85 B722 7189 +tree eebfed94e75e7760540d1485c740902590a00332 +parent 04b871796dc0420f8e7561a895b52484b701d51a +author A U Thor <author@example.com> 1465981137 +0000 +committer C O Mitter <committer@example.com> 1465981137 +0000 + +signed commit + +signed commit message body</pre> </div> </div> </div> <h2 id="_mergetag_signatures">Mergetag signatures</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>created by: <code>git merge</code> on signed tag</p> </li> <li> <p>payload/embedding: the whole signed tag object is embedded into the (merge) commit object as header entry <code>mergetag</code></p> </li> <li> <p>example: merge of the signed tag <code>signedtag</code> as above</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre>tree c7b1cff039a93f3600a1d18b82d26688668c7dea +parent c33429be94b5f2d3ee9b0adad223f877f174b05d +parent 04b871796dc0420f8e7561a895b52484b701d51a +author A U Thor <author@example.com> 1465982009 +0000 +committer C O Mitter <committer@example.com> 1465982009 +0000 +mergetag object 04b871796dc0420f8e7561a895b52484b701d51a + type commit + tag signedtag + tagger C O Mitter <committer@example.com> 1465981006 +0000 + $ + signed tag + $ + signed tag message body + -----BEGIN PGP SIGNATURE----- + Version: GnuPG v1 + $ + iQEcBAABAgAGBQJXYRhOAAoJEGEJLoW3InGJklkIAIcnhL7RwEb/+QeX9enkXhxn + rxfdqrvWd1K80sl2TOt8Bg/NYwrUBw/RWJ+sg/hhHp4WtvE1HDGHlkEz3y11Lkuh + 8tSxS3qKTxXUGozyPGuE90sJfExhZlW4knIQ1wt/yWqM+33E9pN4hzPqLwyrdods + q8FWEqPPUbSJXoMbRPw04S5jrLtZSsUWbRYjmJCHzlhSfFWW4eFd37uquIaLUBS0 + rkC3Jrx7420jkIpgFcTI2s60uhSQLzgcCwdA2ukSYIRnjg/zDkj8+3h/GaROJ72x + lZyI6HWixKJkWw8lE9aAOD9TmTW9sFJwcVAzmAuFX2kUreDUKMZduGcoRYGpD7E= + =jpXa + -----END PGP SIGNATURE----- + +Merge tag 'signedtag' into downstream + +signed tag + +signed tag message body + +# gpg: Signature made Wed Jun 15 08:56:46 2016 UTC using RSA key ID B7227189 +# gpg: Good signature from "Eris Discordia <discord@example.net>" +# gpg: WARNING: This key is not certified with a trusted signature! +# gpg: There is no indication that the signature belongs to the owner. +# Primary key fingerprint: D4BE 2231 1AD3 131E 5EDA 29A4 6109 2E85 B722 7189</pre> </div> </div> <div class="ulist"> <ul> <li> <p>verify with: verification is embedded in merge commit message by default, alternatively with <code>git show --show-signature</code>:</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre>commit 9863f0c76ff78712b6800e199a46aa56afbcbd49 +merged tag 'signedtag' +gpg: Signature made Wed Jun 15 10:56:46 2016 CEST using RSA key ID B7227189 +gpg: Good signature from "Eris Discordia <discord@example.net>" +gpg: WARNING: This key is not certified with a trusted signature! +gpg: There is no indication that the signature belongs to the owner. +Primary key fingerprint: D4BE 2231 1AD3 131E 5EDA 29A4 6109 2E85 B722 7189 +Merge: c33429b 04b8717 +Author: A U Thor <author@example.com> +Date: Wed Jun 15 09:13:29 2016 +0000 + + Merge tag 'signedtag' into downstream + + signed tag + + signed tag message body + + # gpg: Signature made Wed Jun 15 08:56:46 2016 UTC using RSA key ID B7227189 + # gpg: Good signature from "Eris Discordia <discord@example.net>" + # gpg: WARNING: This key is not certified with a trusted signature! + # gpg: There is no indication that the signature belongs to the owner. + # Primary key fingerprint: D4BE 2231 1AD3 131E 5EDA 29A4 6109 2E85 B722 7189</pre> </div> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitformat-signature" class="_attribution-link">https://git-scm.com/docs/gitformat-signature</a> + </p> +</div> diff --git a/devdocs/git/gitglossary.html b/devdocs/git/gitglossary.html new file mode 100644 index 00000000..9d1a2a31 --- /dev/null +++ b/devdocs/git/gitglossary.html @@ -0,0 +1,8 @@ +<h1>gitglossary</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitglossary - A Git Glossary</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>*</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefalternateobjectdatabaseaalternateobjectdatabase"> alternate object database </dt> <dd> <p>Via the alternates mechanism, a <a href="#def_repository">repository</a> can inherit part of its <a href="#def_object_database">object database</a> from another object database, which is called an "alternate".</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefbarerepositoryabarerepository"> bare repository </dt> <dd> <p>A bare repository is normally an appropriately named <a href="#def_directory">directory</a> with a <code>.git</code> suffix that does not have a locally checked-out copy of any of the files under revision control. That is, all of the Git administrative and control files that would normally be present in the hidden <code>.git</code> sub-directory are directly present in the <code>repository.git</code> directory instead, and no other files are present and checked out. Usually publishers of public repositories make bare repositories available.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefblobobjectablobobject"> blob object </dt> <dd> <p>Untyped <a href="#def_object">object</a>, e.g. the contents of a file.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefbranchabranch"> branch </dt> <dd> <p>A "branch" is a line of development. The most recent <a href="#def_commit">commit</a> on a branch is referred to as the tip of that branch. The tip of the branch is <a href="#def_ref">referenced</a> by a branch <a href="#def_head">head</a>, which moves forward as additional development is done on the branch. A single Git <a href="#def_repository">repository</a> can track an arbitrary number of branches, but your <a href="#def_working_tree">working tree</a> is associated with just one of them (the "current" or "checked out" branch), and <a href="#def_HEAD">HEAD</a> points to that branch.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefcacheacache"> cache </dt> <dd> <p>Obsolete for: <a href="#def_index">index</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefchainachain"> chain </dt> <dd> <p>A list of objects, where each <a href="#def_object">object</a> in the list contains a reference to its successor (for example, the successor of a <a href="#def_commit">commit</a> could be one of its <a href="#def_parent">parents</a>).</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefchangesetachangeset"> changeset </dt> <dd> <p>BitKeeper/cvsps speak for "<a href="#def_commit">commit</a>". Since Git does not store changes, but states, it really does not make sense to use the term "changesets" with Git.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefcheckoutacheckout"> checkout </dt> <dd> <p>The action of updating all or part of the <a href="#def_working_tree">working tree</a> with a <a href="#def_tree_object">tree object</a> or <a href="#def_blob_object">blob</a> from the <a href="#def_object_database">object database</a>, and updating the <a href="#def_index">index</a> and <a href="#def_HEAD">HEAD</a> if the whole working tree has been pointed at a new <a href="#def_branch">branch</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefcherry-pickingacherry-picking"> cherry-picking </dt> <dd> <p>In <a href="#def_SCM">SCM</a> jargon, "cherry pick" means to choose a subset of changes out of a series of changes (typically commits) and record them as a new series of changes on top of a different codebase. In Git, this is performed by the "git cherry-pick" command to extract the change introduced by an existing <a href="#def_commit">commit</a> and to record it based on the tip of the current <a href="#def_branch">branch</a> as a new commit.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefcleanaclean"> clean </dt> <dd> <p>A <a href="#def_working_tree">working tree</a> is clean, if it corresponds to the <a href="#def_revision">revision</a> referenced by the current <a href="#def_head">head</a>. Also see "<a href="#def_dirty">dirty</a>".</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefcommitacommit"> commit </dt> <dd> <p>As a noun: A single point in the Git history; the entire history of a project is represented as a set of interrelated commits. The word "commit" is often used by Git in the same places other revision control systems use the words "revision" or "version". Also used as a short hand for <a href="#def_commit_object">commit object</a>.</p> <p>As a verb: The action of storing a new snapshot of the project’s state in the Git history, by creating a new commit representing the current state of the <a href="#def_index">index</a> and advancing <a href="#def_HEAD">HEAD</a> to point at the new commit.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefcommitgraphgeneralacommitgraphconceptrepresentationsandusage"> commit graph concept, representations and usage </dt> <dd> <p>A synonym for the <a href="#def_DAG">DAG</a> structure formed by the commits in the object database, <a href="#def_ref">referenced</a> by branch tips, using their <a href="#def_chain">chain</a> of linked commits. This structure is the definitive commit graph. The graph can be represented in other ways, e.g. the <a href="#def_commit_graph_file">"commit-graph" file</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefcommitgraphfileacommit-graphfile"> commit-graph file </dt> <dd> <p>The "commit-graph" (normally hyphenated) file is a supplemental representation of the <a href="#def_commit_graph_general">commit graph</a> which accelerates commit graph walks. The "commit-graph" file is stored either in the .git/objects/info directory or in the info directory of an alternate object database.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefcommitobjectacommitobject"> commit object </dt> <dd> <p>An <a href="#def_object">object</a> which contains the information about a particular <a href="#def_revision">revision</a>, such as <a href="#def_parent">parents</a>, committer, author, date and the <a href="#def_tree_object">tree object</a> which corresponds to the top <a href="#def_directory">directory</a> of the stored revision.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefcommit-ishacommit-ishalsocommittish"> commit-ish (also committish) </dt> <dd> <p>A <a href="#def_commit_object">commit object</a> or an <a href="#def_object">object</a> that can be recursively <a href="#def_dereference">dereferenced</a> to a commit object. The following are all commit-ishes: a commit object, a <a href="#def_tag_object">tag object</a> that points to a commit object, a tag object that points to a tag object that points to a commit object, etc.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefcoregitacoreGit"> core Git </dt> <dd> <p>Fundamental data structures and utilities of Git. Exposes only limited source code management tools.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefDAGaDAG"> DAG </dt> <dd> <p>Directed acyclic graph. The <a href="#def_commit_object">commit objects</a> form a directed acyclic graph, because they have parents (directed), and the graph of commit objects is acyclic (there is no <a href="#def_chain">chain</a> which begins and ends with the same <a href="#def_object">object</a>).</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefdanglingobjectadanglingobject"> dangling object </dt> <dd> <p>An <a href="#def_unreachable_object">unreachable object</a> which is not <a href="#def_reachable">reachable</a> even from other unreachable objects; a dangling object has no references to it from any reference or <a href="#def_object">object</a> in the <a href="#def_repository">repository</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefdereferenceadereference"> dereference </dt> <dd> <p>Referring to a <a href="#def_symref">symbolic ref</a>: the action of accessing the <a href="#def_ref">reference</a> pointed at by a symbolic ref. Recursive dereferencing involves repeating the aforementioned process on the resulting ref until a non-symbolic reference is found.</p> <p>Referring to a <a href="#def_tag_object">tag object</a>: the action of accessing the <a href="#def_object">object</a> a tag points at. Tags are recursively dereferenced by repeating the operation on the result object until the result has either a specified <a href="#def_object_type">object type</a> (where applicable) or any non-"tag" object type. A synonym for "recursive dereference" in the context of tags is "<a href="#def_peel">peel</a>".</p> <p>Referring to a <a href="#def_commit_object">commit object</a>: the action of accessing the commit’s tree object. Commits cannot be dereferenced recursively.</p> <p>Unless otherwise specified, "dereferencing" as it used in the context of Git commands or protocols is implicitly recursive.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefdetachedHEADadetachedHEAD"> detached HEAD </dt> <dd> <p>Normally the <a href="#def_HEAD">HEAD</a> stores the name of a <a href="#def_branch">branch</a>, and commands that operate on the history HEAD represents operate on the history leading to the tip of the branch the HEAD points at. However, Git also allows you to <a href="#def_checkout">check out</a> an arbitrary <a href="#def_commit">commit</a> that isn’t necessarily the tip of any particular branch. The HEAD in such a state is called "detached".</p> <p>Note that commands that operate on the history of the current branch (e.g. <code>git commit</code> to build a new history on top of it) still work while the HEAD is detached. They update the HEAD to point at the tip of the updated history without affecting any branch. Commands that update or inquire information <code>about</code> the current branch (e.g. <code>git +branch --set-upstream-to</code> that sets what remote-tracking branch the current branch integrates with) obviously do not work, as there is no (real) current branch to ask about in this state.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefdirectoryadirectory"> directory </dt> <dd> <p>The list you get with "ls" :-)</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefdirtyadirty"> dirty </dt> <dd> <p>A <a href="#def_working_tree">working tree</a> is said to be "dirty" if it contains modifications which have not been <a href="#def_commit">committed</a> to the current <a href="#def_branch">branch</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefevilmergeaevilmerge"> evil merge </dt> <dd> <p>An evil merge is a <a href="#def_merge">merge</a> that introduces changes that do not appear in any <a href="#def_parent">parent</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddeffastforwardafast-forward"> fast-forward </dt> <dd> <p>A fast-forward is a special type of <a href="#def_merge">merge</a> where you have a <a href="#def_revision">revision</a> and you are "merging" another <a href="#def_branch">branch</a>'s changes that happen to be a descendant of what you have. In such a case, you do not make a new <a href="#def_merge">merge</a> <a href="#def_commit">commit</a> but instead just update your branch to point at the same revision as the branch you are merging. This will happen frequently on a <a href="#def_remote_tracking_branch">remote-tracking branch</a> of a remote <a href="#def_repository">repository</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddeffetchafetch"> fetch </dt> <dd> <p>Fetching a <a href="#def_branch">branch</a> means to get the branch’s <a href="#def_head_ref">head ref</a> from a remote <a href="#def_repository">repository</a>, to find out which objects are missing from the local <a href="#def_object_database">object database</a>, and to get them, too. See also <a href="git-fetch">git-fetch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddeffilesystemafilesystem"> file system </dt> <dd> <p>Linus Torvalds originally designed Git to be a user space file system, i.e. the infrastructure to hold files and directories. That ensured the efficiency and speed of Git.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefgitarchiveaGitarchive"> Git archive </dt> <dd> <p>Synonym for <a href="#def_repository">repository</a> (for arch people).</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefgitfileagitfile"> gitfile </dt> <dd> <p>A plain file <code>.git</code> at the root of a working tree that points at the directory that is the real repository. For proper use see <a href="git-worktree">git-worktree[1]</a> or <a href="git-submodule">git-submodule[1]</a>. For syntax see <a href="gitrepository-layout">gitrepository-layout[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefgraftsagrafts"> grafts </dt> <dd> <p>Grafts enable two otherwise different lines of development to be joined together by recording fake ancestry information for commits. This way you can make Git pretend the set of <a href="#def_parent">parents</a> a <a href="#def_commit">commit</a> has is different from what was recorded when the commit was created. Configured via the <code>.git/info/grafts</code> file.</p> <p>Note that the grafts mechanism is outdated and can lead to problems transferring objects between repositories; see <a href="git-replace">git-replace[1]</a> for a more flexible and robust system to do the same thing.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefhashahash"> hash </dt> <dd> <p>In Git’s context, synonym for <a href="#def_object_name">object name</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefheadahead"> head </dt> <dd> <p>A <a href="#def_ref">named reference</a> to the <a href="#def_commit">commit</a> at the tip of a <a href="#def_branch">branch</a>. Heads are stored in a file in <code>$GIT_DIR/refs/heads/</code> directory, except when using packed refs. (See <a href="git-pack-refs">git-pack-refs[1]</a>.)</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefHEADaHEAD"> HEAD </dt> <dd> <p>The current <a href="#def_branch">branch</a>. In more detail: Your <a href="#def_working_tree">working tree</a> is normally derived from the state of the tree referred to by HEAD. HEAD is a reference to one of the <a href="#def_head">heads</a> in your repository, except when using a <a href="#def_detached_HEAD">detached HEAD</a>, in which case it directly references an arbitrary commit.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefheadrefaheadref"> head ref </dt> <dd> <p>A synonym for <a href="#def_head">head</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefhookahook"> hook </dt> <dd> <p>During the normal execution of several Git commands, call-outs are made to optional scripts that allow a developer to add functionality or checking. Typically, the hooks allow for a command to be pre-verified and potentially aborted, and allow for a post-notification after the operation is done. The hook scripts are found in the <code>$GIT_DIR/hooks/</code> directory, and are enabled by simply removing the <code>.sample</code> suffix from the filename. In earlier versions of Git you had to make them executable.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefindexaindex"> index </dt> <dd> <p>A collection of files with stat information, whose contents are stored as objects. The index is a stored version of your <a href="#def_working_tree">working tree</a>. Truth be told, it can also contain a second, and even a third version of a working tree, which are used when <a href="#def_merge">merging</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefindexentryaindexentry"> index entry </dt> <dd> <p>The information regarding a particular file, stored in the <a href="#def_index">index</a>. An index entry can be unmerged, if a <a href="#def_merge">merge</a> was started, but not yet finished (i.e. if the index contains multiple versions of that file).</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefmasteramaster"> master </dt> <dd> <p>The default development <a href="#def_branch">branch</a>. Whenever you create a Git <a href="#def_repository">repository</a>, a branch named "master" is created, and becomes the active branch. In most cases, this contains the local development, though that is purely by convention and is not required.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefmergeamerge"> merge </dt> <dd> <p>As a verb: To bring the contents of another <a href="#def_branch">branch</a> (possibly from an external <a href="#def_repository">repository</a>) into the current branch. In the case where the merged-in branch is from a different repository, this is done by first <a href="#def_fetch">fetching</a> the remote branch and then merging the result into the current branch. This combination of fetch and merge operations is called a <a href="#def_pull">pull</a>. Merging is performed by an automatic process that identifies changes made since the branches diverged, and then applies all those changes together. In cases where changes conflict, manual intervention may be required to complete the merge.</p> <p>As a noun: unless it is a <a href="#def_fast_forward">fast-forward</a>, a successful merge results in the creation of a new <a href="#def_commit">commit</a> representing the result of the merge, and having as <a href="#def_parent">parents</a> the tips of the merged <a href="#def_branch">branches</a>. This commit is referred to as a "merge commit", or sometimes just a "merge".</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefobjectaobject"> object </dt> <dd> <p>The unit of storage in Git. It is uniquely identified by the <a href="#def_SHA1">SHA-1</a> of its contents. Consequently, an object cannot be changed.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefobjectdatabaseaobjectdatabase"> object database </dt> <dd> <p>Stores a set of "objects", and an individual <a href="#def_object">object</a> is identified by its <a href="#def_object_name">object name</a>. The objects usually live in <code>$GIT_DIR/objects/</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefobjectidentifieraobjectidentifieroid"> object identifier (oid) </dt> <dd> <p>Synonym for <a href="#def_object_name">object name</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefobjectnameaobjectname"> object name </dt> <dd> <p>The unique identifier of an <a href="#def_object">object</a>. The object name is usually represented by a 40 character hexadecimal string. Also colloquially called <a href="#def_SHA1">SHA-1</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefobjecttypeaobjecttype"> object type </dt> <dd> <p>One of the identifiers "<a href="#def_commit_object">commit</a>", "<a href="#def_tree_object">tree</a>", "<a href="#def_tag_object">tag</a>" or "<a href="#def_blob_object">blob</a>" describing the type of an <a href="#def_object">object</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefoctopusaoctopus"> octopus </dt> <dd> <p>To <a href="#def_merge">merge</a> more than two <a href="#def_branch">branches</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddeforphanaorphan"> orphan </dt> <dd> <p>The act of getting on a <a href="#def_branch">branch</a> that does not exist yet (i.e., an <a href="#def_unborn">unborn</a> branch). After such an operation, the commit first created becomes a commit without a parent, starting a new history.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddeforiginaorigin"> origin </dt> <dd> <p>The default upstream <a href="#def_repository">repository</a>. Most projects have at least one upstream project which they track. By default <code>origin</code> is used for that purpose. New upstream updates will be fetched into <a href="#def_remote_tracking_branch">remote-tracking branches</a> named origin/name-of-upstream-branch, which you can see using <code>git branch -r</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefoverlayaoverlay"> overlay </dt> <dd> <p>Only update and add files to the working directory, but don’t delete them, similar to how <code>cp -R</code> would update the contents in the destination directory. This is the default mode in a <a href="#def_checkout">checkout</a> when checking out files from the <a href="#def_index">index</a> or a <a href="#def_tree-ish">tree-ish</a>. In contrast, no-overlay mode also deletes tracked files not present in the source, similar to <code>rsync --delete</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefpackapack"> pack </dt> <dd> <p>A set of objects which have been compressed into one file (to save space or to transmit them efficiently).</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefpackindexapackindex"> pack index </dt> <dd> <p>The list of identifiers, and other information, of the objects in a <a href="#def_pack">pack</a>, to assist in efficiently accessing the contents of a pack.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefpathspecapathspec"> pathspec </dt> <dd> <p>Pattern used to limit paths in Git commands.</p> <p>Pathspecs are used on the command line of "git ls-files", "git ls-tree", "git add", "git grep", "git diff", "git checkout", and many other commands to limit the scope of operations to some subset of the tree or working tree. See the documentation of each command for whether paths are relative to the current directory or toplevel. The pathspec syntax is as follows:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>any path matches itself</p> </li> <li> <p>the pathspec up to the last slash represents a directory prefix. The scope of that pathspec is limited to that subtree.</p> </li> <li> <p>the rest of the pathspec is a pattern for the remainder of the pathname. Paths relative to the directory prefix will be matched against that pattern using fnmatch(3); in particular, <code>*</code> and <code>?</code> <code>can</code> match directory separators.</p> </li> </ul> </div> </div> </div> <p>For example, Documentation/*.jpg will match all .jpg files in the Documentation subtree, including Documentation/chapter_1/figure_1.jpg.</p> <p>A pathspec that begins with a colon <code>:</code> has special meaning. In the short form, the leading colon <code>:</code> is followed by zero or more "magic signature" letters (which optionally is terminated by another colon <code>:</code>), and the remainder is the pattern to match against the path. The "magic signature" consists of ASCII symbols that are neither alphanumeric, glob, regex special characters nor colon. The optional colon that terminates the "magic signature" can be omitted if the pattern begins with a character that does not belong to "magic signature" symbol set and is not a colon.</p> <p>In the long form, the leading colon <code>:</code> is followed by an open parenthesis <code>(</code>, a comma-separated list of zero or more "magic words", and a close parentheses <code>)</code>, and the remainder is the pattern to match against the path.</p> <p>A pathspec with only a colon means "there is no pathspec". This form should not be combined with other pathspec.</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitglossary.txt-top"> top </dt> <dd> <p>The magic word <code>top</code> (magic signature: <code>/</code>) makes the pattern match from the root of the working tree, even when you are running the command from inside a subdirectory.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-literal"> literal </dt> <dd> <p>Wildcards in the pattern such as <code>*</code> or <code>?</code> are treated as literal characters.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-icase"> icase </dt> <dd> <p>Case insensitive match.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-glob"> glob </dt> <dd> <p>Git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname. For example, "Documentation/*.html" matches "Documentation/git.html" but not "Documentation/ppc/ppc.html" or "tools/perf/Documentation/perf.html".</p> <p>Two consecutive asterisks ("<code>**</code>") in patterns matched against full pathname may have special meaning:</p> <div class="ulist"> <ul> <li> <p>A leading "<code>**</code>" followed by a slash means match in all directories. For example, "<code>**/foo</code>" matches file or directory "<code>foo</code>" anywhere, the same as pattern "<code>foo</code>". "<code>**/foo/bar</code>" matches file or directory "<code>bar</code>" anywhere that is directly under directory "<code>foo</code>".</p> </li> <li> <p>A trailing "<code>/**</code>" matches everything inside. For example, "<code>abc/**</code>" matches all files inside directory "abc", relative to the location of the <code>.gitignore</code> file, with infinite depth.</p> </li> <li> <p>A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "<code>a/**/b</code>" matches "<code>a/b</code>", "<code>a/x/b</code>", "<code>a/x/y/b</code>" and so on.</p> </li> <li> <p>Other consecutive asterisks are considered invalid.</p> <p>Glob magic is incompatible with literal magic.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-attr"> attr </dt> <dd> <p>After <code>attr:</code> comes a space separated list of "attribute requirements", all of which must be met in order for the path to be considered a match; this is in addition to the usual non-magic pathspec pattern matching. See <a href="gitattributes">gitattributes[5]</a>.</p> <p>Each of the attribute requirements for the path takes one of these forms:</p> <div class="ulist"> <ul> <li> <p>"<code>ATTR</code>" requires that the attribute <code>ATTR</code> be set.</p> </li> <li> <p>"<code>-ATTR</code>" requires that the attribute <code>ATTR</code> be unset.</p> </li> <li> <p>"<code>ATTR=VALUE</code>" requires that the attribute <code>ATTR</code> be set to the string <code>VALUE</code>.</p> </li> <li> <p>"<code>!ATTR</code>" requires that the attribute <code>ATTR</code> be unspecified.</p> <p>Note that when matching against a tree object, attributes are still obtained from working tree, not from the given tree object.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-exclude"> exclude </dt> <dd> <p>After a path matches any non-exclude pathspec, it will be run through all exclude pathspecs (magic signature: <code>!</code> or its synonym <code>^</code>). If it matches, the path is ignored. When there is no non-exclude pathspec, the exclusion is applied to the result set as if invoked without any pathspec.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefparentaparent"> parent </dt> <dd> <p>A <a href="#def_commit_object">commit object</a> contains a (possibly empty) list of the logical predecessor(s) in the line of development, i.e. its parents.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefpeelapeel"> peel </dt> <dd> <p>The action of recursively <a href="#def_dereference">dereferencing</a> a <a href="#def_tag_object">tag object</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefpickaxeapickaxe"> pickaxe </dt> <dd> <p>The term <a href="#def_pickaxe">pickaxe</a> refers to an option to the diffcore routines that help select changes that add or delete a given text string. With the <code>--pickaxe-all</code> option, it can be used to view the full <a href="#def_changeset">changeset</a> that introduced or removed, say, a particular line of text. See <a href="git-diff">git-diff[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefplumbingaplumbing"> plumbing </dt> <dd> <p>Cute name for <a href="#def_core_git">core Git</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefporcelainaporcelain"> porcelain </dt> <dd> <p>Cute name for programs and program suites depending on <a href="#def_core_git">core Git</a>, presenting a high level access to core Git. Porcelains expose more of a <a href="#def_SCM">SCM</a> interface than the <a href="#def_plumbing">plumbing</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefperworktreerefaper-worktreeref"> per-worktree ref </dt> <dd> <p>Refs that are per-<a href="#def_worktree">worktree</a>, rather than global. This is presently only <a href="#def_HEAD">HEAD</a> and any refs that start with <code>refs/bisect/</code>, but might later include other unusual refs.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefpseudorefapseudoref"> pseudoref </dt> <dd> <p>Pseudorefs are a class of files under <code>$GIT_DIR</code> which behave like refs for the purposes of rev-parse, but which are treated specially by git. Pseudorefs both have names that are all-caps, and always start with a line consisting of a <a href="#def_SHA1">SHA-1</a> followed by whitespace. So, HEAD is not a pseudoref, because it is sometimes a symbolic ref. They might optionally contain some additional data. <code>MERGE_HEAD</code> and <code>CHERRY_PICK_HEAD</code> are examples. Unlike <a href="#def_per_worktree_ref">per-worktree refs</a>, these files cannot be symbolic refs, and never have reflogs. They also cannot be updated through the normal ref update machinery. Instead, they are updated by directly writing to the files. However, they can be read as if they were refs, so <code>git rev-parse +MERGE_HEAD</code> will work.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefpullapull"> pull </dt> <dd> <p>Pulling a <a href="#def_branch">branch</a> means to <a href="#def_fetch">fetch</a> it and <a href="#def_merge">merge</a> it. See also <a href="git-pull">git-pull[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefpushapush"> push </dt> <dd> <p>Pushing a <a href="#def_branch">branch</a> means to get the branch’s <a href="#def_head_ref">head ref</a> from a remote <a href="#def_repository">repository</a>, find out if it is an ancestor to the branch’s local head ref, and in that case, putting all objects, which are <a href="#def_reachable">reachable</a> from the local head ref, and which are missing from the remote repository, into the remote <a href="#def_object_database">object database</a>, and updating the remote head ref. If the remote <a href="#def_head">head</a> is not an ancestor to the local head, the push fails.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefreachableareachable"> reachable </dt> <dd> <p>All of the ancestors of a given <a href="#def_commit">commit</a> are said to be "reachable" from that commit. More generally, one <a href="#def_object">object</a> is reachable from another if we can reach the one from the other by a <a href="#def_chain">chain</a> that follows <a href="#def_tag">tags</a> to whatever they tag, <a href="#def_commit_object">commits</a> to their parents or trees, and <a href="#def_tree_object">trees</a> to the trees or <a href="#def_blob_object">blobs</a> that they contain.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefreachabilitybitmapareachabilitybitmaps"> reachability bitmaps </dt> <dd> <p>Reachability bitmaps store information about the <a href="#def_reachable">reachability</a> of a selected set of commits in a packfile, or a multi-pack index (MIDX), to speed up object search. The bitmaps are stored in a ".bitmap" file. A repository may have at most one bitmap file in use. The bitmap file may belong to either one pack, or the repository’s multi-pack index (if it exists).</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefrebasearebase"> rebase </dt> <dd> <p>To reapply a series of changes from a <a href="#def_branch">branch</a> to a different base, and reset the <a href="#def_head">head</a> of that branch to the result.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefrefaref"> ref </dt> <dd> <p>A name that begins with <code>refs/</code> (e.g. <code>refs/heads/master</code>) that points to an <a href="#def_object_name">object name</a> or another ref (the latter is called a <a href="#def_symref">symbolic ref</a>). For convenience, a ref can sometimes be abbreviated when used as an argument to a Git command; see <a href="gitrevisions">gitrevisions[7]</a> for details. Refs are stored in the <a href="#def_repository">repository</a>.</p> <p>The ref namespace is hierarchical. Different subhierarchies are used for different purposes (e.g. the <code>refs/heads/</code> hierarchy is used to represent local branches).</p> <p>There are a few special-purpose refs that do not begin with <code>refs/</code>. The most notable example is <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefreflogareflog"> reflog </dt> <dd> <p>A reflog shows the local "history" of a ref. In other words, it can tell you what the 3rd last revision in <code>this</code> repository was, and what was the current state in <code>this</code> repository, yesterday 9:14pm. See <a href="git-reflog">git-reflog[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefrefspecarefspec"> refspec </dt> <dd> <p>A "refspec" is used by <a href="#def_fetch">fetch</a> and <a href="#def_push">push</a> to describe the mapping between remote <a href="#def_ref">ref</a> and local ref.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefremotearemoterepository"> remote repository </dt> <dd> <p>A <a href="#def_repository">repository</a> which is used to track the same project but resides somewhere else. To communicate with remotes, see <a href="#def_fetch">fetch</a> or <a href="#def_push">push</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefremotetrackingbrancharemote-trackingbranch"> remote-tracking branch </dt> <dd> <p>A <a href="#def_ref">ref</a> that is used to follow changes from another <a href="#def_repository">repository</a>. It typically looks like <code>refs/remotes/foo/bar</code> (indicating that it tracks a branch named <code>bar</code> in a remote named <code>foo</code>), and matches the right-hand-side of a configured fetch <a href="#def_refspec">refspec</a>. A remote-tracking branch should not contain direct modifications or have local commits made to it.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefrepositoryarepository"> repository </dt> <dd> <p>A collection of <a href="#def_ref">refs</a> together with an <a href="#def_object_database">object database</a> containing all objects which are <a href="#def_reachable">reachable</a> from the refs, possibly accompanied by meta data from one or more <a href="#def_porcelain">porcelains</a>. A repository can share an object database with other repositories via <a href="#def_alternate_object_database">alternates mechanism</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefresolvearesolve"> resolve </dt> <dd> <p>The action of fixing up manually what a failed automatic <a href="#def_merge">merge</a> left behind.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefrevisionarevision"> revision </dt> <dd> <p>Synonym for <a href="#def_commit">commit</a> (the noun).</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefrewindarewind"> rewind </dt> <dd> <p>To throw away part of the development, i.e. to assign the <a href="#def_head">head</a> to an earlier <a href="#def_revision">revision</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefSCMaSCM"> SCM </dt> <dd> <p>Source code management (tool).</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefSHA1aSHA-1"> SHA-1 </dt> <dd> <p>"Secure Hash Algorithm 1"; a cryptographic hash function. In the context of Git used as a synonym for <a href="#def_object_name">object name</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefshallowcloneashallowclone"> shallow clone </dt> <dd> <p>Mostly a synonym to <a href="#def_shallow_repository">shallow repository</a> but the phrase makes it more explicit that it was created by running <code>git clone --depth=...</code> command.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefshallowrepositoryashallowrepository"> shallow repository </dt> <dd> <p>A shallow <a href="#def_repository">repository</a> has an incomplete history some of whose <a href="#def_commit">commits</a> have <a href="#def_parent">parents</a> cauterized away (in other words, Git is told to pretend that these commits do not have the parents, even though they are recorded in the <a href="#def_commit_object">commit object</a>). This is sometimes useful when you are interested only in the recent history of a project even though the real history recorded in the upstream is much larger. A shallow repository is created by giving the <code>--depth</code> option to <a href="git-clone">git-clone[1]</a>, and its history can be later deepened with <a href="git-fetch">git-fetch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefstashastashentry"> stash entry </dt> <dd> <p>An <a href="#def_object">object</a> used to temporarily store the contents of a <a href="#def_dirty">dirty</a> working directory and the index for future reuse.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefsubmoduleasubmodule"> submodule </dt> <dd> <p>A <a href="#def_repository">repository</a> that holds the history of a separate project inside another repository (the latter of which is called <a href="#def_superproject">superproject</a>).</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefsuperprojectasuperproject"> superproject </dt> <dd> <p>A <a href="#def_repository">repository</a> that references repositories of other projects in its working tree as <a href="#def_submodule">submodules</a>. The superproject knows about the names of (but does not hold copies of) commit objects of the contained submodules.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefsymrefasymref"> symref </dt> <dd> <p>Symbolic reference: instead of containing the <a href="#def_SHA1">SHA-1</a> id itself, it is of the format <code>ref: refs/some/thing</code> and when referenced, it recursively <a href="#def_dereference">dereferences</a> to this reference. <code><a href="#def_HEAD">HEAD</a></code> is a prime example of a symref. Symbolic references are manipulated with the <a href="git-symbolic-ref">git-symbolic-ref[1]</a> command.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddeftagatag"> tag </dt> <dd> <p>A <a href="#def_ref">ref</a> under <code>refs/tags/</code> namespace that points to an object of an arbitrary type (typically a tag points to either a <a href="#def_tag_object">tag</a> or a <a href="#def_commit_object">commit object</a>). In contrast to a <a href="#def_head">head</a>, a tag is not updated by the <code>commit</code> command. A Git tag has nothing to do with a Lisp tag (which would be called an <a href="#def_object_type">object type</a> in Git’s context). A tag is most typically used to mark a particular point in the commit ancestry <a href="#def_chain">chain</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddeftagobjectatagobject"> tag object </dt> <dd> <p>An <a href="#def_object">object</a> containing a <a href="#def_ref">ref</a> pointing to another object, which can contain a message just like a <a href="#def_commit_object">commit object</a>. It can also contain a (PGP) signature, in which case it is called a "signed tag object".</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddeftopicbranchatopicbranch"> topic branch </dt> <dd> <p>A regular Git <a href="#def_branch">branch</a> that is used by a developer to identify a conceptual line of development. Since branches are very easy and inexpensive, it is often desirable to have several small branches that each contain very well defined concepts or small incremental yet related changes.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddeftreeatree"> tree </dt> <dd> <p>Either a <a href="#def_working_tree">working tree</a>, or a <a href="#def_tree_object">tree object</a> together with the dependent <a href="#def_blob_object">blob</a> and tree objects (i.e. a stored representation of a working tree).</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddeftreeobjectatreeobject"> tree object </dt> <dd> <p>An <a href="#def_object">object</a> containing a list of file names and modes along with refs to the associated blob and/or tree objects. A <a href="#def_tree">tree</a> is equivalent to a <a href="#def_directory">directory</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddeftree-ishatree-ishalsotreeish"> tree-ish (also treeish) </dt> <dd> <p>A <a href="#def_tree_object">tree object</a> or an <a href="#def_object">object</a> that can be recursively <a href="#def_dereference">dereferenced</a> to a tree object. Dereferencing a <a href="#def_commit_object">commit object</a> yields the tree object corresponding to the <a href="#def_revision">revision</a>'s top <a href="#def_directory">directory</a>. The following are all tree-ishes: a <a href="#def_commit-ish">commit-ish</a>, a tree object, a <a href="#def_tag_object">tag object</a> that points to a tree object, a tag object that points to a tag object that points to a tree object, etc.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefunbornaunborn"> unborn </dt> <dd> <p>The <a href="#def_HEAD">HEAD</a> can point at a <a href="#def_branch">branch</a> that does not yet exist and that does not have any commit on it yet, and such a branch is called an unborn branch. The most typical way users encounter an unborn branch is by creating a repository anew without cloning from elsewhere. The HEAD would point at the <code>main</code> (or <code>master</code>, depending on your configuration) branch that is yet to be born. Also some operations can get you on an unborn branch with their <a href="#def_orphan">orphan</a> option.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefunmergedindexaunmergedindex"> unmerged index </dt> <dd> <p>An <a href="#def_index">index</a> which contains unmerged <a href="#def_index_entry">index entries</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefunreachableobjectaunreachableobject"> unreachable object </dt> <dd> <p>An <a href="#def_object">object</a> which is not <a href="#def_reachable">reachable</a> from a <a href="#def_branch">branch</a>, <a href="#def_tag">tag</a>, or any other reference.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefupstreambranchaupstreambranch"> upstream branch </dt> <dd> <p>The default <a href="#def_branch">branch</a> that is merged into the branch in question (or the branch in question is rebased onto). It is configured via branch.<name>.remote and branch.<name>.merge. If the upstream branch of <code>A</code> is <code>origin/B</code> sometimes we say "<code>A</code> is tracking <code>origin/B</code>".</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefworkingtreeaworkingtree"> working tree </dt> <dd> <p>The tree of actual checked out files. The working tree normally contains the contents of the <a href="#def_HEAD">HEAD</a> commit’s tree, plus any local changes that you have made but not yet committed.</p> </dd> <dt class="hdlist1" id="Documentation/gitglossary.txt-aiddefworktreeaworktree"> worktree </dt> <dd> <p>A repository can have zero (i.e. bare repository) or one or more worktrees attached to it. One "worktree" consists of a "working tree" and repository metadata, most of which are shared among other worktrees of a single repository, and some of which are maintained separately per worktree (e.g. the index, HEAD and pseudorefs like MERGE_HEAD, per-worktree refs and per-worktree configuration file).</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gittutorial">gittutorial[7]</a>, <a href="gittutorial-2">gittutorial-2[7]</a>, <a href="gitcvs-migration">gitcvs-migration[7]</a>, <a href="giteveryday">giteveryday[7]</a>, <a href="user-manual">The Git User’s Manual</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitglossary" class="_attribution-link">https://git-scm.com/docs/gitglossary</a> + </p> +</div> diff --git a/devdocs/git/githooks.html b/devdocs/git/githooks.html new file mode 100644 index 00000000..7b138df5 --- /dev/null +++ b/devdocs/git/githooks.html @@ -0,0 +1,68 @@ +<h1>githooks</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>githooks - Hooks used by Git</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>$GIT_DIR/hooks/* (or `git config core.hooksPath`/*)</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Hooks are programs you can place in a hooks directory to trigger actions at certain points in git’s execution. Hooks that don’t have the executable bit set are ignored.</p> <p>By default the hooks directory is <code>$GIT_DIR/hooks</code>, but that can be changed via the <code>core.hooksPath</code> configuration variable (see <a href="git-config">git-config[1]</a>).</p> <p>Before Git invokes a hook, it changes its working directory to either $GIT_DIR in a bare repository or the root of the working tree in a non-bare repository. An exception are hooks triggered during a push (<code>pre-receive</code>, <code>update</code>, <code>post-receive</code>, <code>post-update</code>, <code>push-to-checkout</code>) which are always executed in $GIT_DIR.</p> <p>Environment variables, such as <code>GIT_DIR</code>, <code>GIT_WORK_TREE</code>, etc., are exported so that Git commands run by the hook can correctly locate the repository. If your hook needs to invoke Git commands in a foreign repository or in a different working tree of the same repository, then it should clear these environment variables so they do not interfere with Git operations at the foreign location. For example:</p> <div class="listingblock"> <div class="content"> <pre>local_desc=$(git describe) +foreign_desc=$(unset $(git rev-parse --local-env-vars); git -C ../foreign-repo describe)</pre> </div> </div> <p>Hooks can get their arguments via the environment, command-line arguments, and stdin. See the documentation for each hook below for details.</p> <p><code>git init</code> may copy hooks to the new repository, depending on its configuration. See the "TEMPLATE DIRECTORY" section in <a href="git-init">git-init[1]</a> for details. When the rest of this document refers to "default hooks" it’s talking about the default template shipped with Git.</p> <p>The currently supported hooks are described below.</p> </div> <h2 id="_hooks">Hooks</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_applypatch_msg"> +applypatch-msg</h3> <p>This hook is invoked by <a href="git-am">git-am[1]</a>. It takes a single parameter, the name of the file that holds the proposed commit log message. Exiting with a non-zero status causes <code>git am</code> to abort before applying the patch.</p> <p>The hook is allowed to edit the message file in place, and can be used to normalize the message into some project standard format. It can also be used to refuse the commit after inspecting the message file.</p> <p>The default <code>applypatch-msg</code> hook, when enabled, runs the <code>commit-msg</code> hook, if the latter is enabled.</p> </div> <div class="sect2"> <h3 id="_pre_applypatch"> +pre-applypatch</h3> <p>This hook is invoked by <a href="git-am">git-am[1]</a>. It takes no parameter, and is invoked after the patch is applied, but before a commit is made.</p> <p>If it exits with non-zero status, then the working tree will not be committed after applying the patch.</p> <p>It can be used to inspect the current working tree and refuse to make a commit if it does not pass certain tests.</p> <p>The default <code>pre-applypatch</code> hook, when enabled, runs the <code>pre-commit</code> hook, if the latter is enabled.</p> </div> <div class="sect2"> <h3 id="_post_applypatch"> +post-applypatch</h3> <p>This hook is invoked by <a href="git-am">git-am[1]</a>. It takes no parameter, and is invoked after the patch is applied and a commit is made.</p> <p>This hook is meant primarily for notification, and cannot affect the outcome of <code>git am</code>.</p> </div> <div class="sect2"> <h3 id="_pre_commit"> +pre-commit</h3> <p>This hook is invoked by <a href="git-commit">git-commit[1]</a>, and can be bypassed with the <code>--no-verify</code> option. It takes no parameters, and is invoked before obtaining the proposed commit log message and making a commit. Exiting with a non-zero status from this script causes the <code>git commit</code> command to abort before creating a commit.</p> <p>The default <code>pre-commit</code> hook, when enabled, catches introduction of lines with trailing whitespaces and aborts the commit when such a line is found.</p> <p>All the <code>git commit</code> hooks are invoked with the environment variable <code>GIT_EDITOR=:</code> if the command will not bring up an editor to modify the commit message.</p> <p>The default <code>pre-commit</code> hook, when enabled—and with the <code>hooks.allownonascii</code> config option unset or set to false—prevents the use of non-ASCII filenames.</p> </div> <div class="sect2"> <h3 id="_pre_merge_commit"> +pre-merge-commit</h3> <p>This hook is invoked by <a href="git-merge">git-merge[1]</a>, and can be bypassed with the <code>--no-verify</code> option. It takes no parameters, and is invoked after the merge has been carried out successfully and before obtaining the proposed commit log message to make a commit. Exiting with a non-zero status from this script causes the <code>git merge</code> command to abort before creating a commit.</p> <p>The default <code>pre-merge-commit</code> hook, when enabled, runs the <code>pre-commit</code> hook, if the latter is enabled.</p> <p>This hook is invoked with the environment variable <code>GIT_EDITOR=:</code> if the command will not bring up an editor to modify the commit message.</p> <p>If the merge cannot be carried out automatically, the conflicts need to be resolved and the result committed separately (see <a href="git-merge">git-merge[1]</a>). At that point, this hook will not be executed, but the <code>pre-commit</code> hook will, if it is enabled.</p> </div> <div class="sect2"> <h3 id="_prepare_commit_msg"> +prepare-commit-msg</h3> <p>This hook is invoked by <a href="git-commit">git-commit[1]</a> right after preparing the default log message, and before the editor is started.</p> <p>It takes one to three parameters. The first is the name of the file that contains the commit log message. The second is the source of the commit message, and can be: <code>message</code> (if a <code>-m</code> or <code>-F</code> option was given); <code>template</code> (if a <code>-t</code> option was given or the configuration option <code>commit.template</code> is set); <code>merge</code> (if the commit is a merge or a <code>.git/MERGE_MSG</code> file exists); <code>squash</code> (if a <code>.git/SQUASH_MSG</code> file exists); or <code>commit</code>, followed by a commit object name (if a <code>-c</code>, <code>-C</code> or <code>--amend</code> option was given).</p> <p>If the exit status is non-zero, <code>git commit</code> will abort.</p> <p>The purpose of the hook is to edit the message file in place, and it is not suppressed by the <code>--no-verify</code> option. A non-zero exit means a failure of the hook and aborts the commit. It should not be used as a replacement for the pre-commit hook.</p> <p>The sample <code>prepare-commit-msg</code> hook that comes with Git removes the help message found in the commented portion of the commit template.</p> </div> <div class="sect2"> <h3 id="_commit_msg"> +commit-msg</h3> <p>This hook is invoked by <a href="git-commit">git-commit[1]</a> and <a href="git-merge">git-merge[1]</a>, and can be bypassed with the <code>--no-verify</code> option. It takes a single parameter, the name of the file that holds the proposed commit log message. Exiting with a non-zero status causes the command to abort.</p> <p>The hook is allowed to edit the message file in place, and can be used to normalize the message into some project standard format. It can also be used to refuse the commit after inspecting the message file.</p> <p>The default <code>commit-msg</code> hook, when enabled, detects duplicate <code>Signed-off-by</code> trailers, and aborts the commit if one is found.</p> </div> <div class="sect2"> <h3 id="_post_commit"> +post-commit</h3> <p>This hook is invoked by <a href="git-commit">git-commit[1]</a>. It takes no parameters, and is invoked after a commit is made.</p> <p>This hook is meant primarily for notification, and cannot affect the outcome of <code>git commit</code>.</p> </div> <div class="sect2"> <h3 id="_pre_rebase"> +pre-rebase</h3> <p>This hook is called by <a href="git-rebase">git-rebase[1]</a> and can be used to prevent a branch from getting rebased. The hook may be called with one or two parameters. The first parameter is the upstream from which the series was forked. The second parameter is the branch being rebased, and is not set when rebasing the current branch.</p> </div> <div class="sect2"> <h3 id="_post_checkout"> +post-checkout</h3> <p>This hook is invoked when a <a href="git-checkout">git-checkout[1]</a> or <a href="git-switch">git-switch[1]</a> is run after having updated the worktree. The hook is given three parameters: the ref of the previous HEAD, the ref of the new HEAD (which may or may not have changed), and a flag indicating whether the checkout was a branch checkout (changing branches, flag=1) or a file checkout (retrieving a file from the index, flag=0). This hook cannot affect the outcome of <code>git switch</code> or <code>git checkout</code>, other than that the hook’s exit status becomes the exit status of these two commands.</p> <p>It is also run after <a href="git-clone">git-clone[1]</a>, unless the <code>--no-checkout</code> (<code>-n</code>) option is used. The first parameter given to the hook is the null-ref, the second the ref of the new HEAD and the flag is always 1. Likewise for <code>git worktree add</code> unless <code>--no-checkout</code> is used.</p> <p>This hook can be used to perform repository validity checks, auto-display differences from the previous HEAD if different, or set working dir metadata properties.</p> </div> <div class="sect2"> <h3 id="_post_merge"> +post-merge</h3> <p>This hook is invoked by <a href="git-merge">git-merge[1]</a>, which happens when a <code>git pull</code> is done on a local repository. The hook takes a single parameter, a status flag specifying whether or not the merge being done was a squash merge. This hook cannot affect the outcome of <code>git merge</code> and is not executed, if the merge failed due to conflicts.</p> <p>This hook can be used in conjunction with a corresponding pre-commit hook to save and restore any form of metadata associated with the working tree (e.g.: permissions/ownership, ACLS, etc). See contrib/hooks/setgitperms.perl for an example of how to do this.</p> </div> <div class="sect2"> <h3 id="_pre_push"> +pre-push</h3> <p>This hook is called by <a href="git-push">git-push[1]</a> and can be used to prevent a push from taking place. The hook is called with two parameters which provide the name and location of the destination remote, if a named remote is not being used both values will be the same.</p> <p>Information about what is to be pushed is provided on the hook’s standard input with lines of the form:</p> <div class="literalblock"> <div class="content"> <pre><local ref> SP <local object name> SP <remote ref> SP <remote object name> LF</pre> </div> </div> <p>For instance, if the command <code>git push origin master:foreign</code> were run the hook would receive a line like the following:</p> <div class="literalblock"> <div class="content"> <pre>refs/heads/master 67890 refs/heads/foreign 12345</pre> </div> </div> <p>although the full object name would be supplied. If the foreign ref does not yet exist the <code><remote object name></code> will be the all-zeroes object name. If a ref is to be deleted, the <code><local ref></code> will be supplied as <code>(delete)</code> and the <code><local object name></code> will be the all-zeroes object name. If the local commit was specified by something other than a name which could be expanded (such as <code>HEAD~</code>, or an object name) it will be supplied as it was originally given.</p> <p>If this hook exits with a non-zero status, <code>git push</code> will abort without pushing anything. Information about why the push is rejected may be sent to the user by writing to standard error.</p> </div> <div class="sect2"> <h3 id="pre-receive"> +pre-receive</h3> <p>This hook is invoked by <a href="git-receive-pack">git-receive-pack[1]</a> when it reacts to <code>git push</code> and updates reference(s) in its repository. Just before starting to update refs on the remote repository, the pre-receive hook is invoked. Its exit status determines the success or failure of the update.</p> <p>This hook executes once for the receive operation. It takes no arguments, but for each ref to be updated it receives on standard input a line of the format:</p> <div class="literalblock"> <div class="content"> <pre><old-value> SP <new-value> SP <ref-name> LF</pre> </div> </div> <p>where <code><old-value></code> is the old object name stored in the ref, <code><new-value></code> is the new object name to be stored in the ref and <code><ref-name></code> is the full name of the ref. When creating a new ref, <code><old-value></code> is the all-zeroes object name.</p> <p>If the hook exits with non-zero status, none of the refs will be updated. If the hook exits with zero, updating of individual refs can still be prevented by the <a href="#update"><em>update</em></a> hook.</p> <p>Both standard output and standard error output are forwarded to <code>git send-pack</code> on the other end, so you can simply <code>echo</code> messages for the user.</p> <p>The number of push options given on the command line of <code>git push --push-option=...</code> can be read from the environment variable <code>GIT_PUSH_OPTION_COUNT</code>, and the options themselves are found in <code>GIT_PUSH_OPTION_0</code>, <code>GIT_PUSH_OPTION_1</code>,… If it is negotiated to not use the push options phase, the environment variables will not be set. If the client selects to use push options, but doesn’t transmit any, the count variable will be set to zero, <code>GIT_PUSH_OPTION_COUNT=0</code>.</p> <p>See the section on "Quarantine Environment" in <a href="git-receive-pack">git-receive-pack[1]</a> for some caveats.</p> </div> <div class="sect2"> <h3 id="update"> +update</h3> <p>This hook is invoked by <a href="git-receive-pack">git-receive-pack[1]</a> when it reacts to <code>git push</code> and updates reference(s) in its repository. Just before updating the ref on the remote repository, the update hook is invoked. Its exit status determines the success or failure of the ref update.</p> <p>The hook executes once for each ref to be updated, and takes three parameters:</p> <div class="ulist"> <ul> <li> <p>the name of the ref being updated,</p> </li> <li> <p>the old object name stored in the ref,</p> </li> <li> <p>and the new object name to be stored in the ref.</p> </li> </ul> </div> <p>A zero exit from the update hook allows the ref to be updated. Exiting with a non-zero status prevents <code>git receive-pack</code> from updating that ref.</p> <p>This hook can be used to prevent <code>forced</code> update on certain refs by making sure that the object name is a commit object that is a descendant of the commit object named by the old object name. That is, to enforce a "fast-forward only" policy.</p> <p>It could also be used to log the old..new status. However, it does not know the entire set of branches, so it would end up firing one e-mail per ref when used naively, though. The <a href="#post-receive"><em>post-receive</em></a> hook is more suited to that.</p> <p>In an environment that restricts the users' access only to git commands over the wire, this hook can be used to implement access control without relying on filesystem ownership and group membership. See <a href="git-shell">git-shell[1]</a> for how you might use the login shell to restrict the user’s access to only git commands.</p> <p>Both standard output and standard error output are forwarded to <code>git send-pack</code> on the other end, so you can simply <code>echo</code> messages for the user.</p> <p>The default <code>update</code> hook, when enabled—and with <code>hooks.allowunannotated</code> config option unset or set to false—prevents unannotated tags from being pushed.</p> </div> <div class="sect2"> <h3 id="proc-receive"> +proc-receive</h3> <p>This hook is invoked by <a href="git-receive-pack">git-receive-pack[1]</a>. If the server has set the multi-valued config variable <code>receive.procReceiveRefs</code>, and the commands sent to <code>receive-pack</code> have matching reference names, these commands will be executed by this hook, instead of by the internal <code>execute_commands()</code> function. This hook is responsible for updating the relevant references and reporting the results back to <code>receive-pack</code>.</p> <p>This hook executes once for the receive operation. It takes no arguments, but uses a pkt-line format protocol to communicate with <code>receive-pack</code> to read commands, push-options and send results. In the following example for the protocol, the letter <code>S</code> stands for <code>receive-pack</code> and the letter <code>H</code> stands for this hook.</p> <div class="literalblock"> <div class="content"> <pre># Version and features negotiation. +S: PKT-LINE(version=1\0push-options atomic...) +S: flush-pkt +H: PKT-LINE(version=1\0push-options...) +H: flush-pkt</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre># Send commands from server to the hook. +S: PKT-LINE(<old-oid> <new-oid> <ref>) +S: ... ... +S: flush-pkt +# Send push-options only if the 'push-options' feature is enabled. +S: PKT-LINE(push-option) +S: ... ... +S: flush-pkt</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre># Receive results from the hook. +# OK, run this command successfully. +H: PKT-LINE(ok <ref>) +# NO, I reject it. +H: PKT-LINE(ng <ref> <reason>) +# Fall through, let 'receive-pack' execute it. +H: PKT-LINE(ok <ref>) +H: PKT-LINE(option fall-through) +# OK, but has an alternate reference. The alternate reference name +# and other status can be given in option directives. +H: PKT-LINE(ok <ref>) +H: PKT-LINE(option refname <refname>) +H: PKT-LINE(option old-oid <old-oid>) +H: PKT-LINE(option new-oid <new-oid>) +H: PKT-LINE(option forced-update) +H: ... ... +H: flush-pkt</pre> </div> </div> <p>Each command for the <code>proc-receive</code> hook may point to a pseudo-reference and always has a zero-old as its old-oid, while the <code>proc-receive</code> hook may update an alternate reference and the alternate reference may exist already with a non-zero old-oid. For this case, this hook will use "option" directives to report extended attributes for the reference given by the leading "ok" directive.</p> <p>The report of the commands of this hook should have the same order as the input. The exit status of the <code>proc-receive</code> hook only determines the success or failure of the group of commands sent to it, unless atomic push is in use.</p> </div> <div class="sect2"> <h3 id="post-receive"> +post-receive</h3> <p>This hook is invoked by <a href="git-receive-pack">git-receive-pack[1]</a> when it reacts to <code>git push</code> and updates reference(s) in its repository. It executes on the remote repository once after all the refs have been updated.</p> <p>This hook executes once for the receive operation. It takes no arguments, but gets the same information as the <a href="#pre-receive"><em>pre-receive</em></a> hook does on its standard input.</p> <p>This hook does not affect the outcome of <code>git receive-pack</code>, as it is called after the real work is done.</p> <p>This supersedes the <a href="#post-update"><em>post-update</em></a> hook in that it gets both old and new values of all the refs in addition to their names.</p> <p>Both standard output and standard error output are forwarded to <code>git send-pack</code> on the other end, so you can simply <code>echo</code> messages for the user.</p> <p>The default <code>post-receive</code> hook is empty, but there is a sample script <code>post-receive-email</code> provided in the <code>contrib/hooks</code> directory in Git distribution, which implements sending commit emails.</p> <p>The number of push options given on the command line of <code>git push --push-option=...</code> can be read from the environment variable <code>GIT_PUSH_OPTION_COUNT</code>, and the options themselves are found in <code>GIT_PUSH_OPTION_0</code>, <code>GIT_PUSH_OPTION_1</code>,… If it is negotiated to not use the push options phase, the environment variables will not be set. If the client selects to use push options, but doesn’t transmit any, the count variable will be set to zero, <code>GIT_PUSH_OPTION_COUNT=0</code>.</p> </div> <div class="sect2"> <h3 id="post-update"> +post-update</h3> <p>This hook is invoked by <a href="git-receive-pack">git-receive-pack[1]</a> when it reacts to <code>git push</code> and updates reference(s) in its repository. It executes on the remote repository once after all the refs have been updated.</p> <p>It takes a variable number of parameters, each of which is the name of ref that was actually updated.</p> <p>This hook is meant primarily for notification, and cannot affect the outcome of <code>git receive-pack</code>.</p> <p>The <code>post-update</code> hook can tell what are the heads that were pushed, but it does not know what their original and updated values are, so it is a poor place to do log old..new. The <a href="#post-receive"><em>post-receive</em></a> hook does get both original and updated values of the refs. You might consider it instead if you need them.</p> <p>When enabled, the default <code>post-update</code> hook runs <code>git update-server-info</code> to keep the information used by dumb transports (e.g., HTTP) up to date. If you are publishing a Git repository that is accessible via HTTP, you should probably enable this hook.</p> <p>Both standard output and standard error output are forwarded to <code>git send-pack</code> on the other end, so you can simply <code>echo</code> messages for the user.</p> </div> <div class="sect2"> <h3 id="_reference_transaction"> +reference-transaction</h3> <p>This hook is invoked by any Git command that performs reference updates. It executes whenever a reference transaction is prepared, committed or aborted and may thus get called multiple times. The hook does not cover symbolic references (but that may change in the future).</p> <p>The hook takes exactly one argument, which is the current state the given reference transaction is in:</p> <div class="ulist"> <ul> <li> <p>"prepared": All reference updates have been queued to the transaction and references were locked on disk.</p> </li> <li> <p>"committed": The reference transaction was committed and all references now have their respective new value.</p> </li> <li> <p>"aborted": The reference transaction was aborted, no changes were performed and the locks have been released.</p> </li> </ul> </div> <p>For each reference update that was added to the transaction, the hook receives on standard input a line of the format:</p> <div class="literalblock"> <div class="content"> <pre><old-value> SP <new-value> SP <ref-name> LF</pre> </div> </div> <p>where <code><old-value></code> is the old object name passed into the reference transaction, <code><new-value></code> is the new object name to be stored in the ref and <code><ref-name></code> is the full name of the ref. When force updating the reference regardless of its current value or when the reference is to be created anew, <code><old-value></code> is the all-zeroes object name. To distinguish these cases, you can inspect the current value of <code><ref-name></code> via <code>git rev-parse</code>.</p> <p>The exit status of the hook is ignored for any state except for the "prepared" state. In the "prepared" state, a non-zero exit status will cause the transaction to be aborted. The hook will not be called with "aborted" state in that case.</p> </div> <div class="sect2"> <h3 id="_push_to_checkout"> +push-to-checkout</h3> <p>This hook is invoked by <a href="git-receive-pack">git-receive-pack[1]</a> when it reacts to <code>git push</code> and updates reference(s) in its repository, and when the push tries to update the branch that is currently checked out and the <code>receive.denyCurrentBranch</code> configuration variable is set to <code>updateInstead</code>. Such a push by default is refused if the working tree and the index of the remote repository has any difference from the currently checked out commit; when both the working tree and the index match the current commit, they are updated to match the newly pushed tip of the branch. This hook is to be used to override the default behaviour.</p> <p>The hook receives the commit with which the tip of the current branch is going to be updated. It can exit with a non-zero status to refuse the push (when it does so, it must not modify the index or the working tree). Or it can make any necessary changes to the working tree and to the index to bring them to the desired state when the tip of the current branch is updated to the new commit, and exit with a zero status.</p> <p>For example, the hook can simply run <code>git read-tree -u -m HEAD "$1"</code> in order to emulate <code>git fetch</code> that is run in the reverse direction with <code>git push</code>, as the two-tree form of <code>git read-tree -u -m</code> is essentially the same as <code>git switch</code> or <code>git checkout</code> that switches branches while keeping the local changes in the working tree that do not interfere with the difference between the branches.</p> </div> <div class="sect2"> <h3 id="_pre_auto_gc"> +pre-auto-gc</h3> <p>This hook is invoked by <code>git gc --auto</code> (see <a href="git-gc">git-gc[1]</a>). It takes no parameter, and exiting with non-zero status from this script causes the <code>git gc --auto</code> to abort.</p> </div> <div class="sect2"> <h3 id="_post_rewrite"> +post-rewrite</h3> <p>This hook is invoked by commands that rewrite commits (<a href="git-commit">git-commit[1]</a> when called with <code>--amend</code> and <a href="git-rebase">git-rebase[1]</a>; however, full-history (re)writing tools like <a href="git-fast-import">git-fast-import[1]</a> or <a href="https://github.com/newren/git-filter-repo">git-filter-repo</a> typically do not call it!). Its first argument denotes the command it was invoked by: currently one of <code>amend</code> or <code>rebase</code>. Further command-dependent arguments may be passed in the future.</p> <p>The hook receives a list of the rewritten commits on stdin, in the format</p> <div class="literalblock"> <div class="content"> <pre><old-object-name> SP <new-object-name> [ SP <extra-info> ] LF</pre> </div> </div> <p>The <code>extra-info</code> is again command-dependent. If it is empty, the preceding SP is also omitted. Currently, no commands pass any <code>extra-info</code>.</p> <p>The hook always runs after the automatic note copying (see "notes.rewrite.<command>" in <a href="git-config">git-config[1]</a>) has happened, and thus has access to these notes.</p> <p>The following command-specific comments apply:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/githooks.txt-rebase"> rebase </dt> <dd> <p>For the <code>squash</code> and <code>fixup</code> operation, all commits that were squashed are listed as being rewritten to the squashed commit. This means that there will be several lines sharing the same <code>new-object-name</code>.</p> <p>The commits are guaranteed to be listed in the order that they were processed by rebase.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_sendemail_validate"> +sendemail-validate</h3> <p>This hook is invoked by <a href="git-send-email">git-send-email[1]</a>.</p> <p>It takes these command line arguments. They are, 1. the name of the file which holds the contents of the email to be sent. 2. The name of the file which holds the SMTP headers of the email.</p> <p>The SMTP headers are passed in the exact same way as they are passed to the user’s Mail Transport Agent (MTA). In effect, the email given to the user’s MTA, is the contents of $2 followed by the contents of $1.</p> <p>An example of a few common headers is shown below. Take notice of the capitalization and multi-line tab structure.</p> <div class="literalblock"> <div class="content"> <pre>From: Example <from@example.com> +To: to@example.com +Cc: cc@example.com, + A <author@example.com>, + One <one@example.com>, + two@example.com +Subject: PATCH-STRING</pre> </div> </div> <p>Exiting with a non-zero status causes <code>git send-email</code> to abort before sending any e-mails.</p> <p>The following environment variables are set when executing the hook.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/githooks.txt-codeGITSENDEMAILFILECOUNTERcode"> <code>GIT_SENDEMAIL_FILE_COUNTER</code> </dt> <dd> <p>A 1-based counter incremented by one for every file holding an e-mail to be sent (excluding any FIFOs). This counter does not follow the patch series counter scheme. It will always start at 1 and will end at GIT_SENDEMAIL_FILE_TOTAL.</p> </dd> <dt class="hdlist1" id="Documentation/githooks.txt-codeGITSENDEMAILFILETOTALcode"> <code>GIT_SENDEMAIL_FILE_TOTAL</code> </dt> <dd> <p>The total number of files that will be sent (excluding any FIFOs). This counter does not follow the patch series counter scheme. It will always be equal to the number of files being sent, whether there is a cover letter or not.</p> </dd> </dl> </div> <p>These variables may for instance be used to validate patch series.</p> <p>The sample <code>sendemail-validate</code> hook that comes with Git checks that all sent patches (excluding the cover letter) can be applied on top of the upstream repository default branch without conflicts. Some placeholders are left for additional validation steps to be performed after all patches of a given series have been applied.</p> </div> <div class="sect2"> <h3 id="_fsmonitor_watchman"> +fsmonitor-watchman</h3> <p>This hook is invoked when the configuration option <code>core.fsmonitor</code> is set to <code>.git/hooks/fsmonitor-watchman</code> or <code>.git/hooks/fsmonitor-watchmanv2</code> depending on the version of the hook to use.</p> <p>Version 1 takes two arguments, a version (1) and the time in elapsed nanoseconds since midnight, January 1, 1970.</p> <p>Version 2 takes two arguments, a version (2) and a token that is used for identifying changes since the token. For watchman this would be a clock id. This version must output to stdout the new token followed by a NUL before the list of files.</p> <p>The hook should output to stdout the list of all files in the working directory that may have changed since the requested time. The logic should be inclusive so that it does not miss any potential changes. The paths should be relative to the root of the working directory and be separated by a single NUL.</p> <p>It is OK to include files which have not actually changed. All changes including newly-created and deleted files should be included. When files are renamed, both the old and the new name should be included.</p> <p>Git will limit what files it checks for changes as well as which directories are checked for untracked files based on the path names given.</p> <p>An optimized way to tell git "all files have changed" is to return the filename <code>/</code>.</p> <p>The exit status determines whether git will use the data from the hook to limit its search. On error, it will fall back to verifying all files and folders.</p> </div> <div class="sect2"> <h3 id="_p4_changelist"> +p4-changelist</h3> <p>This hook is invoked by <code>git-p4 submit</code>.</p> <p>The <code>p4-changelist</code> hook is executed after the changelist message has been edited by the user. It can be bypassed with the <code>--no-verify</code> option. It takes a single parameter, the name of the file that holds the proposed changelist text. Exiting with a non-zero status causes the command to abort.</p> <p>The hook is allowed to edit the changelist file and can be used to normalize the text into some project standard format. It can also be used to refuse the Submit after inspect the message file.</p> <p>Run <code>git-p4 submit --help</code> for details.</p> </div> <div class="sect2"> <h3 id="_p4_prepare_changelist"> +p4-prepare-changelist</h3> <p>This hook is invoked by <code>git-p4 submit</code>.</p> <p>The <code>p4-prepare-changelist</code> hook is executed right after preparing the default changelist message and before the editor is started. It takes one parameter, the name of the file that contains the changelist text. Exiting with a non-zero status from the script will abort the process.</p> <p>The purpose of the hook is to edit the message file in place, and it is not suppressed by the <code>--no-verify</code> option. This hook is called even if <code>--prepare-p4-only</code> is set.</p> <p>Run <code>git-p4 submit --help</code> for details.</p> </div> <div class="sect2"> <h3 id="_p4_post_changelist"> +p4-post-changelist</h3> <p>This hook is invoked by <code>git-p4 submit</code>.</p> <p>The <code>p4-post-changelist</code> hook is invoked after the submit has successfully occurred in P4. It takes no parameters and is meant primarily for notification and cannot affect the outcome of the git p4 submit action.</p> <p>Run <code>git-p4 submit --help</code> for details.</p> </div> <div class="sect2"> <h3 id="_p4_pre_submit"> +p4-pre-submit</h3> <p>This hook is invoked by <code>git-p4 submit</code>. It takes no parameters and nothing from standard input. Exiting with non-zero status from this script prevent <code>git-p4 submit</code> from launching. It can be bypassed with the <code>--no-verify</code> command line option. Run <code>git-p4 submit --help</code> for details.</p> </div> <div class="sect2"> <h3 id="_post_index_change"> +post-index-change</h3> <p>This hook is invoked when the index is written in read-cache.c do_write_locked_index.</p> <p>The first parameter passed to the hook is the indicator for the working directory being updated. "1" meaning working directory was updated or "0" when the working directory was not updated.</p> <p>The second parameter passed to the hook is the indicator for whether or not the index was updated and the skip-worktree bit could have changed. "1" meaning skip-worktree bits could have been updated and "0" meaning they were not.</p> <p>Only one parameter should be set to "1" when the hook runs. The hook running passing "1", "1" should not be possible.</p> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-hook">git-hook[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/githooks" class="_attribution-link">https://git-scm.com/docs/githooks</a> + </p> +</div> diff --git a/devdocs/git/gitignore.html b/devdocs/git/gitignore.html new file mode 100644 index 00000000..99b84bd1 --- /dev/null +++ b/devdocs/git/gitignore.html @@ -0,0 +1,38 @@ +<h1>gitignore</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitignore - Specifies intentionally untracked files to ignore</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>$XDG_CONFIG_HOME/git/ignore, $GIT_DIR/info/exclude, .gitignore</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>A <code>gitignore</code> file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES below for details.</p> <p>Each line in a <code>gitignore</code> file specifies a pattern. When deciding whether to ignore a path, Git normally checks <code>gitignore</code> patterns from multiple sources, with the following order of precedence, from highest to lowest (within one level of precedence, the last matching pattern decides the outcome):</p> <div class="ulist"> <ul> <li> <p>Patterns read from the command line for those commands that support them.</p> </li> <li> <p>Patterns read from a <code>.gitignore</code> file in the same directory as the path, or in any parent directory (up to the top-level of the working tree), with patterns in the higher level files being overridden by those in lower level files down to the directory containing the file. These patterns match relative to the location of the <code>.gitignore</code> file. A project normally includes such <code>.gitignore</code> files in its repository, containing patterns for files generated as part of the project build.</p> </li> <li> <p>Patterns read from <code>$GIT_DIR/info/exclude</code>.</p> </li> <li> <p>Patterns read from the file specified by the configuration variable <code>core.excludesFile</code>.</p> </li> </ul> </div> <p>Which file to place a pattern in depends on how the pattern is meant to be used.</p> <div class="ulist"> <ul> <li> <p>Patterns which should be version-controlled and distributed to other repositories via clone (i.e., files that all developers will want to ignore) should go into a <code>.gitignore</code> file.</p> </li> <li> <p>Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user’s workflow) should go into the <code>$GIT_DIR/info/exclude</code> file.</p> </li> <li> <p>Patterns which a user wants Git to ignore in all situations (e.g., backup or temporary files generated by the user’s editor of choice) generally go into a file specified by <code>core.excludesFile</code> in the user’s <code>~/.gitconfig</code>. Its default value is $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore is used instead.</p> </li> </ul> </div> <p>The underlying Git plumbing tools, such as <code>git ls-files</code> and <code>git read-tree</code>, read <code>gitignore</code> patterns specified by command-line options, or from files specified by command-line options. Higher-level Git tools, such as <code>git status</code> and <code>git add</code>, use patterns from the sources specified above.</p> </div> <h2 id="_pattern_format">Pattern format</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>A blank line matches no files, so it can serve as a separator for readability.</p> </li> <li> <p>A line starting with # serves as a comment. Put a backslash ("<code>\</code>") in front of the first hash for patterns that begin with a hash.</p> </li> <li> <p>Trailing spaces are ignored unless they are quoted with backslash ("<code>\</code>").</p> </li> <li> <p>An optional prefix "<code>!</code>" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined. Put a backslash ("<code>\</code>") in front of the first "<code>!</code>" for patterns that begin with a literal "<code>!</code>", for example, "<code>\!important!.txt</code>".</p> </li> <li> <p>The slash "<code>/</code>" is used as the directory separator. Separators may occur at the beginning, middle or end of the <code>.gitignore</code> search pattern.</p> </li> <li> <p>If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular <code>.gitignore</code> file itself. Otherwise the pattern may also match at any level below the <code>.gitignore</code> level.</p> </li> <li> <p>If there is a separator at the end of the pattern then the pattern will only match directories, otherwise the pattern can match both files and directories.</p> </li> <li> <p>For example, a pattern <code>doc/frotz/</code> matches <code>doc/frotz</code> directory, but not <code>a/doc/frotz</code> directory; however <code>frotz/</code> matches <code>frotz</code> and <code>a/frotz</code> that is a directory (all paths are relative from the <code>.gitignore</code> file).</p> </li> <li> <p>An asterisk "<code>*</code>" matches anything except a slash. The character "<code>?</code>" matches any one character except "<code>/</code>". The range notation, e.g. <code>[a-zA-Z]</code>, can be used to match one of the characters in a range. See fnmatch(3) and the FNM_PATHNAME flag for a more detailed description.</p> </li> </ul> </div> <p>Two consecutive asterisks ("<code>**</code>") in patterns matched against full pathname may have special meaning:</p> <div class="ulist"> <ul> <li> <p>A leading "<code>**</code>" followed by a slash means match in all directories. For example, "<code>**/foo</code>" matches file or directory "<code>foo</code>" anywhere, the same as pattern "<code>foo</code>". "<code>**/foo/bar</code>" matches file or directory "<code>bar</code>" anywhere that is directly under directory "<code>foo</code>".</p> </li> <li> <p>A trailing "<code>/**</code>" matches everything inside. For example, "<code>abc/**</code>" matches all files inside directory "<code>abc</code>", relative to the location of the <code>.gitignore</code> file, with infinite depth.</p> </li> <li> <p>A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "<code>a/**/b</code>" matches "<code>a/b</code>", "<code>a/x/b</code>", "<code>a/x/y/b</code>" and so on.</p> </li> <li> <p>Other consecutive asterisks are considered regular asterisks and will match according to the previous rules.</p> </li> </ul> </div> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>The optional configuration variable <code>core.excludesFile</code> indicates a path to a file containing patterns of file names to exclude, similar to <code>$GIT_DIR/info/exclude</code>. Patterns in the exclude file are used in addition to those in <code>$GIT_DIR/info/exclude</code>.</p> </div> <h2 id="_notes">Notes</h2> <div class="sectionbody"> <p>The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked.</p> <p>To stop tracking a file that is currently tracked, use <code>git rm --cached</code> to remove the file from the index. The filename can then be added to the <code>.gitignore</code> file to stop the file from being reintroduced in later commits.</p> <p>Git does not follow symbolic links when accessing a <code>.gitignore</code> file in the working tree. This keeps behavior consistent when the file is accessed from the index or a tree versus from the filesystem.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>The pattern <code>hello.*</code> matches any file or directory whose name begins with <code>hello.</code>. If one wants to restrict this only to the directory and not in its subdirectories, one can prepend the pattern with a slash, i.e. <code>/hello.*</code>; the pattern now matches <code>hello.txt</code>, <code>hello.c</code> but not <code>a/hello.java</code>.</p> </li> <li> <p>The pattern <code>foo/</code> will match a directory <code>foo</code> and paths underneath it, but will not match a regular file or a symbolic link <code>foo</code> (this is consistent with the way how pathspec works in general in Git)</p> </li> <li> <p>The pattern <code>doc/frotz</code> and <code>/doc/frotz</code> have the same effect in any <code>.gitignore</code> file. In other words, a leading slash is not relevant if there is already a middle slash in the pattern.</p> </li> <li> <p>The pattern <code>foo/*</code>, matches <code>foo/test.json</code> (a regular file), <code>foo/bar</code> (a directory), but it does not match <code>foo/bar/hello.c</code> (a regular file), as the asterisk in the pattern does not match <code>bar/hello.c</code> which has a slash in it.</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre> $ git status + [...] + # Untracked files: + [...] + # Documentation/foo.html + # Documentation/gitignore.html + # file.o + # lib.a + # src/internal.o + [...] + $ cat .git/info/exclude + # ignore objects and archives, anywhere in the tree. + *.[oa] + $ cat Documentation/.gitignore + # ignore generated html files, + *.html + # except foo.html which is maintained by hand + !foo.html + $ git status + [...] + # Untracked files: + [...] + # Documentation/foo.html + [...]</pre> </div> </div> <p>Another example:</p> <div class="listingblock"> <div class="content"> <pre> $ cat .gitignore + vmlinux* + $ ls arch/foo/kernel/vm* + arch/foo/kernel/vmlinux.lds.S + $ echo '!/vmlinux*' >arch/foo/kernel/.gitignore</pre> </div> </div> <p>The second .gitignore prevents Git from ignoring <code>arch/foo/kernel/vmlinux.lds.S</code>.</p> <p>Example to exclude everything except a specific directory <code>foo/bar</code> (note the <code>/*</code> - without the slash, the wildcard would also exclude everything within <code>foo/bar</code>):</p> <div class="listingblock"> <div class="content"> <pre> $ cat .gitignore + # exclude everything except directory foo/bar + /* + !/foo + /foo/* + !/foo/bar</pre> </div> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-rm">git-rm[1]</a>, <a href="gitrepository-layout">gitrepository-layout[5]</a>, <a href="git-check-ignore">git-check-ignore[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitignore" class="_attribution-link">https://git-scm.com/docs/gitignore</a> + </p> +</div> diff --git a/devdocs/git/gitk.html b/devdocs/git/gitk.html new file mode 100644 index 00000000..19944593 --- /dev/null +++ b/devdocs/git/gitk.html @@ -0,0 +1,8 @@ +<h1>gitk</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitk - The Git repository browser</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content">gitk [<options>] [<revision range>] [--] [<path>…]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Displays changes in a repository or a selected set of commits. This includes visualizing the commit graph, showing information related to each commit, and the files in the trees of each revision.</p> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <p>To control which revisions to show, gitk supports most options applicable to the <code>git rev-list</code> command. It also supports a few options applicable to the <code>git diff-*</code> commands to control how the changes each commit introduces are shown. Finally, it supports some gitk-specific options.</p> <p>gitk generally only understands options with arguments in the <code>stuck</code> form (see <a href="gitcli">gitcli[7]</a>) due to limitations in the command-line parser.</p> <div class="sect2"> <h3 id="_rev_list_options_and_arguments"> +rev-list options and arguments</h3> <p>This manual page describes only the most frequently used options. See <a href="git-rev-list">git-rev-list[1]</a> for a complete list.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitk.txt---all"> --all </dt> <dd> <p>Show all refs (branches, tags, etc.).</p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt---branchesltpatterngt"> --branches[=<pattern>] </dt> <dt class="hdlist1" id="Documentation/gitk.txt---tagsltpatterngt"> --tags[=<pattern>] </dt> <dt class="hdlist1" id="Documentation/gitk.txt---remotesltpatterngt"> --remotes[=<pattern>] </dt> <dd> <p>Pretend as if all the branches (tags, remote branches, resp.) are listed on the command line as <code><commit></code>. If <code><pattern></code> is given, limit refs to ones matching given shell glob. If pattern lacks <code>?</code>, <code>*</code>, or <code>[</code>, <code>/*</code> at the end is implied.</p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt---sinceltdategt"> --since=<date> </dt> <dd> <p>Show commits more recent than a specific date.</p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt---untilltdategt"> --until=<date> </dt> <dd> <p>Show commits older than a specific date.</p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt---date-order"> --date-order </dt> <dd> <p>Sort commits by date when possible.</p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt---merge"> --merge </dt> <dd> <p>After an attempt to merge stops with conflicts, show the commits on the history between two branches (i.e. the HEAD and the MERGE_HEAD) that modify the conflicted files and do not exist on all the heads being merged.</p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt---left-right"> --left-right </dt> <dd> <p>Mark which side of a symmetric difference a commit is reachable from. Commits from the left side are prefixed with a <code><</code> symbol and those from the right with a <code>></code> symbol.</p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt---full-history"> --full-history </dt> <dd> <p>When filtering history with <code><path>…</code>, does not prune some history. (See "History simplification" in <a href="git-log">git-log[1]</a> for a more detailed explanation.)</p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt---simplify-merges"> --simplify-merges </dt> <dd> <p>Additional option to <code>--full-history</code> to remove some needless merges from the resulting history, as there are no selected commits contributing to this merge. (See "History simplification" in <a href="git-log">git-log[1]</a> for a more detailed explanation.)</p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt---ancestry-path"> --ancestry-path </dt> <dd> <p>When given a range of commits to display (e.g. <code>commit1..commit2</code> or <code>commit2 ^commit1</code>), only display commits that exist directly on the ancestry chain between the <code>commit1</code> and <code>commit2</code>, i.e. commits that are both descendants of <code>commit1</code>, and ancestors of <code>commit2</code>. (See "History simplification" in <a href="git-log">git-log[1]</a> for a more detailed explanation.)</p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt--Lltstartgtltendgtltfilegt"> -L<start>,<end>:<file> </dt> <dt class="hdlist1" id="Documentation/gitk.txt--Lltfuncnamegtltfilegt"> -L:<funcname>:<file> </dt> <dd> <p>Trace the evolution of the line range given by <code><start>,<end></code>, or by the function name regex <code><funcname></code>, within the <code><file></code>. You may not give any pathspec limiters. This is currently limited to a walk starting from a single revision, i.e., you may only give zero or one positive revision arguments, and <code><start></code> and <code><end></code> (or <code><funcname></code>) must exist in the starting revision. You can specify this option more than once. Implies <code>--patch</code>. Patch output can be suppressed using <code>--no-patch</code>, but other diff formats (namely <code>--raw</code>, <code>--numstat</code>, <code>--shortstat</code>, <code>--dirstat</code>, <code>--summary</code>, <code>--name-only</code>, <code>--name-status</code>, <code>--check</code>) are not currently implemented.</p> <p><code><start></code> and <code><end></code> can take one of these forms:</p> <div class="ulist"> <ul> <li> <p>number</p> <p>If <code><start></code> or <code><end></code> is a number, it specifies an absolute line number (lines count from 1).</p> </li> <li> <p><code>/regex/</code></p> <p>This form will use the first line matching the given POSIX regex. If <code><start></code> is a regex, it will search from the end of the previous <code>-L</code> range, if any, otherwise from the start of file. If <code><start></code> is <code>^/regex/</code>, it will search from the start of file. If <code><end></code> is a regex, it will search starting at the line given by <code><start></code>.</p> </li> <li> <p>+offset or -offset</p> <p>This is only valid for <code><end></code> and will specify a number of lines before or after the line given by <code><start></code>.</p> </li> </ul> </div> <p>If <code>:<funcname></code> is given in place of <code><start></code> and <code><end></code>, it is a regular expression that denotes the range from the first funcname line that matches <code><funcname></code>, up to the next funcname line. <code>:<funcname></code> searches from the end of the previous <code>-L</code> range, if any, otherwise from the start of file. <code>^:<funcname></code> searches from the start of file. The function names are determined in the same way as <code>git diff</code> works out patch hunk headers (see <code>Defining a custom hunk-header</code> in <a href="gitattributes">gitattributes[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt-ltrevisionrangegt"> <revision range> </dt> <dd> <p>Limit the revisions to show. This can be either a single revision meaning show from the given revision and back, or it can be a range in the form "<code><from></code>..<code><to></code>" to show all revisions between <code><from></code> and back to <code><to></code>. Note, more advanced revision selection can be applied. For a more complete list of ways to spell object names, see <a href="gitrevisions">gitrevisions[7]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt-ltpathgt82308203"> <path>… </dt> <dd> <p>Limit commits to the ones touching files in the given paths. Note, to avoid ambiguity with respect to revision names use "--" to separate the paths from any preceding options.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_gitk_specific_options"> +gitk-specific options</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitk.txt---argscmdltcommandgt"> --argscmd=<command> </dt> <dd> <p>Command to be run each time gitk has to determine the revision range to show. The command is expected to print on its standard output a list of additional revisions to be shown, one per line. Use this instead of explicitly specifying a <code><revision range></code> if the set of commits to show may vary between refreshes.</p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt---select-commitltrefgt"> --select-commit=<ref> </dt> <dd> <p>Select the specified commit after loading the graph. Default behavior is equivalent to specifying <code>--select-commit=HEAD</code>.</p> </dd> </dl> </div> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitk.txt-gitkv2612includescsidriversscsi"> gitk v2.6.12.. include/scsi drivers/scsi </dt> <dd> <p>Show the changes since version <code>v2.6.12</code> that changed any file in the include/scsi or drivers/scsi subdirectories</p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt-gitk--since2weeksago--gitk"> gitk --since="2 weeks ago" -- gitk </dt> <dd> <p>Show the changes during the last two weeks to the file <code>gitk</code>. The "--" is necessary to avoid confusion with the <strong>branch</strong> named <code>gitk</code></p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt-gitk--max-count100--all--Makefile"> gitk --max-count=100 --all -- Makefile </dt> <dd> <p>Show at most 100 changes made to the file <code>Makefile</code>. Instead of only looking for changes in the current branch look in all branches.</p> </dd> </dl> </div> </div> <h2 id="_files">Files</h2> <div class="sectionbody"> <p>User configuration and preferences are stored at:</p> <div class="ulist"> <ul> <li> <p><code>$XDG_CONFIG_HOME/git/gitk</code> if it exists, otherwise</p> </li> <li> <p><code>$HOME/.gitk</code> if it exists</p> </li> </ul> </div> <p>If neither of the above exist then <code>$XDG_CONFIG_HOME/git/gitk</code> is created and used by default. If <code>$XDG_CONFIG_HOME</code> is not set it defaults to <code>$HOME/.config</code> in all cases.</p> </div> <h2 id="_history">History</h2> <div class="sectionbody"> <p>Gitk was the first graphical repository browser. It’s written in tcl/tk.</p> <p><code>gitk</code> is actually maintained as an independent project, but stable versions are distributed as part of the Git suite for the convenience of end users.</p> <p>gitk-git/ comes from Paul Mackerras’s gitk project:</p> <div class="literalblock"> <div class="content"> <pre>git://ozlabs.org/~paulus/gitk</pre> </div> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitk.txt-emqgit1em"> <em>qgit(1)</em> </dt> <dd> <p>A repository browser written in C++ using Qt.</p> </dd> <dt class="hdlist1" id="Documentation/gitk.txt-emtig1em"> <em>tig(1)</em> </dt> <dd> <p>A minimal repository browser and Git tool output highlighter written in C using Ncurses.</p> </dd> </dl> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitk" class="_attribution-link">https://git-scm.com/docs/gitk</a> + </p> +</div> diff --git a/devdocs/git/gitmailmap.html b/devdocs/git/gitmailmap.html new file mode 100644 index 00000000..79d9a9ef --- /dev/null +++ b/devdocs/git/gitmailmap.html @@ -0,0 +1,19 @@ +<h1>gitmailmap</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitmailmap - Map author/committer names and/or E-Mail addresses</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>$GIT_WORK_TREE/.mailmap</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>If the file <code>.mailmap</code> exists at the toplevel of the repository, or at the location pointed to by the <code>mailmap.file</code> or <code>mailmap.blob</code> configuration options (see <a href="git-config">git-config[1]</a>), it is used to map author and committer names and email addresses to canonical real names and email addresses.</p> </div> <h2 id="_syntax">Syntax</h2> <div class="sectionbody"> <p>The <code>#</code> character begins a comment to the end of line, blank lines are ignored.</p> <p>In the simple form, each line in the file consists of the canonical real name of an author, whitespace, and an email address used in the commit (enclosed by <code><</code> and <code>></code>) to map to the name. For example:</p> <div class="openblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre>Proper Name <commit@email.xx></pre> </div> </div> </div> </div> <p>The more complex forms are:</p> <div class="openblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre><proper@email.xx> <commit@email.xx></pre> </div> </div> </div> </div> <p>which allows mailmap to replace only the email part of a commit, and:</p> <div class="openblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre>Proper Name <proper@email.xx> <commit@email.xx></pre> </div> </div> </div> </div> <p>which allows mailmap to replace both the name and the email of a commit matching the specified commit email address, and:</p> <div class="openblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre>Proper Name <proper@email.xx> Commit Name <commit@email.xx></pre> </div> </div> </div> </div> <p>which allows mailmap to replace both the name and the email of a commit matching both the specified commit name and email address.</p> <p>Both E-Mails and names are matched case-insensitively. For example this would also match the <code>Commit Name <commit@email.xx></code> above:</p> <div class="openblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre>Proper Name <proper@email.xx> CoMmIt NaMe <CoMmIt@EmAiL.xX></pre> </div> </div> </div> </div> </div> <h2 id="_notes">Notes</h2> <div class="sectionbody"> <p>Git does not follow symbolic links when accessing a <code>.mailmap</code> file in the working tree. This keeps behavior consistent when the file is accessed from the index or a tree versus from the filesystem.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>Your history contains commits by two authors, Jane and Joe, whose names appear in the repository under several forms:</p> <div class="listingblock"> <div class="content"> <pre>Joe Developer <joe@example.com> +Joe R. Developer <joe@example.com> +Jane Doe <jane@example.com> +Jane Doe <jane@laptop.(none)> +Jane D. <jane@desktop.(none)></pre> </div> </div> <p>Now suppose that Joe wants his middle name initial used, and Jane prefers her family name fully spelled out. A <code>.mailmap</code> file to correct the names would look like:</p> <div class="listingblock"> <div class="content"> <pre>Joe R. Developer <joe@example.com> +Jane Doe <jane@example.com> +Jane Doe <jane@desktop.(none)></pre> </div> </div> <p>Note that there’s no need to map the name for <code><jane@laptop.(none)></code> to only correct the names. However, leaving the obviously broken <code><jane@laptop.(none)></code> and <code><jane@desktop.(none)></code> E-Mails as-is is usually not what you want. A <code>.mailmap</code> file which also corrects those is:</p> <div class="listingblock"> <div class="content"> <pre>Joe R. Developer <joe@example.com> +Jane Doe <jane@example.com> <jane@laptop.(none)> +Jane Doe <jane@example.com> <jane@desktop.(none)></pre> </div> </div> <p>Finally, let’s say that Joe and Jane shared an E-Mail address, but not a name, e.g. by having these two commits in the history generated by a bug reporting system. I.e. names appearing in history as:</p> <div class="listingblock"> <div class="content"> <pre>Joe <bugs@example.com> +Jane <bugs@example.com></pre> </div> </div> <p>A full <code>.mailmap</code> file which also handles those cases (an addition of two lines to the above example) would be:</p> <div class="listingblock"> <div class="content"> <pre>Joe R. Developer <joe@example.com> +Jane Doe <jane@example.com> <jane@laptop.(none)> +Jane Doe <jane@example.com> <jane@desktop.(none)> +Joe R. Developer <joe@example.com> Joe <bugs@example.com> +Jane Doe <jane@example.com> Jane <bugs@example.com></pre> </div> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-check-mailmap">git-check-mailmap[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitmailmap" class="_attribution-link">https://git-scm.com/docs/gitmailmap</a> + </p> +</div> diff --git a/devdocs/git/gitmodules.html b/devdocs/git/gitmodules.html new file mode 100644 index 00000000..e2fddc05 --- /dev/null +++ b/devdocs/git/gitmodules.html @@ -0,0 +1,13 @@ +<h1>gitmodules</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitmodules - Defining submodule properties</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>$GIT_WORK_TREE/.gitmodules</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>The <code>.gitmodules</code> file, located in the top-level directory of a Git working tree, is a text file with a syntax matching the requirements of <a href="git-config">git-config[1]</a>.</p> <p>The file contains one subsection per submodule, and the subsection value is the name of the submodule. The name is set to the path where the submodule has been added unless it was customized with the <code>--name</code> option of <code>git submodule add</code>. Each submodule section also contains the following required keys:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitmodules.txt-submoduleltnamegtpath"> submodule.<name>.path </dt> <dd> <p>Defines the path, relative to the top-level directory of the Git working tree, where the submodule is expected to be checked out. The path name must not end with a <code>/</code>. All submodule paths must be unique within the <code>.gitmodules</code> file.</p> </dd> <dt class="hdlist1" id="Documentation/gitmodules.txt-submoduleltnamegturl"> submodule.<name>.url </dt> <dd> <p>Defines a URL from which the submodule repository can be cloned. This may be either an absolute URL ready to be passed to <a href="git-clone">git-clone[1]</a> or (if it begins with <code>./</code> or <code>../</code>) a location relative to the superproject’s origin repository.</p> </dd> </dl> </div> <p>In addition, there are a number of optional keys:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitmodules.txt-submoduleltnamegtupdate"> submodule.<name>.update </dt> <dd> <p>Defines the default update procedure for the named submodule, i.e. how the submodule is updated by the <code>git submodule update</code> command in the superproject. This is only used by <code>git +submodule init</code> to initialize the configuration variable of the same name. Allowed values here are <code>checkout</code>, <code>rebase</code>, <code>merge</code> or <code>none</code>, but not <code>!command</code> (for security reasons). See the description of the <code>update</code> command in <a href="git-submodule">git-submodule[1]</a> for more details.</p> </dd> <dt class="hdlist1" id="Documentation/gitmodules.txt-submoduleltnamegtbranch"> submodule.<name>.branch </dt> <dd> <p>A remote branch name for tracking updates in the upstream submodule. If the option is not specified, it defaults to the remote <code>HEAD</code>. A special value of <code>.</code> is used to indicate that the name of the branch in the submodule should be the same name as the current branch in the current repository. See the <code>--remote</code> documentation in <a href="git-submodule">git-submodule[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/gitmodules.txt-submoduleltnamegtfetchRecurseSubmodules"> submodule.<name>.fetchRecurseSubmodules </dt> <dd> <p>This option can be used to control recursive fetching of this submodule. If this option is also present in the submodule’s entry in <code>.git/config</code> of the superproject, the setting there will override the one found in <code>.gitmodules</code>. Both settings can be overridden on the command line by using the <code>--[no-]recurse-submodules</code> option to <code>git fetch</code> and <code>git pull</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitmodules.txt-submoduleltnamegtignore"> submodule.<name>.ignore </dt> <dd> <p>Defines under what circumstances <code>git status</code> and the diff family show a submodule as modified. The following values are supported:</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitmodules.txt-all"> all </dt> <dd> <p>The submodule will never be considered modified (but will nonetheless show up in the output of status and commit when it has been staged).</p> </dd> <dt class="hdlist1" id="Documentation/gitmodules.txt-dirty"> dirty </dt> <dd> <p>All changes to the submodule’s work tree will be ignored, only committed differences between the <code>HEAD</code> of the submodule and its recorded state in the superproject are taken into account.</p> </dd> <dt class="hdlist1" id="Documentation/gitmodules.txt-untracked"> untracked </dt> <dd> <p>Only untracked files in submodules will be ignored. Committed differences and modifications to tracked files will show up.</p> </dd> <dt class="hdlist1" id="Documentation/gitmodules.txt-none"> none </dt> <dd> <p>No modifications to submodules are ignored, all of committed differences, and modifications to tracked and untracked files are shown. This is the default option.</p> </dd> </dl> </div> <p>If this option is also present in the submodule’s entry in <code>.git/config</code> of the superproject, the setting there will override the one found in <code>.gitmodules</code>.</p> <p>Both settings can be overridden on the command line by using the <code>--ignore-submodules</code> option. The <code>git submodule</code> commands are not affected by this setting.</p> </div> </div> </dd> <dt class="hdlist1" id="Documentation/gitmodules.txt-submoduleltnamegtshallow"> submodule.<name>.shallow </dt> <dd> <p>When set to true, a clone of this submodule will be performed as a shallow clone (with a history depth of 1) unless the user explicitly asks for a non-shallow clone.</p> </dd> </dl> </div> </div> <h2 id="_notes">Notes</h2> <div class="sectionbody"> <p>Git does not allow the <code>.gitmodules</code> file within a working tree to be a symbolic link, and will refuse to check out such a tree entry. This keeps behavior consistent when the file is accessed from the index or a tree versus from the filesystem, and helps Git reliably enforce security checks of the file contents.</p> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>Consider the following <code>.gitmodules</code> file:</p> <div class="listingblock"> <div class="content"> <pre>[submodule "libfoo"] + path = include/foo + url = git://foo.com/git/lib.git + +[submodule "libbar"] + path = include/bar + url = git://bar.com/git/lib.git</pre> </div> </div> <p>This defines two submodules, <code>libfoo</code> and <code>libbar</code>. These are expected to be checked out in the paths <code>include/foo</code> and <code>include/bar</code>, and for both submodules a URL is specified which can be used for cloning the submodules.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-submodule">git-submodule[1]</a>, <a href="gitsubmodules">gitsubmodules[7]</a>, <a href="git-config">git-config[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitmodules" class="_attribution-link">https://git-scm.com/docs/gitmodules</a> + </p> +</div> diff --git a/devdocs/git/gitnamespaces.html b/devdocs/git/gitnamespaces.html new file mode 100644 index 00000000..c61093f3 --- /dev/null +++ b/devdocs/git/gitnamespaces.html @@ -0,0 +1,7 @@ +<h1>gitnamespaces</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitnamespaces - Git namespaces</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content">GIT_NAMESPACE=<namespace> git upload-pack +GIT_NAMESPACE=<namespace> git receive-pack</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Git supports dividing the refs of a single repository into multiple namespaces, each of which has its own branches, tags, and HEAD. Git can expose each namespace as an independent repository to pull from and push to, while sharing the object store, and exposing all the refs to operations such as <a href="git-gc">git-gc[1]</a>.</p> <p>Storing multiple repositories as namespaces of a single repository avoids storing duplicate copies of the same objects, such as when storing multiple branches of the same source. The alternates mechanism provides similar support for avoiding duplicates, but alternates do not prevent duplication between new objects added to the repositories without ongoing maintenance, while namespaces do.</p> <p>To specify a namespace, set the <code>GIT_NAMESPACE</code> environment variable to the namespace. For each ref namespace, Git stores the corresponding refs in a directory under <code>refs/namespaces/</code>. For example, <code>GIT_NAMESPACE=foo</code> will store refs under <code>refs/namespaces/foo/</code>. You can also specify namespaces via the <code>--namespace</code> option to <a href="git">git[1]</a>.</p> <p>Note that namespaces which include a <code>/</code> will expand to a hierarchy of namespaces; for example, <code>GIT_NAMESPACE=foo/bar</code> will store refs under <code>refs/namespaces/foo/refs/namespaces/bar/</code>. This makes paths in <code>GIT_NAMESPACE</code> behave hierarchically, so that cloning with <code>GIT_NAMESPACE=foo/bar</code> produces the same result as cloning with <code>GIT_NAMESPACE=foo</code> and cloning from that repo with <code>GIT_NAMESPACE=bar</code>. It also avoids ambiguity with strange namespace paths such as <code>foo/refs/heads/</code>, which could otherwise generate directory/file conflicts within the <code>refs</code> directory.</p> <p><a href="git-upload-pack">git-upload-pack[1]</a> and <a href="git-receive-pack">git-receive-pack[1]</a> rewrite the names of refs as specified by <code>GIT_NAMESPACE</code>. git-upload-pack and git-receive-pack will ignore all references outside the specified namespace.</p> <p>The smart HTTP server, <a href="git-http-backend">git-http-backend[1]</a>, will pass GIT_NAMESPACE through to the backend programs; see <a href="git-http-backend">git-http-backend[1]</a> for sample configuration to expose repository namespaces as repositories.</p> <p>For a simple local test, you can use <a href="git-remote-ext">git-remote-ext[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell">git clone ext::'git --namespace=foo %s /tmp/prefixed.git'</pre> </div> </div> </div> <h2 id="_security">Security</h2> <div class="sectionbody"> <p>The fetch and push protocols are not designed to prevent one side from stealing data from the other repository that was not intended to be shared. If you have private data that you need to protect from a malicious peer, your best option is to store it in another repository. This applies to both clients and servers. In particular, namespaces on a server are not effective for read access control; you should only grant read access to a namespace to clients that you would trust with read access to the entire repository.</p> <p>The known attack vectors are as follows:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>The victim sends "have" lines advertising the IDs of objects it has that are not explicitly intended to be shared but can be used to optimize the transfer if the peer also has them. The attacker chooses an object ID X to steal and sends a ref to X, but isn’t required to send the content of X because the victim already has it. Now the victim believes that the attacker has X, and it sends the content of X back to the attacker later. (This attack is most straightforward for a client to perform on a server, by creating a ref to X in the namespace the client has access to and then fetching it. The most likely way for a server to perform it on a client is to "merge" X into a public branch and hope that the user does additional work on this branch and pushes it back to the server without noticing the merge.)</p> </li> <li> <p>As in #1, the attacker chooses an object ID X to steal. The victim sends an object Y that the attacker already has, and the attacker falsely claims to have X and not Y, so the victim sends Y as a delta against X. The delta reveals regions of X that are similar to Y to the attacker.</p> </li> </ol> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitnamespaces" class="_attribution-link">https://git-scm.com/docs/gitnamespaces</a> + </p> +</div> diff --git a/devdocs/git/gitprotocol-capabilities.html b/devdocs/git/gitprotocol-capabilities.html new file mode 100644 index 00000000..b9f3b4d1 --- /dev/null +++ b/devdocs/git/gitprotocol-capabilities.html @@ -0,0 +1,13 @@ +<h1>gitprotocol-capabilities</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitprotocol-capabilities - Protocol v0 and v1 capabilities</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content"><over-the-wire-protocol></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> this document describes capabilities for versions 0 and 1 of the pack protocol. For version 2, please refer to the <a href="gitprotocol-v2">gitprotocol-v2[5]</a> doc. </td> </tr> </table> </div> <p>Servers SHOULD support all capabilities defined in this document.</p> <p>On the very first line of the initial server response of either receive-pack and upload-pack the first reference is followed by a NUL byte and then a list of space delimited server capabilities. These allow the server to declare what it can and cannot support to the client.</p> <p>Client will then send a space separated list of capabilities it wants to be in effect. The client MUST NOT ask for capabilities the server did not say it supports.</p> <p>Server MUST diagnose and abort if capabilities it does not understand were sent. Server MUST NOT ignore capabilities that client requested and server advertised. As a consequence of these rules, server MUST NOT advertise capabilities it does not understand.</p> <p>The <code>atomic</code>, <code>report-status</code>, <code>report-status-v2</code>, <code>delete-refs</code>, <code>quiet</code>, and <code>push-cert</code> capabilities are sent and recognized by the receive-pack (push to server) process.</p> <p>The <code>ofs-delta</code> and <code>side-band-64k</code> capabilities are sent and recognized by both upload-pack and receive-pack protocols. The <code>agent</code> and <code>session-id</code> capabilities may optionally be sent in both protocols.</p> <p>All other capabilities are only recognized by the upload-pack (fetch from server) process.</p> </div> <h2 id="_multi_ack">Multi_ack</h2> <div class="sectionbody"> <p>The <code>multi_ack</code> capability allows the server to return "ACK obj-id continue" as soon as it finds a commit that it can use as a common base, between the client’s wants and the client’s have set.</p> <p>By sending this early, the server can potentially head off the client from walking any further down that particular branch of the client’s repository history. The client may still need to walk down other branches, sending have lines for those, until the server has a complete cut across the DAG, or the client has said "done".</p> <p>Without multi_ack, a client sends have lines in --date-order until the server has found a common base. That means the client will send have lines that are already known by the server to be common, because they overlap in time with another branch on which the server hasn’t found a common base yet.</p> <p>For example suppose the client has commits in caps that the server doesn’t and the server has commits in lower case that the client doesn’t, as in the following diagram:</p> <div class="literalblock"> <div class="content"> <pre> +---- u ---------------------- x + / +----- y + / / + a -- b -- c -- d -- E -- F + \ ++--- Q -- R -- S</pre> </div> </div> <p>If the client wants x,y and starts out by saying have F,S, the server doesn’t know what F,S is. Eventually the client says "have d" and the server sends "ACK d continue" to let the client know to stop walking down that line (so don’t send c-b-a), but it’s not done yet, it needs a base for x. The client keeps going with S-R-Q, until a gets reached, at which point the server has a clear base and it all ends.</p> <p>Without multi_ack the client would have sent that c-b-a chain anyway, interleaved with S-R-Q.</p> </div> <h2 id="_multi_ack_detailed">Multi_ack_detailed</h2> <div class="sectionbody"> <p>This is an extension of multi_ack that permits the client to better understand the server’s in-memory state. See <a href="gitprotocol-pack">gitprotocol-pack[5]</a>, section "Packfile Negotiation" for more information.</p> </div> <h2 id="_no_done">No-done</h2> <div class="sectionbody"> <p>This capability should only be used with the smart HTTP protocol. If multi_ack_detailed and no-done are both present, then the sender is free to immediately send a pack following its first "ACK obj-id ready" message.</p> <p>Without no-done in the smart HTTP protocol, the server session would end and the client has to make another trip to send "done" before the server can send the pack. no-done removes the last round and thus slightly reduces latency.</p> </div> <h2 id="_thin_pack">Thin-pack</h2> <div class="sectionbody"> <p>A thin pack is one with deltas which reference base objects not contained within the pack (but are known to exist at the receiving end). This can reduce the network traffic significantly, but it requires the receiving end to know how to "thicken" these packs by adding the missing bases to the pack.</p> <p>The upload-pack server advertises <code>thin-pack</code> when it can generate and send a thin pack. A client requests the <code>thin-pack</code> capability when it understands how to "thicken" it, notifying the server that it can receive such a pack. A client MUST NOT request the <code>thin-pack</code> capability if it cannot turn a thin pack into a self-contained pack.</p> <p>Receive-pack, on the other hand, is assumed by default to be able to handle thin packs, but can ask the client not to use the feature by advertising the <code>no-thin</code> capability. A client MUST NOT send a thin pack if the server advertises the <code>no-thin</code> capability.</p> <p>The reasons for this asymmetry are historical. The receive-pack program did not exist until after the invention of thin packs, so historically the reference implementation of receive-pack always understood thin packs. Adding <code>no-thin</code> later allowed receive-pack to disable the feature in a backwards-compatible manner.</p> </div> <h2 id="_side_band_side_band_64k">Side-band, side-band-64k</h2> <div class="sectionbody"> <p>This capability means that the server can send, and the client can understand, multiplexed progress reports and error info interleaved with the packfile itself.</p> <p>These two options are mutually exclusive. A modern client always favors <code>side-band-64k</code>.</p> <p>Either mode indicates that the packfile data will be streamed broken up into packets of up to either 1000 bytes in the case of <code>side_band</code>, or 65520 bytes in the case of <code>side_band_64k</code>. Each packet is made up of a leading 4-byte pkt-line length of how much data is in the packet, followed by a 1-byte stream code, followed by the actual data.</p> <p>The stream code can be one of:</p> <div class="literalblock"> <div class="content"> <pre>1 - pack data +2 - progress messages +3 - fatal error message just before stream aborts</pre> </div> </div> <p>The "side-band-64k" capability came about as a way for newer clients that can handle much larger packets to request packets that are actually crammed nearly full, while maintaining backward compatibility for the older clients.</p> <p>Further, with side-band and its up to 1000-byte messages, it’s actually 999 bytes of payload and 1 byte for the stream code. With side-band-64k, same deal, you have up to 65519 bytes of data and 1 byte for the stream code.</p> <p>The client MUST send only one of "side-band" and "side- band-64k". The server MUST diagnose it as an error if client requests both.</p> </div> <h2 id="_ofs_delta">Ofs-delta</h2> <div class="sectionbody"> <p>The server can send, and the client can understand, PACKv2 with delta referring to its base by position in pack rather than by an obj-id. That is, they can send/read OBJ_OFS_DELTA (aka type 6) in a packfile.</p> </div> <h2 id="_agent">Agent</h2> <div class="sectionbody"> <p>The server may optionally send a capability of the form <code>agent=X</code> to notify the client that the server is running version <code>X</code>. The client may optionally return its own agent string by responding with an <code>agent=Y</code> capability (but it MUST NOT do so if the server did not mention the agent capability). The <code>X</code> and <code>Y</code> strings may contain any printable ASCII characters except space (i.e., the byte range 32 < x < 127), and are typically of the form "package/version" (e.g., "git/1.8.3.1"). The agent strings are purely informative for statistics and debugging purposes, and MUST NOT be used to programmatically assume the presence or absence of particular features.</p> </div> <h2 id="_object_format">Object-format</h2> <div class="sectionbody"> <p>This capability, which takes a hash algorithm as an argument, indicates that the server supports the given hash algorithms. It may be sent multiple times; if so, the first one given is the one used in the ref advertisement.</p> <p>When provided by the client, this indicates that it intends to use the given hash algorithm to communicate. The algorithm provided must be one that the server supports.</p> <p>If this capability is not provided, it is assumed that the only supported algorithm is SHA-1.</p> </div> <h2 id="_symref">Symref</h2> <div class="sectionbody"> <p>This parameterized capability is used to inform the receiver which symbolic ref points to which ref; for example, "symref=HEAD:refs/heads/master" tells the receiver that HEAD points to master. This capability can be repeated to represent multiple symrefs.</p> <p>Servers SHOULD include this capability for the HEAD symref if it is one of the refs being sent.</p> <p>Clients MAY use the parameters from this capability to select the proper initial branch when cloning a repository.</p> </div> <h2 id="_shallow">Shallow</h2> <div class="sectionbody"> <p>This capability adds "deepen", "shallow" and "unshallow" commands to the fetch-pack/upload-pack protocol so clients can request shallow clones.</p> </div> <h2 id="_deepen_since">Deepen-since</h2> <div class="sectionbody"> <p>This capability adds "deepen-since" command to fetch-pack/upload-pack protocol so the client can request shallow clones that are cut at a specific time, instead of depth. Internally it’s equivalent of doing "rev-list --max-age=<timestamp>" on the server side. "deepen-since" cannot be used with "deepen".</p> </div> <h2 id="_deepen_not">Deepen-not</h2> <div class="sectionbody"> <p>This capability adds "deepen-not" command to fetch-pack/upload-pack protocol so the client can request shallow clones that are cut at a specific revision, instead of depth. Internally it’s equivalent of doing "rev-list --not <rev>" on the server side. "deepen-not" cannot be used with "deepen", but can be used with "deepen-since".</p> </div> <h2 id="_deepen_relative">Deepen-relative</h2> <div class="sectionbody"> <p>If this capability is requested by the client, the semantics of "deepen" command is changed. The "depth" argument is the depth from the current shallow boundary, instead of the depth from remote refs.</p> </div> <h2 id="_no_progress">No-progress</h2> <div class="sectionbody"> <p>The client was started with "git clone -q" or something similar, and doesn’t want that side band 2. Basically the client just says "I do not wish to receive stream 2 on sideband, so do not send it to me, and if you did, I will drop it on the floor anyway". However, the sideband channel 3 is still used for error responses.</p> </div> <h2 id="_include_tag">Include-tag</h2> <div class="sectionbody"> <p>The <code>include-tag</code> capability is about sending annotated tags if we are sending objects they point to. If we pack an object to the client, and a tag object points exactly at that object, we pack the tag object too. In general this allows a client to get all new annotated tags when it fetches a branch, in a single network connection.</p> <p>Clients MAY always send include-tag, hardcoding it into a request when the server advertises this capability. The decision for a client to request include-tag only has to do with the client’s desires for tag data, whether or not a server had advertised objects in the refs/tags/* namespace.</p> <p>Servers MUST pack the tags if their referent is packed and the client has requested include-tags.</p> <p>Clients MUST be prepared for the case where a server has ignored include-tag and has not actually sent tags in the pack. In such cases the client SHOULD issue a subsequent fetch to acquire the tags that include-tag would have otherwise given the client.</p> <p>The server SHOULD send include-tag, if it supports it, regardless of whether or not there are tags available.</p> </div> <h2 id="_report_status">Report-status</h2> <div class="sectionbody"> <p>The receive-pack process can receive a <code>report-status</code> capability, which tells it that the client wants a report of what happened after a packfile upload and reference update. If the pushing client requests this capability, after unpacking and updating references the server will respond with whether the packfile unpacked successfully and if each reference was updated successfully. If any of those were not successful, it will send back an error message. See <a href="gitprotocol-pack">gitprotocol-pack[5]</a> for example messages.</p> </div> <h2 id="_report_status_v2">Report-status-v2</h2> <div class="sectionbody"> <p>Capability <code>report-status-v2</code> extends capability <code>report-status</code> by adding new "option" directives in order to support reference rewritten by the "proc-receive" hook. The "proc-receive" hook may handle a command for a pseudo-reference which may create or update a reference with different name, new-oid, and old-oid. While the capability <code>report-status</code> cannot report for such case. See <a href="gitprotocol-pack">gitprotocol-pack[5]</a> for details.</p> </div> <h2 id="_delete_refs">Delete-refs</h2> <div class="sectionbody"> <p>If the server sends back the <code>delete-refs</code> capability, it means that it is capable of accepting a zero-id value as the target value of a reference update. It is not sent back by the client, it simply informs the client that it can be sent zero-id values to delete references.</p> </div> <h2 id="_quiet">Quiet</h2> <div class="sectionbody"> <p>If the receive-pack server advertises the <code>quiet</code> capability, it is capable of silencing human-readable progress output which otherwise may be shown when processing the received pack. A send-pack client should respond with the <code>quiet</code> capability to suppress server-side progress reporting if the local progress reporting is also being suppressed (e.g., via <code>push -q</code>, or if stderr does not go to a tty).</p> </div> <h2 id="_atomic">Atomic</h2> <div class="sectionbody"> <p>If the server sends the <code>atomic</code> capability it is capable of accepting atomic pushes. If the pushing client requests this capability, the server will update the refs in one atomic transaction. Either all refs are updated or none.</p> </div> <h2 id="_push_options">Push-options</h2> <div class="sectionbody"> <p>If the server sends the <code>push-options</code> capability it is able to accept push options after the update commands have been sent, but before the packfile is streamed. If the pushing client requests this capability, the server will pass the options to the pre- and post- receive hooks that process this push request.</p> </div> <h2 id="_allow_tip_sha1_in_want">Allow-tip-sha1-in-want</h2> <div class="sectionbody"> <p>If the upload-pack server advertises this capability, fetch-pack may send "want" lines with object names that exist at the server but are not advertised by upload-pack. For historical reasons, the name of this capability contains "sha1". Object names are always given using the object format negotiated through the <code>object-format</code> capability.</p> </div> <h2 id="_allow_reachable_sha1_in_want">Allow-reachable-sha1-in-want</h2> <div class="sectionbody"> <p>If the upload-pack server advertises this capability, fetch-pack may send "want" lines with object names that exist at the server but are not advertised by upload-pack. For historical reasons, the name of this capability contains "sha1". Object names are always given using the object format negotiated through the <code>object-format</code> capability.</p> </div> <h2 id="_push_certnonce">Push-cert=<nonce></h2> <div class="sectionbody"> <p>The receive-pack server that advertises this capability is willing to accept a signed push certificate, and asks the <nonce> to be included in the push certificate. A send-pack client MUST NOT send a push-cert packet unless the receive-pack server advertises this capability.</p> </div> <h2 id="_filter">Filter</h2> <div class="sectionbody"> <p>If the upload-pack server advertises the <code>filter</code> capability, fetch-pack may send "filter" commands to request a partial clone or partial fetch and request that the server omit various objects from the packfile.</p> </div> <h2 id="_session_idsession_id">Session-id=<session id></h2> <div class="sectionbody"> <p>The server may advertise a session ID that can be used to identify this process across multiple requests. The client may advertise its own session ID back to the server as well.</p> <p>Session IDs should be unique to a given process. They must fit within a packet-line, and must not contain non-printable or whitespace characters. The current implementation uses trace2 session IDs (see <a href="api-trace2">api-trace2</a> for details), but this may change and users of the session ID should not rely on this fact.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitprotocol-capabilities" class="_attribution-link">https://git-scm.com/docs/gitprotocol-capabilities</a> + </p> +</div> diff --git a/devdocs/git/gitprotocol-common.html b/devdocs/git/gitprotocol-common.html new file mode 100644 index 00000000..7d7112f1 --- /dev/null +++ b/devdocs/git/gitprotocol-common.html @@ -0,0 +1,22 @@ +<h1>gitprotocol-common</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitprotocol-common - Things common to various protocols</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content"><over-the-wire-protocol></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This document defines things common to various over-the-wire protocols and file formats used in Git.</p> </div> <h2 id="_abnf_notation">Abnf notation</h2> <div class="sectionbody"> <p>ABNF notation as described by RFC 5234 is used within the protocol documents, except the following replacement core rules are used:</p> <div class="listingblock"> <div class="content"> <pre> HEXDIG = DIGIT / "a" / "b" / "c" / "d" / "e" / "f"</pre> </div> </div> <p>We also define the following common rules:</p> <div class="listingblock"> <div class="content"> <pre> NUL = %x00 + zero-id = 40*"0" + obj-id = 40*(HEXDIGIT) + + refname = "HEAD" + refname /= "refs/" <see discussion below></pre> </div> </div> <p>A refname is a hierarchical octet string beginning with "refs/" and not violating the <code>git-check-ref-format</code> command’s validation rules. More specifically, they:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>They can include slash <code>/</code> for hierarchical (directory) grouping, but no slash-separated component can begin with a dot <code>.</code>.</p> </li> <li> <p>They must contain at least one <code>/</code>. This enforces the presence of a category like <code>heads/</code>, <code>tags/</code> etc. but the actual names are not restricted.</p> </li> <li> <p>They cannot have two consecutive dots <code>..</code> anywhere.</p> </li> <li> <p>They cannot have ASCII control characters (i.e. bytes whose values are lower than \040, or \177 <code>DEL</code>), space, tilde <code>~</code>, caret <code>^</code>, colon <code>:</code>, question-mark <code>?</code>, asterisk <code>*</code>, or open bracket <code>[</code> anywhere.</p> </li> <li> <p>They cannot end with a slash <code>/</code> or a dot <code>.</code>.</p> </li> <li> <p>They cannot end with the sequence <code>.lock</code>.</p> </li> <li> <p>They cannot contain a sequence <code>@{</code>.</p> </li> <li> <p>They cannot contain a <code>\\</code>.</p> </li> </ol> </div> </div> <h2 id="_pkt_line_format">Pkt-line format</h2> <div class="sectionbody"> <p>Much (but not all) of the payload is described around pkt-lines.</p> <p>A pkt-line is a variable length binary string. The first four bytes of the line, the pkt-len, indicates the total length of the line, in hexadecimal. The pkt-len includes the 4 bytes used to contain the length’s hexadecimal representation.</p> <p>A pkt-line MAY contain binary data, so implementors MUST ensure pkt-line parsing/formatting routines are 8-bit clean.</p> <p>A non-binary line SHOULD BE terminated by an LF, which if present MUST be included in the total length. Receivers MUST treat pkt-lines with non-binary data the same whether or not they contain the trailing LF (stripping the LF if present, and not complaining when it is missing).</p> <p>The maximum length of a pkt-line’s data component is 65516 bytes. Implementations MUST NOT send pkt-line whose length exceeds 65520 (65516 bytes of payload + 4 bytes of length data).</p> <p>Implementations SHOULD NOT send an empty pkt-line ("0004").</p> <p>A pkt-line with a length field of 0 ("0000"), called a flush-pkt, is a special case and MUST be handled differently than an empty pkt-line ("0004").</p> <div class="listingblock"> <div class="content"> <pre> pkt-line = data-pkt / flush-pkt + + data-pkt = pkt-len pkt-payload + pkt-len = 4*(HEXDIG) + pkt-payload = (pkt-len - 4)*(OCTET) + + flush-pkt = "0000"</pre> </div> </div> <p>Examples (as C-style strings):</p> <div class="listingblock"> <div class="content"> <pre> pkt-line actual value + --------------------------------- + "0006a\n" "a\n" + "0005a" "a" + "000bfoobar\n" "foobar\n" + "0004" ""</pre> </div> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitprotocol-common" class="_attribution-link">https://git-scm.com/docs/gitprotocol-common</a> + </p> +</div> diff --git a/devdocs/git/gitprotocol-http.html b/devdocs/git/gitprotocol-http.html new file mode 100644 index 00000000..d5b3babc --- /dev/null +++ b/devdocs/git/gitprotocol-http.html @@ -0,0 +1,90 @@ +<h1>gitprotocol-http</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitprotocol-http - Git HTTP-based protocols</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content"><over-the-wire-protocol></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Git supports two HTTP based transfer protocols. A "dumb" protocol which requires only a standard HTTP server on the server end of the connection, and a "smart" protocol which requires a Git aware CGI (or server module). This document describes both protocols.</p> <p>As a design feature smart clients can automatically upgrade "dumb" protocol URLs to smart URLs. This permits all users to have the same published URL, and the peers automatically select the most efficient transport available to them.</p> </div> <h2 id="_url_format">Url format</h2> <div class="sectionbody"> <p>URLs for Git repositories accessed by HTTP use the standard HTTP URL syntax documented by RFC 1738, so they are of the form:</p> <div class="literalblock"> <div class="content"> <pre>http://<host>:<port>/<path>?<searchpart></pre> </div> </div> <p>Within this documentation the placeholder <code>$GIT_URL</code> will stand for the http:// repository URL entered by the end-user.</p> <p>Servers SHOULD handle all requests to locations matching <code>$GIT_URL</code>, as both the "smart" and "dumb" HTTP protocols used by Git operate by appending additional path components onto the end of the user supplied <code>$GIT_URL</code> string.</p> <p>An example of a dumb client requesting a loose object:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$GIT_URL: http://example.com:8080/git/repo.git +URL request: http://example.com:8080/git/repo.git/objects/d0/49f6c27a2244e12041955e262a404c7faba355</pre> </div> </div> <p>An example of a smart request to a catch-all gateway:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$GIT_URL: http://example.com/daemon.cgi?svc=git&q= +URL request: http://example.com/daemon.cgi?svc=git&q=/info/refs&service=git-receive-pack</pre> </div> </div> <p>An example of a request to a submodule:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$GIT_URL: http://example.com/git/repo.git/path/submodule.git +URL request: http://example.com/git/repo.git/path/submodule.git/info/refs</pre> </div> </div> <p>Clients MUST strip a trailing <code>/</code>, if present, from the user supplied <code>$GIT_URL</code> string to prevent empty path tokens (<code>//</code>) from appearing in any URL sent to a server. Compatible clients MUST expand <code>$GIT_URL/info/refs</code> as <code>foo/info/refs</code> and not <code>foo//info/refs</code>.</p> </div> <h2 id="_authentication">Authentication</h2> <div class="sectionbody"> <p>Standard HTTP authentication is used if authentication is required to access a repository, and MAY be configured and enforced by the HTTP server software.</p> <p>Because Git repositories are accessed by standard path components server administrators MAY use directory based permissions within their HTTP server to control repository access.</p> <p>Clients SHOULD support Basic authentication as described by RFC 2617. Servers SHOULD support Basic authentication by relying upon the HTTP server placed in front of the Git server software.</p> <p>Servers SHOULD NOT require HTTP cookies for the purposes of authentication or access control.</p> <p>Clients and servers MAY support other common forms of HTTP based authentication, such as Digest authentication.</p> </div> <h2 id="_ssl">Ssl</h2> <div class="sectionbody"> <p>Clients and servers SHOULD support SSL, particularly to protect passwords when relying on Basic HTTP authentication.</p> </div> <h2 id="_session_state">Session state</h2> <div class="sectionbody"> <p>The Git over HTTP protocol (much like HTTP itself) is stateless from the perspective of the HTTP server side. All state MUST be retained and managed by the client process. This permits simple round-robin load-balancing on the server side, without needing to worry about state management.</p> <p>Clients MUST NOT require state management on the server side in order to function correctly.</p> <p>Servers MUST NOT require HTTP cookies in order to function correctly. Clients MAY store and forward HTTP cookies during request processing as described by RFC 2616 (HTTP/1.1). Servers SHOULD ignore any cookies sent by a client.</p> </div> <h2 id="_general_request_processing">General request processing</h2> <div class="sectionbody"> <p>Except where noted, all standard HTTP behavior SHOULD be assumed by both client and server. This includes (but is not necessarily limited to):</p> <p>If there is no repository at <code>$GIT_URL</code>, or the resource pointed to by a location matching <code>$GIT_URL</code> does not exist, the server MUST NOT respond with <code>200 OK</code> response. A server SHOULD respond with <code>404 Not Found</code>, <code>410 Gone</code>, or any other suitable HTTP status code which does not imply the resource exists as requested.</p> <p>If there is a repository at <code>$GIT_URL</code>, but access is not currently permitted, the server MUST respond with the <code>403 Forbidden</code> HTTP status code.</p> <p>Servers SHOULD support both HTTP 1.0 and HTTP 1.1. Servers SHOULD support chunked encoding for both request and response bodies.</p> <p>Clients SHOULD support both HTTP 1.0 and HTTP 1.1. Clients SHOULD support chunked encoding for both request and response bodies.</p> <p>Servers MAY return ETag and/or Last-Modified headers.</p> <p>Clients MAY revalidate cached entities by including If-Modified-Since and/or If-None-Match request headers.</p> <p>Servers MAY return <code>304 Not Modified</code> if the relevant headers appear in the request and the entity has not changed. Clients MUST treat <code>304 Not Modified</code> identical to <code>200 OK</code> by reusing the cached entity.</p> <p>Clients MAY reuse a cached entity without revalidation if the Cache-Control and/or Expires header permits caching. Clients and servers MUST follow RFC 2616 for cache controls.</p> </div> <h2 id="_discovering_references">Discovering references</h2> <div class="sectionbody"> <p>All HTTP clients MUST begin either a fetch or a push exchange by discovering the references available on the remote repository.</p> <div class="sect2"> <h3 id="_dumb_clients"> +Dumb Clients</h3> <p>HTTP clients that only support the "dumb" protocol MUST discover references by making a request for the special info/refs file of the repository.</p> <p>Dumb HTTP clients MUST make a <code>GET</code> request to <code>$GIT_URL/info/refs</code>, without any search/query parameters.</p> <div class="literalblock"> <div class="content"> <pre>C: GET $GIT_URL/info/refs HTTP/1.0</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>S: 200 OK +S: +S: 95dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint +S: d049f6c27a2244e12041955e262a404c7faba355 refs/heads/master +S: 2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0 +S: a3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}</pre> </div> </div> <p>The Content-Type of the returned info/refs entity SHOULD be <code>text/plain; charset=utf-8</code>, but MAY be any content type. Clients MUST NOT attempt to validate the returned Content-Type. Dumb servers MUST NOT return a return type starting with <code>application/x-git-</code>.</p> <p>Cache-Control headers MAY be returned to disable caching of the returned entity.</p> <p>When examining the response clients SHOULD only examine the HTTP status code. Valid responses are <code>200 OK</code>, or <code>304 Not Modified</code>.</p> <p>The returned content is a UNIX formatted text file describing each ref and its known value. The file SHOULD be sorted by name according to the C locale ordering. The file SHOULD NOT include the default ref named <code>HEAD</code>.</p> <div class="literalblock"> <div class="content"> <pre>info_refs = *( ref_record ) +ref_record = any_ref / peeled_ref</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>any_ref = obj-id HTAB refname LF +peeled_ref = obj-id HTAB refname LF + obj-id HTAB refname "^{}" LF</pre> </div> </div> </div> <div class="sect2"> <h3 id="_smart_clients"> +Smart Clients</h3> <p>HTTP clients that support the "smart" protocol (or both the "smart" and "dumb" protocols) MUST discover references by making a parameterized request for the info/refs file of the repository.</p> <p>The request MUST contain exactly one query parameter, <code>service=$servicename</code>, where <code>$servicename</code> MUST be the service name the client wishes to contact to complete the operation. The request MUST NOT contain additional query parameters.</p> <div class="literalblock"> <div class="content"> <pre>C: GET $GIT_URL/info/refs?service=git-upload-pack HTTP/1.0</pre> </div> </div> <p>dumb server reply:</p> <div class="literalblock"> <div class="content"> <pre>S: 200 OK +S: +S: 95dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint +S: d049f6c27a2244e12041955e262a404c7faba355 refs/heads/master +S: 2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0 +S: a3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}</pre> </div> </div> <p>smart server reply:</p> <div class="literalblock"> <div class="content"> <pre>S: 200 OK +S: Content-Type: application/x-git-upload-pack-advertisement +S: Cache-Control: no-cache +S: +S: 001e# service=git-upload-pack\n +S: 0000 +S: 004895dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint\0multi_ack\n +S: 003fd049f6c27a2244e12041955e262a404c7faba355 refs/heads/master\n +S: 003c2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0\n +S: 003fa3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}\n +S: 0000</pre> </div> </div> <p>The client may send Extra Parameters (see <a href="gitprotocol-pack">gitprotocol-pack[5]</a>) as a colon-separated string in the Git-Protocol HTTP header.</p> <p>Uses the <code>--http-backend-info-refs</code> option to <a href="git-upload-pack">git-upload-pack[1]</a>.</p> <div class="sect3"> <h4 id="_dumb_server_response"> +Dumb Server Response</h4> <p>Dumb servers MUST respond with the dumb server reply format.</p> <p>See the prior section under dumb clients for a more detailed description of the dumb server response.</p> </div> <div class="sect3"> <h4 id="_smart_server_response"> +Smart Server Response</h4> <p>If the server does not recognize the requested service name, or the requested service name has been disabled by the server administrator, the server MUST respond with the <code>403 Forbidden</code> HTTP status code.</p> <p>Otherwise, smart servers MUST respond with the smart server reply format for the requested service name.</p> <p>Cache-Control headers SHOULD be used to disable caching of the returned entity.</p> <p>The Content-Type MUST be <code>application/x-$servicename-advertisement</code>. Clients SHOULD fall back to the dumb protocol if another content type is returned. When falling back to the dumb protocol clients SHOULD NOT make an additional request to <code>$GIT_URL/info/refs</code>, but instead SHOULD use the response already in hand. Clients MUST NOT continue if they do not support the dumb protocol.</p> <p>Clients MUST validate the status code is either <code>200 OK</code> or <code>304 Not Modified</code>.</p> <p>Clients MUST validate the first five bytes of the response entity matches the regex <code>^[0-9a-f]{4}#</code>. If this test fails, clients MUST NOT continue.</p> <p>Clients MUST parse the entire response as a sequence of pkt-line records.</p> <p>Clients MUST verify the first pkt-line is <code># service=$servicename</code>. Servers MUST set $servicename to be the request parameter value. Servers SHOULD include an LF at the end of this line. Clients MUST ignore an LF at the end of the line.</p> <p>Servers MUST terminate the response with the magic <code>0000</code> end pkt-line marker.</p> <p>The returned response is a pkt-line stream describing each ref and its known value. The stream SHOULD be sorted by name according to the C locale ordering. The stream SHOULD include the default ref named <code>HEAD</code> as the first ref. The stream MUST include capability declarations behind a NUL on the first ref.</p> <p>The returned response contains "version 1" if "version=1" was sent as an Extra Parameter.</p> <div class="literalblock"> <div class="content"> <pre>smart_reply = PKT-LINE("# service=$servicename" LF) + "0000" + *1("version 1") + ref_list + "0000" +ref_list = empty_list / non_empty_list</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>empty_list = PKT-LINE(zero-id SP "capabilities^{}" NUL cap-list LF)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>non_empty_list = PKT-LINE(obj-id SP name NUL cap_list LF) + *ref_record</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>cap-list = capability *(SP capability) +capability = 1*(LC_ALPHA / DIGIT / "-" / "_") +LC_ALPHA = %x61-7A</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>ref_record = any_ref / peeled_ref +any_ref = PKT-LINE(obj-id SP name LF) +peeled_ref = PKT-LINE(obj-id SP name LF) + PKT-LINE(obj-id SP name "^{}" LF</pre> </div> </div> </div> </div> </div> <h2 id="_smart_service_git_upload_pack">Smart service git-upload-pack</h2> <div class="sectionbody"> <p>This service reads from the repository pointed to by <code>$GIT_URL</code>.</p> <p>Clients MUST first perform ref discovery with <code>$GIT_URL/info/refs?service=git-upload-pack</code>.</p> <div class="literalblock"> <div class="content"> <pre>C: POST $GIT_URL/git-upload-pack HTTP/1.0 +C: Content-Type: application/x-git-upload-pack-request +C: +C: 0032want 0a53e9ddeaddad63ad106860237bbf53411d11a7\n +C: 0032have 441b40d833fdfa93eb2908e52742248faf0ee993\n +C: 0000</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>S: 200 OK +S: Content-Type: application/x-git-upload-pack-result +S: Cache-Control: no-cache +S: +S: ....ACK %s, continue +S: ....NAK</pre> </div> </div> <p>Clients MUST NOT reuse or revalidate a cached response. Servers MUST include sufficient Cache-Control headers to prevent caching of the response.</p> <p>Servers SHOULD support all capabilities defined here.</p> <p>Clients MUST send at least one "want" command in the request body. Clients MUST NOT reference an id in a "want" command which did not appear in the response obtained through ref discovery unless the server advertises capability <code>allow-tip-sha1-in-want</code> or <code>allow-reachable-sha1-in-want</code>.</p> <div class="literalblock"> <div class="content"> <pre>compute_request = want_list + have_list + request_end +request_end = "0000" / "done"</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>want_list = PKT-LINE(want SP cap_list LF) + *(want_pkt) +want_pkt = PKT-LINE(want LF) +want = "want" SP id +cap_list = capability *(SP capability)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>have_list = *PKT-LINE("have" SP id LF)</pre> </div> </div> <p>TODO: Document this further.</p> <div class="sect2"> <h3 id="_the_negotiation_algorithm"> +The Negotiation Algorithm</h3> <p>The computation to select the minimal pack proceeds as follows (C = client, S = server):</p> <p><code>init step:</code></p> <p>C: Use ref discovery to obtain the advertised refs.</p> <p>C: Place any object seen into set <code>advertised</code>.</p> <p>C: Build an empty set, <code>common</code>, to hold the objects that are later determined to be on both ends.</p> <p>C: Build a set, <code>want</code>, of the objects from <code>advertised</code> that the client wants to fetch, based on what it saw during ref discovery.</p> <p>C: Start a queue, <code>c_pending</code>, ordered by commit time (popping newest first). Add all client refs. When a commit is popped from the queue its parents SHOULD be automatically inserted back. Commits MUST only enter the queue once.</p> <p><code>one compute step:</code></p> <p>C: Send one <code>$GIT_URL/git-upload-pack</code> request:</p> <div class="literalblock"> <div class="content"> <pre>C: 0032want <want #1>............................... +C: 0032want <want #2>............................... +.... +C: 0032have <common #1>............................. +C: 0032have <common #2>............................. +.... +C: 0032have <have #1>............................... +C: 0032have <have #2>............................... +.... +C: 0000</pre> </div> </div> <p>The stream is organized into "commands", with each command appearing by itself in a pkt-line. Within a command line, the text leading up to the first space is the command name, and the remainder of the line to the first LF is the value. Command lines are terminated with an LF as the last byte of the pkt-line value.</p> <p>Commands MUST appear in the following order, if they appear at all in the request stream:</p> <div class="ulist"> <ul> <li> <p>"want"</p> </li> <li> <p>"have"</p> </li> </ul> </div> <p>The stream is terminated by a pkt-line flush (<code>0000</code>).</p> <p>A single "want" or "have" command MUST have one hex formatted object name as its value. Multiple object names MUST be sent by sending multiple commands. Object names MUST be given using the object format negotiated through the <code>object-format</code> capability (default SHA-1).</p> <p>The <code>have</code> list is created by popping the first 32 commits from <code>c_pending</code>. Fewer can be supplied if <code>c_pending</code> empties.</p> <p>If the client has sent 256 "have" commits and has not yet received one of those back from <code>s_common</code>, or the client has emptied <code>c_pending</code> it SHOULD include a "done" command to let the server know it won’t proceed:</p> <div class="literalblock"> <div class="content"> <pre>C: 0009done</pre> </div> </div> <p>S: Parse the git-upload-pack request:</p> <p>Verify all objects in <code>want</code> are directly reachable from refs.</p> <p>The server MAY walk backwards through history or through the reflog to permit slightly stale requests.</p> <p>If no "want" objects are received, send an error: TODO: Define error if no "want" lines are requested.</p> <p>If any "want" object is not reachable, send an error: TODO: Define error if an invalid "want" is requested.</p> <p>Create an empty list, <code>s_common</code>.</p> <p>If "have" was sent:</p> <p>Loop through the objects in the order supplied by the client.</p> <p>For each object, if the server has the object reachable from a ref, add it to <code>s_common</code>. If a commit is added to <code>s_common</code>, do not add any ancestors, even if they also appear in <code>have</code>.</p> <p>S: Send the git-upload-pack response:</p> <p>If the server has found a closed set of objects to pack or the request ends with "done", it replies with the pack. TODO: Document the pack based response</p> <div class="literalblock"> <div class="content"> <pre>S: PACK...</pre> </div> </div> <p>The returned stream is the side-band-64k protocol supported by the git-upload-pack service, and the pack is embedded into stream 1. Progress messages from the server side MAY appear in stream 2.</p> <p>Here a "closed set of objects" is defined to have at least one path from every "want" to at least one "common" object.</p> <p>If the server needs more information, it replies with a status continue response: TODO: Document the non-pack response</p> <p>C: Parse the upload-pack response: TODO: Document parsing response</p> <p><code>Do another compute step.</code></p> </div> </div> <h2 id="_smart_service_git_receive_pack">Smart service git-receive-pack</h2> <div class="sectionbody"> <p>This service reads from the repository pointed to by <code>$GIT_URL</code>.</p> <p>Clients MUST first perform ref discovery with <code>$GIT_URL/info/refs?service=git-receive-pack</code>.</p> <div class="literalblock"> <div class="content"> <pre>C: POST $GIT_URL/git-receive-pack HTTP/1.0 +C: Content-Type: application/x-git-receive-pack-request +C: +C: ....0a53e9ddeaddad63ad106860237bbf53411d11a7 441b40d833fdfa93eb2908e52742248faf0ee993 refs/heads/maint\0 report-status +C: 0000 +C: PACK....</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>S: 200 OK +S: Content-Type: application/x-git-receive-pack-result +S: Cache-Control: no-cache +S: +S: ....</pre> </div> </div> <p>Clients MUST NOT reuse or revalidate a cached response. Servers MUST include sufficient Cache-Control headers to prevent caching of the response.</p> <p>Servers SHOULD support all capabilities defined here.</p> <p>Clients MUST send at least one command in the request body. Within the command portion of the request body clients SHOULD send the id obtained through ref discovery as old_id.</p> <div class="literalblock"> <div class="content"> <pre>update_request = command_list + "PACK" <binary data></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>command_list = PKT-LINE(command NUL cap_list LF) + *(command_pkt) +command_pkt = PKT-LINE(command LF) +cap_list = *(SP capability) SP</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>command = create / delete / update +create = zero-id SP new_id SP name +delete = old_id SP zero-id SP name +update = old_id SP new_id SP name</pre> </div> </div> <p>TODO: Document this further.</p> </div> <h2 id="_references">References</h2> <div class="sectionbody"> <p><a href="https://www.ietf.org/rfc/rfc1738.txt">RFC 1738: Uniform Resource Locators (URL)</a> <a href="https://www.ietf.org/rfc/rfc2616.txt">RFC 2616: Hypertext Transfer Protocol — HTTP/1.1</a></p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gitprotocol-pack">gitprotocol-pack[5]</a> <a href="gitprotocol-capabilities">gitprotocol-capabilities[5]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitprotocol-http" class="_attribution-link">https://git-scm.com/docs/gitprotocol-http</a> + </p> +</div> diff --git a/devdocs/git/gitprotocol-pack.html b/devdocs/git/gitprotocol-pack.html new file mode 100644 index 00000000..c64cad4e --- /dev/null +++ b/devdocs/git/gitprotocol-pack.html @@ -0,0 +1,191 @@ +<h1>gitprotocol-pack</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitprotocol-pack - How packs are transferred over-the-wire</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content"><over-the-wire-protocol></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Git supports transferring data in packfiles over the ssh://, git://, http:// and file:// transports. There exist two sets of protocols, one for pushing data from a client to a server and another for fetching data from a server to a client. The three transports (ssh, git, file) use the same protocol to transfer data. http is documented in <a href="gitprotocol-http">gitprotocol-http[5]</a>.</p> <p>The processes invoked in the canonical Git implementation are <code>upload-pack</code> on the server side and <code>fetch-pack</code> on the client side for fetching data; then <code>receive-pack</code> on the server and <code>send-pack</code> on the client for pushing data. The protocol functions to have a server tell a client what is currently on the server, then for the two to negotiate the smallest amount of data to send in order to fully update one or the other.</p> </div> <h2 id="_pkt_line_format">Pkt-line format</h2> <div class="sectionbody"> <p>The descriptions below build on the pkt-line format described in <a href="gitprotocol-common">gitprotocol-common[5]</a>. When the grammar indicates <code>PKT-LINE(...)</code>, unless otherwise noted the usual pkt-line LF rules apply: the sender SHOULD include a LF, but the receiver MUST NOT complain if it is not present.</p> <p>An error packet is a special pkt-line that contains an error string.</p> <div class="listingblock"> <div class="content"> <pre> error-line = PKT-LINE("ERR" SP explanation-text)</pre> </div> </div> <p>Throughout the protocol, where <code>PKT-LINE(...)</code> is expected, an error packet MAY be sent. Once this packet is sent by a client or a server, the data transfer process defined in this protocol is terminated.</p> </div> <h2 id="_transports">Transports</h2> <div class="sectionbody"> <p>There are three transports over which the packfile protocol is initiated. The Git transport is a simple, unauthenticated server that takes the command (almost always <code>upload-pack</code>, though Git servers can be configured to be globally writable, in which <code>receive- pack</code> initiation is also allowed) with which the client wishes to communicate and executes it and connects it to the requesting process.</p> <p>In the SSH transport, the client just runs the <code>upload-pack</code> or <code>receive-pack</code> process on the server over the SSH protocol and then communicates with that invoked process over the SSH connection.</p> <p>The file:// transport runs the <code>upload-pack</code> or <code>receive-pack</code> process locally and communicates with it over a pipe.</p> </div> <h2 id="_extra_parameters">Extra parameters</h2> <div class="sectionbody"> <p>The protocol provides a mechanism in which clients can send additional information in its first message to the server. These are called "Extra Parameters", and are supported by the Git, SSH, and HTTP protocols.</p> <p>Each Extra Parameter takes the form of <code><key>=<value></code> or <code><key></code>.</p> <p>Servers that receive any such Extra Parameters MUST ignore all unrecognized keys. Currently, the only Extra Parameter recognized is "version" with a value of <code>1</code> or <code>2</code>. See <a href="gitprotocol-v2">gitprotocol-v2[5]</a> for more information on protocol version 2.</p> </div> <h2 id="_git_transport">Git transport</h2> <div class="sectionbody"> <p>The Git transport starts off by sending the command and repository on the wire using the pkt-line format, followed by a NUL byte and a hostname parameter, terminated by a NUL byte.</p> <div class="literalblock"> <div class="content"> <pre>0033git-upload-pack /project.git\0host=myserver.com\0</pre> </div> </div> <p>The transport may send Extra Parameters by adding an additional NUL byte, and then adding one or more NUL-terminated strings:</p> <div class="literalblock"> <div class="content"> <pre>003egit-upload-pack /project.git\0host=myserver.com\0\0version=1\0</pre> </div> </div> <div class="openblock"> <div class="content"> <div class="literalblock"> <div class="content"> <pre>git-proto-request = request-command SP pathname NUL + [ host-parameter NUL ] [ NUL extra-parameters ] +request-command = "git-upload-pack" / "git-receive-pack" / + "git-upload-archive" ; case sensitive +pathname = *( %x01-ff ) ; exclude NUL +host-parameter = "host=" hostname [ ":" port ] +extra-parameters = 1*extra-parameter +extra-parameter = 1*( %x01-ff ) NUL</pre> </div> </div> </div> </div> <p>host-parameter is used for the git-daemon name based virtual hosting. See --interpolated-path option to git daemon, with the %H/%CH format characters.</p> <p>Basically what the Git client is doing to connect to an <code>upload-pack</code> process on the server side over the Git protocol is this:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$ echo -e -n \ + "003agit-upload-pack /schacon/gitbook.git\0host=example.com\0" | + nc -v example.com 9418</pre> </div> </div> </div> <h2 id="_ssh_transport">Ssh transport</h2> <div class="sectionbody"> <p>Initiating the upload-pack or receive-pack processes over SSH is executing the binary on the server via SSH remote execution. It is basically equivalent to running this:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$ ssh git.example.com "git-upload-pack '/project.git'"</pre> </div> </div> <p>For a server to support Git pushing and pulling for a given user over SSH, that user needs to be able to execute one or both of those commands via the SSH shell that they are provided on login. On some systems, that shell access is limited to only being able to run those two commands, or even just one of them.</p> <p>In an ssh:// format URI, it’s absolute in the URI, so the <code>/</code> after the host name (or port number) is sent as an argument, which is then read by the remote git-upload-pack exactly as is, so it’s effectively an absolute path in the remote filesystem.</p> <div class="literalblock"> <div class="content"> <pre> git clone ssh://user@example.com/project.git + | + v +ssh user@example.com "git-upload-pack '/project.git'"</pre> </div> </div> <p>In a "user@host:path" format URI, it’s relative to the user’s home directory, because the Git client will run:</p> <div class="literalblock"> <div class="content"> <pre> git clone user@example.com:project.git + | + v +ssh user@example.com "git-upload-pack 'project.git'"</pre> </div> </div> <p>The exception is if a <code>~</code> is used, in which case we execute it without the leading <code>/</code>.</p> <div class="literalblock"> <div class="content"> <pre> ssh://user@example.com/~alice/project.git, + | + v +ssh user@example.com "git-upload-pack '~alice/project.git'"</pre> </div> </div> <p>Depending on the value of the <code>protocol.version</code> configuration variable, Git may attempt to send Extra Parameters as a colon-separated string in the GIT_PROTOCOL environment variable. This is done only if the <code>ssh.variant</code> configuration variable indicates that the ssh command supports passing environment variables as an argument.</p> <p>A few things to remember here:</p> <div class="ulist"> <ul> <li> <p>The "command name" is spelled with dash (e.g. git-upload-pack), but this can be overridden by the client;</p> </li> <li> <p>The repository path is always quoted with single quotes.</p> </li> </ul> </div> </div> <h2 id="_fetching_data_from_a_server">Fetching data from a server</h2> <div class="sectionbody"> <p>When one Git repository wants to get data that a second repository has, the first can <code>fetch</code> from the second. This operation determines what data the server has that the client does not then streams that data down to the client in packfile format.</p> </div> <h2 id="_reference_discovery">Reference discovery</h2> <div class="sectionbody"> <p>When the client initially connects the server will immediately respond with a version number (if "version=1" is sent as an Extra Parameter), and a listing of each reference it has (all branches and tags) along with the object name that each reference currently points to.</p> <div class="literalblock"> <div class="content"> <pre> $ echo -e -n "0045git-upload-pack /schacon/gitbook.git\0host=example.com\0\0version=1\0" | + nc -v example.com 9418 + 000eversion 1 + 00887217a7c7e582c46cec22a130adf4b9d7d950fba0 HEAD\0multi_ack thin-pack +side-band side-band-64k ofs-delta shallow no-progress include-tag + 00441d3fcd5ced445d1abc402225c0b8a1299641f497 refs/heads/integration + 003f7217a7c7e582c46cec22a130adf4b9d7d950fba0 refs/heads/master + 003cb88d2441cac0977faf98efc80305012112238d9d refs/tags/v0.9 + 003c525128480b96c89e6418b1e40909bf6c5b2d580f refs/tags/v1.0 + 003fe92df48743b7bc7d26bcaabfddde0a1e20cae47c refs/tags/v1.0^{} + 0000</pre> </div> </div> <p>The returned response is a pkt-line stream describing each ref and its current value. The stream MUST be sorted by name according to the C locale ordering.</p> <p>If HEAD is a valid ref, HEAD MUST appear as the first advertised ref. If HEAD is not a valid ref, HEAD MUST NOT appear in the advertisement list at all, but other refs may still appear.</p> <p>The stream MUST include capability declarations behind a NUL on the first ref. The peeled value of a ref (that is "ref^{}") MUST be immediately after the ref itself, if presented. A conforming server MUST peel the ref if it’s an annotated tag.</p> <div class="listingblock"> <div class="content"> <pre> advertised-refs = *1("version 1") + (no-refs / list-of-refs) + *shallow + flush-pkt + + no-refs = PKT-LINE(zero-id SP "capabilities^{}" + NUL capability-list) + + list-of-refs = first-ref *other-ref + first-ref = PKT-LINE(obj-id SP refname + NUL capability-list) + + other-ref = PKT-LINE(other-tip / other-peeled) + other-tip = obj-id SP refname + other-peeled = obj-id SP refname "^{}" + + shallow = PKT-LINE("shallow" SP obj-id) + + capability-list = capability *(SP capability) + capability = 1*(LC_ALPHA / DIGIT / "-" / "_") + LC_ALPHA = %x61-7A</pre> </div> </div> <p>Server and client MUST use lowercase for obj-id, both MUST treat obj-id as case-insensitive.</p> <p>See protocol-capabilities.txt for a list of allowed server capabilities and descriptions.</p> </div> <h2 id="_packfile_negotiation">Packfile negotiation</h2> <div class="sectionbody"> <p>After reference and capabilities discovery, the client can decide to terminate the connection by sending a flush-pkt, telling the server it can now gracefully terminate, and disconnect, when it does not need any pack data. This can happen with the ls-remote command, and also can happen when the client already is up to date.</p> <p>Otherwise, it enters the negotiation phase, where the client and server determine what the minimal packfile necessary for transport is, by telling the server what objects it wants, its shallow objects (if any), and the maximum commit depth it wants (if any). The client will also send a list of the capabilities it wants to be in effect, out of what the server said it could do with the first <code>want</code> line.</p> <div class="listingblock"> <div class="content"> <pre> upload-request = want-list + *shallow-line + *1depth-request + [filter-request] + flush-pkt + + want-list = first-want + *additional-want + + shallow-line = PKT-LINE("shallow" SP obj-id) + + depth-request = PKT-LINE("deepen" SP depth) / + PKT-LINE("deepen-since" SP timestamp) / + PKT-LINE("deepen-not" SP ref) + + first-want = PKT-LINE("want" SP obj-id SP capability-list) + additional-want = PKT-LINE("want" SP obj-id) + + depth = 1*DIGIT + + filter-request = PKT-LINE("filter" SP filter-spec)</pre> </div> </div> <p>Clients MUST send all the obj-ids it wants from the reference discovery phase as <code>want</code> lines. Clients MUST send at least one <code>want</code> command in the request body. Clients MUST NOT mention an obj-id in a <code>want</code> command which did not appear in the response obtained through ref discovery.</p> <p>The client MUST write all obj-ids which it only has shallow copies of (meaning that it does not have the parents of a commit) as <code>shallow</code> lines so that the server is aware of the limitations of the client’s history.</p> <p>The client now sends the maximum commit history depth it wants for this transaction, which is the number of commits it wants from the tip of the history, if any, as a <code>deepen</code> line. A depth of 0 is the same as not making a depth request. The client does not want to receive any commits beyond this depth, nor does it want objects needed only to complete those commits. Commits whose parents are not received as a result are defined as shallow and marked as such in the server. This information is sent back to the client in the next step.</p> <p>The client can optionally request that pack-objects omit various objects from the packfile using one of several filtering techniques. These are intended for use with partial clone and partial fetch operations. An object that does not meet a filter-spec value is omitted unless explicitly requested in a <code>want</code> line. See <code>rev-list</code> for possible filter-spec values.</p> <p>Once all the <code>want’s and 'shallow’s (and optional 'deepen</code>) are transferred, clients MUST send a flush-pkt, to tell the server side that it is done sending the list.</p> <p>Otherwise, if the client sent a positive depth request, the server will determine which commits will and will not be shallow and send this information to the client. If the client did not request a positive depth, this step is skipped.</p> <div class="listingblock"> <div class="content"> <pre> shallow-update = *shallow-line + *unshallow-line + flush-pkt + + shallow-line = PKT-LINE("shallow" SP obj-id) + + unshallow-line = PKT-LINE("unshallow" SP obj-id)</pre> </div> </div> <p>If the client has requested a positive depth, the server will compute the set of commits which are no deeper than the desired depth. The set of commits starts at the client’s wants.</p> <p>The server writes <code>shallow</code> lines for each commit whose parents will not be sent as a result. The server writes an <code>unshallow</code> line for each commit which the client has indicated is shallow, but is no longer shallow at the currently requested depth (that is, its parents will now be sent). The server MUST NOT mark as unshallow anything which the client has not indicated was shallow.</p> <p>Now the client will send a list of the obj-ids it has using <code>have</code> lines, so the server can make a packfile that only contains the objects that the client needs. In multi_ack mode, the canonical implementation will send up to 32 of these at a time, then will send a flush-pkt. The canonical implementation will skip ahead and send the next 32 immediately, so that there is always a block of 32 "in-flight on the wire" at a time.</p> <div class="listingblock"> <div class="content"> <pre> upload-haves = have-list + compute-end + + have-list = *have-line + have-line = PKT-LINE("have" SP obj-id) + compute-end = flush-pkt / PKT-LINE("done")</pre> </div> </div> <p>If the server reads <code>have</code> lines, it then will respond by ACKing any of the obj-ids the client said it had that the server also has. The server will ACK obj-ids differently depending on which ack mode is chosen by the client.</p> <p>In multi_ack mode:</p> <div class="ulist"> <ul> <li> <p>the server will respond with <code>ACK obj-id continue</code> for any common commits.</p> </li> <li> <p>once the server has found an acceptable common base commit and is ready to make a packfile, it will blindly ACK all <code>have</code> obj-ids back to the client.</p> </li> <li> <p>the server will then send a <code>NAK</code> and then wait for another response from the client - either a <code>done</code> or another list of <code>have</code> lines.</p> </li> </ul> </div> <p>In multi_ack_detailed mode:</p> <div class="ulist"> <ul> <li> <p>the server will differentiate the ACKs where it is signaling that it is ready to send data with <code>ACK obj-id ready</code> lines, and signals the identified common commits with <code>ACK obj-id common</code> lines.</p> </li> </ul> </div> <p>Without either multi_ack or multi_ack_detailed:</p> <div class="ulist"> <ul> <li> <p>upload-pack sends "ACK obj-id" on the first common object it finds. After that it says nothing until the client gives it a "done".</p> </li> <li> <p>upload-pack sends "NAK" on a flush-pkt if no common object has been found yet. If one has been found, and thus an ACK was already sent, it’s silent on the flush-pkt.</p> </li> </ul> </div> <p>After the client has gotten enough ACK responses that it can determine that the server has enough information to send an efficient packfile (in the canonical implementation, this is determined when it has received enough ACKs that it can color everything left in the --date-order queue as common with the server, or the --date-order queue is empty), or the client determines that it wants to give up (in the canonical implementation, this is determined when the client sends 256 <code>have</code> lines without getting any of them ACKed by the server - meaning there is nothing in common and the server should just send all of its objects), then the client will send a <code>done</code> command. The <code>done</code> command signals to the server that the client is ready to receive its packfile data.</p> <p>However, the 256 limit <strong>only</strong> turns on in the canonical client implementation if we have received at least one "ACK %s continue" during a prior round. This helps to ensure that at least one common ancestor is found before we give up entirely.</p> <p>Once the <code>done</code> line is read from the client, the server will either send a final <code>ACK obj-id</code> or it will send a <code>NAK</code>. <code>obj-id</code> is the object name of the last commit determined to be common. The server only sends ACK after <code>done</code> if there is at least one common base and multi_ack or multi_ack_detailed is enabled. The server always sends NAK after <code>done</code> if there is no common base found.</p> <p>Instead of <code>ACK</code> or <code>NAK</code>, the server may send an error message (for example, if it does not recognize an object in a <code>want</code> line received from the client).</p> <p>Then the server will start sending its packfile data.</p> <div class="listingblock"> <div class="content"> <pre> server-response = *ack_multi ack / nak + ack_multi = PKT-LINE("ACK" SP obj-id ack_status) + ack_status = "continue" / "common" / "ready" + ack = PKT-LINE("ACK" SP obj-id) + nak = PKT-LINE("NAK")</pre> </div> </div> <p>A simple clone may look like this (with no <code>have</code> lines):</p> <div class="listingblock"> <div class="content"> <pre> C: 0054want 74730d410fcb6603ace96f1dc55ea6196122532d multi_ack \ + side-band-64k ofs-delta\n + C: 0032want 7d1665144a3a975c05f1f43902ddaf084e784dbe\n + C: 0032want 5a3f6be755bbb7deae50065988cbfa1ffa9ab68a\n + C: 0032want 7e47fe2bd8d01d481f44d7af0531bd93d3b21c01\n + C: 0032want 74730d410fcb6603ace96f1dc55ea6196122532d\n + C: 0000 + C: 0009done\n + + S: 0008NAK\n + S: [PACKFILE]</pre> </div> </div> <p>An incremental update (fetch) response might look like this:</p> <div class="listingblock"> <div class="content"> <pre> C: 0054want 74730d410fcb6603ace96f1dc55ea6196122532d multi_ack \ + side-band-64k ofs-delta\n + C: 0032want 7d1665144a3a975c05f1f43902ddaf084e784dbe\n + C: 0032want 5a3f6be755bbb7deae50065988cbfa1ffa9ab68a\n + C: 0000 + C: 0032have 7e47fe2bd8d01d481f44d7af0531bd93d3b21c01\n + C: [30 more have lines] + C: 0032have 74730d410fcb6603ace96f1dc55ea6196122532d\n + C: 0000 + + S: 003aACK 7e47fe2bd8d01d481f44d7af0531bd93d3b21c01 continue\n + S: 003aACK 74730d410fcb6603ace96f1dc55ea6196122532d continue\n + S: 0008NAK\n + + C: 0009done\n + + S: 0031ACK 74730d410fcb6603ace96f1dc55ea6196122532d\n + S: [PACKFILE]</pre> </div> </div> </div> <h2 id="_packfile_data">Packfile data</h2> <div class="sectionbody"> <p>Now that the client and server have finished negotiation about what the minimal amount of data that needs to be sent to the client is, the server will construct and send the required data in packfile format.</p> <p>See <a href="gitformat-pack">gitformat-pack[5]</a> for what the packfile itself actually looks like.</p> <p>If <code>side-band</code> or <code>side-band-64k</code> capabilities have been specified by the client, the server will send the packfile data multiplexed.</p> <p>Each packet starting with the packet-line length of the amount of data that follows, followed by a single byte specifying the sideband the following data is coming in on.</p> <p>In <code>side-band</code> mode, it will send up to 999 data bytes plus 1 control code, for a total of up to 1000 bytes in a pkt-line. In <code>side-band-64k</code> mode it will send up to 65519 data bytes plus 1 control code, for a total of up to 65520 bytes in a pkt-line.</p> <p>The sideband byte will be a <code>1</code>, <code>2</code> or a <code>3</code>. Sideband <code>1</code> will contain packfile data, sideband <code>2</code> will be used for progress information that the client will generally print to stderr and sideband <code>3</code> is used for error information.</p> <p>If no <code>side-band</code> capability was specified, the server will stream the entire packfile without multiplexing.</p> </div> <h2 id="_pushing_data_to_a_server">Pushing data to a server</h2> <div class="sectionbody"> <p>Pushing data to a server will invoke the <code>receive-pack</code> process on the server, which will allow the client to tell it which references it should update and then send all the data the server will need for those new references to be complete. Once all the data is received and validated, the server will then update its references to what the client specified.</p> </div> <h2 id="_authentication">Authentication</h2> <div class="sectionbody"> <p>The protocol itself contains no authentication mechanisms. That is to be handled by the transport, such as SSH, before the <code>receive-pack</code> process is invoked. If <code>receive-pack</code> is configured over the Git transport, those repositories will be writable by anyone who can access that port (9418) as that transport is unauthenticated.</p> </div> <h2 id="_reference_discovery_2">Reference discovery</h2> <div class="sectionbody"> <p>The reference discovery phase is done nearly the same way as it is in the fetching protocol. Each reference obj-id and name on the server is sent in packet-line format to the client, followed by a flush-pkt. The only real difference is that the capability listing is different - the only possible values are <code>report-status</code>, <code>report-status-v2</code>, <code>delete-refs</code>, <code>ofs-delta</code>, <code>atomic</code> and <code>push-options</code>.</p> </div> <h2 id="_reference_update_request_and_packfile_transfer">Reference update request and packfile transfer</h2> <div class="sectionbody"> <p>Once the client knows what references the server is at, it can send a list of reference update requests. For each reference on the server that it wants to update, it sends a line listing the obj-id currently on the server, the obj-id the client would like to update it to and the name of the reference.</p> <p>This list is followed by a flush-pkt.</p> <div class="listingblock"> <div class="content"> <pre> update-requests = *shallow ( command-list | push-cert ) + + shallow = PKT-LINE("shallow" SP obj-id) + + command-list = PKT-LINE(command NUL capability-list) + *PKT-LINE(command) + flush-pkt + + command = create / delete / update + create = zero-id SP new-id SP name + delete = old-id SP zero-id SP name + update = old-id SP new-id SP name + + old-id = obj-id + new-id = obj-id + + push-cert = PKT-LINE("push-cert" NUL capability-list LF) + PKT-LINE("certificate version 0.1" LF) + PKT-LINE("pusher" SP ident LF) + PKT-LINE("pushee" SP url LF) + PKT-LINE("nonce" SP nonce LF) + *PKT-LINE("push-option" SP push-option LF) + PKT-LINE(LF) + *PKT-LINE(command LF) + *PKT-LINE(gpg-signature-lines LF) + PKT-LINE("push-cert-end" LF) + + push-option = 1*( VCHAR | SP )</pre> </div> </div> <p>If the server has advertised the <code>push-options</code> capability and the client has specified <code>push-options</code> as part of the capability list above, the client then sends its push options followed by a flush-pkt.</p> <div class="listingblock"> <div class="content"> <pre> push-options = *PKT-LINE(push-option) flush-pkt</pre> </div> </div> <p>For backwards compatibility with older Git servers, if the client sends a push cert and push options, it MUST send its push options both embedded within the push cert and after the push cert. (Note that the push options within the cert are prefixed, but the push options after the cert are not.) Both these lists MUST be the same, modulo the prefix.</p> <p>After that the packfile that should contain all the objects that the server will need to complete the new references will be sent.</p> <div class="listingblock"> <div class="content"> <pre> packfile = "PACK" 28*(OCTET)</pre> </div> </div> <p>If the receiving end does not support delete-refs, the sending end MUST NOT ask for delete command.</p> <p>If the receiving end does not support push-cert, the sending end MUST NOT send a push-cert command. When a push-cert command is sent, command-list MUST NOT be sent; the commands recorded in the push certificate is used instead.</p> <p>The packfile MUST NOT be sent if the only command used is <code>delete</code>.</p> <p>A packfile MUST be sent if either create or update command is used, even if the server already has all the necessary objects. In this case the client MUST send an empty packfile. The only time this is likely to happen is if the client is creating a new branch or a tag that points to an existing obj-id.</p> <p>The server will receive the packfile, unpack it, then validate each reference that is being updated that it hasn’t changed while the request was being processed (the obj-id is still the same as the old-id), and it will run any update hooks to make sure that the update is acceptable. If all of that is fine, the server will then update the references.</p> </div> <h2 id="_push_certificate">Push certificate</h2> <div class="sectionbody"> <p>A push certificate begins with a set of header lines. After the header and an empty line, the protocol commands follow, one per line. Note that the trailing LF in push-cert PKT-LINEs is <code>not</code> optional; it must be present.</p> <p>Currently, the following header fields are defined:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitprotocol-pack.txt-codepushercodeident"> <code>pusher</code> ident </dt> <dd> <p>Identify the GPG key in "Human Readable Name <email@address>" format.</p> </dd> <dt class="hdlist1" id="Documentation/gitprotocol-pack.txt-codepusheecodeurl"> <code>pushee</code> url </dt> <dd> <p>The repository URL (anonymized, if the URL contains authentication material) the user who ran <code>git push</code> intended to push into.</p> </dd> <dt class="hdlist1" id="Documentation/gitprotocol-pack.txt-codenoncecodenonce"> <code>nonce</code> nonce </dt> <dd> <p>The <code>nonce</code> string the receiving repository asked the pushing user to include in the certificate, to prevent replay attacks.</p> </dd> </dl> </div> <p>The GPG signature lines are a detached signature for the contents recorded in the push certificate before the signature block begins. The detached signature is used to certify that the commands were given by the pusher, who must be the signer.</p> </div> <h2 id="_report_status">Report status</h2> <div class="sectionbody"> <p>After receiving the pack data from the sender, the receiver sends a report if <code>report-status</code> or <code>report-status-v2</code> capability is in effect. It is a short listing of what happened in that update. It will first list the status of the packfile unpacking as either <code>unpack ok</code> or <code>unpack [error]</code>. Then it will list the status for each of the references that it tried to update. Each line is either <code>ok [refname]</code> if the update was successful, or <code>ng [refname] [error]</code> if the update was not.</p> <div class="listingblock"> <div class="content"> <pre> report-status = unpack-status + 1*(command-status) + flush-pkt + + unpack-status = PKT-LINE("unpack" SP unpack-result) + unpack-result = "ok" / error-msg + + command-status = command-ok / command-fail + command-ok = PKT-LINE("ok" SP refname) + command-fail = PKT-LINE("ng" SP refname SP error-msg) + + error-msg = 1*(OCTET) ; where not "ok"</pre> </div> </div> <p>The <code>report-status-v2</code> capability extends the protocol by adding new option lines in order to support reporting of reference rewritten by the <code>proc-receive</code> hook. The <code>proc-receive</code> hook may handle a command for a pseudo-reference which may create or update one or more references, and each reference may have different name, different new-oid, and different old-oid.</p> <div class="listingblock"> <div class="content"> <pre> report-status-v2 = unpack-status + 1*(command-status-v2) + flush-pkt + + unpack-status = PKT-LINE("unpack" SP unpack-result) + unpack-result = "ok" / error-msg + + command-status-v2 = command-ok-v2 / command-fail + command-ok-v2 = command-ok + *option-line + + command-ok = PKT-LINE("ok" SP refname) + command-fail = PKT-LINE("ng" SP refname SP error-msg) + + error-msg = 1*(OCTET) ; where not "ok" + + option-line = *1(option-refname) + *1(option-old-oid) + *1(option-new-oid) + *1(option-forced-update) + + option-refname = PKT-LINE("option" SP "refname" SP refname) + option-old-oid = PKT-LINE("option" SP "old-oid" SP obj-id) + option-new-oid = PKT-LINE("option" SP "new-oid" SP obj-id) + option-force = PKT-LINE("option" SP "forced-update")</pre> </div> </div> <p>Updates can be unsuccessful for a number of reasons. The reference can have changed since the reference discovery phase was originally sent, meaning someone pushed in the meantime. The reference being pushed could be a non-fast-forward reference and the update hooks or configuration could be set to not allow that, etc. Also, some references can be updated while others can be rejected.</p> <p>An example client/server communication might look like this:</p> <div class="listingblock"> <div class="content"> <pre> S: 006274730d410fcb6603ace96f1dc55ea6196122532d refs/heads/local\0report-status delete-refs ofs-delta\n + S: 003e7d1665144a3a975c05f1f43902ddaf084e784dbe refs/heads/debug\n + S: 003f74730d410fcb6603ace96f1dc55ea6196122532d refs/heads/master\n + S: 003d74730d410fcb6603ace96f1dc55ea6196122532d refs/heads/team\n + S: 0000 + + C: 00677d1665144a3a975c05f1f43902ddaf084e784dbe 74730d410fcb6603ace96f1dc55ea6196122532d refs/heads/debug\n + C: 006874730d410fcb6603ace96f1dc55ea6196122532d 5a3f6be755bbb7deae50065988cbfa1ffa9ab68a refs/heads/master\n + C: 0000 + C: [PACKDATA] + + S: 000eunpack ok\n + S: 0018ok refs/heads/debug\n + S: 002ang refs/heads/master non-fast-forward\n</pre> </div> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitprotocol-pack" class="_attribution-link">https://git-scm.com/docs/gitprotocol-pack</a> + </p> +</div> diff --git a/devdocs/git/gitprotocol-v2.html b/devdocs/git/gitprotocol-v2.html new file mode 100644 index 00000000..c647d6d7 --- /dev/null +++ b/devdocs/git/gitprotocol-v2.html @@ -0,0 +1,179 @@ +<h1>gitprotocol-v2</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitprotocol-v2 - Git Wire Protocol, Version 2</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content"><over-the-wire-protocol></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This document presents a specification for a version 2 of Git’s wire protocol. Protocol v2 will improve upon v1 in the following ways:</p> <div class="ulist"> <ul> <li> <p>Instead of multiple service names, multiple commands will be supported by a single service</p> </li> <li> <p>Easily extendable as capabilities are moved into their own section of the protocol, no longer being hidden behind a NUL byte and limited by the size of a pkt-line</p> </li> <li> <p>Separate out other information hidden behind NUL bytes (e.g. agent string as a capability and symrefs can be requested using <code>ls-refs</code>)</p> </li> <li> <p>Reference advertisement will be omitted unless explicitly requested</p> </li> <li> <p>ls-refs command to explicitly request some refs</p> </li> <li> <p>Designed with http and stateless-rpc in mind. With clear flush semantics the http remote helper can simply act as a proxy</p> </li> </ul> </div> <p>In protocol v2 communication is command oriented. When first contacting a server a list of capabilities will be advertised. Some of these capabilities will be commands which a client can request be executed. Once a command has completed, a client can reuse the connection and request that other commands be executed.</p> </div> <h2 id="_packet_line_framing">Packet-line framing</h2> <div class="sectionbody"> <p>All communication is done using packet-line framing, just as in v1. See <a href="gitprotocol-pack">gitprotocol-pack[5]</a> and <a href="gitprotocol-common">gitprotocol-common[5]</a> for more information.</p> <p>In protocol v2 these special packets will have the following semantics:</p> <div class="ulist"> <ul> <li> <p><code>0000</code> Flush Packet (flush-pkt) - indicates the end of a message</p> </li> <li> <p><code>0001</code> Delimiter Packet (delim-pkt) - separates sections of a message</p> </li> <li> <p><code>0002</code> Response End Packet (response-end-pkt) - indicates the end of a response for stateless connections</p> </li> </ul> </div> </div> <h2 id="_initial_client_request">Initial client request</h2> <div class="sectionbody"> <p>In general a client can request to speak protocol v2 by sending <code>version=2</code> through the respective side-channel for the transport being used which inevitably sets <code>GIT_PROTOCOL</code>. More information can be found in <a href="gitprotocol-pack">gitprotocol-pack[5]</a> and <a href="gitprotocol-http">gitprotocol-http[5]</a>, as well as the <code>GIT_PROTOCOL</code> definition in <code>git.txt</code>. In all cases the response from the server is the capability advertisement.</p> <div class="sect2"> <h3 id="_git_transport"> +Git Transport</h3> <p>When using the git:// transport, you can request to use protocol v2 by sending "version=2" as an extra parameter:</p> <div class="literalblock"> <div class="content"> <pre>003egit-upload-pack /project.git\0host=myserver.com\0\0version=2\0</pre> </div> </div> </div> <div class="sect2"> <h3 id="_ssh_and_file_transport"> +SSH and File Transport</h3> <p>When using either the ssh:// or file:// transport, the GIT_PROTOCOL environment variable must be set explicitly to include "version=2". The server may need to be configured to allow this environment variable to pass.</p> </div> <div class="sect2"> <h3 id="_http_transport"> +HTTP Transport</h3> <p>When using the http:// or https:// transport a client makes a "smart" info/refs request as described in <a href="gitprotocol-http">gitprotocol-http[5]</a> and requests that v2 be used by supplying "version=2" in the <code>Git-Protocol</code> header.</p> <div class="literalblock"> <div class="content"> <pre>C: GET $GIT_URL/info/refs?service=git-upload-pack HTTP/1.0 +C: Git-Protocol: version=2</pre> </div> </div> <p>A v2 server would reply:</p> <div class="literalblock"> <div class="content"> <pre>S: 200 OK +S: <Some headers> +S: ... +S: +S: 000eversion 2\n +S: <capability-advertisement></pre> </div> </div> <p>Subsequent requests are then made directly to the service <code>$GIT_URL/git-upload-pack</code>. (This works the same for git-receive-pack).</p> <p>Uses the <code>--http-backend-info-refs</code> option to <a href="git-upload-pack">git-upload-pack[1]</a>.</p> <p>The server may need to be configured to pass this header’s contents via the <code>GIT_PROTOCOL</code> variable. See the discussion in <code>git-http-backend.txt</code>.</p> </div> </div> <h2 id="_capability_advertisement">Capability advertisement</h2> <div class="sectionbody"> <p>A server which decides to communicate (based on a request from a client) using protocol version 2, notifies the client by sending a version string in its initial response followed by an advertisement of its capabilities. Each capability is a key with an optional value. Clients must ignore all unknown keys. Semantics of unknown values are left to the definition of each key. Some capabilities will describe commands which can be requested to be executed by the client.</p> <div class="literalblock"> <div class="content"> <pre>capability-advertisement = protocol-version + capability-list + flush-pkt</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>protocol-version = PKT-LINE("version 2" LF) +capability-list = *capability +capability = PKT-LINE(key[=value] LF)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>key = 1*(ALPHA | DIGIT | "-_") +value = 1*(ALPHA | DIGIT | " -_.,?\/{}[]()<>!@#$%^&*+=:;")</pre> </div> </div> </div> <h2 id="_command_request">Command request</h2> <div class="sectionbody"> <p>After receiving the capability advertisement, a client can then issue a request to select the command it wants with any particular capabilities or arguments. There is then an optional section where the client can provide any command specific parameters or queries. Only a single command can be requested at a time.</p> <div class="literalblock"> <div class="content"> <pre>request = empty-request | command-request +empty-request = flush-pkt +command-request = command + capability-list + delim-pkt + command-args + flush-pkt +command = PKT-LINE("command=" key LF) +command-args = *command-specific-arg</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>command-specific-args are packet line framed arguments defined by +each individual command.</pre> </div> </div> <p>The server will then check to ensure that the client’s request is comprised of a valid command as well as valid capabilities which were advertised. If the request is valid the server will then execute the command. A server MUST wait till it has received the client’s entire request before issuing a response. The format of the response is determined by the command being executed, but in all cases a flush-pkt indicates the end of the response.</p> <p>When a command has finished, and the client has received the entire response from the server, a client can either request that another command be executed or can terminate the connection. A client may optionally send an empty request consisting of just a flush-pkt to indicate that no more requests will be made.</p> </div> <h2 id="_capabilities">Capabilities</h2> <div class="sectionbody"> <p>There are two different types of capabilities: normal capabilities, which can be used to convey information or alter the behavior of a request, and commands, which are the core actions that a client wants to perform (fetch, push, etc).</p> <p>Protocol version 2 is stateless by default. This means that all commands must only last a single round and be stateless from the perspective of the server side, unless the client has requested a capability indicating that state should be maintained by the server. Clients MUST NOT require state management on the server side in order to function correctly. This permits simple round-robin load-balancing on the server side, without needing to worry about state management.</p> <div class="sect2"> <h3 id="_agent"> +agent</h3> <p>The server can advertise the <code>agent</code> capability with a value <code>X</code> (in the form <code>agent=X</code>) to notify the client that the server is running version <code>X</code>. The client may optionally send its own agent string by including the <code>agent</code> capability with a value <code>Y</code> (in the form <code>agent=Y</code>) in its request to the server (but it MUST NOT do so if the server did not advertise the agent capability). The <code>X</code> and <code>Y</code> strings may contain any printable ASCII characters except space (i.e., the byte range 32 < x < 127), and are typically of the form "package/version" (e.g., "git/1.8.3.1"). The agent strings are purely informative for statistics and debugging purposes, and MUST NOT be used to programmatically assume the presence or absence of particular features.</p> </div> <div class="sect2"> <h3 id="_ls_refs"> +ls-refs</h3> <p><code>ls-refs</code> is the command used to request a reference advertisement in v2. Unlike the current reference advertisement, ls-refs takes in arguments which can be used to limit the refs sent from the server.</p> <p>Additional features not supported in the base command will be advertised as the value of the command in the capability advertisement in the form of a space separated list of features: "<command>=<feature 1> <feature 2>"</p> <p>ls-refs takes in the following arguments:</p> <div class="literalblock"> <div class="content"> <pre> symrefs +In addition to the object pointed by it, show the underlying ref +pointed by it when showing a symbolic ref. + peel +Show peeled tags. + ref-prefix <prefix> +When specified, only references having a prefix matching one of +the provided prefixes are displayed. Multiple instances may be +given, in which case references matching any prefix will be +shown. Note that this is purely for optimization; a server MAY +show refs not matching the prefix if it chooses, and clients +should filter the result themselves.</pre> </div> </div> <p>If the <code>unborn</code> feature is advertised the following argument can be included in the client’s request.</p> <div class="literalblock"> <div class="content"> <pre> unborn +The server will send information about HEAD even if it is a symref +pointing to an unborn branch in the form "unborn HEAD +symref-target:<target>".</pre> </div> </div> <p>The output of ls-refs is as follows:</p> <div class="literalblock"> <div class="content"> <pre>output = *ref + flush-pkt +obj-id-or-unborn = (obj-id | "unborn") +ref = PKT-LINE(obj-id-or-unborn SP refname *(SP ref-attribute) LF) +ref-attribute = (symref | peeled) +symref = "symref-target:" symref-target +peeled = "peeled:" obj-id</pre> </div> </div> </div> <div class="sect2"> <h3 id="_fetch"> +fetch</h3> <p><code>fetch</code> is the command used to fetch a packfile in v2. It can be looked at as a modified version of the v1 fetch where the ref-advertisement is stripped out (since the <code>ls-refs</code> command fills that role) and the message format is tweaked to eliminate redundancies and permit easy addition of future extensions.</p> <p>Additional features not supported in the base command will be advertised as the value of the command in the capability advertisement in the form of a space separated list of features: "<command>=<feature 1> <feature 2>"</p> <p>A <code>fetch</code> request can take the following arguments:</p> <div class="literalblock"> <div class="content"> <pre> want <oid> +Indicates to the server an object which the client wants to +retrieve. Wants can be anything and are not limited to +advertised objects.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> have <oid> +Indicates to the server an object which the client has locally. +This allows the server to make a packfile which only contains +the objects that the client needs. Multiple 'have' lines can be +supplied.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> done +Indicates to the server that negotiation should terminate (or +not even begin if performing a clone) and that the server should +use the information supplied in the request to construct the +packfile.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> thin-pack +Request that a thin pack be sent, which is a pack with deltas +which reference base objects not contained within the pack (but +are known to exist at the receiving end). This can reduce the +network traffic significantly, but it requires the receiving end +to know how to "thicken" these packs by adding the missing bases +to the pack.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> no-progress +Request that progress information that would normally be sent on +side-band channel 2, during the packfile transfer, should not be +sent. However, the side-band channel 3 is still used for error +responses.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> include-tag +Request that annotated tags should be sent if the objects they +point to are being sent.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> ofs-delta +Indicate that the client understands PACKv2 with delta referring +to its base by position in pack rather than by an oid. That is, +they can read OBJ_OFS_DELTA (aka type 6) in a packfile.</pre> </div> </div> <p>If the <code>shallow</code> feature is advertised the following arguments can be included in the clients request as well as the potential addition of the <code>shallow-info</code> section in the server’s response as explained below.</p> <div class="literalblock"> <div class="content"> <pre> shallow <oid> +A client must notify the server of all commits for which it only +has shallow copies (meaning that it doesn't have the parents of +a commit) by supplying a 'shallow <oid>' line for each such +object so that the server is aware of the limitations of the +client's history. This is so that the server is aware that the +client may not have all objects reachable from such commits.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> deepen <depth> +Requests that the fetch/clone should be shallow having a commit +depth of <depth> relative to the remote side.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> deepen-relative +Requests that the semantics of the "deepen" command be changed +to indicate that the depth requested is relative to the client's +current shallow boundary, instead of relative to the requested +commits.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> deepen-since <timestamp> +Requests that the shallow clone/fetch should be cut at a +specific time, instead of depth. Internally it's equivalent to +doing "git rev-list --max-age=<timestamp>". Cannot be used with +"deepen".</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> deepen-not <rev> +Requests that the shallow clone/fetch should be cut at a +specific revision specified by '<rev>', instead of a depth. +Internally it's equivalent of doing "git rev-list --not <rev>". +Cannot be used with "deepen", but can be used with +"deepen-since".</pre> </div> </div> <p>If the <code>filter</code> feature is advertised, the following argument can be included in the client’s request:</p> <div class="literalblock"> <div class="content"> <pre> filter <filter-spec> +Request that various objects from the packfile be omitted +using one of several filtering techniques. These are intended +for use with partial clone and partial fetch operations. See +`rev-list` for possible "filter-spec" values. When communicating +with other processes, senders SHOULD translate scaled integers +(e.g. "1k") into a fully-expanded form (e.g. "1024") to aid +interoperability with older receivers that may not understand +newly-invented scaling suffixes. However, receivers SHOULD +accept the following suffixes: 'k', 'm', and 'g' for 1024, +1048576, and 1073741824, respectively.</pre> </div> </div> <p>If the <code>ref-in-want</code> feature is advertised, the following argument can be included in the client’s request as well as the potential addition of the <code>wanted-refs</code> section in the server’s response as explained below.</p> <div class="literalblock"> <div class="content"> <pre> want-ref <ref> +Indicates to the server that the client wants to retrieve a +particular ref, where <ref> is the full name of a ref on the +server.</pre> </div> </div> <p>If the <code>sideband-all</code> feature is advertised, the following argument can be included in the client’s request:</p> <div class="literalblock"> <div class="content"> <pre> sideband-all +Instruct the server to send the whole response multiplexed, not just +the packfile section. All non-flush and non-delim PKT-LINE in the +response (not only in the packfile section) will then start with a byte +indicating its sideband (1, 2, or 3), and the server may send "0005\2" +(a PKT-LINE of sideband 2 with no payload) as a keepalive packet.</pre> </div> </div> <p>If the <code>packfile-uris</code> feature is advertised, the following argument can be included in the client’s request as well as the potential addition of the <code>packfile-uris</code> section in the server’s response as explained below.</p> <div class="literalblock"> <div class="content"> <pre> packfile-uris <comma-separated list of protocols> +Indicates to the server that the client is willing to receive +URIs of any of the given protocols in place of objects in the +sent packfile. Before performing the connectivity check, the +client should download from all given URIs. Currently, the +protocols supported are "http" and "https".</pre> </div> </div> <p>If the <code>wait-for-done</code> feature is advertised, the following argument can be included in the client’s request.</p> <div class="literalblock"> <div class="content"> <pre> wait-for-done +Indicates to the server that it should never send "ready", but +should wait for the client to say "done" before sending the +packfile.</pre> </div> </div> <p>The response of <code>fetch</code> is broken into a number of sections separated by delimiter packets (0001), with each section beginning with its section header. Most sections are sent only when the packfile is sent.</p> <div class="literalblock"> <div class="content"> <pre>output = acknowledgements flush-pkt | + [acknowledgments delim-pkt] [shallow-info delim-pkt] + [wanted-refs delim-pkt] [packfile-uris delim-pkt] + packfile flush-pkt</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>acknowledgments = PKT-LINE("acknowledgments" LF) + (nak | *ack) + (ready) +ready = PKT-LINE("ready" LF) +nak = PKT-LINE("NAK" LF) +ack = PKT-LINE("ACK" SP obj-id LF)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>shallow-info = PKT-LINE("shallow-info" LF) + *PKT-LINE((shallow | unshallow) LF) +shallow = "shallow" SP obj-id +unshallow = "unshallow" SP obj-id</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>wanted-refs = PKT-LINE("wanted-refs" LF) +*PKT-LINE(wanted-ref LF) +wanted-ref = obj-id SP refname</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>packfile-uris = PKT-LINE("packfile-uris" LF) *packfile-uri +packfile-uri = PKT-LINE(40*(HEXDIGIT) SP *%x20-ff LF)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>packfile = PKT-LINE("packfile" LF) + *PKT-LINE(%x01-03 *%x00-ff)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre> acknowledgments section +* If the client determines that it is finished with negotiations by + sending a "done" line (thus requiring the server to send a packfile), + the acknowledgments sections MUST be omitted from the server's + response.</pre> </div> </div> <div class="ulist"> <ul> <li> <p>Always begins with the section header "acknowledgments"</p> </li> <li> <p>The server will respond with "NAK" if none of the object ids sent as have lines were common.</p> </li> <li> <p>The server will respond with "ACK obj-id" for all of the object ids sent as have lines which are common.</p> </li> <li> <p>A response cannot have both "ACK" lines as well as a "NAK" line.</p> </li> <li> <p>The server will respond with a "ready" line indicating that the server has found an acceptable common base and is ready to make and send a packfile (which will be found in the packfile section of the same response)</p> </li> <li> <p>If the server has found a suitable cut point and has decided to send a "ready" line, then the server can decide to (as an optimization) omit any "ACK" lines it would have sent during its response. This is because the server will have already determined the objects it plans to send to the client and no further negotiation is needed.</p> <div class="literalblock"> <div class="content"> <pre> shallow-info section +* If the client has requested a shallow fetch/clone, a shallow + client requests a fetch or the server is shallow then the + server's response may include a shallow-info section. The + shallow-info section will be included if (due to one of the + above conditions) the server needs to inform the client of any + shallow boundaries or adjustments to the clients already + existing shallow boundaries.</pre> </div> </div> </li> <li> <p>Always begins with the section header "shallow-info"</p> </li> <li> <p>If a positive depth is requested, the server will compute the set of commits which are no deeper than the desired depth.</p> </li> <li> <p>The server sends a "shallow obj-id" line for each commit whose parents will not be sent in the following packfile.</p> </li> <li> <p>The server sends an "unshallow obj-id" line for each commit which the client has indicated is shallow, but is no longer shallow as a result of the fetch (due to its parents being sent in the following packfile).</p> </li> <li> <p>The server MUST NOT send any "unshallow" lines for anything which the client has not indicated was shallow as a part of its request.</p> <div class="literalblock"> <div class="content"> <pre> wanted-refs section +* This section is only included if the client has requested a + ref using a 'want-ref' line and if a packfile section is also + included in the response.</pre> </div> </div> </li> <li> <p>Always begins with the section header "wanted-refs".</p> </li> <li> <p>The server will send a ref listing ("<oid> <refname>") for each reference requested using <code>want-ref</code> lines.</p> </li> <li> <p>The server MUST NOT send any refs which were not requested using <code>want-ref</code> lines.</p> <div class="literalblock"> <div class="content"> <pre> packfile-uris section +* This section is only included if the client sent + 'packfile-uris' and the server has at least one such URI to + send.</pre> </div> </div> </li> <li> <p>Always begins with the section header "packfile-uris".</p> </li> <li> <p>For each URI the server sends, it sends a hash of the pack’s contents (as output by git index-pack) followed by the URI.</p> </li> <li> <p>The hashes are 40 hex characters long. When Git upgrades to a new hash algorithm, this might need to be updated. (It should match whatever index-pack outputs after "pack\t" or "keep\t".</p> <div class="literalblock"> <div class="content"> <pre> packfile section +* This section is only included if the client has sent 'want' + lines in its request and either requested that no more + negotiation be done by sending 'done' or if the server has + decided it has found a sufficient cut point to produce a + packfile.</pre> </div> </div> </li> <li> <p>Always begins with the section header "packfile"</p> </li> <li> <p>The transmission of the packfile begins immediately after the section header</p> </li> <li> <p>The data transfer of the packfile is always multiplexed, using the same semantics of the <code>side-band-64k</code> capability from protocol version 1. This means that each packet, during the packfile data stream, is made up of a leading 4-byte pkt-line length (typical of the pkt-line format), followed by a 1-byte stream code, followed by the actual data.</p> <div class="literalblock"> <div class="content"> <pre> The stream code can be one of: +1 - pack data +2 - progress messages +3 - fatal error message just before stream aborts</pre> </div> </div> </li> </ul> </div> </div> <div class="sect2"> <h3 id="_server_option"> +server-option</h3> <p>If advertised, indicates that any number of server specific options can be included in a request. This is done by sending each option as a "server-option=<option>" capability line in the capability-list section of a request.</p> <p>The provided options must not contain a NUL or LF character.</p> </div> <div class="sect2"> <h3 id="_object_format"> + object-format</h3> <p>The server can advertise the <code>object-format</code> capability with a value <code>X</code> (in the form <code>object-format=X</code>) to notify the client that the server is able to deal with objects using hash algorithm X. If not specified, the server is assumed to only handle SHA-1. If the client would like to use a hash algorithm other than SHA-1, it should specify its object-format string.</p> </div> <div class="sect2"> <h3 id="_session_idsession_id"> +session-id=<session id></h3> <p>The server may advertise a session ID that can be used to identify this process across multiple requests. The client may advertise its own session ID back to the server as well.</p> <p>Session IDs should be unique to a given process. They must fit within a packet-line, and must not contain non-printable or whitespace characters. The current implementation uses trace2 session IDs (see <a href="api-trace2">api-trace2</a> for details), but this may change and users of the session ID should not rely on this fact.</p> </div> <div class="sect2"> <h3 id="_object_info"> +object-info</h3> <p><code>object-info</code> is the command to retrieve information about one or more objects. Its main purpose is to allow a client to make decisions based on this information without having to fully fetch objects. Object size is the only information that is currently supported.</p> <p>An <code>object-info</code> request takes the following arguments:</p> <div class="literalblock"> <div class="content"> <pre>size +Requests size information to be returned for each listed object id.</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>oid <oid> +Indicates to the server an object which the client wants to obtain +information for.</pre> </div> </div> <p>The response of <code>object-info</code> is a list of the requested object ids and associated requested information, each separated by a single space.</p> <div class="literalblock"> <div class="content"> <pre>output = info flush-pkt</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>info = PKT-LINE(attrs) LF) + *PKT-LINE(obj-info LF)</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>attrs = attr | attrs SP attrs</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>attr = "size"</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>obj-info = obj-id SP obj-size</pre> </div> </div> </div> <div class="sect2"> <h3 id="_bundle_uri"> +bundle-uri</h3> <p>If the <code>bundle-uri</code> capability is advertised, the server supports the ‘bundle-uri’ command.</p> <p>The capability is currently advertised with no value (i.e. not "bundle-uri=somevalue"), a value may be added in the future for supporting command-wide extensions. Clients MUST ignore any unknown capability values and proceed with the 'bundle-uri` dialog they support.</p> <p>The <code>bundle-uri</code> command is intended to be issued before <code>fetch</code> to get URIs to bundle files (see <a href="git-bundle">git-bundle[1]</a>) to "seed" and inform the subsequent <code>fetch</code> command.</p> <p>The client CAN issue <code>bundle-uri</code> before or after any other valid command. To be useful to clients it’s expected that it’ll be issued after an <code>ls-refs</code> and before <code>fetch</code>, but CAN be issued at any time in the dialog.</p> <div class="sect3"> <h4 id="_discussion_of_bundle_uri"> +DISCUSSION of bundle-uri</h4> <p>The intent of the feature is optimize for server resource consumption in the common case by changing the common case of fetching a very large PACK during <a href="git-clone">git-clone[1]</a> into a smaller incremental fetch.</p> <p>It also allows servers to achieve better caching in combination with an <code>uploadpack.packObjectsHook</code> (see <a href="git-config">git-config[1]</a>).</p> <p>By having new clones or fetches be a more predictable and common negotiation against the tips of recently produces *.bundle file(s). Servers might even pre-generate the results of such negotiations for the <code>uploadpack.packObjectsHook</code> as new pushes come in.</p> <p>One way that servers could take advantage of these bundles is that the server would anticipate that fresh clones will download a known bundle, followed by catching up to the current state of the repository using ref tips found in that bundle (or bundles).</p> </div> <div class="sect3"> <h4 id="_protocol_for_bundle_uri"> +PROTOCOL for bundle-uri</h4> <p>A <code>bundle-uri</code> request takes no arguments, and as noted above does not currently advertise a capability value. Both may be added in the future.</p> <p>When the client issues a <code>command=bundle-uri</code> request, the response is a list of key-value pairs provided as packet lines with value <code><key>=<value></code>. Each <code><key></code> should be interpreted as a config key from the <code>bundle.*</code> namespace to construct a list of bundles. These keys are grouped by a <code>bundle.<id>.</code> subsection, where each key corresponding to a given <code><id></code> contributes attributes to the bundle defined by that <code><id></code>. See <a href="git-config">git-config[1]</a> for the specific details of these keys and how the Git client will interpret their values.</p> <p>Clients MUST parse the line according to the above format, lines that do not conform to the format SHOULD be discarded. The user MAY be warned in such a case.</p> </div> <div class="sect3"> <h4 id="_bundle_uri_client_and_server_expectations"> +bundle-uri CLIENT AND SERVER EXPECTATIONS</h4> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitprotocol-v2.txt-URICONTENTS"> URI CONTENTS </dt> <dd> <p>The content at the advertised URIs MUST be one of two types.</p> <p>The advertised URI may contain a bundle file that <code>git bundle verify</code> would accept. I.e. they MUST contain one or more reference tips for use by the client, MUST indicate prerequisites (in any) with standard "-" prefixes, and MUST indicate their "object-format", if applicable.</p> <p>The advertised URI may alternatively contain a plaintext file that <code>git +config --list</code> would accept (with the <code>--file</code> option). The key-value pairs in this list are in the <code>bundle.*</code> namespace (see <a href="git-config">git-config[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/gitprotocol-v2.txt-bundle-uriCLIENTERRORRECOVERY"> bundle-uri CLIENT ERROR RECOVERY </dt> <dd> <p>A client MUST above all gracefully degrade on errors, whether that error is because of bad missing/data in the bundle URI(s), because that client is too dumb to e.g. understand and fully parse out bundle headers and their prerequisite relationships, or something else.</p> <p>Server operators should feel confident in turning on "bundle-uri" and not worry if e.g. their CDN goes down that clones or fetches will run into hard failures. Even if the server bundle(s) are incomplete, or bad in some way the client should still end up with a functioning repository, just as if it had chosen not to use this protocol extension.</p> <p>All subsequent discussion on client and server interaction MUST keep this in mind.</p> </dd> <dt class="hdlist1" id="Documentation/gitprotocol-v2.txt-bundle-uriSERVERTOCLIENT"> bundle-uri SERVER TO CLIENT </dt> <dd> <p>The ordering of the returned bundle uris is not significant. Clients MUST parse their headers to discover their contained OIDS and prerequisites. A client MUST consider the content of the bundle(s) themselves and their header as the ultimate source of truth.</p> <p>A server MAY even return bundle(s) that don’t have any direct relationship to the repository being cloned (either through accident, or intentional "clever" configuration), and expect a client to sort out what data they’d like from the bundle(s), if any.</p> </dd> <dt class="hdlist1" id="Documentation/gitprotocol-v2.txt-bundle-uriCLIENTTOSERVER"> bundle-uri CLIENT TO SERVER </dt> <dd> <p>The client SHOULD provide reference tips found in the bundle header(s) as <code>have</code> lines in any subsequent <code>fetch</code> request. A client MAY also ignore the bundle(s) entirely if doing so is deemed worse for some reason, e.g. if the bundles can’t be downloaded, it doesn’t like the tips it finds etc.</p> </dd> <dt class="hdlist1" id="Documentation/gitprotocol-v2.txt-WHENADVERTISEDBUNDLESREQUIRENOFURTHERNEGOTIATION"> WHEN ADVERTISED BUNDLE(S) REQUIRE NO FURTHER NEGOTIATION </dt> <dd> <p>If after issuing <code>bundle-uri</code> and <code>ls-refs</code>, and getting the header(s) of the bundle(s) the client finds that the ref tips it wants can be retrieved entirely from advertised bundle(s), the client MAY disconnect from the Git server. The results of such a <code>clone</code> or <code>fetch</code> should be indistinguishable from the state attained without using bundle-uri.</p> </dd> <dt class="hdlist1" id="Documentation/gitprotocol-v2.txt-EARLYCLIENTDISCONNECTIONSANDERRORRECOVERY"> EARLY CLIENT DISCONNECTIONS AND ERROR RECOVERY </dt> <dd> <p>A client MAY perform an early disconnect while still downloading the bundle(s) (having streamed and parsed their headers). In such a case the client MUST gracefully recover from any errors related to finishing the download and validation of the bundle(s).</p> <p>I.e. a client might need to re-connect and issue a <code>fetch</code> command, and possibly fall back to not making use of <code>bundle-uri</code> at all.</p> <p>This "MAY" behavior is specified as such (and not a "SHOULD") on the assumption that a server advertising bundle uris is more likely than not to be serving up a relatively large repository, and to be pointing to URIs that have a good chance of being in working order. A client MAY e.g. look at the payload size of the bundles as a heuristic to see if an early disconnect is worth it, should falling back on a full "fetch" dialog be necessary.</p> </dd> <dt class="hdlist1" id="Documentation/gitprotocol-v2.txt-WHENADVERTISEDBUNDLESREQUIREFURTHERNEGOTIATION"> WHEN ADVERTISED BUNDLE(S) REQUIRE FURTHER NEGOTIATION </dt> <dd> <p>A client SHOULD commence a negotiation of a PACK from the server via the "fetch" command using the OID tips found in advertised bundles, even if’s still in the process of downloading those bundle(s).</p> <p>This allows for aggressive early disconnects from any interactive server dialog. The client blindly trusts that the advertised OID tips are relevant, and issues them as <code>have</code> lines, it then requests any tips it would like (usually from the "ls-refs" advertisement) via <code>want</code> lines. The server will then compute a (hopefully small) PACK with the expected difference between the tips from the bundle(s) and the data requested.</p> <p>The only connection the client then needs to keep active is to the concurrently downloading static bundle(s), when those and the incremental PACK are retrieved they should be inflated and validated. Any errors at this point should be gracefully recovered from, see above.</p> </dd> </dl> </div> </div> <div class="sect3"> <h4 id="_bundle_uri_protocol_features"> +bundle-uri PROTOCOL FEATURES</h4> <p>The client constructs a bundle list from the <code><key>=<value></code> pairs provided by the server. These pairs are part of the <code>bundle.*</code> namespace as documented in <a href="git-config">git-config[1]</a>. In this section, we discuss some of these keys and describe the actions the client will do in response to this information.</p> <p>In particular, the <code>bundle.version</code> key specifies an integer value. The only accepted value at the moment is <code>1</code>, but if the client sees an unexpected value here then the client MUST ignore the bundle list.</p> <p>As long as <code>bundle.version</code> is understood, all other unknown keys MAY be ignored by the client. The server will guarantee compatibility with older clients, though newer clients may be better able to use the extra keys to minimize downloads.</p> <p>Any backwards-incompatible addition of pre-URI key-value will be guarded by a new <code>bundle.version</code> value or values in <code>bundle-uri</code> capability advertisement itself, and/or by new future <code>bundle-uri</code> request arguments.</p> <p>Some example key-value pairs that are not currently implemented but could be implemented in the future include:</p> <div class="ulist"> <ul> <li> <p>Add a "hash=<val>" or "size=<bytes>" advertise the expected hash or size of the bundle file.</p> </li> <li> <p>Advertise that one or more bundle files are the same (to e.g. have clients round-robin or otherwise choose one of N possible files).</p> </li> <li> <p>A "oid=<OID>" shortcut and "prerequisite=<OID>" shortcut. For expressing the common case of a bundle with one tip and no prerequisites, or one tip and one prerequisite.</p> <p>This would allow for optimizing the common case of servers who’d like to provide one "big bundle" containing only their "main" branch, and/or incremental updates thereof.</p> <p>A client receiving such a a response MAY assume that they can skip retrieving the header from a bundle at the indicated URI, and thus save themselves and the server(s) the request(s) needed to inspect the headers of that bundle or bundles.</p> </li> </ul> </div> </div> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitprotocol-v2" class="_attribution-link">https://git-scm.com/docs/gitprotocol-v2</a> + </p> +</div> diff --git a/devdocs/git/gitremote-helpers.html b/devdocs/git/gitremote-helpers.html new file mode 100644 index 00000000..924d677c --- /dev/null +++ b/devdocs/git/gitremote-helpers.html @@ -0,0 +1,14 @@ +<h1>gitremote-helpers</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitremote-helpers - Helper programs to interact with remote repositories</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git remote-<transport> <repository> [<URL>]</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Remote helper programs are normally not used directly by end users, but they are invoked by Git when it needs to interact with remote repositories Git does not support natively. A given helper will implement a subset of the capabilities documented here. When Git needs to interact with a repository using a remote helper, it spawns the helper as an independent process, sends commands to the helper’s standard input, and expects results from the helper’s standard output. Because a remote helper runs as an independent process from Git, there is no need to re-link Git to add a new helper, nor any need to link the helper with the implementation of Git.</p> <p>Every helper must support the "capabilities" command, which Git uses to determine what other commands the helper will accept. Those other commands can be used to discover and update remote refs, transport objects between the object database and the remote repository, and update the local object store.</p> <p>Git comes with a "curl" family of remote helpers, that handle various transport protocols, such as <code>git-remote-http</code>, <code>git-remote-https</code>, <code>git-remote-ftp</code> and <code>git-remote-ftps</code>. They implement the capabilities <code>fetch</code>, <code>option</code>, and <code>push</code>.</p> </div> <h2 id="_invocation">Invocation</h2> <div class="sectionbody"> <p>Remote helper programs are invoked with one or (optionally) two arguments. The first argument specifies a remote repository as in Git; it is either the name of a configured remote or a URL. The second argument specifies a URL; it is usually of the form <code><transport>://<address></code>, but any arbitrary string is possible. The <code>GIT_DIR</code> environment variable is set up for the remote helper and can be used to determine where to store additional data or from which directory to invoke auxiliary Git commands.</p> <p>When Git encounters a URL of the form <code><transport>://<address></code>, where <code><transport></code> is a protocol that it cannot handle natively, it automatically invokes <code>git remote-<transport></code> with the full URL as the second argument. If such a URL is encountered directly on the command line, the first argument is the same as the second, and if it is encountered in a configured remote, the first argument is the name of that remote.</p> <p>A URL of the form <code><transport>::<address></code> explicitly instructs Git to invoke <code>git remote-<transport></code> with <code><address></code> as the second argument. If such a URL is encountered directly on the command line, the first argument is <code><address></code>, and if it is encountered in a configured remote, the first argument is the name of that remote.</p> <p>Additionally, when a configured remote has <code>remote.<name>.vcs</code> set to <code><transport></code>, Git explicitly invokes <code>git remote-<transport></code> with <code><name></code> as the first argument. If set, the second argument is <code>remote.<name>.url</code>; otherwise, the second argument is omitted.</p> </div> <h2 id="_input_format">Input format</h2> <div class="sectionbody"> <p>Git sends the remote helper a list of commands on standard input, one per line. The first command is always the <code>capabilities</code> command, in response to which the remote helper must print a list of the capabilities it supports (see below) followed by a blank line. The response to the capabilities command determines what commands Git uses in the remainder of the command stream.</p> <p>The command stream is terminated by a blank line. In some cases (indicated in the documentation of the relevant commands), this blank line is followed by a payload in some other protocol (e.g., the pack protocol), while in others it indicates the end of input.</p> <div class="sect2"> <h3 id="_capabilities"> +Capabilities</h3> <p>Each remote helper is expected to support only a subset of commands. The operations a helper supports are declared to Git in the response to the <code>capabilities</code> command (see COMMANDS, below).</p> <p>In the following, we list all defined capabilities and for each we list which commands a helper with that capability must provide.</p> <div class="sect3"> <h4 id="_capabilities_for_pushing"> +Capabilities for Pushing</h4> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emconnectem"> <em>connect</em> </dt> <dd> <p>Can attempt to connect to <code>git receive-pack</code> (for pushing), <code>git upload-pack</code>, etc for communication using git’s native packfile protocol. This requires a bidirectional, full-duplex connection.</p> <p>Supported commands: <code>connect</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emstateless-connectem"> <em>stateless-connect</em> </dt> <dd> <p>Experimental; for internal use only. Can attempt to connect to a remote server for communication using git’s wire-protocol version 2. See the documentation for the stateless-connect command for more information.</p> <p>Supported commands: <code>stateless-connect</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-empushem"> <em>push</em> </dt> <dd> <p>Can discover remote refs and push local commits and the history leading up to them to new or existing remote refs.</p> <p>Supported commands: <code>list for-push</code>, <code>push</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emexportem"> <em>export</em> </dt> <dd> <p>Can discover remote refs and push specified objects from a fast-import stream to remote refs.</p> <p>Supported commands: <code>list for-push</code>, <code>export</code>.</p> </dd> </dl> </div> <p>If a helper advertises <code>connect</code>, Git will use it if possible and fall back to another capability if the helper requests so when connecting (see the <code>connect</code> command under COMMANDS). When choosing between <code>push</code> and <code>export</code>, Git prefers <code>push</code>. Other frontends may have some other order of preference.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emno-private-updateem"> <em>no-private-update</em> </dt> <dd> <p>When using the <code>refspec</code> capability, git normally updates the private ref on successful push. This update is disabled when the remote-helper declares the capability <code>no-private-update</code>.</p> </dd> </dl> </div> </div> <div class="sect3"> <h4 id="_capabilities_for_fetching"> +Capabilities for Fetching</h4> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emconnectem-1"> <em>connect</em> </dt> <dd> <p>Can try to connect to <code>git upload-pack</code> (for fetching), <code>git receive-pack</code>, etc for communication using the Git’s native packfile protocol. This requires a bidirectional, full-duplex connection.</p> <p>Supported commands: <code>connect</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emstateless-connectem-1"> <em>stateless-connect</em> </dt> <dd> <p>Experimental; for internal use only. Can attempt to connect to a remote server for communication using git’s wire-protocol version 2. See the documentation for the stateless-connect command for more information.</p> <p>Supported commands: <code>stateless-connect</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emfetchem"> <em>fetch</em> </dt> <dd> <p>Can discover remote refs and transfer objects reachable from them to the local object store.</p> <p>Supported commands: <code>list</code>, <code>fetch</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emimportem"> <em>import</em> </dt> <dd> <p>Can discover remote refs and output objects reachable from them as a stream in fast-import format.</p> <p>Supported commands: <code>list</code>, <code>import</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emcheck-connectivityem"> <em>check-connectivity</em> </dt> <dd> <p>Can guarantee that when a clone is requested, the received pack is self contained and is connected.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emgetem"> <em>get</em> </dt> <dd> <p>Can use the <code>get</code> command to download a file from a given URI.</p> </dd> </dl> </div> <p>If a helper advertises <code>connect</code>, Git will use it if possible and fall back to another capability if the helper requests so when connecting (see the <code>connect</code> command under COMMANDS). When choosing between <code>fetch</code> and <code>import</code>, Git prefers <code>fetch</code>. Other frontends may have some other order of preference.</p> </div> <div class="sect3"> <h4 id="_miscellaneous_capabilities"> +Miscellaneous capabilities</h4> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptionem"> <em>option</em> </dt> <dd> <p>For specifying settings like <code>verbosity</code> (how much output to write to stderr) and <code>depth</code> (how much history is wanted in the case of a shallow clone) that affect how other commands are carried out.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emrefspecemltrefspecgt"> <em>refspec</em> <refspec> </dt> <dd> <p>For remote helpers that implement <code>import</code> or <code>export</code>, this capability allows the refs to be constrained to a private namespace, instead of writing to refs/heads or refs/remotes directly. It is recommended that all importers providing the <code>import</code> capability use this. It’s mandatory for <code>export</code>.</p> <p>A helper advertising the capability <code>refspec refs/heads/*:refs/svn/origin/branches/*</code> is saying that, when it is asked to <code>import refs/heads/topic</code>, the stream it outputs will update the <code>refs/svn/origin/branches/topic</code> ref.</p> <p>This capability can be advertised multiple times. The first applicable refspec takes precedence. The left-hand of refspecs advertised with this capability must cover all refs reported by the list command. If no <code>refspec</code> capability is advertised, there is an implied <code>refspec *:*</code>.</p> <p>When writing remote-helpers for decentralized version control systems, it is advised to keep a local copy of the repository to interact with, and to let the private namespace refs point to this local repository, while the refs/remotes namespace is used to track the remote repository.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-embidi-importem"> <em>bidi-import</em> </dt> <dd> <p>This modifies the <code>import</code> capability. The fast-import commands <code>cat-blob</code> and <code>ls</code> can be used by remote-helpers to retrieve information about blobs and trees that already exist in fast-import’s memory. This requires a channel from fast-import to the remote-helper. If it is advertised in addition to "import", Git establishes a pipe from fast-import to the remote-helper’s stdin. It follows that Git and fast-import are both connected to the remote-helper’s stdin. Because Git can send multiple commands to the remote-helper it is required that helpers that use <code>bidi-import</code> buffer all <code>import</code> commands of a batch before sending data to fast-import. This is to prevent mixing commands and fast-import responses on the helper’s stdin.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emexport-marksemltfilegt"> <em>export-marks</em> <file> </dt> <dd> <p>This modifies the <code>export</code> capability, instructing Git to dump the internal marks table to <file> when complete. For details, read up on <code>--export-marks=<file></code> in <a href="git-fast-export">git-fast-export[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emimport-marksemltfilegt"> <em>import-marks</em> <file> </dt> <dd> <p>This modifies the <code>export</code> capability, instructing Git to load the marks specified in <file> before processing any input. For details, read up on <code>--import-marks=<file></code> in <a href="git-fast-export">git-fast-export[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emsigned-tagsem"> <em>signed-tags</em> </dt> <dd> <p>This modifies the <code>export</code> capability, instructing Git to pass <code>--signed-tags=verbatim</code> to <a href="git-fast-export">git-fast-export[1]</a>. In the absence of this capability, Git will use <code>--signed-tags=warn-strip</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emobject-formatem"> <em>object-format</em> </dt> <dd> <p>This indicates that the helper is able to interact with the remote side using an explicit hash algorithm extension.</p> </dd> </dl> </div> </div> </div> </div> <h2 id="_commands">Commands</h2> <div class="sectionbody"> <p>Commands are given by the caller on the helper’s standard input, one per line.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emcapabilitiesem"> <em>capabilities</em> </dt> <dd> <p>Lists the capabilities of the helper, one per line, ending with a blank line. Each capability may be preceded with <code>*</code>, which marks them mandatory for Git versions using the remote helper to understand. Any unknown mandatory capability is a fatal error.</p> <p>Support for this command is mandatory.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emlistem"> <em>list</em> </dt> <dd> <p>Lists the refs, one per line, in the format "<value> <name> [<attr> …]". The value may be a hex sha1 hash, "@<dest>" for a symref, ":<keyword> <value>" for a key-value pair, or "?" to indicate that the helper could not get the value of the ref. A space-separated list of attributes follows the name; unrecognized attributes are ignored. The list ends with a blank line.</p> <p>See REF LIST ATTRIBUTES for a list of currently defined attributes. See REF LIST KEYWORDS for a list of currently defined keywords.</p> <p>Supported if the helper has the "fetch" or "import" capability.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emlistfor-pushem"> <em>list for-push</em> </dt> <dd> <p>Similar to <code>list</code>, except that it is used if and only if the caller wants to the resulting ref list to prepare push commands. A helper supporting both push and fetch can use this to distinguish for which operation the output of <code>list</code> is going to be used, possibly reducing the amount of work that needs to be performed.</p> <p>Supported if the helper has the "push" or "export" capability.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptionemltnamegtltvaluegt"> <em>option</em> <name> <value> </dt> <dd> <p>Sets the transport helper option <name> to <value>. Outputs a single line containing one of <code>ok</code> (option successfully set), <code>unsupported</code> (option not recognized) or <code>error <msg></code> (option <name> is supported but <value> is not valid for it). Options should be set before other commands, and may influence the behavior of those commands.</p> <p>See OPTIONS for a list of currently defined options.</p> <p>Supported if the helper has the "option" capability.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emfetchemltsha1gtltnamegt"> <em>fetch</em> <sha1> <name> </dt> <dd> <p>Fetches the given object, writing the necessary objects to the database. Fetch commands are sent in a batch, one per line, terminated with a blank line. Outputs a single blank line when all fetch commands in the same batch are complete. Only objects which were reported in the output of <code>list</code> with a sha1 may be fetched this way.</p> <p>Optionally may output a <code>lock <file></code> line indicating the full path of a file under <code>$GIT_DIR/objects/pack</code> which is keeping a pack until refs can be suitably updated. The path must end with <code>.keep</code>. This is a mechanism to name a <pack,idx,keep> tuple by giving only the keep component. The kept pack will not be deleted by a concurrent repack, even though its objects may not be referenced until the fetch completes. The <code>.keep</code> file will be deleted at the conclusion of the fetch.</p> <p>If option <code>check-connectivity</code> is requested, the helper must output <code>connectivity-ok</code> if the clone is self-contained and connected.</p> <p>Supported if the helper has the "fetch" capability.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-empushemltsrcgtltdstgt"> <em>push</em> +<src>:<dst> </dt> <dd> <p>Pushes the given local <src> commit or branch to the remote branch described by <dst>. A batch sequence of one or more <code>push</code> commands is terminated with a blank line (if there is only one reference to push, a single <code>push</code> command is followed by a blank line). For example, the following would be two batches of <code>push</code>, the first asking the remote-helper to push the local ref <code>master</code> to the remote ref <code>master</code> and the local <code>HEAD</code> to the remote <code>branch</code>, and the second asking to push ref <code>foo</code> to ref <code>bar</code> (forced update requested by the <code>+</code>).</p> <div class="listingblock"> <div class="content"> <pre>push refs/heads/master:refs/heads/master +push HEAD:refs/heads/branch +\n +push +refs/heads/foo:refs/heads/bar +\n</pre> </div> </div> <p>Zero or more protocol options may be entered after the last <code>push</code> command, before the batch’s terminating blank line.</p> <p>When the push is complete, outputs one or more <code>ok <dst></code> or <code>error <dst> <why>?</code> lines to indicate success or failure of each pushed ref. The status report output is terminated by a blank line. The option field <why> may be quoted in a C style string if it contains an LF.</p> <p>Supported if the helper has the "push" capability.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emimportemltnamegt"> <em>import</em> <name> </dt> <dd> <p>Produces a fast-import stream which imports the current value of the named ref. It may additionally import other refs as needed to construct the history efficiently. The script writes to a helper-specific private namespace. The value of the named ref should be written to a location in this namespace derived by applying the refspecs from the "refspec" capability to the name of the ref.</p> <p>Especially useful for interoperability with a foreign versioning system.</p> <p>Just like <code>push</code>, a batch sequence of one or more <code>import</code> is terminated with a blank line. For each batch of <code>import</code>, the remote helper should produce a fast-import stream terminated by a <code>done</code> command.</p> <p>Note that if the <code>bidi-import</code> capability is used the complete batch sequence has to be buffered before starting to send data to fast-import to prevent mixing of commands and fast-import responses on the helper’s stdin.</p> <p>Supported if the helper has the "import" capability.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emexportem-1"> <em>export</em> </dt> <dd> <p>Instructs the remote helper that any subsequent input is part of a fast-import stream (generated by <code>git fast-export</code>) containing objects which should be pushed to the remote.</p> <p>Especially useful for interoperability with a foreign versioning system.</p> <p>The <code>export-marks</code> and <code>import-marks</code> capabilities, if specified, affect this command in so far as they are passed on to <code>git fast-export</code>, which then will load/store a table of marks for local objects. This can be used to implement for incremental operations.</p> <p>Supported if the helper has the "export" capability.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emconnectemltservicegt"> <em>connect</em> <service> </dt> <dd> <p>Connects to given service. Standard input and standard output of helper are connected to specified service (git prefix is included in service name so e.g. fetching uses <code>git-upload-pack</code> as service) on remote side. Valid replies to this command are empty line (connection established), <code>fallback</code> (no smart transport support, fall back to dumb transports) and just exiting with error message printed (can’t connect, don’t bother trying to fall back). After line feed terminating the positive (empty) response, the output of service starts. After the connection ends, the remote helper exits.</p> <p>Supported if the helper has the "connect" capability.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emstateless-connectemltservicegt"> <em>stateless-connect</em> <service> </dt> <dd> <p>Experimental; for internal use only. Connects to the given remote service for communication using git’s wire-protocol version 2. Valid replies to this command are empty line (connection established), <code>fallback</code> (no smart transport support, fall back to dumb transports) and just exiting with error message printed (can’t connect, don’t bother trying to fall back). After line feed terminating the positive (empty) response, the output of the service starts. Messages (both request and response) must consist of zero or more PKT-LINEs, terminating in a flush packet. Response messages will then have a response end packet after the flush packet to indicate the end of a response. The client must not expect the server to store any state in between request-response pairs. After the connection ends, the remote helper exits.</p> <p>Supported if the helper has the "stateless-connect" capability.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emgetemlturigtltpathgt"> <em>get</em> <uri> <path> </dt> <dd> <p>Downloads the file from the given <code><uri></code> to the given <code><path></code>. If <code><path>.temp</code> exists, then Git assumes that the <code>.temp</code> file is a partial download from a previous attempt and will resume the download from that position.</p> </dd> </dl> </div> <p>If a fatal error occurs, the program writes the error message to stderr and exits. The caller should expect that a suitable error message has been printed if the child closes the connection without completing a valid response for the current command.</p> <p>Additional commands may be supported, as may be determined from capabilities reported by the helper.</p> </div> <h2 id="_ref_list_attributes">Ref list attributes</h2> <div class="sectionbody"> <p>The <code>list</code> command produces a list of refs in which each ref may be followed by a list of attributes. The following ref list attributes are defined.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emunchangedem"> <em>unchanged</em> </dt> <dd> <p>This ref is unchanged since the last import or fetch, although the helper cannot necessarily determine what value that produced.</p> </dd> </dl> </div> </div> <h2 id="_ref_list_keywords">Ref list keywords</h2> <div class="sectionbody"> <p>The <code>list</code> command may produce a list of key-value pairs. The following keys are defined.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emobject-formatem-1"> <em>object-format</em> </dt> <dd> <p>The refs are using the given hash algorithm. This keyword is only used if the server and client both support the object-format extension.</p> </dd> </dl> </div> </div> <h2 id="_options">Options</h2> <div class="sectionbody"> <p>The following options are defined and (under suitable circumstances) set by Git if the remote helper has the <code>option</code> capability.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptionverbosityemltngt"> <em>option verbosity</em> <n> </dt> <dd> <p>Changes the verbosity of messages displayed by the helper. A value of 0 for <n> means that processes operate quietly, and the helper produces only error output. 1 is the default level of verbosity, and higher values of <n> correspond to the number of -v flags passed on the command line.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptionprogressememtrueememfalseem"> <em>option progress</em> {<em>true</em>|<em>false</em>} </dt> <dd> <p>Enables (or disables) progress messages displayed by the transport helper during a command.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptiondepthemltdepthgt"> <em>option depth</em> <depth> </dt> <dd> <p>Deepens the history of a shallow repository.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-optiondeepen-sincelttimestampgt"> 'option deepen-since <timestamp> </dt> <dd> <p>Deepens the history of a shallow repository based on time.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-optiondeepen-notltrefgt"> 'option deepen-not <ref> </dt> <dd> <p>Deepens the history of a shallow repository excluding ref. Multiple options add up.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptiondeepen-relativetrueememfalseem"> <em>option deepen-relative {'true</em>|<em>false</em>} </dt> <dd> <p>Deepens the history of a shallow repository relative to current boundary. Only valid when used with "option depth".</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptionfollowtagsememtrueememfalseem"> <em>option followtags</em> {<em>true</em>|<em>false</em>} </dt> <dd> <p>If enabled the helper should automatically fetch annotated tag objects if the object the tag points at was transferred during the fetch command. If the tag is not fetched by the helper a second fetch command will usually be sent to ask for the tag specifically. Some helpers may be able to use this option to avoid a second network connection.</p> </dd> </dl> </div> <p><code>option dry-run</code> {<code>true</code>|<code>false</code>}: If true, pretend the operation completed successfully, but don’t actually change any repository data. For most helpers this only applies to the <code>push</code>, if supported.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptionservpathltc-style-quoted-pathgtem"> <em>option servpath <c-style-quoted-path></em> </dt> <dd> <p>Sets service path (--upload-pack, --receive-pack etc.) for next connect. Remote helper may support this option, but must not rely on this option being set before connect request occurs.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptioncheck-connectivityememtrueememfalseem"> <em>option check-connectivity</em> {<em>true</em>|<em>false</em>} </dt> <dd> <p>Request the helper to check connectivity of a clone.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptionforceememtrueememfalseem"> <em>option force</em> {<em>true</em>|<em>false</em>} </dt> <dd> <p>Request the helper to perform a force update. Defaults to <code>false</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptioncloningememtrueememfalseem"> <em>option cloning</em> {<em>true</em>|<em>false</em>} </dt> <dd> <p>Notify the helper this is a clone request (i.e. the current repository is guaranteed empty).</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptionupdate-shallowememtrueememfalseem"> <em>option update-shallow</em> {<em>true</em>|<em>false</em>} </dt> <dd> <p>Allow to extend .git/shallow if the new refs require it.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptionpushcertememtrueememfalseem"> <em>option pushcert</em> {<em>true</em>|<em>false</em>} </dt> <dd> <p>GPG sign pushes.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-optionpush-optionltstringgt"> 'option push-option <string> </dt> <dd> <p>Transmit <string> as a push option. As the push option must not contain LF or NUL characters, the string is not encoded.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptionfrom-promisorememtrueememfalseem"> <em>option from-promisor</em> {<em>true</em>|<em>false</em>} </dt> <dd> <p>Indicate that these objects are being fetched from a promisor.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptionno-dependentsememtrueememfalseem"> <em>option no-dependents</em> {<em>true</em>|<em>false</em>} </dt> <dd> <p>Indicate that only the objects wanted need to be fetched, not their dependents.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptionatomicememtrueememfalseem"> <em>option atomic</em> {<em>true</em>|<em>false</em>} </dt> <dd> <p>When pushing, request the remote server to update refs in a single atomic transaction. If successful, all refs will be updated, or none will. If the remote side does not support this capability, the push will fail.</p> </dd> <dt class="hdlist1" id="Documentation/gitremote-helpers.txt-emoptionobject-formatememtrueemalgorithm"> <em>option object-format</em> {<em>true</em>|algorithm} </dt> <dd> <p>If <code>true</code>, indicate that the caller wants hash algorithm information to be passed back from the remote. This mode is used when fetching refs.</p> <p>If set to an algorithm, indicate that the caller wants to interact with the remote side using that algorithm.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-remote">git-remote[1]</a></p> <p><a href="git-remote-ext">git-remote-ext[1]</a></p> <p><a href="git-remote-fd">git-remote-fd[1]</a></p> <p><a href="git-fast-import">git-fast-import[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitremote-helpers" class="_attribution-link">https://git-scm.com/docs/gitremote-helpers</a> + </p> +</div> diff --git a/devdocs/git/gitrepository-layout.html b/devdocs/git/gitrepository-layout.html new file mode 100644 index 00000000..db8f0006 --- /dev/null +++ b/devdocs/git/gitrepository-layout.html @@ -0,0 +1,18 @@ +<h1>gitrepository-layout</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitrepository-layout - Git Repository Layout</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>$GIT_DIR/*</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>A Git repository comes in two different flavours:</p> <div class="ulist"> <ul> <li> <p>a <code>.git</code> directory at the root of the working tree;</p> </li> <li> <p>a <code><project>.git</code> directory that is a <code>bare</code> repository (i.e. without its own working tree), that is typically used for exchanging histories with others by pushing into it and fetching from it.</p> </li> </ul> </div> <p><strong>Note</strong>: Also you can have a plain text file <code>.git</code> at the root of your working tree, containing <code>gitdir: <path></code> to point at the real directory that has the repository. This mechanism is called a <code>gitfile</code> and is usually managed via the <code>git submodule</code> and <code>git worktree</code> commands. It is often used for a working tree of a submodule checkout, to allow you in the containing superproject to <code>git checkout</code> a branch that does not have the submodule. The <code>checkout</code> has to remove the entire submodule working tree, without losing the submodule repository.</p> <p>These things may exist in a Git repository.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-objects"> objects </dt> <dd> <p>Object store associated with this repository. Usually an object store is self sufficient (i.e. all the objects that are referred to by an object found in it are also found in it), but there are a few ways to violate it.</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>You could have an incomplete but locally usable repository by creating a shallow clone. See <a href="git-clone">git-clone[1]</a>.</p> </li> <li> <p>You could be using the <code>objects/info/alternates</code> or <code>$GIT_ALTERNATE_OBJECT_DIRECTORIES</code> mechanisms to <code>borrow</code> objects from other object stores. A repository with this kind of incomplete object store is not suitable to be published for use with dumb transports but otherwise is OK as long as <code>objects/info/alternates</code> points at the object stores it borrows from.</p> <p>This directory is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/objects" will be used instead.</p> </li> </ol> </div> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-objects0-9a-f0-9a-f"> objects/[0-9a-f][0-9a-f] </dt> <dd> <p>A newly created object is stored in its own file. The objects are splayed over 256 subdirectories using the first two characters of the sha1 object name to keep the number of directory entries in <code>objects</code> itself to a manageable number. Objects found here are often called <code>unpacked</code> (or <code>loose</code>) objects.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-objectspack"> objects/pack </dt> <dd> <p>Packs (files that store many objects in compressed form, along with index files to allow them to be randomly accessed) are found in this directory.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-objectsinfo"> objects/info </dt> <dd> <p>Additional information about the object store is recorded in this directory.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-objectsinfopacks"> objects/info/packs </dt> <dd> <p>This file is to help dumb transports discover what packs are available in this object store. Whenever a pack is added or removed, <code>git update-server-info</code> should be run to keep this file up to date if the repository is published for dumb transports. <code>git repack</code> does this by default.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-objectsinfoalternates"> objects/info/alternates </dt> <dd> <p>This file records paths to alternate object stores that this object store borrows objects from, one pathname per line. Note that not only native Git tools use it locally, but the HTTP fetcher also tries to use it remotely; this will usually work if you have relative paths (relative to the object database, not to the repository!) in your alternates file, but it will not work if you use absolute paths unless the absolute path in filesystem and web URL is the same. See also <code>objects/info/http-alternates</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-objectsinfohttp-alternates"> objects/info/http-alternates </dt> <dd> <p>This file records URLs to alternate object stores that this object store borrows objects from, to be used when the repository is fetched over HTTP.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-refs"> refs </dt> <dd> <p>References are stored in subdirectories of this directory. The <code>git prune</code> command knows to preserve objects reachable from refs found in this directory and its subdirectories. This directory is ignored (except refs/bisect, refs/rewritten and refs/worktree) if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/refs" will be used instead.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-refsheadscodenamecode"> refs/heads/<code>name</code> </dt> <dd> <p>records tip-of-the-tree commit objects of branch <code>name</code></p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-refstagscodenamecode"> refs/tags/<code>name</code> </dt> <dd> <p>records any object name (not necessarily a commit object, or a tag object that points at a commit object).</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-refsremotescodenamecode"> refs/remotes/<code>name</code> </dt> <dd> <p>records tip-of-the-tree commit objects of branches copied from a remote repository.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-refsreplacecodeltobj-sha1gtcode"> refs/replace/<code><obj-sha1></code> </dt> <dd> <p>records the SHA-1 of the object that replaces <code><obj-sha1></code>. This is similar to info/grafts and is internally used and maintained by <a href="git-replace">git-replace[1]</a>. Such refs can be exchanged between repositories while grafts are not.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-packed-refs"> packed-refs </dt> <dd> <p>records the same information as refs/heads/, refs/tags/, and friends record in a more efficient way. See <a href="git-pack-refs">git-pack-refs[1]</a>. This file is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/packed-refs" will be used instead.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-HEAD"> HEAD </dt> <dd> <p>A symref (see glossary) to the <code>refs/heads/</code> namespace describing the currently active branch. It does not mean much if the repository is not associated with any working tree (i.e. a <code>bare</code> repository), but a valid Git repository <strong>must</strong> have the HEAD file; some porcelains may use it to guess the designated "default" branch of the repository (usually <code>master</code>). It is legal if the named branch <code>name</code> does not (yet) exist. In some legacy setups, it is a symbolic link instead of a symref that points at the current branch.</p> <p>HEAD can also record a specific commit directly, instead of being a symref to point at the current branch. Such a state is often called <code>detached HEAD.</code> See <a href="git-checkout">git-checkout[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-config"> config </dt> <dd> <p>Repository specific configuration file. This file is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/config" will be used instead.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-configworktree"> config.worktree </dt> <dd> <p>Working directory specific configuration file for the main working directory in multiple working directory setup (see <a href="git-worktree">git-worktree[1]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-branches"> branches </dt> <dd> <p>A slightly deprecated way to store shorthands to be used to specify a URL to <code>git fetch</code>, <code>git pull</code> and <code>git push</code>. A file can be stored as <code>branches/<name></code> and then <code>name</code> can be given to these commands in place of <code>repository</code> argument. See the REMOTES section in <a href="git-fetch">git-fetch[1]</a> for details. This mechanism is legacy and not likely to be found in modern repositories. This directory is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/branches" will be used instead.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-hooks"> hooks </dt> <dd> <p>Hooks are customization scripts used by various Git commands. A handful of sample hooks are installed when <code>git init</code> is run, but all of them are disabled by default. To enable, the <code>.sample</code> suffix has to be removed from the filename by renaming. Read <a href="githooks">githooks[5]</a> for more details about each hook. This directory is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/hooks" will be used instead.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-common"> common </dt> <dd> <p>When multiple working trees are used, most of files in $GIT_DIR are per-worktree with a few known exceptions. All files under <code>common</code> however will be shared between all working trees.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-index"> index </dt> <dd> <p>The current index file for the repository. It is usually not found in a bare repository.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-sharedindexltSHA-1gt"> sharedindex.<SHA-1> </dt> <dd> <p>The shared index part, to be referenced by $GIT_DIR/index and other temporary index files. Only valid in split index mode.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-info"> info </dt> <dd> <p>Additional information about the repository is recorded in this directory. This directory is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/info" will be used instead.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-inforefs"> info/refs </dt> <dd> <p>This file helps dumb transports discover what refs are available in this repository. If the repository is published for dumb transports, this file should be regenerated by <code>git update-server-info</code> every time a tag or branch is created or modified. This is normally done from the <code>hooks/update</code> hook, which is run by the <code>git-receive-pack</code> command when you <code>git push</code> into the repository.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-infografts"> info/grafts </dt> <dd> <p>This file records fake commit ancestry information, to pretend the set of parents a commit has is different from how the commit was actually created. One record per line describes a commit and its fake parents by listing their 40-byte hexadecimal object names separated by a space and terminated by a newline.</p> <p>Note that the grafts mechanism is outdated and can lead to problems transferring objects between repositories; see <a href="git-replace">git-replace[1]</a> for a more flexible and robust system to do the same thing.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-infoexclude"> info/exclude </dt> <dd> <p>This file, by convention among Porcelains, stores the exclude pattern list. <code>.gitignore</code> is the per-directory ignore file. <code>git status</code>, <code>git add</code>, <code>git rm</code> and <code>git clean</code> look at it but the core Git commands do not look at it. See also: <a href="gitignore">gitignore[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-infoattributes"> info/attributes </dt> <dd> <p>Defines which attributes to assign to a path, similar to per-directory <code>.gitattributes</code> files. See also: <a href="gitattributes">gitattributes[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-infosparse-checkout"> info/sparse-checkout </dt> <dd> <p>This file stores sparse checkout patterns. See also: <a href="git-read-tree">git-read-tree[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-remotes"> remotes </dt> <dd> <p>Stores shorthands for URL and default refnames for use when interacting with remote repositories via <code>git fetch</code>, <code>git pull</code> and <code>git push</code> commands. See the REMOTES section in <a href="git-fetch">git-fetch[1]</a> for details. This mechanism is legacy and not likely to be found in modern repositories. This directory is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/remotes" will be used instead.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-logs"> logs </dt> <dd> <p>Records of changes made to refs are stored in this directory. See <a href="git-update-ref">git-update-ref[1]</a> for more information. This directory is ignored (except logs/HEAD) if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/logs" will be used instead.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-logsrefsheadscodenamecode"> logs/refs/heads/<code>name</code> </dt> <dd> <p>Records all changes made to the branch tip named <code>name</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-logsrefstagscodenamecode"> logs/refs/tags/<code>name</code> </dt> <dd> <p>Records all changes made to the tag named <code>name</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-shallow"> shallow </dt> <dd> <p>This is similar to <code>info/grafts</code> but is internally used and maintained by shallow clone mechanism. See <code>--depth</code> option to <a href="git-clone">git-clone[1]</a> and <a href="git-fetch">git-fetch[1]</a>. This file is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/shallow" will be used instead.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-commondir"> commondir </dt> <dd> <p>If this file exists, $GIT_COMMON_DIR (see <a href="git">git[1]</a>) will be set to the path specified in this file if it is not explicitly set. If the specified path is relative, it is relative to $GIT_DIR. The repository with commondir is incomplete without the repository pointed by "commondir".</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-modules"> modules </dt> <dd> <p>Contains the git-repositories of the submodules.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-worktrees"> worktrees </dt> <dd> <p>Contains administrative data for linked working trees. Each subdirectory contains the working tree-related part of a linked working tree. This directory is ignored if $GIT_COMMON_DIR is set, in which case "$GIT_COMMON_DIR/worktrees" will be used instead.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-worktreesltidgtgitdir"> worktrees/<id>/gitdir </dt> <dd> <p>A text file containing the absolute path back to the .git file that points to here. This is used to check if the linked repository has been manually removed and there is no need to keep this directory any more. The mtime of this file should be updated every time the linked repository is accessed.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-worktreesltidgtlocked"> worktrees/<id>/locked </dt> <dd> <p>If this file exists, the linked working tree may be on a portable device and not available. The presence of this file prevents <code>worktrees/<id></code> from being pruned either automatically or manually by <code>git worktree prune</code>. The file may contain a string explaining why the repository is locked.</p> </dd> <dt class="hdlist1" id="Documentation/gitrepository-layout.txt-worktreesltidgtconfigworktree"> worktrees/<id>/config.worktree </dt> <dd> <p>Working directory specific configuration file.</p> </dd> </dl> </div> </div> <h2 id="_git_repository_format_versions">Git repository format versions</h2> <div class="sectionbody"> <p>Every git repository is marked with a numeric version in the <code>core.repositoryformatversion</code> key of its <code>config</code> file. This version specifies the rules for operating on the on-disk repository data. An implementation of git which does not understand a particular version advertised by an on-disk repository MUST NOT operate on that repository; doing so risks not only producing wrong results, but actually losing data.</p> <p>Because of this rule, version bumps should be kept to an absolute minimum. Instead, we generally prefer these strategies:</p> <div class="ulist"> <ul> <li> <p>bumping format version numbers of individual data files (e.g., index, packfiles, etc). This restricts the incompatibilities only to those files.</p> </li> <li> <p>introducing new data that gracefully degrades when used by older clients (e.g., pack bitmap files are ignored by older clients, which simply do not take advantage of the optimization they provide).</p> </li> </ul> </div> <p>A whole-repository format version bump should only be part of a change that cannot be independently versioned. For instance, if one were to change the reachability rules for objects, or the rules for locking refs, that would require a bump of the repository format version.</p> <p>Note that this applies only to accessing the repository’s disk contents directly. An older client which understands only format <code>0</code> may still connect via <code>git://</code> to a repository using format <code>1</code>, as long as the server process understands format <code>1</code>.</p> <p>The preferred strategy for rolling out a version bump (whether whole repository or for a single file) is to teach git to read the new format, and allow writing the new format with a config switch or command line option (for experimentation or for those who do not care about backwards compatibility with older gits). Then after a long period to allow the reading capability to become common, we may switch to writing the new format by default.</p> <p>The currently defined format versions are:</p> <div class="sect2"> <h3 id="_version_0"> +Version <code>0</code> +</h3> <p>This is the format defined by the initial version of git, including but not limited to the format of the repository directory, the repository configuration file, and the object and ref storage. Specifying the complete behavior of git is beyond the scope of this document.</p> </div> <div class="sect2"> <h3 id="_version_1"> +Version <code>1</code> +</h3> <p>This format is identical to version <code>0</code>, with the following exceptions:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>When reading the <code>core.repositoryformatversion</code> variable, a git implementation which supports version 1 MUST also read any configuration keys found in the <code>extensions</code> section of the configuration file.</p> </li> <li> <p>If a version-1 repository specifies any <code>extensions.*</code> keys that the running git has not implemented, the operation MUST NOT proceed. Similarly, if the value of any known key is not understood by the implementation, the operation MUST NOT proceed.</p> </li> </ol> </div> <p>Note that if no extensions are specified in the config file, then <code>core.repositoryformatversion</code> SHOULD be set to <code>0</code> (setting it to <code>1</code> provides no benefit, and makes the repository incompatible with older implementations of git).</p> <p>This document will serve as the master list for extensions. Any implementation wishing to define a new extension should make a note of it here, in order to claim the name.</p> <p>The defined extensions are:</p> <div class="sect3"> <h4 id="_noop"> +<code>noop</code> +</h4> <p>This extension does not change git’s behavior at all. It is useful only for testing format-1 compatibility.</p> </div> <div class="sect3"> <h4 id="_preciousobjects"> +<code>preciousObjects</code> +</h4> <p>When the config key <code>extensions.preciousObjects</code> is set to <code>true</code>, objects in the repository MUST NOT be deleted (e.g., by <code>git-prune</code> or <code>git repack -d</code>).</p> </div> <div class="sect3"> <h4 id="_partialclone"> +<code>partialClone</code> +</h4> <p>When the config key <code>extensions.partialClone</code> is set, it indicates that the repo was created with a partial clone (or later performed a partial fetch) and that the remote may have omitted sending certain unwanted objects. Such a remote is called a "promisor remote" and it promises that all such omitted objects can be fetched from it in the future.</p> <p>The value of this key is the name of the promisor remote.</p> </div> <div class="sect3"> <h4 id="_worktreeconfig"> +<code>worktreeConfig</code> +</h4> <p>If set, by default "git config" reads from both "config" and "config.worktree" files from GIT_DIR in that order. In multiple working directory mode, "config" file is shared while "config.worktree" is per-working directory (i.e., it’s in GIT_COMMON_DIR/worktrees/<id>/config.worktree)</p> </div> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-init">git-init[1]</a>, <a href="git-clone">git-clone[1]</a>, <a href="git-fetch">git-fetch[1]</a>, <a href="git-pack-refs">git-pack-refs[1]</a>, <a href="git-gc">git-gc[1]</a>, <a href="git-checkout">git-checkout[1]</a>, <a href="gitglossary">gitglossary[7]</a>, <a href="user-manual">The Git User’s Manual</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitrepository-layout" class="_attribution-link">https://git-scm.com/docs/gitrepository-layout</a> + </p> +</div> diff --git a/devdocs/git/gitrevisions.html b/devdocs/git/gitrevisions.html new file mode 100644 index 00000000..a64b1753 --- /dev/null +++ b/devdocs/git/gitrevisions.html @@ -0,0 +1,59 @@ +<h1>gitrevisions</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitrevisions - Specifying revisions and ranges for Git</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>gitrevisions</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Many Git commands take revision parameters as arguments. Depending on the command, they denote a specific commit or, for commands which walk the revision graph (such as <a href="git-log">git-log[1]</a>), all commits which are reachable from that commit. For commands that walk the revision graph one can also specify a range of revisions explicitly.</p> <p>In addition, some Git commands (such as <a href="git-show">git-show[1]</a> and <a href="git-push">git-push[1]</a>) can also take revision parameters which denote other objects than commits, e.g. blobs ("files") or trees ("directories of files").</p> </div> <h2 id="_specifying_revisions">Specifying revisions</h2> <div class="sectionbody"> <p>A revision parameter <code><rev></code> typically, but not necessarily, names a commit object. It uses what is called an <code>extended SHA-1</code> syntax. Here are various ways to spell object names. The ones listed near the end of this list name trees and blobs contained in a commit.</p> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> This document shows the "raw" syntax as seen by git. The shell and other UIs might require additional quoting to protect special characters and to avoid word splitting. </td> </tr> </table> </div> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltsha1gtemegemdae86e1950b1277e545cee180551750029cfe735ememdae86eem"> <em><sha1></em>, e.g. <em>dae86e1950b1277e545cee180551750029cfe735</em>, <em>dae86e</em> </dt> <dd> <p>The full SHA-1 object name (40-byte hexadecimal string), or a leading substring that is unique within the repository. E.g. dae86e1950b1277e545cee180551750029cfe735 and dae86e both name the same commit object if there is no other object in your repository whose object name starts with dae86e.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltdescribeOutputgtemegemv1742-679-g3bee7fbem"> <em><describeOutput></em>, e.g. <em>v1.7.4.2-679-g3bee7fb</em> </dt> <dd> <p>Output from <code>git describe</code>; i.e. a closest tag, optionally followed by a dash and a number of commits, followed by a dash, a <code>g</code>, and an abbreviated object name.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrefnamegtemegemmasterememheadsmasterememrefsheadsmasterem"> <em><refname></em>, e.g. <em>master</em>, <em>heads/master</em>, <em>refs/heads/master</em> </dt> <dd> <p>A symbolic ref name. E.g. <code>master</code> typically means the commit object referenced by <code>refs/heads/master</code>. If you happen to have both <code>heads/master</code> and <code>tags/master</code>, you can explicitly say <code>heads/master</code> to tell Git which one you mean. When ambiguous, a <code><refname></code> is disambiguated by taking the first match in the following rules:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>If <code>$GIT_DIR/<refname></code> exists, that is what you mean (this is usually useful only for <code>HEAD</code>, <code>FETCH_HEAD</code>, <code>ORIG_HEAD</code>, <code>MERGE_HEAD</code>, <code>REBASE_HEAD</code>, <code>REVERT_HEAD</code>, <code>CHERRY_PICK_HEAD</code>, <code>BISECT_HEAD</code> and <code>AUTO_MERGE</code>);</p> </li> <li> <p>otherwise, <code>refs/<refname></code> if it exists;</p> </li> <li> <p>otherwise, <code>refs/tags/<refname></code> if it exists;</p> </li> <li> <p>otherwise, <code>refs/heads/<refname></code> if it exists;</p> </li> <li> <p>otherwise, <code>refs/remotes/<refname></code> if it exists;</p> </li> <li> <p>otherwise, <code>refs/remotes/<refname>/HEAD</code> if it exists.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitrevisions.txt-codeHEADcode"> <code>HEAD</code> </dt> <dd> <p>names the commit on which you based the changes in the working tree.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-codeFETCHHEADcode"> <code>FETCH_HEAD</code> </dt> <dd> <p>records the branch which you fetched from a remote repository with your last <code>git fetch</code> invocation.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-codeORIGHEADcode"> <code>ORIG_HEAD</code> </dt> <dd> <p>is created by commands that move your <code>HEAD</code> in a drastic way (<code>git +am</code>, <code>git merge</code>, <code>git rebase</code>, <code>git reset</code>), to record the position of the <code>HEAD</code> before their operation, so that you can easily change the tip of the branch back to the state before you ran them.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-codeMERGEHEADcode"> <code>MERGE_HEAD</code> </dt> <dd> <p>records the commit(s) which you are merging into your branch when you run <code>git merge</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-codeREBASEHEADcode"> <code>REBASE_HEAD</code> </dt> <dd> <p>during a rebase, records the commit at which the operation is currently stopped, either because of conflicts or an <code>edit</code> command in an interactive rebase.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-codeREVERTHEADcode"> <code>REVERT_HEAD</code> </dt> <dd> <p>records the commit which you are reverting when you run <code>git revert</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-codeCHERRYPICKHEADcode"> <code>CHERRY_PICK_HEAD</code> </dt> <dd> <p>records the commit which you are cherry-picking when you run <code>git +cherry-pick</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-codeBISECTHEADcode"> <code>BISECT_HEAD</code> </dt> <dd> <p>records the current commit to be tested when you run <code>git bisect +--no-checkout</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-codeAUTOMERGEcode"> <code>AUTO_MERGE</code> </dt> <dd> <p>records a tree object corresponding to the state the <code>ort</code> merge strategy wrote to the working tree when a merge operation resulted in conflicts.</p> </dd> </dl> </div> </li> </ol> </div> <p>Note that any of the <code>refs/*</code> cases above may come either from the <code>$GIT_DIR/refs</code> directory or from the <code>$GIT_DIR/packed-refs</code> file. While the ref name encoding is unspecified, UTF-8 is preferred as some output processing may assume ref names in UTF-8.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emem"> <em>@</em> </dt> <dd> <p><code>@</code> alone is a shortcut for <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrefnamegtltdategtemegemmasteryesterdayememHEAD5minutesagoem"> <em>[<refname>]@{<date>}</em>, e.g. <em>master@{yesterday}</em>, <em>HEAD@{5 minutes ago}</em> </dt> <dd> <p>A ref followed by the suffix <code>@</code> with a date specification enclosed in a brace pair (e.g. <code>{yesterday}</code>, <code>{1 month 2 weeks 3 days 1 hour 1 second ago}</code> or <code>{1979-02-26 18:30:00}</code>) specifies the value of the ref at a prior point in time. This suffix may only be used immediately following a ref name and the ref must have an existing log (<code>$GIT_DIR/logs/<ref></code>). Note that this looks up the state of your <strong>local</strong> ref at a given time; e.g., what was in your local <code>master</code> branch last week. If you want to look at commits made during certain times, see <code>--since</code> and <code>--until</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrefnamegtltngtemegemmaster1em"> <em><refname>@{<n>}</em>, e.g. <em>master@{1}</em> </dt> <dd> <p>A ref followed by the suffix <code>@</code> with an ordinal specification enclosed in a brace pair (e.g. <code>{1}</code>, <code>{15}</code>) specifies the n-th prior value of that ref. For example <code>master@{1}</code> is the immediate prior value of <code>master</code> while <code>master@{5}</code> is the 5th prior value of <code>master</code>. This suffix may only be used immediately following a ref name and the ref must have an existing log (<code>$GIT_DIR/logs/<refname></code>).</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltngtemegem1em"> <em>@{<n>}</em>, e.g. <em>@{1}</em> </dt> <dd> <p>You can use the <code>@</code> construct with an empty ref part to get at a reflog entry of the current branch. For example, if you are on branch <code>blabla</code> then <code>@{1}</code> means the same as <code>blabla@{1}</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-em-ltngtemegem-1em"> <em>@{-<n>}</em>, e.g. <em>@{-1}</em> </dt> <dd> <p>The construct <code>@{-<n>}</code> means the <n>th branch/commit checked out before the current one.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltbranchnamegtupstreamemegemmasterupstreamememuem"> <em>[<branchname>]@{upstream}</em>, e.g. <em>master@{upstream}</em>, <em>@{u}</em> </dt> <dd> <p>A branch B may be set up to build on top of a branch X (configured with <code>branch.<name>.merge</code>) at a remote R (configured with <code>branch.<name>.remote</code>). B@{u} refers to the remote-tracking branch for the branch X taken from remote R, typically found at <code>refs/remotes/R/X</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltbranchnamegtpushemegemmasterpushemempushem"> <em>[<branchname>]@{push}</em>, e.g. <em>master@{push}</em>, <em>@{push}</em> </dt> <dd> <p>The suffix <code>@{push}</code> reports the branch "where we would push to" if <code>git push</code> were run while <code>branchname</code> was checked out (or the current <code>HEAD</code> if no branchname is specified). Like for <code>@{upstream}</code>, we report the remote-tracking branch that corresponds to that branch at the remote.</p> <p>Here’s an example to make it more clear:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config push.default current +$ git config remote.pushdefault myfork +$ git switch -c mybranch origin/master + +$ git rev-parse --symbolic-full-name @{upstream} +refs/remotes/origin/master + +$ git rev-parse --symbolic-full-name @{push} +refs/remotes/myfork/mybranch</pre> </div> </div> <p>Note in the example that we set up a triangular workflow, where we pull from one location and push to another. In a non-triangular workflow, <code>@{push}</code> is the same as <code>@{upstream}</code>, and there is no need for it.</p> <p>This suffix is also accepted when spelled in uppercase, and means the same thing no matter the case.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrevgtltngtemegemHEADv1510em"> <em><rev>^[<n>]</em>, e.g. <em>HEAD^, v1.5.1^0</em> </dt> <dd> <p>A suffix <code>^</code> to a revision parameter means the first parent of that commit object. <code>^<n></code> means the <n>th parent (i.e. <code><rev>^</code> is equivalent to <code><rev>^1</code>). As a special rule, <code><rev>^0</code> means the commit itself and is used when <code><rev></code> is the object name of a tag object that refers to a commit object.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrevgtltngtemegemHEADmaster3em"> <em><rev>~[<n>]</em>, e.g. <em>HEAD~, master~3</em> </dt> <dd> <p>A suffix <code>~</code> to a revision parameter means the first parent of that commit object. A suffix <code>~<n></code> to a revision parameter means the commit object that is the <n>th generation ancestor of the named commit object, following only the first parents. I.e. <code><rev>~3</code> is equivalent to <code><rev>^^^</code> which is equivalent to <code><rev>^1^1^1</code>. See below for an illustration of the usage of this form.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrevgtlttypegtemegemv0998commitem"> <em><rev>^{<type>}</em>, e.g. <em>v0.99.8^{commit}</em> </dt> <dd> <p>A suffix <code>^</code> followed by an object type name enclosed in brace pair means dereference the object at <code><rev></code> recursively until an object of type <code><type></code> is found or the object cannot be dereferenced anymore (in which case, barf). For example, if <code><rev></code> is a commit-ish, <code><rev>^{commit}</code> describes the corresponding commit object. Similarly, if <code><rev></code> is a tree-ish, <code><rev>^{tree}</code> describes the corresponding tree object. <code><rev>^0</code> is a short-hand for <code><rev>^{commit}</code>.</p> <p><code><rev>^{object}</code> can be used to make sure <code><rev></code> names an object that exists, without requiring <code><rev></code> to be a tag, and without dereferencing <code><rev></code>; because a tag is already an object, it does not have to be dereferenced even once to get to an object.</p> <p><code><rev>^{tag}</code> can be used to ensure that <code><rev></code> identifies an existing tag object.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrevgtemegemv0998em"> <em><rev>^{}</em>, e.g. <em>v0.99.8^{}</em> </dt> <dd> <p>A suffix <code>^</code> followed by an empty brace pair means the object could be a tag, and dereference the tag recursively until a non-tag object is found.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrevgtlttextgtemegemHEADfixnastybugem"> <em><rev>^{/<text>}</em>, e.g. <em>HEAD^{/fix nasty bug}</em> </dt> <dd> <p>A suffix <code>^</code> to a revision parameter, followed by a brace pair that contains a text led by a slash, is the same as the <code>:/fix nasty bug</code> syntax below except that it returns the youngest matching commit which is reachable from the <code><rev></code> before <code>^</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emlttextgtemegemfixnastybugem"> <em>:/<text></em>, e.g. <em>:/fix nasty bug</em> </dt> <dd> <p>A colon, followed by a slash, followed by a text, names a commit whose commit message matches the specified regular expression. This name returns the youngest matching commit which is reachable from any ref, including HEAD. The regular expression can match any part of the commit message. To match messages starting with a string, one can use e.g. <code>:/^foo</code>. The special sequence <code>:/!</code> is reserved for modifiers to what is matched. <code>:/!-foo</code> performs a negative match, while <code>:/!!foo</code> matches a literal <code>!</code> character, followed by <code>foo</code>. Any other sequence beginning with <code>:/!</code> is reserved for now. Depending on the given text, the shell’s word splitting rules might require additional quoting.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrevgtltpathgtemegemHEADREADMEememmasterREADMEem"> <em><rev>:<path></em>, e.g. <em>HEAD:README</em>, <em>master:./README</em> </dt> <dd> <p>A suffix <code>:</code> followed by a path names the blob or tree at the given path in the tree-ish object named by the part before the colon. A path starting with <code>./</code> or <code>../</code> is relative to the current working directory. The given path will be converted to be relative to the working tree’s root directory. This is most useful to address a blob or tree from a commit or tree that has the same tree structure as the working tree.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltngtltpathgtemegem0READMEememREADMEem"> <em>:[<n>:]<path></em>, e.g. <em>:0:README</em>, <em>:README</em> </dt> <dd> <p>A colon, optionally followed by a stage number (0 to 3) and a colon, followed by a path, names a blob object in the index at the given path. A missing stage number (and the colon that follows it) names a stage 0 entry. During a merge, stage 1 is the common ancestor, stage 2 is the target branch’s version (typically the current branch), and stage 3 is the version from the branch which is being merged.</p> </dd> </dl> </div> <p>Here is an illustration, by Jon Loeliger. Both commit nodes B and C are parents of commit node A. Parent commits are ordered left-to-right.</p> <div class="literalblock"> <div class="content"> <pre>G H I J + \ / \ / + D E F + \ | / \ + \ | / | + \|/ | + B C + \ / + \ / + A</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre>A = = A^0 +B = A^ = A^1 = A~1 +C = = A^2 +D = A^^ = A^1^1 = A~2 +E = B^2 = A^^2 +F = B^3 = A^^3 +G = A^^^ = A^1^1^1 = A~3 +H = D^2 = B^^2 = A^^^2 = A~2^2 +I = F^ = B^3^ = A^^3^ +J = F^2 = B^3^2 = A^^3^2</pre> </div> </div> </div> <h2 id="_specifying_ranges">Specifying ranges</h2> <div class="sectionbody"> <p>History traversing commands such as <code>git log</code> operate on a set of commits, not just a single commit.</p> <p>For these commands, specifying a single revision, using the notation described in the previous section, means the set of commits <code>reachable</code> from the given commit.</p> <p>Specifying several revisions means the set of commits reachable from any of the given commits.</p> <p>A commit’s reachable set is the commit itself and the commits in its ancestry chain.</p> <p>There are several notations to specify a set of connected commits (called a "revision range"), illustrated below.</p> <div class="sect2"> <h3 id="_commit_exclusions"> +Commit Exclusions</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrevgtemcaretNotation"> <em>^<rev></em> (caret) Notation </dt> <dd> <p>To exclude commits reachable from a commit, a prefix <code>^</code> notation is used. E.g. <code>^r1 r2</code> means commits reachable from <code>r2</code> but exclude the ones reachable from <code>r1</code> (i.e. <code>r1</code> and its ancestors).</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_dotted_range_notations"> +Dotted Range Notations</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitrevisions.txt-Theememtwo-dotRangeNotation"> The <em>..</em> (two-dot) Range Notation </dt> <dd> <p>The <code>^r1 r2</code> set operation appears so often that there is a shorthand for it. When you have two commits <code>r1</code> and <code>r2</code> (named according to the syntax explained in SPECIFYING REVISIONS above), you can ask for commits that are reachable from r2 excluding those that are reachable from r1 by <code>^r1 r2</code> and it can be written as <code>r1..r2</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-Theememthree-dotSymmetricDifferenceNotation"> The <em>...</em> (three-dot) Symmetric Difference Notation </dt> <dd> <p>A similar notation <code>r1...r2</code> is called symmetric difference of <code>r1</code> and <code>r2</code> and is defined as <code>r1 r2 --not $(git merge-base --all r1 r2)</code>. It is the set of commits that are reachable from either one of <code>r1</code> (left side) or <code>r2</code> (right side) but not from both.</p> </dd> </dl> </div> <p>In these two shorthand notations, you can omit one end and let it default to HEAD. For example, <code>origin..</code> is a shorthand for <code>origin..HEAD</code> and asks "What did I do since I forked from the origin branch?" Similarly, <code>..origin</code> is a shorthand for <code>HEAD..origin</code> and asks "What did the origin do since I forked from them?" Note that <code>..</code> would mean <code>HEAD..HEAD</code> which is an empty range that is both reachable and unreachable from HEAD.</p> <p>Commands that are specifically designed to take two distinct ranges (e.g. "git range-diff R1 R2" to compare two ranges) do exist, but they are exceptions. Unless otherwise noted, all "git" commands that operate on a set of commits work on a single revision range. In other words, writing two "two-dot range notation" next to each other, e.g.</p> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$ git log A..B C..D</pre> </div> </div> <p>does <strong>not</strong> specify two revision ranges for most commands. Instead it will name a single connected set of commits, i.e. those that are reachable from either B or D but are reachable from neither A or C. In a linear history like this:</p> <div class="literalblock"> <div class="content"> <pre>---A---B---o---o---C---D</pre> </div> </div> <p>because A and B are reachable from C, the revision range specified by these two dotted ranges is a single commit D.</p> </div> <div class="sect2"> <h3 id="_other_rev_parent_shorthand_notations"> +Other <rev>^ Parent Shorthand Notations</h3> <p>Three other shorthands exist, particularly useful for merge commits, for naming a set that is formed by a commit and its parent commits.</p> <p>The <code>r1^@</code> notation means all parents of <code>r1</code>.</p> <p>The <code>r1^!</code> notation includes commit <code>r1</code> but excludes all of its parents. By itself, this notation denotes the single commit <code>r1</code>.</p> <p>The <code><rev>^-[<n>]</code> notation includes <code><rev></code> but excludes the <n>th parent (i.e. a shorthand for <code><rev>^<n>..<rev></code>), with <code><n></code> = 1 if not given. This is typically useful for merge commits where you can just pass <code><commit>^-</code> to get all the commits in the branch that was merged in merge commit <code><commit></code> (including <code><commit></code> itself).</p> <p>While <code><rev>^<n></code> was about specifying a single commit parent, these three notations also consider its parents. For example you can say <code>HEAD^2^@</code>, however you cannot say <code>HEAD^@^2</code>.</p> </div> </div> <h2 id="_revision_range_summary">Revision range summary</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrevgtem"> <em><rev></em> </dt> <dd> <p>Include commits that are reachable from <rev> (i.e. <rev> and its ancestors).</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrevgtem-1"> <em>^<rev></em> </dt> <dd> <p>Exclude commits that are reachable from <rev> (i.e. <rev> and its ancestors).</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrev1gtltrev2gtem"> <em><rev1>..<rev2></em> </dt> <dd> <p>Include commits that are reachable from <rev2> but exclude those that are reachable from <rev1>. When either <rev1> or <rev2> is omitted, it defaults to <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrev1gtltrev2gtem-1"> <em><rev1>...<rev2></em> </dt> <dd> <p>Include commits that are reachable from either <rev1> or <rev2> but exclude those that are reachable from both. When either <rev1> or <rev2> is omitted, it defaults to <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrevgtemegemHEADem"> <em><rev>^@</em>, e.g. <em>HEAD^@</em> </dt> <dd> <p>A suffix <code>^</code> followed by an at sign is the same as listing all parents of <code><rev></code> (meaning, include anything reachable from its parents, but not the commit itself).</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrevgtemegemHEADem-1"> <em><rev>^!</em>, e.g. <em>HEAD^!</em> </dt> <dd> <p>A suffix <code>^</code> followed by an exclamation mark is the same as giving commit <code><rev></code> and all its parents prefixed with <code>^</code> to exclude them (and their ancestors).</p> </dd> <dt class="hdlist1" id="Documentation/gitrevisions.txt-emltrevgt-ltngtemegemHEAD-HEAD-2em"> <em><rev>^-<n></em>, e.g. <em>HEAD^-, HEAD^-2</em> </dt> <dd> <p>Equivalent to <code><rev>^<n>..<rev></code>, with <code><n></code> = 1 if not given.</p> </dd> </dl> </div> <p>Here are a handful of examples using the Loeliger illustration above, with each step in the notation’s expansion and selection carefully spelt out:</p> <div class="literalblock"> <div class="content"> <pre> Args Expanded arguments Selected commits + D G H D + D F G H I J D F + ^G D H D + ^D B E I J F B + ^D B C E I J F B C + C I J F C + B..C = ^B C C + B...C = B ^F C G H D E B C + B^- = B^..B + = ^B^1 B E I J F B + C^@ = C^1 + = F I J F + B^@ = B^1 B^2 B^3 + = D E F D G H E F I J + C^! = C ^C^@ + = C ^C^1 + = C ^F C + B^! = B ^B^@ + = B ^B^1 ^B^2 ^B^3 + = B ^D ^E ^F B + F^! D = F ^I ^J D G H D F</pre> </div> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-rev-parse">git-rev-parse[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitrevisions" class="_attribution-link">https://git-scm.com/docs/gitrevisions</a> + </p> +</div> diff --git a/devdocs/git/gitsubmodules.html b/devdocs/git/gitsubmodules.html new file mode 100644 index 00000000..e57f5802 --- /dev/null +++ b/devdocs/git/gitsubmodules.html @@ -0,0 +1,41 @@ +<h1>gitsubmodules</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitsubmodules - Mounting one repository inside another</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="literalblock"> <div class="content"> <pre>.gitmodules, $GIT_DIR/config</pre> </div> </div> <div class="listingblock"> <div class="content"> <pre data-language="shell">git submodule +git <command> --recurse-submodules</pre> </div> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>A submodule is a repository embedded inside another repository. The submodule has its own history; the repository it is embedded in is called a superproject.</p> <p>On the filesystem, a submodule usually (but not always - see FORMS below) consists of (i) a Git directory located under the <code>$GIT_DIR/modules/</code> directory of its superproject, (ii) a working directory inside the superproject’s working directory, and a <code>.git</code> file at the root of the submodule’s working directory pointing to (i).</p> <p>Assuming the submodule has a Git directory at <code>$GIT_DIR/modules/foo/</code> and a working directory at <code>path/to/bar/</code>, the superproject tracks the submodule via a <code>gitlink</code> entry in the tree at <code>path/to/bar</code> and an entry in its <code>.gitmodules</code> file (see <a href="gitmodules">gitmodules[5]</a>) of the form <code>submodule.foo.path = path/to/bar</code>.</p> <p>The <code>gitlink</code> entry contains the object name of the commit that the superproject expects the submodule’s working directory to be at.</p> <p>The section <code>submodule.foo.*</code> in the <code>.gitmodules</code> file gives additional hints to Git’s porcelain layer. For example, the <code>submodule.foo.url</code> setting specifies where to obtain the submodule.</p> <p>Submodules can be used for at least two different use cases:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Using another project while maintaining independent history. Submodules allow you to contain the working tree of another project within your own working tree while keeping the history of both projects separate. Also, since submodules are fixed to an arbitrary version, the other project can be independently developed without affecting the superproject, allowing the superproject project to fix itself to new versions only when desired.</p> </li> <li> <p>Splitting a (logically single) project into multiple repositories and tying them back together. This can be used to overcome current limitations of Git’s implementation to have finer grained access:</p> <div class="ulist"> <ul> <li> <p>Size of the Git repository: In its current form Git scales up poorly for large repositories containing content that is not compressed by delta computation between trees. For example, you can use submodules to hold large binary assets and these repositories can be shallowly cloned such that you do not have a large history locally.</p> </li> <li> <p>Transfer size: In its current form Git requires the whole working tree present. It does not allow partial trees to be transferred in fetch or clone. If the project you work on consists of multiple repositories tied together as submodules in a superproject, you can avoid fetching the working trees of the repositories you are not interested in.</p> </li> <li> <p>Access control: By restricting user access to submodules, this can be used to implement read/write policies for different users.</p> </li> </ul> </div> </li> </ol> </div> </div> <h2 id="_the_configuration_of_submodules">The configuration of submodules</h2> <div class="sectionbody"> <p>Submodule operations can be configured using the following mechanisms (from highest to lowest precedence):</p> <div class="ulist"> <ul> <li> <p>The command line for those commands that support taking submodules as part of their pathspecs. Most commands have a boolean flag <code>--recurse-submodules</code> which specifies whether to recurse into submodules. Examples are <code>grep</code> and <code>checkout</code>. Some commands take enums, such as <code>fetch</code> and <code>push</code>, where you can specify how submodules are affected.</p> </li> <li> <p>The configuration inside the submodule. This includes <code>$GIT_DIR/config</code> in the submodule, but also settings in the tree such as a <code>.gitattributes</code> or <code>.gitignore</code> files that specify behavior of commands inside the submodule.</p> <p>For example an effect from the submodule’s <code>.gitignore</code> file would be observed when you run <code>git status --ignore-submodules=none</code> in the superproject. This collects information from the submodule’s working directory by running <code>status</code> in the submodule while paying attention to the <code>.gitignore</code> file of the submodule.</p> <p>The submodule’s <code>$GIT_DIR/config</code> file would come into play when running <code>git push --recurse-submodules=check</code> in the superproject, as this would check if the submodule has any changes not published to any remote. The remotes are configured in the submodule as usual in the <code>$GIT_DIR/config</code> file.</p> </li> <li> <p>The configuration file <code>$GIT_DIR/config</code> in the superproject. Git only recurses into active submodules (see "ACTIVE SUBMODULES" section below).</p> <p>If the submodule is not yet initialized, then the configuration inside the submodule does not exist yet, so where to obtain the submodule from is configured here for example.</p> </li> <li> <p>The <code>.gitmodules</code> file inside the superproject. A project usually uses this file to suggest defaults for the upstream collection of repositories for the mapping that is required between a submodule’s name and its path.</p> <p>This file mainly serves as the mapping between the name and path of submodules in the superproject, such that the submodule’s Git directory can be located.</p> <p>If the submodule has never been initialized, this is the only place where submodule configuration is found. It serves as the last fallback to specify where to obtain the submodule from.</p> </li> </ul> </div> </div> <h2 id="_forms">Forms</h2> <div class="sectionbody"> <p>Submodules can take the following forms:</p> <div class="ulist"> <ul> <li> <p>The basic form described in DESCRIPTION with a Git directory, a working directory, a <code>gitlink</code>, and a <code>.gitmodules</code> entry.</p> </li> <li> <p>"Old-form" submodule: A working directory with an embedded <code>.git</code> directory, and the tracking <code>gitlink</code> and <code>.gitmodules</code> entry in the superproject. This is typically found in repositories generated using older versions of Git.</p> <p>It is possible to construct these old form repositories manually.</p> <p>When deinitialized or deleted (see below), the submodule’s Git directory is automatically moved to <code>$GIT_DIR/modules/<name>/</code> of the superproject.</p> </li> <li> <p>Deinitialized submodule: A <code>gitlink</code>, and a <code>.gitmodules</code> entry, but no submodule working directory. The submodule’s Git directory may be there as after deinitializing the Git directory is kept around. The directory which is supposed to be the working directory is empty instead.</p> <p>A submodule can be deinitialized by running <code>git submodule deinit</code>. Besides emptying the working directory, this command only modifies the superproject’s <code>$GIT_DIR/config</code> file, so the superproject’s history is not affected. This can be undone using <code>git submodule init</code>.</p> </li> <li> <p>Deleted submodule: A submodule can be deleted by running <code>git rm <submodule path> && git commit</code>. This can be undone using <code>git revert</code>.</p> <p>The deletion removes the superproject’s tracking data, which are both the <code>gitlink</code> entry and the section in the <code>.gitmodules</code> file. The submodule’s working directory is removed from the file system, but the Git directory is kept around as it to make it possible to checkout past commits without requiring fetching from another repository.</p> <p>To completely remove a submodule, manually delete <code>$GIT_DIR/modules/<name>/</code>.</p> </li> </ul> </div> </div> <h2 id="_active_submodules">Active submodules</h2> <div class="sectionbody"> <p>A submodule is considered active,</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>if <code>submodule.<name>.active</code> is set to <code>true</code></p> <p>or</p> </li> <li> <p>if the submodule’s path matches the pathspec in <code>submodule.active</code></p> <p>or</p> </li> <li> <p>if <code>submodule.<name>.url</code> is set.</p> </li> </ol> </div> <p>and these are evaluated in this order.</p> <p>For example:</p> <div class="literalblock"> <div class="content"> <pre>[submodule "foo"] + active = false + url = https://example.org/foo +[submodule "bar"] + active = true + url = https://example.org/bar +[submodule "baz"] + url = https://example.org/baz</pre> </div> </div> <p>In the above config only the submodules <code>bar</code> and <code>baz</code> are active, <code>bar</code> due to (1) and <code>baz</code> due to (3). <code>foo</code> is inactive because (1) takes precedence over (3)</p> <p>Note that (3) is a historical artefact and will be ignored if the (1) and (2) specify that the submodule is not active. In other words, if we have a <code>submodule.<name>.active</code> set to <code>false</code> or if the submodule’s path is excluded in the pathspec in <code>submodule.active</code>, the url doesn’t matter whether it is present or not. This is illustrated in the example that follows.</p> <div class="literalblock"> <div class="content"> <pre>[submodule "foo"] + active = true + url = https://example.org/foo +[submodule "bar"] + url = https://example.org/bar +[submodule "baz"] + url = https://example.org/baz +[submodule "bob"] + ignore = true +[submodule] + active = b* + active = :(exclude) baz</pre> </div> </div> <p>In here all submodules except <code>baz</code> (foo, bar, bob) are active. <code>foo</code> due to its own active flag and all the others due to the submodule active pathspec, which specifies that any submodule starting with <code>b</code> except <code>baz</code> are also active, regardless of the presence of the .url field.</p> </div> <h2 id="_workflow_for_a_third_party_library">Workflow for a third party library</h2> <div class="sectionbody"> <div class="literalblock"> <div class="content"> <pre># Add a submodule +git submodule add <URL> <path></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre># Occasionally update the submodule to a new version: +git -C <path> checkout <new version> +git add <path> +git commit -m "update submodule to new version"</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre># See the list of submodules in a superproject +git submodule status</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre># See FORMS on removing submodules</pre> </div> </div> </div> <h2 id="_workflow_for_an_artificially_split_repo">Workflow for an artificially split repo</h2> <div class="sectionbody"> <div class="literalblock"> <div class="content"> <pre># Enable recursion for relevant commands, such that +# regular commands recurse into submodules by default +git config --global submodule.recurse true</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre># Unlike most other commands below, clone still needs +# its own recurse flag: +git clone --recurse <URL> <directory> +cd <directory></pre> </div> </div> <div class="literalblock"> <div class="content"> <pre># Get to know the code: +git grep foo +git ls-files --recurse-submodules</pre> </div> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> <code>git ls-files</code> also requires its own <code>--recurse-submodules</code> flag. </td> </tr> </table> </div> <div class="literalblock"> <div class="content"> <pre># Get new code +git fetch +git pull --rebase</pre> </div> </div> <div class="literalblock"> <div class="content"> <pre># Change worktree +git checkout +git reset</pre> </div> </div> </div> <h2 id="_implementation_details">Implementation details</h2> <div class="sectionbody"> <p>When cloning or pulling a repository containing submodules the submodules will not be checked out by default; you can instruct <code>clone</code> to recurse into submodules. The <code>init</code> and <code>update</code> subcommands of <code>git submodule</code> will maintain submodules checked out and at an appropriate revision in your working tree. Alternatively you can set <code>submodule.recurse</code> to have <code>checkout</code> recurse into submodules (note that <code>submodule.recurse</code> also affects other Git commands, see <a href="git-config">git-config[1]</a> for a complete list).</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-submodule">git-submodule[1]</a>, <a href="gitmodules">gitmodules[5]</a>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitsubmodules" class="_attribution-link">https://git-scm.com/docs/gitsubmodules</a> + </p> +</div> diff --git a/devdocs/git/gittutorial-2.html b/devdocs/git/gittutorial-2.html new file mode 100644 index 00000000..41b0e25f --- /dev/null +++ b/devdocs/git/gittutorial-2.html @@ -0,0 +1,132 @@ +<h1>gittutorial-2</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gittutorial-2 - A tutorial introduction to Git: part two</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git *</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>You should work through <a href="gittutorial">gittutorial[7]</a> before reading this tutorial.</p> <p>The goal of this tutorial is to introduce two fundamental pieces of Git’s architecture—the object database and the index file—and to provide the reader with everything necessary to understand the rest of the Git documentation.</p> </div> <h2 id="_the_git_object_database">The git object database</h2> <div class="sectionbody"> <p>Let’s start a new project and create a small amount of history:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ mkdir test-project +$ cd test-project +$ git init +Initialized empty Git repository in .git/ +$ echo 'hello world' > file.txt +$ git add . +$ git commit -a -m "initial commit" +[master (root-commit) 54196cc] initial commit + 1 file changed, 1 insertion(+) + create mode 100644 file.txt +$ echo 'hello world!' >file.txt +$ git commit -a -m "add emphasis" +[master c4d59f3] add emphasis + 1 file changed, 1 insertion(+), 1 deletion(-)</pre> </div> </div> <p>What are the 7 digits of hex that Git responded to the commit with?</p> <p>We saw in part one of the tutorial that commits have names like this. It turns out that every object in the Git history is stored under a 40-digit hex name. That name is the SHA-1 hash of the object’s contents; among other things, this ensures that Git will never store the same data twice (since identical data is given an identical SHA-1 name), and that the contents of a Git object will never change (since that would change the object’s name as well). The 7 char hex strings here are simply the abbreviation of such 40 character long strings. Abbreviations can be used everywhere where the 40 character strings can be used, so long as they are unambiguous.</p> <p>It is expected that the content of the commit object you created while following the example above generates a different SHA-1 hash than the one shown above because the commit object records the time when it was created and the name of the person performing the commit.</p> <p>We can ask Git about this particular object with the <code>cat-file</code> command. Don’t copy the 40 hex digits from this example but use those from your own version. Note that you can shorten it to only a few characters to save yourself typing all 40 hex digits:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cat-file -t 54196cc2 +commit +$ git cat-file commit 54196cc2 +tree 92b8b694ffb1675e5975148e1121810081dbdffe +author J. Bruce Fields <bfields@puzzle.fieldses.org> 1143414668 -0500 +committer J. Bruce Fields <bfields@puzzle.fieldses.org> 1143414668 -0500 + +initial commit</pre> </div> </div> <p>A tree can refer to one or more "blob" objects, each corresponding to a file. In addition, a tree can also refer to other tree objects, thus creating a directory hierarchy. You can examine the contents of any tree using ls-tree (remember that a long enough initial portion of the SHA-1 will also work):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-tree 92b8b694 +100644 blob 3b18e512dba79e4c8300dd08aeb37f8e728b8dad file.txt</pre> </div> </div> <p>Thus we see that this tree has one file in it. The SHA-1 hash is a reference to that file’s data:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cat-file -t 3b18e512 +blob</pre> </div> </div> <p>A "blob" is just file data, which we can also examine with cat-file:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cat-file blob 3b18e512 +hello world</pre> </div> </div> <p>Note that this is the old file data; so the object that Git named in its response to the initial tree was a tree with a snapshot of the directory state that was recorded by the first commit.</p> <p>All of these objects are stored under their SHA-1 names inside the Git directory:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ find .git/objects/ +.git/objects/ +.git/objects/pack +.git/objects/info +.git/objects/3b +.git/objects/3b/18e512dba79e4c8300dd08aeb37f8e728b8dad +.git/objects/92 +.git/objects/92/b8b694ffb1675e5975148e1121810081dbdffe +.git/objects/54 +.git/objects/54/196cc2703dc165cbd373a65a4dcf22d50ae7f7 +.git/objects/a0 +.git/objects/a0/423896973644771497bdc03eb99d5281615b51 +.git/objects/d0 +.git/objects/d0/492b368b66bdabf2ac1fd8c92b39d3db916e59 +.git/objects/c4 +.git/objects/c4/d59f390b9cfd4318117afde11d601c1085f241</pre> </div> </div> <p>and the contents of these files is just the compressed data plus a header identifying their length and their type. The type is either a blob, a tree, a commit, or a tag.</p> <p>The simplest commit to find is the HEAD commit, which we can find from .git/HEAD:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat .git/HEAD +ref: refs/heads/master</pre> </div> </div> <p>As you can see, this tells us which branch we’re currently on, and it tells us this by naming a file under the .git directory, which itself contains a SHA-1 name referring to a commit object, which we can examine with cat-file:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat .git/refs/heads/master +c4d59f390b9cfd4318117afde11d601c1085f241 +$ git cat-file -t c4d59f39 +commit +$ git cat-file commit c4d59f39 +tree d0492b368b66bdabf2ac1fd8c92b39d3db916e59 +parent 54196cc2703dc165cbd373a65a4dcf22d50ae7f7 +author J. Bruce Fields <bfields@puzzle.fieldses.org> 1143418702 -0500 +committer J. Bruce Fields <bfields@puzzle.fieldses.org> 1143418702 -0500 + +add emphasis</pre> </div> </div> <p>The "tree" object here refers to the new state of the tree:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-tree d0492b36 +100644 blob a0423896973644771497bdc03eb99d5281615b51 file.txt +$ git cat-file blob a0423896 +hello world!</pre> </div> </div> <p>and the "parent" object refers to the previous commit:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cat-file commit 54196cc2 +tree 92b8b694ffb1675e5975148e1121810081dbdffe +author J. Bruce Fields <bfields@puzzle.fieldses.org> 1143414668 -0500 +committer J. Bruce Fields <bfields@puzzle.fieldses.org> 1143414668 -0500 + +initial commit</pre> </div> </div> <p>The tree object is the tree we examined first, and this commit is unusual in that it lacks any parent.</p> <p>Most commits have only one parent, but it is also common for a commit to have multiple parents. In that case the commit represents a merge, with the parent references pointing to the heads of the merged branches.</p> <p>Besides blobs, trees, and commits, the only remaining type of object is a "tag", which we won’t discuss here; refer to <a href="git-tag">git-tag[1]</a> for details.</p> <p>So now we know how Git uses the object database to represent a project’s history:</p> <div class="ulist"> <ul> <li> <p>"commit" objects refer to "tree" objects representing the snapshot of a directory tree at a particular point in the history, and refer to "parent" commits to show how they’re connected into the project history.</p> </li> <li> <p>"tree" objects represent the state of a single directory, associating directory names to "blob" objects containing file data and "tree" objects containing subdirectory information.</p> </li> <li> <p>"blob" objects contain file data without any other structure.</p> </li> <li> <p>References to commit objects at the head of each branch are stored in files under .git/refs/heads/.</p> </li> <li> <p>The name of the current branch is stored in .git/HEAD.</p> </li> </ul> </div> <p>Note, by the way, that lots of commands take a tree as an argument. But as we can see above, a tree can be referred to in many different ways—by the SHA-1 name for that tree, by the name of a commit that refers to the tree, by the name of a branch whose head refers to that tree, etc.--and most such commands can accept any of these names.</p> <p>In command synopses, the word "tree-ish" is sometimes used to designate such an argument.</p> </div> <h2 id="_the_index_file">The index file</h2> <div class="sectionbody"> <p>The primary tool we’ve been using to create commits is <code>git-commit +-a</code>, which creates a commit including every change you’ve made to your working tree. But what if you want to commit changes only to certain files? Or only certain changes to certain files?</p> <p>If we look at the way commits are created under the cover, we’ll see that there are more flexible ways creating commits.</p> <p>Continuing with our test-project, let’s modify file.txt again:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ echo "hello world, again" >>file.txt</pre> </div> </div> <p>but this time instead of immediately making the commit, let’s take an intermediate step, and ask for diffs along the way to keep track of what’s happening:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff +--- a/file.txt ++++ b/file.txt +@@ -1 +1,2 @@ + hello world! ++hello world, again +$ git add file.txt +$ git diff</pre> </div> </div> <p>The last diff is empty, but no new commits have been made, and the head still doesn’t contain the new line:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff HEAD +diff --git a/file.txt b/file.txt +index a042389..513feba 100644 +--- a/file.txt ++++ b/file.txt +@@ -1 +1,2 @@ + hello world! ++hello world, again</pre> </div> </div> <p>So <code>git diff</code> is comparing against something other than the head. The thing that it’s comparing against is actually the index file, which is stored in .git/index in a binary format, but whose contents we can examine with ls-files:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-files --stage +100644 513feba2e53ebbd2532419ded848ba19de88ba00 0 file.txt +$ git cat-file -t 513feba2 +blob +$ git cat-file blob 513feba2 +hello world! +hello world, again</pre> </div> </div> <p>So what our <code>git add</code> did was store a new blob and then put a reference to it in the index file. If we modify the file again, we’ll see that the new modifications are reflected in the <code>git diff</code> output:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ echo 'again?' >>file.txt +$ git diff +index 513feba..ba3da7b 100644 +--- a/file.txt ++++ b/file.txt +@@ -1,2 +1,3 @@ + hello world! + hello world, again ++again?</pre> </div> </div> <p>With the right arguments, <code>git diff</code> can also show us the difference between the working directory and the last commit, or between the index and the last commit:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff HEAD +diff --git a/file.txt b/file.txt +index a042389..ba3da7b 100644 +--- a/file.txt ++++ b/file.txt +@@ -1 +1,3 @@ + hello world! ++hello world, again ++again? +$ git diff --cached +diff --git a/file.txt b/file.txt +index a042389..513feba 100644 +--- a/file.txt ++++ b/file.txt +@@ -1 +1,2 @@ + hello world! ++hello world, again</pre> </div> </div> <p>At any time, we can create a new commit using <code>git commit</code> (without the "-a" option), and verify that the state committed only includes the changes stored in the index file, not the additional change that is still only in our working tree:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit -m "repeat" +$ git diff HEAD +diff --git a/file.txt b/file.txt +index 513feba..ba3da7b 100644 +--- a/file.txt ++++ b/file.txt +@@ -1,2 +1,3 @@ + hello world! + hello world, again ++again?</pre> </div> </div> <p>So by default <code>git commit</code> uses the index to create the commit, not the working tree; the "-a" option to commit tells it to first update the index with all changes in the working tree.</p> <p>Finally, it’s worth looking at the effect of <code>git add</code> on the index file:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ echo "goodbye, world" >closing.txt +$ git add closing.txt</pre> </div> </div> <p>The effect of the <code>git add</code> was to add one entry to the index file:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-files --stage +100644 8b9743b20d4b15be3955fc8d5cd2b09cd2336138 0 closing.txt +100644 513feba2e53ebbd2532419ded848ba19de88ba00 0 file.txt</pre> </div> </div> <p>And, as you can see with cat-file, this new entry refers to the current contents of the file:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cat-file blob 8b9743b2 +goodbye, world</pre> </div> </div> <p>The "status" command is a useful way to get a quick summary of the situation:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git status +On branch master +Changes to be committed: + (use "git restore --staged <file>..." to unstage) + + new file: closing.txt + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git restore <file>..." to discard changes in working directory) + + modified: file.txt</pre> </div> </div> <p>Since the current state of closing.txt is cached in the index file, it is listed as "Changes to be committed". Since file.txt has changes in the working directory that aren’t reflected in the index, it is marked "changed but not updated". At this point, running "git commit" would create a commit that added closing.txt (with its new contents), but that didn’t modify file.txt.</p> <p>Also, note that a bare <code>git diff</code> shows the changes to file.txt, but not the addition of closing.txt, because the version of closing.txt in the index file is identical to the one in the working directory.</p> <p>In addition to being the staging area for new commits, the index file is also populated from the object database when checking out a branch, and is used to hold the trees involved in a merge operation. See <a href="gitcore-tutorial">gitcore-tutorial[7]</a> and the relevant man pages for details.</p> </div> <h2 id="_what_next">What next?</h2> <div class="sectionbody"> <p>At this point you should know everything necessary to read the man pages for any of the git commands; one good place to start would be with the commands mentioned in <a href="giteveryday">giteveryday[7]</a>. You should be able to find any unknown jargon in <a href="gitglossary">gitglossary[7]</a>.</p> <p>The <a href="user-manual">Git User’s Manual</a> provides a more comprehensive introduction to Git.</p> <p><a href="gitcvs-migration">gitcvs-migration[7]</a> explains how to import a CVS repository into Git, and shows how to use Git in a CVS-like way.</p> <p>For some interesting examples of Git use, see the <a href="howto-index">howtos</a>.</p> <p>For Git developers, <a href="gitcore-tutorial">gitcore-tutorial[7]</a> goes into detail on the lower-level Git mechanisms involved in, for example, creating a new commit.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gittutorial">gittutorial[7]</a>, <a href="gitcvs-migration">gitcvs-migration[7]</a>, <a href="gitcore-tutorial">gitcore-tutorial[7]</a>, <a href="gitglossary">gitglossary[7]</a>, <a href="git-help">git-help[1]</a>, <a href="giteveryday">giteveryday[7]</a>, <a href="user-manual">The Git User’s Manual</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gittutorial-2" class="_attribution-link">https://git-scm.com/docs/gittutorial-2</a> + </p> +</div> diff --git a/devdocs/git/gittutorial.html b/devdocs/git/gittutorial.html new file mode 100644 index 00000000..9ec074fd --- /dev/null +++ b/devdocs/git/gittutorial.html @@ -0,0 +1,45 @@ +<h1>gittutorial</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gittutorial - A tutorial introduction to Git</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git *</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This tutorial explains how to import a new project into Git, make changes to it, and share changes with other developers.</p> <p>If you are instead primarily interested in using Git to fetch a project, for example, to test the latest version, you may prefer to start with the first two chapters of <a href="user-manual">The Git User’s Manual</a>.</p> <p>First, note that you can get documentation for a command such as <code>git log --graph</code> with:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ man git-log</pre> </div> </div> <p>or:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git help log</pre> </div> </div> <p>With the latter, you can use the manual viewer of your choice; see <a href="git-help">git-help[1]</a> for more information.</p> <p>It is a good idea to introduce yourself to Git with your name and public email address before doing any operation. The easiest way to do so is:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config --global user.name "Your Name Comes Here" +$ git config --global user.email you@yourdomain.example.com</pre> </div> </div> </div> <h2 id="_importing_a_new_project">Importing a new project</h2> <div class="sectionbody"> <p>Assume you have a tarball <code>project.tar.gz</code> with your initial work. You can place it under Git revision control as follows.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ tar xzf project.tar.gz +$ cd project +$ git init</pre> </div> </div> <p>Git will reply</p> <div class="listingblock"> <div class="content"> <pre>Initialized empty Git repository in .git/</pre> </div> </div> <p>You’ve now initialized the working directory—you may notice a new directory created, named <code>.git</code>.</p> <p>Next, tell Git to take a snapshot of the contents of all files under the current directory (note the <code>.</code>), with <code>git add</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git add .</pre> </div> </div> <p>This snapshot is now stored in a temporary staging area which Git calls the "index". You can permanently store the contents of the index in the repository with <code>git commit</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit</pre> </div> </div> <p>This will prompt you for a commit message. You’ve now stored the first version of your project in Git.</p> </div> <h2 id="_making_changes">Making changes</h2> <div class="sectionbody"> <p>Modify some files, then add their updated contents to the index:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git add file1 file2 file3</pre> </div> </div> <p>You are now ready to commit. You can see what is about to be committed using <code>git diff</code> with the <code>--cached</code> option:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff --cached</pre> </div> </div> <p>(Without <code>--cached</code>, <code>git diff</code> will show you any changes that you’ve made but not yet added to the index.) You can also get a brief summary of the situation with <code>git status</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git status +On branch master +Changes to be committed: + (use "git restore --staged <file>..." to unstage) + + modified: file1 + modified: file2 + modified: file3</pre> </div> </div> <p>If you need to make any further adjustments, do so now, and then add any newly modified content to the index. Finally, commit your changes with:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit</pre> </div> </div> <p>This will again prompt you for a message describing the change, and then record a new version of the project.</p> <p>Alternatively, instead of running <code>git add</code> beforehand, you can use</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit -a</pre> </div> </div> <p>which will automatically notice any modified (but not new) files, add them to the index, and commit, all in one step.</p> <p>A note on commit messages: Though not required, it’s a good idea to begin the commit message with a single short (no more than 50 characters) line summarizing the change, followed by a blank line and then a more thorough description. The text up to the first blank line in a commit message is treated as the commit title, and that title is used throughout Git. For example, <a href="git-format-patch">git-format-patch[1]</a> turns a commit into email, and it uses the title on the Subject line and the rest of the commit in the body.</p> </div> <h2 id="_git_tracks_content_not_files">Git tracks content not files</h2> <div class="sectionbody"> <p>Many revision control systems provide an <code>add</code> command that tells the system to start tracking changes to a new file. Git’s <code>add</code> command does something simpler and more powerful: <code>git add</code> is used both for new and newly modified files, and in both cases it takes a snapshot of the given files and stages that content in the index, ready for inclusion in the next commit.</p> </div> <h2 id="_viewing_project_history">Viewing project history</h2> <div class="sectionbody"> <p>At any point you can view the history of your changes using</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log</pre> </div> </div> <p>If you also want to see complete diffs at each step, use</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log -p</pre> </div> </div> <p>Often the overview of the change is useful to get a feel of each step</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log --stat --summary</pre> </div> </div> </div> <h2 id="_managing_branches">Managing branches</h2> <div class="sectionbody"> <p>A single Git repository can maintain multiple branches of development. To create a new branch named <code>experimental</code>, use</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch experimental</pre> </div> </div> <p>If you now run</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch</pre> </div> </div> <p>you’ll get a list of all existing branches:</p> <div class="listingblock"> <div class="content"> <pre> experimental +* master</pre> </div> </div> <p>The <code>experimental</code> branch is the one you just created, and the <code>master</code> branch is a default branch that was created for you automatically. The asterisk marks the branch you are currently on; type</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch experimental</pre> </div> </div> <p>to switch to the <code>experimental</code> branch. Now edit a file, commit the change, and switch back to the <code>master</code> branch:</p> <div class="listingblock"> <div class="content"> <pre>(edit file) +$ git commit -a +$ git switch master</pre> </div> </div> <p>Check that the change you made is no longer visible, since it was made on the <code>experimental</code> branch and you’re back on the <code>master</code> branch.</p> <p>You can make a different change on the <code>master</code> branch:</p> <div class="listingblock"> <div class="content"> <pre>(edit file) +$ git commit -a</pre> </div> </div> <p>at this point the two branches have diverged, with different changes made in each. To merge the changes made in <code>experimental</code> into <code>master</code>, run</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git merge experimental</pre> </div> </div> <p>If the changes don’t conflict, you’re done. If there are conflicts, markers will be left in the problematic files showing the conflict;</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff</pre> </div> </div> <p>will show this. Once you’ve edited the files to resolve the conflicts,</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit -a</pre> </div> </div> <p>will commit the result of the merge. Finally,</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ gitk</pre> </div> </div> <p>will show a nice graphical representation of the resulting history.</p> <p>At this point you could delete the <code>experimental</code> branch with</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch -d experimental</pre> </div> </div> <p>This command ensures that the changes in the <code>experimental</code> branch are already in the current branch.</p> <p>If you develop on a branch <code>crazy-idea</code>, then regret it, you can always delete the branch with</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch -D crazy-idea</pre> </div> </div> <p>Branches are cheap and easy, so this is a good way to try something out.</p> </div> <h2 id="_using_git_for_collaboration">Using git for collaboration</h2> <div class="sectionbody"> <p>Suppose that Alice has started a new project with a Git repository in <code>/home/alice/project</code>, and that Bob, who has a home directory on the same machine, wants to contribute.</p> <p>Bob begins with:</p> <div class="listingblock"> <div class="content"> <pre>bob$ git clone /home/alice/project myrepo</pre> </div> </div> <p>This creates a new directory <code>myrepo</code> containing a clone of Alice’s repository. The clone is on an equal footing with the original project, possessing its own copy of the original project’s history.</p> <p>Bob then makes some changes and commits them:</p> <div class="listingblock"> <div class="content"> <pre>(edit files) +bob$ git commit -a +(repeat as necessary)</pre> </div> </div> <p>When he’s ready, he tells Alice to pull changes from the repository at <code>/home/bob/myrepo</code>. She does this with:</p> <div class="listingblock"> <div class="content"> <pre>alice$ cd /home/alice/project +alice$ git pull /home/bob/myrepo master</pre> </div> </div> <p>This merges the changes from Bob’s <code>master</code> branch into Alice’s current branch. If Alice has made her own changes in the meantime, then she may need to manually fix any conflicts.</p> <p>The <code>pull</code> command thus performs two operations: it fetches changes from a remote branch, then merges them into the current branch.</p> <p>Note that in general, Alice would want her local changes committed before initiating this <code>pull</code>. If Bob’s work conflicts with what Alice did since their histories forked, Alice will use her working tree and the index to resolve conflicts, and existing local changes will interfere with the conflict resolution process (Git will still perform the fetch but will refuse to merge — Alice will have to get rid of her local changes in some way and pull again when this happens).</p> <p>Alice can peek at what Bob did without merging first, using the <code>fetch</code> command; this allows Alice to inspect what Bob did, using a special symbol <code>FETCH_HEAD</code>, in order to determine if he has anything worth pulling, like this:</p> <div class="listingblock"> <div class="content"> <pre>alice$ git fetch /home/bob/myrepo master +alice$ git log -p HEAD..FETCH_HEAD</pre> </div> </div> <p>This operation is safe even if Alice has uncommitted local changes. The range notation <code>HEAD..FETCH_HEAD</code> means "show everything that is reachable from the <code>FETCH_HEAD</code> but exclude anything that is reachable from <code>HEAD</code>". Alice already knows everything that leads to her current state (<code>HEAD</code>), and reviews what Bob has in his state (<code>FETCH_HEAD</code>) that she has not seen with this command.</p> <p>If Alice wants to visualize what Bob did since their histories forked she can issue the following command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ gitk HEAD..FETCH_HEAD</pre> </div> </div> <p>This uses the same two-dot range notation we saw earlier with <code>git log</code>.</p> <p>Alice may want to view what both of them did since they forked. She can use three-dot form instead of the two-dot form:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ gitk HEAD...FETCH_HEAD</pre> </div> </div> <p>This means "show everything that is reachable from either one, but exclude anything that is reachable from both of them".</p> <p>Please note that these range notation can be used with both <code>gitk</code> and <code>git log</code>.</p> <p>After inspecting what Bob did, if there is nothing urgent, Alice may decide to continue working without pulling from Bob. If Bob’s history does have something Alice would immediately need, Alice may choose to stash her work-in-progress first, do a <code>pull</code>, and then finally unstash her work-in-progress on top of the resulting history.</p> <p>When you are working in a small closely knit group, it is not unusual to interact with the same repository over and over again. By defining <code>remote</code> repository shorthand, you can make it easier:</p> <div class="listingblock"> <div class="content"> <pre>alice$ git remote add bob /home/bob/myrepo</pre> </div> </div> <p>With this, Alice can perform the first part of the <code>pull</code> operation alone using the <code>git fetch</code> command without merging them with her own branch, using:</p> <div class="listingblock"> <div class="content"> <pre>alice$ git fetch bob</pre> </div> </div> <p>Unlike the longhand form, when Alice fetches from Bob using a remote repository shorthand set up with <code>git remote</code>, what was fetched is stored in a remote-tracking branch, in this case <code>bob/master</code>. So after this:</p> <div class="listingblock"> <div class="content"> <pre>alice$ git log -p master..bob/master</pre> </div> </div> <p>shows a list of all the changes that Bob made since he branched from Alice’s <code>master</code> branch.</p> <p>After examining those changes, Alice could merge the changes into her <code>master</code> branch:</p> <div class="listingblock"> <div class="content"> <pre>alice$ git merge bob/master</pre> </div> </div> <p>This <code>merge</code> can also be done by <code>pulling from her own remote-tracking branch</code>, like this:</p> <div class="listingblock"> <div class="content"> <pre>alice$ git pull . remotes/bob/master</pre> </div> </div> <p>Note that git pull always merges into the current branch, regardless of what else is given on the command line.</p> <p>Later, Bob can update his repo with Alice’s latest changes using</p> <div class="listingblock"> <div class="content"> <pre>bob$ git pull</pre> </div> </div> <p>Note that he doesn’t need to give the path to Alice’s repository; when Bob cloned Alice’s repository, Git stored the location of her repository in the repository configuration, and that location is used for pulls:</p> <div class="listingblock"> <div class="content"> <pre>bob$ git config --get remote.origin.url +/home/alice/project</pre> </div> </div> <p>(The complete configuration created by <code>git clone</code> is visible using <code>git config -l</code>, and the <a href="git-config">git-config[1]</a> man page explains the meaning of each option.)</p> <p>Git also keeps a pristine copy of Alice’s <code>master</code> branch under the name <code>origin/master</code>:</p> <div class="listingblock"> <div class="content"> <pre>bob$ git branch -r + origin/master</pre> </div> </div> <p>If Bob later decides to work from a different host, he can still perform clones and pulls using the ssh protocol:</p> <div class="listingblock"> <div class="content"> <pre>bob$ git clone alice.org:/home/alice/project myrepo</pre> </div> </div> <p>Alternatively, Git has a native protocol, or can use http; see <a href="git-pull">git-pull[1]</a> for details.</p> <p>Git can also be used in a CVS-like mode, with a central repository that various users push changes to; see <a href="git-push">git-push[1]</a> and <a href="gitcvs-migration">gitcvs-migration[7]</a>.</p> </div> <h2 id="_exploring_history">Exploring history</h2> <div class="sectionbody"> <p>Git history is represented as a series of interrelated commits. We have already seen that the <code>git log</code> command can list those commits. Note that first line of each <code>git log</code> entry also gives a name for the commit:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log +commit c82a22c39cbc32576f64f5c6b3f24b99ea8149c7 +Author: Junio C Hamano <junkio@cox.net> +Date: Tue May 16 17:18:22 2006 -0700 + + merge-base: Clarify the comments on post processing.</pre> </div> </div> <p>We can give this name to <code>git show</code> to see the details about this commit.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show c82a22c39cbc32576f64f5c6b3f24b99ea8149c7</pre> </div> </div> <p>But there are other ways to refer to commits. You can use any initial part of the name that is long enough to uniquely identify the commit:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show c82a22c39c # the first few characters of the name are + # usually enough +$ git show HEAD # the tip of the current branch +$ git show experimental # the tip of the "experimental" branch</pre> </div> </div> <p>Every commit usually has one "parent" commit which points to the previous state of the project:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show HEAD^ # to see the parent of HEAD +$ git show HEAD^^ # to see the grandparent of HEAD +$ git show HEAD~4 # to see the great-great grandparent of HEAD</pre> </div> </div> <p>Note that merge commits may have more than one parent:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show HEAD^1 # show the first parent of HEAD (same as HEAD^) +$ git show HEAD^2 # show the second parent of HEAD</pre> </div> </div> <p>You can also give commits names of your own; after running</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git tag v2.5 1b2e1d63ff</pre> </div> </div> <p>you can refer to <code>1b2e1d63ff</code> by the name <code>v2.5</code>. If you intend to share this name with other people (for example, to identify a release version), you should create a "tag" object, and perhaps sign it; see <a href="git-tag">git-tag[1]</a> for details.</p> <p>Any Git command that needs to know a commit can take any of these names. For example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff v2.5 HEAD # compare the current HEAD to v2.5 +$ git branch stable v2.5 # start a new branch named "stable" based + # at v2.5 +$ git reset --hard HEAD^ # reset your current branch and working + # directory to its state at HEAD^</pre> </div> </div> <p>Be careful with that last command: in addition to losing any changes in the working directory, it will also remove all later commits from this branch. If this branch is the only branch containing those commits, they will be lost. Also, don’t use <code>git reset</code> on a publicly-visible branch that other developers pull from, as it will force needless merges on other developers to clean up the history. If you need to undo changes that you have pushed, use <code>git revert</code> instead.</p> <p>The <code>git grep</code> command can search for strings in any version of your project, so</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git grep "hello" v2.5</pre> </div> </div> <p>searches for all occurrences of "hello" in <code>v2.5</code>.</p> <p>If you leave out the commit name, <code>git grep</code> will search any of the files it manages in your current directory. So</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git grep "hello"</pre> </div> </div> <p>is a quick way to search just the files that are tracked by Git.</p> <p>Many Git commands also take sets of commits, which can be specified in a number of ways. Here are some examples with <code>git log</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log v2.5..v2.6 # commits between v2.5 and v2.6 +$ git log v2.5.. # commits since v2.5 +$ git log --since="2 weeks ago" # commits from the last 2 weeks +$ git log v2.5.. Makefile # commits since v2.5 which modify + # Makefile</pre> </div> </div> <p>You can also give <code>git log</code> a "range" of commits where the first is not necessarily an ancestor of the second; for example, if the tips of the branches <code>stable</code> and <code>master</code> diverged from a common commit some time ago, then</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log stable..master</pre> </div> </div> <p>will list commits made in the <code>master</code> branch but not in the stable branch, while</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log master..stable</pre> </div> </div> <p>will show the list of commits made on the stable branch but not the <code>master</code> branch.</p> <p>The <code>git log</code> command has a weakness: it must present commits in a list. When the history has lines of development that diverged and then merged back together, the order in which <code>git log</code> presents those commits is meaningless.</p> <p>Most projects with multiple contributors (such as the Linux kernel, or Git itself) have frequent merges, and <code>gitk</code> does a better job of visualizing their history. For example,</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ gitk --since="2 weeks ago" drivers/</pre> </div> </div> <p>allows you to browse any commits from the last 2 weeks of commits that modified files under the <code>drivers</code> directory. (Note: you can adjust gitk’s fonts by holding down the control key while pressing "-" or "+".)</p> <p>Finally, most commands that take filenames will optionally allow you to precede any filename by a commit, to specify a particular version of the file:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff v2.5:Makefile HEAD:Makefile.in</pre> </div> </div> <p>You can also use <code>git show</code> to see any such file:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show v2.5:Makefile</pre> </div> </div> </div> <h2 id="_next_steps">Next steps</h2> <div class="sectionbody"> <p>This tutorial should be enough to perform basic distributed revision control for your projects. However, to fully understand the depth and power of Git you need to understand two simple ideas on which it is based:</p> <div class="ulist"> <ul> <li> <p>The object database is the rather elegant system used to store the history of your project—files, directories, and commits.</p> </li> <li> <p>The index file is a cache of the state of a directory tree, used to create commits, check out working directories, and hold the various trees involved in a merge.</p> </li> </ul> </div> <p>Part two of this tutorial explains the object database, the index file, and a few other odds and ends that you’ll need to make the most of Git. You can find it at <a href="gittutorial-2">gittutorial-2[7]</a>.</p> <p>If you don’t want to continue with that right away, a few other digressions that may be interesting at this point are:</p> <div class="ulist"> <ul> <li> <p><a href="git-format-patch">git-format-patch[1]</a>, <a href="git-am">git-am[1]</a>: These convert series of git commits into emailed patches, and vice versa, useful for projects such as the Linux kernel which rely heavily on emailed patches.</p> </li> <li> <p><a href="git-bisect">git-bisect[1]</a>: When there is a regression in your project, one way to track down the bug is by searching through the history to find the exact commit that’s to blame. <code>git bisect</code> can help you perform a binary search for that commit. It is smart enough to perform a close-to-optimal search even in the case of complex non-linear history with lots of merged branches.</p> </li> <li> <p><a href="gitworkflows">gitworkflows[7]</a>: Gives an overview of recommended workflows.</p> </li> <li> <p><a href="giteveryday">giteveryday[7]</a>: Everyday Git with 20 Commands Or So.</p> </li> <li> <p><a href="gitcvs-migration">gitcvs-migration[7]</a>: Git for CVS users.</p> </li> </ul> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gittutorial-2">gittutorial-2[7]</a>, <a href="gitcvs-migration">gitcvs-migration[7]</a>, <a href="gitcore-tutorial">gitcore-tutorial[7]</a>, <a href="gitglossary">gitglossary[7]</a>, <a href="git-help">git-help[1]</a>, <a href="gitworkflows">gitworkflows[7]</a>, <a href="giteveryday">giteveryday[7]</a>, <a href="user-manual">The Git User’s Manual</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gittutorial" class="_attribution-link">https://git-scm.com/docs/gittutorial</a> + </p> +</div> diff --git a/devdocs/git/gitweb.conf.html b/devdocs/git/gitweb.conf.html new file mode 100644 index 00000000..b4b60f4b --- /dev/null +++ b/devdocs/git/gitweb.conf.html @@ -0,0 +1,44 @@ +<h1>gitweb.conf</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitweb.conf - Gitweb (Git web interface) configuration file</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>/etc/gitweb.conf, /etc/gitweb-common.conf, $GITWEBDIR/gitweb_config.perl</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>The gitweb CGI script for viewing Git repositories over the web uses a perl script fragment as its configuration file. You can set variables using "<code>our $variable = value</code>"; text from a "#" character until the end of a line is ignored. See <strong>perlsyn</strong>(1) for details.</p> <p>An example:</p> <div class="listingblock"> <div class="content"> <pre># gitweb configuration file for http://git.example.org +# +our $projectroot = "/srv/git"; # FHS recommendation +our $site_name = 'Example.org >> Repos';</pre> </div> </div> <p>The configuration file is used to override the default settings that were built into gitweb at the time the <code>gitweb.cgi</code> script was generated.</p> <p>While one could just alter the configuration settings in the gitweb CGI itself, those changes would be lost upon upgrade. Configuration settings might also be placed into a file in the same directory as the CGI script with the default name <code>gitweb_config.perl</code> — allowing one to have multiple gitweb instances with different configurations by the use of symlinks.</p> <p>Note that some configuration can be controlled on per-repository rather than gitweb-wide basis: see "Per-repository gitweb configuration" subsection on <a href="gitweb">gitweb[1]</a> manpage.</p> </div> <h2 id="_discussion">Discussion</h2> <div class="sectionbody"> <p>Gitweb reads configuration data from the following sources in the following order:</p> <div class="ulist"> <ul> <li> <p>built-in values (some set during build stage),</p> </li> <li> <p>common system-wide configuration file (defaults to <code>/etc/gitweb-common.conf</code>),</p> </li> <li> <p>either per-instance configuration file (defaults to <code>gitweb_config.perl</code> in the same directory as the installed gitweb), or if it does not exist then fallback system-wide configuration file (defaults to <code>/etc/gitweb.conf</code>).</p> </li> </ul> </div> <p>Values obtained in later configuration files override values obtained earlier in the above sequence.</p> <p>Locations of the common system-wide configuration file, the fallback system-wide configuration file and the per-instance configuration file are defined at compile time using build-time Makefile configuration variables, respectively <code>GITWEB_CONFIG_COMMON</code>, <code>GITWEB_CONFIG_SYSTEM</code> and <code>GITWEB_CONFIG</code>.</p> <p>You can also override locations of gitweb configuration files during runtime by setting the following environment variables: <code>GITWEB_CONFIG_COMMON</code>, <code>GITWEB_CONFIG_SYSTEM</code> and <code>GITWEB_CONFIG</code> to a non-empty value.</p> <p>The syntax of the configuration files is that of Perl, since these files are handled by sourcing them as fragments of Perl code (the language that gitweb itself is written in). Variables are typically set using the <code>our</code> qualifier (as in "<code>our $variable = <value>;</code>") to avoid syntax errors if a new version of gitweb no longer uses a variable and therefore stops declaring it.</p> <p>You can include other configuration file using read_config_file() subroutine. For example, one might want to put gitweb configuration related to access control for viewing repositories via Gitolite (one of Git repository management tools) in a separate file, e.g. in <code>/etc/gitweb-gitolite.conf</code>. To include it, put</p> <div class="listingblock"> <div class="content"> <pre>read_config_file("/etc/gitweb-gitolite.conf");</pre> </div> </div> <p>somewhere in gitweb configuration file used, e.g. in per-installation gitweb configuration file. Note that read_config_file() checks itself that the file it reads exists, and does nothing if it is not found. It also handles errors in included file.</p> <p>The default configuration with no configuration file at all may work perfectly well for some installations. Still, a configuration file is useful for customizing or tweaking the behavior of gitweb in many ways, and some optional features will not be present unless explicitly enabled using the configurable <code>%features</code> variable (see also "Configuring gitweb features" section below).</p> </div> <h2 id="_configuration_variables">Configuration variables</h2> <div class="sectionbody"> <p>Some configuration variables have their default values (embedded in the CGI script) set during building gitweb — if that is the case, this fact is put in their description. See gitweb’s <code>INSTALL</code> file for instructions on building and installing gitweb.</p> <div class="sect2"> <h3 id="_location_of_repositories"> +Location of repositories</h3> <p>The configuration variables described below control how gitweb finds Git repositories, and how repositories are displayed and accessed.</p> <p>See also "Repositories" and later subsections in <a href="gitweb">gitweb[1]</a> manpage.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-projectroot"> $projectroot </dt> <dd> <p>Absolute filesystem path which will be prepended to project path; the path to repository is <code>$projectroot/$project</code>. Set to <code>$GITWEB_PROJECTROOT</code> during installation. This variable has to be set correctly for gitweb to find repositories.</p> <p>For example, if <code>$projectroot</code> is set to "/srv/git" by putting the following in gitweb config file:</p> <div class="listingblock"> <div class="content"> <pre>our $projectroot = "/srv/git";</pre> </div> </div> <p>then</p> <div class="listingblock"> <div class="content"> <pre>http://git.example.com/gitweb.cgi?p=foo/bar.git</pre> </div> </div> <p>and its path_info based equivalent</p> <div class="listingblock"> <div class="content"> <pre>http://git.example.com/gitweb.cgi/foo/bar.git</pre> </div> </div> <p>will map to the path <code>/srv/git/foo/bar.git</code> on the filesystem.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-projectslist"> $projects_list </dt> <dd> <p>Name of a plain text file listing projects, or a name of directory to be scanned for projects.</p> <p>Project list files should list one project per line, with each line having the following format</p> <div class="listingblock"> <div class="content"> <pre><URI-encoded filesystem path to repository> SP <URI-encoded repository owner></pre> </div> </div> <p>The default value of this variable is determined by the <code>GITWEB_LIST</code> makefile variable at installation time. If this variable is empty, gitweb will fall back to scanning the <code>$projectroot</code> directory for repositories.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-projectmaxdepth"> $project_maxdepth </dt> <dd> <p>If <code>$projects_list</code> variable is unset, gitweb will recursively scan filesystem for Git repositories. The <code>$project_maxdepth</code> is used to limit traversing depth, relative to <code>$projectroot</code> (starting point); it means that directories which are further from <code>$projectroot</code> than <code>$project_maxdepth</code> will be skipped.</p> <p>It is purely performance optimization, originally intended for MacOS X, where recursive directory traversal is slow. Gitweb follows symbolic links, but it detects cycles, ignoring any duplicate files and directories.</p> <p>The default value of this variable is determined by the build-time configuration variable <code>GITWEB_PROJECT_MAXDEPTH</code>, which defaults to 2007.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-exportok"> $export_ok </dt> <dd> <p>Show repository only if this file exists (in repository). Only effective if this variable evaluates to true. Can be set when building gitweb by setting <code>GITWEB_EXPORT_OK</code>. This path is relative to <code>GIT_DIR</code>. git-daemon[1] uses <code>git-daemon-export-ok</code>, unless started with <code>--export-all</code>. By default this variable is not set, which means that this feature is turned off.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-exportauthhook"> $export_auth_hook </dt> <dd> <p>Function used to determine which repositories should be shown. This subroutine should take one parameter, the full path to a project, and if it returns true, that project will be included in the projects list and can be accessed through gitweb as long as it fulfills the other requirements described by $export_ok, $projects_list, and $projects_maxdepth. Example:</p> <div class="listingblock"> <div class="content"> <pre>our $export_auth_hook = sub { return -e "$_[0]/git-daemon-export-ok"; };</pre> </div> </div> <p>though the above might be done by using <code>$export_ok</code> instead</p> <div class="listingblock"> <div class="content"> <pre>our $export_ok = "git-daemon-export-ok";</pre> </div> </div> <p>If not set (default), it means that this feature is disabled.</p> <p>See also more involved example in "Controlling access to Git repositories" subsection on <a href="gitweb">gitweb[1]</a> manpage.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-strictexport"> $strict_export </dt> <dd> <p>Only allow viewing of repositories also shown on the overview page. This for example makes <code>$export_ok</code> file decide if repository is available and not only if it is shown. If <code>$projects_list</code> points to file with list of project, only those repositories listed would be available for gitweb. Can be set during building gitweb via <code>GITWEB_STRICT_EXPORT</code>. By default this variable is not set, which means that you can directly access those repositories that are hidden from projects list page (e.g. the are not listed in the $projects_list file).</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_finding_files"> +Finding files</h3> <p>The following configuration variables tell gitweb where to find files. The values of these variables are paths on the filesystem.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-GIT"> $GIT </dt> <dd> <p>Core git executable to use. By default set to <code>$GIT_BINDIR/git</code>, which in turn is by default set to <code>$(bindir)/git</code>. If you use Git installed from a binary package, you should usually set this to "/usr/bin/git". This can just be "git" if your web server has a sensible PATH; from security point of view it is better to use absolute path to git binary. If you have multiple Git versions installed it can be used to choose which one to use. Must be (correctly) set for gitweb to be able to work.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-mimetypesfile"> $mimetypes_file </dt> <dd> <p>File to use for (filename extension based) guessing of MIME types before trying <code>/etc/mime.types</code>. <strong>NOTE</strong> that this path, if relative, is taken as relative to the current Git repository, not to CGI script. If unset, only <code>/etc/mime.types</code> is used (if present on filesystem). If no mimetypes file is found, mimetype guessing based on extension of file is disabled. Unset by default.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-highlightbin"> $highlight_bin </dt> <dd> <p>Path to the highlight executable to use (it must be the one from <a href="http://andre-simon.de/zip/download.php" class="bare">http://andre-simon.de/zip/download.php</a> due to assumptions about parameters and output). By default set to <code>highlight</code>; set it to full path to highlight executable if it is not installed on your web server’s PATH. Note that <code>highlight</code> feature must be set for gitweb to actually use syntax highlighting.</p> <p><strong>NOTE</strong>: for a file to be highlighted, its syntax type must be detected and that syntax must be supported by "highlight". The default syntax detection is minimal, and there are many supported syntax types with no detection by default. There are three options for adding syntax detection. The first and second priority are <code>%highlight_basename</code> and <code>%highlight_ext</code>, which detect based on basename (the full filename, for example "Makefile") and extension (for example "sh"). The keys of these hashes are the basename and extension, respectively, and the value for a given key is the name of the syntax to be passed via <code>--syntax <syntax></code> to "highlight". The last priority is the "highlight" configuration of <code>Shebang</code> regular expressions to detect the language based on the first line in the file, (for example, matching the line "#!/bin/bash"). See the highlight documentation and the default config at /etc/highlight/filetypes.conf for more details.</p> <p>For example if repositories you are hosting use "phtml" extension for PHP files, and you want to have correct syntax-highlighting for those files, you can add the following to gitweb configuration:</p> <div class="listingblock"> <div class="content"> <pre>our %highlight_ext; +$highlight_ext{'phtml'} = 'php';</pre> </div> </div> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_links_and_their_targets"> +Links and their targets</h3> <p>The configuration variables described below configure some of gitweb links: their target and their look (text or image), and where to find page prerequisites (stylesheet, favicon, images, scripts). Usually they are left at their default values, with the possible exception of <code>@stylesheets</code> variable.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-stylesheets"> @stylesheets </dt> <dd> <p>List of URIs of stylesheets (relative to the base URI of a page). You might specify more than one stylesheet, for example to use "gitweb.css" as base with site specific modifications in a separate stylesheet to make it easier to upgrade gitweb. For example, you can add a <code>site</code> stylesheet by putting</p> <div class="listingblock"> <div class="content"> <pre>push @stylesheets, "gitweb-site.css";</pre> </div> </div> <p>in the gitweb config file. Those values that are relative paths are relative to base URI of gitweb.</p> <p>This list should contain the URI of gitweb’s standard stylesheet. The default URI of gitweb stylesheet can be set at build time using the <code>GITWEB_CSS</code> makefile variable. Its default value is <code>static/gitweb.css</code> (or <code>static/gitweb.min.css</code> if the <code>CSSMIN</code> variable is defined, i.e. if CSS minifier is used during build).</p> <p><strong>Note</strong>: there is also a legacy <code>$stylesheet</code> configuration variable, which was used by older gitweb. If <code>$stylesheet</code> variable is defined, only CSS stylesheet given by this variable is used by gitweb.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-logo"> $logo </dt> <dd> <p>Points to the location where you put <code>git-logo.png</code> on your web server, or to be more the generic URI of logo, 72x27 size). This image is displayed in the top right corner of each gitweb page and used as a logo for the Atom feed. Relative to the base URI of gitweb (as a path). Can be adjusted when building gitweb using <code>GITWEB_LOGO</code> variable By default set to <code>static/git-logo.png</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-favicon"> $favicon </dt> <dd> <p>Points to the location where you put <code>git-favicon.png</code> on your web server, or to be more the generic URI of favicon, which will be served as "image/png" type. Web browsers that support favicons (website icons) may display them in the browser’s URL bar and next to the site name in bookmarks. Relative to the base URI of gitweb. Can be adjusted at build time using <code>GITWEB_FAVICON</code> variable. By default set to <code>static/git-favicon.png</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-javascript"> $javascript </dt> <dd> <p>Points to the location where you put <code>gitweb.js</code> on your web server, or to be more generic the URI of JavaScript code used by gitweb. Relative to the base URI of gitweb. Can be set at build time using the <code>GITWEB_JS</code> build-time configuration variable.</p> <p>The default value is either <code>static/gitweb.js</code>, or <code>static/gitweb.min.js</code> if the <code>JSMIN</code> build variable was defined, i.e. if JavaScript minifier was used at build time. <strong>Note</strong> that this single file is generated from multiple individual JavaScript "modules".</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-homelink"> $home_link </dt> <dd> <p>Target of the home link on the top of all pages (the first part of view "breadcrumbs"). By default it is set to the absolute URI of a current page (to the value of <code>$my_uri</code> variable, or to "/" if <code>$my_uri</code> is undefined or is an empty string).</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-homelinkstr"> $home_link_str </dt> <dd> <p>Label for the "home link" at the top of all pages, leading to <code>$home_link</code> (usually the main gitweb page, which contains the projects list). It is used as the first component of gitweb’s "breadcrumb trail": <code><home link> / <project> / <action></code>. Can be set at build time using the <code>GITWEB_HOME_LINK_STR</code> variable. By default it is set to "projects", as this link leads to the list of projects. Another popular choice is to set it to the name of site. Note that it is treated as raw HTML so it should not be set from untrusted sources.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-extrabreadcrumbs"> @extra_breadcrumbs </dt> <dd> <p>Additional links to be added to the start of the breadcrumb trail before the home link, to pages that are logically "above" the gitweb projects list, such as the organization and department which host the gitweb server. Each element of the list is a reference to an array, in which element 0 is the link text (equivalent to <code>$home_link_str</code>) and element 1 is the target URL (equivalent to <code>$home_link</code>).</p> <p>For example, the following setting produces a breadcrumb trail like "home / dev / projects / …" where "projects" is the home link.</p> <div class="listingblock"> <div class="content"> <pre> our @extra_breadcrumbs = ( + [ 'home' => 'https://www.example.org/' ], + [ 'dev' => 'https://dev.example.org/' ], + );</pre> </div> </div> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-logourl"> $logo_url </dt> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-logolabel"> $logo_label </dt> <dd> <p>URI and label (title) for the Git logo link (or your site logo, if you chose to use different logo image). By default, these both refer to Git homepage, <a href="https://git-scm.com" class="bare">https://git-scm.com</a>; in the past, they pointed to Git documentation at <a href="https://www.kernel.org" class="bare">https://www.kernel.org</a>.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_changing_gitwebs_look"> +Changing gitweb’s look</h3> <p>You can adjust how pages generated by gitweb look using the variables described below. You can change the site name, add common headers and footers for all pages, and add a description of this gitweb installation on its main page (which is the projects list page), etc.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-sitename"> $site_name </dt> <dd> <p>Name of your site or organization, to appear in page titles. Set it to something descriptive for clearer bookmarks etc. If this variable is not set or is, then gitweb uses the value of the <code>SERVER_NAME</code> <code>CGI</code> environment variable, setting site name to "$SERVER_NAME Git", or "Untitled Git" if this variable is not set (e.g. if running gitweb as standalone script).</p> <p>Can be set using the <code>GITWEB_SITENAME</code> at build time. Unset by default.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-sitehtmlheadstring"> $site_html_head_string </dt> <dd> <p>HTML snippet to be included in the <head> section of each page. Can be set using <code>GITWEB_SITE_HTML_HEAD_STRING</code> at build time. No default value.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-siteheader"> $site_header </dt> <dd> <p>Name of a file with HTML to be included at the top of each page. Relative to the directory containing the <code>gitweb.cgi</code> script. Can be set using <code>GITWEB_SITE_HEADER</code> at build time. No default value.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-sitefooter"> $site_footer </dt> <dd> <p>Name of a file with HTML to be included at the bottom of each page. Relative to the directory containing the <code>gitweb.cgi</code> script. Can be set using <code>GITWEB_SITE_FOOTER</code> at build time. No default value.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-hometext"> $home_text </dt> <dd> <p>Name of a HTML file which, if it exists, is included on the gitweb projects overview page ("projects_list" view). Relative to the directory containing the gitweb.cgi script. Default value can be adjusted during build time using <code>GITWEB_HOMETEXT</code> variable. By default set to <code>indextext.html</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-projectslistdescriptionwidth"> $projects_list_description_width </dt> <dd> <p>The width (in characters) of the "Description" column of the projects list. Longer descriptions will be truncated (trying to cut at word boundary); the full description is available in the <code>title</code> attribute (usually shown on mouseover). The default is 25, which might be too small if you use long project descriptions.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-defaultprojectsorder"> $default_projects_order </dt> <dd> <p>Default value of ordering of projects on projects list page, which means the ordering used if you don’t explicitly sort projects list (if there is no "o" CGI query parameter in the URL). Valid values are "none" (unsorted), "project" (projects are by project name, i.e. path to repository relative to <code>$projectroot</code>), "descr" (project description), "owner", and "age" (by date of most current commit).</p> <p>Default value is "project". Unknown value means unsorted.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_changing_gitwebs_behavior"> +Changing gitweb’s behavior</h3> <p>These configuration variables control <code>internal</code> gitweb behavior.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-defaultblobplainmimetype"> $default_blob_plain_mimetype </dt> <dd> <p>Default mimetype for the blob_plain (raw) view, if mimetype checking doesn’t result in some other type; by default "text/plain". Gitweb guesses mimetype of a file to display based on extension of its filename, using <code>$mimetypes_file</code> (if set and file exists) and <code>/etc/mime.types</code> files (see <strong>mime.types</strong>(5) manpage; only filename extension rules are supported by gitweb).</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-defaulttextplaincharset"> $default_text_plain_charset </dt> <dd> <p>Default charset for text files. If this is not set, the web server configuration will be used. Unset by default.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-fallbackencoding"> $fallback_encoding </dt> <dd> <p>Gitweb assumes this charset when a line contains non-UTF-8 characters. The fallback decoding is used without error checking, so it can be even "utf-8". The value must be a valid encoding; see the <strong>Encoding::Supported</strong>(3pm) man page for a list. The default is "latin1", aka. "iso-8859-1".</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-diffopts"> @diff_opts </dt> <dd> <p>Rename detection options for git-diff and git-diff-tree. The default is ('-M'); set it to ('-C') or ('-C', '-C') to also detect copies, or set it to () i.e. empty list if you don’t want to have renames detection.</p> <p><strong>Note</strong> that rename and especially copy detection can be quite CPU-intensive. Note also that non Git tools can have problems with patches generated with options mentioned above, especially when they involve file copies ('-C') or criss-cross renames ('-B').</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_some_optional_features_and_policies"> +Some optional features and policies</h3> <p>Most of features are configured via <code>%feature</code> hash; however some of extra gitweb features can be turned on and configured using variables described below. This list beside configuration variables that control how gitweb looks does contain variables configuring administrative side of gitweb (e.g. cross-site scripting prevention; admittedly this as side effect affects how "summary" pages look like, or load limiting).</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-gitbaseurllist"> @git_base_url_list </dt> <dd> <p>List of Git base URLs. These URLs are used to generate URLs describing from where to fetch a project, which are shown on project summary page. The full fetch URL is "<code>$git_base_url/$project</code>", for each element of this list. You can set up multiple base URLs (for example one for <code>git://</code> protocol, and one for <code>http://</code> protocol).</p> <p>Note that per repository configuration can be set in <code>$GIT_DIR/cloneurl</code> file, or as values of multi-value <code>gitweb.url</code> configuration variable in project config. Per-repository configuration takes precedence over value composed from <code>@git_base_url_list</code> elements and project name.</p> <p>You can setup one single value (single entry/item in this list) at build time by setting the <code>GITWEB_BASE_URL</code> build-time configuration variable. By default it is set to (), i.e. an empty list. This means that gitweb would not try to create project URL (to fetch) from project name.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-projectslistgroupcategories"> $projects_list_group_categories </dt> <dd> <p>Whether to enable the grouping of projects by category on the project list page. The category of a project is determined by the <code>$GIT_DIR/category</code> file or the <code>gitweb.category</code> variable in each repository’s configuration. Disabled by default (set to 0).</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-projectlistdefaultcategory"> $project_list_default_category </dt> <dd> <p>Default category for projects for which none is specified. If this is set to the empty string, such projects will remain uncategorized and listed at the top, above categorized projects. Used only if project categories are enabled, which means if <code>$projects_list_group_categories</code> is true. By default set to "" (empty string).</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-preventxss"> $prevent_xss </dt> <dd> <p>If true, some gitweb features are disabled to prevent content in repositories from launching cross-site scripting (XSS) attacks. Set this to true if you don’t trust the content of your repositories. False by default (set to 0).</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-maxload"> $maxload </dt> <dd> <p>Used to set the maximum load that we will still respond to gitweb queries. If the server load exceeds this value then gitweb will return "503 Service Unavailable" error. The server load is taken to be 0 if gitweb cannot determine its value. Currently it works only on Linux, where it uses <code>/proc/loadavg</code>; the load there is the number of active tasks on the system — processes that are actually running — averaged over the last minute.</p> <p>Set <code>$maxload</code> to undefined value (<code>undef</code>) to turn this feature off. The default value is 300.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-omitagecolumn"> $omit_age_column </dt> <dd> <p>If true, omit the column with date of the most current commit on the projects list page. It can save a bit of I/O and a fork per repository.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-omitowner"> $omit_owner </dt> <dd> <p>If true prevents displaying information about repository owner.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-perrequestconfig"> $per_request_config </dt> <dd> <p>If this is set to code reference, it will be run once for each request. You can set parts of configuration that change per session this way. For example, one might use the following code in a gitweb configuration file</p> <div class="listingblock"> <div class="content"> <pre>our $per_request_config = sub { + $ENV{GL_USER} = $cgi->remote_user || "gitweb"; +};</pre> </div> </div> <p>If <code>$per_request_config</code> is not a code reference, it is interpreted as boolean value. If it is true gitweb will process config files once per request, and if it is false gitweb will process config files only once, each time it is executed. True by default (set to 1).</p> <p><strong>NOTE</strong>: <code>$my_url</code>, <code>$my_uri</code>, and <code>$base_url</code> are overwritten with their default values before every request, so if you want to change them, be sure to set this variable to true or a code reference effecting the desired changes.</p> <p>This variable matters only when using persistent web environments that serve multiple requests using single gitweb instance, like mod_perl, FastCGI or Plackup.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_other_variables"> +Other variables</h3> <p>Usually you should not need to change (adjust) any of configuration variables described below; they should be automatically set by gitweb to correct value.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-version"> $version </dt> <dd> <p>Gitweb version, set automatically when creating gitweb.cgi from gitweb.perl. You might want to modify it if you are running modified gitweb, for example</p> <div class="listingblock"> <div class="content"> <pre>our $version .= " with caching";</pre> </div> </div> <p>if you run modified version of gitweb with caching support. This variable is purely informational, used e.g. in the "generator" meta header in HTML header.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-myurl"> $my_url </dt> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-myuri"> $my_uri </dt> <dd> <p>Full URL and absolute URL of the gitweb script; in earlier versions of gitweb you might have need to set those variables, but now there should be no need to do it. See <code>$per_request_config</code> if you need to set them still.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-baseurl"> $base_url </dt> <dd> <p>Base URL for relative URLs in pages generated by gitweb, (e.g. <code>$logo</code>, <code>$favicon</code>, <code>@stylesheets</code> if they are relative URLs), needed and used <code><base href="$base_url"></code> only for URLs with nonempty PATH_INFO. Usually gitweb sets its value correctly, and there is no need to set this variable, e.g. to $my_uri or "/". See <code>$per_request_config</code> if you need to override it anyway.</p> </dd> </dl> </div> </div> </div> <h2 id="_configuring_gitweb_features">Configuring gitweb features</h2> <div class="sectionbody"> <p>Many gitweb features can be enabled (or disabled) and configured using the <code>%feature</code> hash. Names of gitweb features are keys of this hash.</p> <p>Each <code>%feature</code> hash element is a hash reference and has the following structure:</p> <div class="listingblock"> <div class="content"> <pre>"<feature_name>" => { + "sub" => <feature-sub (subroutine)>, + "override" => <allow-override (boolean)>, + "default" => [ <options>... ] +},</pre> </div> </div> <p>Some features cannot be overridden per project. For those features the structure of appropriate <code>%feature</code> hash element has a simpler form:</p> <div class="listingblock"> <div class="content"> <pre>"<feature_name>" => { + "override" => 0, + "default" => [ <options>... ] +},</pre> </div> </div> <p>As one can see it lacks the 'sub' element.</p> <p>The meaning of each part of feature configuration is described below:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-default"> default </dt> <dd> <p>List (array reference) of feature parameters (if there are any), used also to toggle (enable or disable) given feature.</p> <p>Note that it is currently <strong>always</strong> an array reference, even if feature doesn’t accept any configuration parameters, and 'default' is used only to turn it on or off. In such case you turn feature on by setting this element to <code>[1]</code>, and torn it off by setting it to <code>[0]</code>. See also the passage about the "blame" feature in the "Examples" section.</p> <p>To disable features that accept parameters (are configurable), you need to set this element to empty list i.e. <code>[]</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-override"> override </dt> <dd> <p>If this field has a true value then the given feature is overridable, which means that it can be configured (or enabled/disabled) on a per-repository basis.</p> <p>Usually given "<feature>" is configurable via the <code>gitweb.<feature></code> config variable in the per-repository Git configuration file.</p> <p><strong>Note</strong> that no feature is overridable by default.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-sub"> sub </dt> <dd> <p>Internal detail of implementation. What is important is that if this field is not present then per-repository override for given feature is not supported.</p> <p>You wouldn’t need to ever change it in gitweb config file.</p> </dd> </dl> </div> <div class="sect2"> <h3 id="_features_in_feature"> +Features in <code>%feature</code> +</h3> <p>The gitweb features that are configurable via <code>%feature</code> hash are listed below. This should be a complete list, but ultimately the authoritative and complete list is in gitweb.cgi source code, with features described in the comments.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-blame"> blame </dt> <dd> <p>Enable the "blame" and "blame_incremental" blob views, showing for each line the last commit that modified it; see <a href="git-blame">git-blame[1]</a>. This can be very CPU-intensive and is therefore disabled by default.</p> <p>This feature can be configured on a per-repository basis via repository’s <code>gitweb.blame</code> configuration variable (boolean).</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-snapshot"> snapshot </dt> <dd> <p>Enable and configure the "snapshot" action, which allows user to download a compressed archive of any tree or commit, as produced by <a href="git-archive">git-archive[1]</a> and possibly additionally compressed. This can potentially generate high traffic if you have large project.</p> <p>The value of 'default' is a list of names of snapshot formats, defined in <code>%known_snapshot_formats</code> hash, that you wish to offer. Supported formats include "tgz", "tbz2", "txz" (gzip/bzip2/xz compressed tar archive) and "zip"; please consult gitweb sources for a definitive list. By default only "tgz" is offered.</p> <p>This feature can be configured on a per-repository basis via repository’s <code>gitweb.snapshot</code> configuration variable, which contains a comma separated list of formats or "none" to disable snapshots. Unknown values are ignored.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-grep"> grep </dt> <dd> <p>Enable grep search, which lists the files in currently selected tree (directory) containing the given string; see <a href="git-grep">git-grep[1]</a>. This can be potentially CPU-intensive, of course. Enabled by default.</p> <p>This feature can be configured on a per-repository basis via repository’s <code>gitweb.grep</code> configuration variable (boolean).</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-pickaxe"> pickaxe </dt> <dd> <p>Enable the so called pickaxe search, which will list the commits that introduced or removed a given string in a file. This can be practical and quite faster alternative to "blame" action, but it is still potentially CPU-intensive. Enabled by default.</p> <p>The pickaxe search is described in <a href="git-log">git-log[1]</a> (the description of <code>-S<string></code> option, which refers to pickaxe entry in <a href="gitdiffcore">gitdiffcore[7]</a> for more details).</p> <p>This feature can be configured on a per-repository basis by setting repository’s <code>gitweb.pickaxe</code> configuration variable (boolean).</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-show-sizes"> show-sizes </dt> <dd> <p>Enable showing size of blobs (ordinary files) in a "tree" view, in a separate column, similar to what <code>ls -l</code> does; see description of <code>-l</code> option in <a href="git-ls-tree">git-ls-tree[1]</a> manpage. This costs a bit of I/O. Enabled by default.</p> <p>This feature can be configured on a per-repository basis via repository’s <code>gitweb.showSizes</code> configuration variable (boolean).</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-patches"> patches </dt> <dd> <p>Enable and configure "patches" view, which displays list of commits in email (plain text) output format; see also <a href="git-format-patch">git-format-patch[1]</a>. The value is the maximum number of patches in a patchset generated in "patches" view. Set the <code>default</code> field to a list containing single item of or to an empty list to disable patch view, or to a list containing a single negative number to remove any limit. Default value is 16.</p> <p>This feature can be configured on a per-repository basis via repository’s <code>gitweb.patches</code> configuration variable (integer).</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-avatar"> avatar </dt> <dd> <p>Avatar support. When this feature is enabled, views such as "shortlog" or "commit" will display an avatar associated with the email of each committer and author.</p> <p>Currently available providers are <strong>"gravatar"</strong> and <strong>"picon"</strong>. Only one provider at a time can be selected (<code>default</code> is one element list). If an unknown provider is specified, the feature is disabled. <strong>Note</strong> that some providers might require extra Perl packages to be installed; see <code>gitweb/INSTALL</code> for more details.</p> <p>This feature can be configured on a per-repository basis via repository’s <code>gitweb.avatar</code> configuration variable.</p> <p>See also <code>%avatar_size</code> with pixel sizes for icons and avatars ("default" is used for one-line like "log" and "shortlog", "double" is used for two-line like "commit", "commitdiff" or "tag"). If the default font sizes or lineheights are changed (e.g. via adding extra CSS stylesheet in <code>@stylesheets</code>), it may be appropriate to change these values.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-email-privacy"> email-privacy </dt> <dd> <p>Redact e-mail addresses from the generated HTML, etc. content. This obscures e-mail addresses retrieved from the author/committer and comment sections of the Git log. It is meant to hinder web crawlers that harvest and abuse addresses. Such crawlers may not respect robots.txt. Note that users and user tools also see the addresses as redacted. If Gitweb is not the final step in a workflow then subsequent steps may misbehave because of the redacted information they receive. Disabled by default.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-highlight"> highlight </dt> <dd> <p>Server-side syntax highlight support in "blob" view. It requires <code>$highlight_bin</code> program to be available (see the description of this variable in the "Configuration variables" section above), and therefore is disabled by default.</p> <p>This feature can be configured on a per-repository basis via repository’s <code>gitweb.highlight</code> configuration variable (boolean).</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-remoteheads"> remote_heads </dt> <dd> <p>Enable displaying remote heads (remote-tracking branches) in the "heads" list. In most cases the list of remote-tracking branches is an unnecessary internal private detail, and this feature is therefore disabled by default. <a href="git-instaweb">git-instaweb[1]</a>, which is usually used to browse local repositories, enables and uses this feature.</p> <p>This feature can be configured on a per-repository basis via repository’s <code>gitweb.remote_heads</code> configuration variable (boolean).</p> </dd> </dl> </div> <p>The remaining features cannot be overridden on a per project basis.</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-search"> search </dt> <dd> <p>Enable text search, which will list the commits which match author, committer or commit text to a given string; see the description of <code>--author</code>, <code>--committer</code> and <code>--grep</code> options in <a href="git-log">git-log[1]</a> manpage. Enabled by default.</p> <p>Project specific override is not supported.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-forks"> forks </dt> <dd> <p>If this feature is enabled, gitweb considers projects in subdirectories of project root (basename) to be forks of existing projects. For each project <code>$projname.git</code>, projects in the <code>$projname/</code> directory and its subdirectories will not be shown in the main projects list. Instead, a '+' mark is shown next to <code>$projname</code>, which links to a "forks" view that lists all the forks (all projects in <code>$projname/</code> subdirectory). Additionally a "forks" view for a project is linked from project summary page.</p> <p>If the project list is taken from a file (<code>$projects_list</code> points to a file), forks are only recognized if they are listed after the main project in that file.</p> <p>Project specific override is not supported.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-actions"> actions </dt> <dd> <p>Insert custom links to the action bar of all project pages. This allows you to link to third-party scripts integrating into gitweb.</p> <p>The "default" value consists of a list of triplets in the form <code>("<label>", "<link>", "<position>")</code> where "position" is the label after which to insert the link, "link" is a format string where <code>%n</code> expands to the project name, <code>%f</code> to the project path within the filesystem (i.e. "$projectroot/$project"), <code>%h</code> to the current hash ('h' gitweb parameter) and <code>%b</code> to the current hash base ('hb' gitweb parameter); <code>%%</code> expands to '%'.</p> <p>For example, at the time this page was written, the <a href="https://repo.or.cz" class="bare">https://repo.or.cz</a> Git hosting site set it to the following to enable graphical log (using the third party tool <strong>git-browser</strong>):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$feature{'actions'}{'default'} = + [ ('graphiclog', '/git-browser/by-commit.html?r=%n', 'summary')];</pre> </div> </div> <p>This adds a link titled "graphiclog" after the "summary" link, leading to <code>git-browser</code> script, passing <code>r=<project></code> as a query parameter.</p> <p>Project specific override is not supported.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-timed"> timed </dt> <dd> <p>Enable displaying how much time and how many Git commands it took to generate and display each page in the page footer (at the bottom of page). For example the footer might contain: "This page took 6.53325 seconds and 13 Git commands to generate." Disabled by default.</p> <p>Project specific override is not supported.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-javascript-timezone"> javascript-timezone </dt> <dd> <p>Enable and configure the ability to change a common time zone for dates in gitweb output via JavaScript. Dates in gitweb output include authordate and committerdate in "commit", "commitdiff" and "log" views, and taggerdate in "tag" view. Enabled by default.</p> <p>The value is a list of three values: a default time zone (for if the client hasn’t selected some other time zone and saved it in a cookie), a name of cookie where to store selected time zone, and a CSS class used to mark up dates for manipulation. If you want to turn this feature off, set "default" to empty list: <code>[]</code>.</p> <p>Typical gitweb config files will only change starting (default) time zone, and leave other elements at their default values:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$feature{'javascript-timezone'}{'default'}[0] = "utc";</pre> </div> </div> <p>The example configuration presented here is guaranteed to be backwards and forward compatible.</p> <p>Time zone values can be "local" (for local time zone that browser uses), "utc" (what gitweb uses when JavaScript or this feature is disabled), or numerical time zones in the form of "+/-HHMM", such as "+0200".</p> <p>Project specific override is not supported.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-extra-branch-refs"> extra-branch-refs </dt> <dd> <p>List of additional directories under "refs" which are going to be used as branch refs. For example if you have a gerrit setup where all branches under refs/heads/ are official, push-after-review ones and branches under refs/sandbox/, refs/wip and refs/other are user ones where permissions are much wider, then you might want to set this variable as follows:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$feature{'extra-branch-refs'}{'default'} = + ['sandbox', 'wip', 'other'];</pre> </div> </div> <p>This feature can be configured on per-repository basis after setting $feature{<code>extra-branch-refs</code>}{<code>override</code>} to true, via repository’s <code>gitweb.extraBranchRefs</code> configuration variable, which contains a space separated list of refs. An example:</p> <div class="listingblock"> <div class="content"> <pre>[gitweb] + extraBranchRefs = sandbox wip other</pre> </div> </div> <p>The gitweb.extraBranchRefs is actually a multi-valued configuration variable, so following example is also correct and the result is the same as of the snippet above:</p> <div class="listingblock"> <div class="content"> <pre>[gitweb] + extraBranchRefs = sandbox + extraBranchRefs = wip other</pre> </div> </div> <p>It is an error to specify a ref that does not pass "git check-ref-format" scrutiny. Duplicated values are filtered.</p> </dd> </dl> </div> </div> </div> <h2 id="_examples">Examples</h2> <div class="sectionbody"> <p>To enable blame, pickaxe search, and snapshot support (allowing "tar.gz" and "zip" snapshots), while allowing individual projects to turn them off, put the following in your GITWEB_CONFIG file:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$feature{'blame'}{'default'} = [1]; +$feature{'blame'}{'override'} = 1; + +$feature{'pickaxe'}{'default'} = [1]; +$feature{'pickaxe'}{'override'} = 1; + +$feature{'snapshot'}{'default'} = ['zip', 'tgz']; +$feature{'snapshot'}{'override'} = 1;</pre> </div> </div> <p>If you allow overriding for the snapshot feature, you can specify which snapshot formats are globally disabled. You can also add any command-line options you want (such as setting the compression level). For instance, you can disable Zip compressed snapshots and set <strong>gzip</strong>(1) to run at level 6 by adding the following lines to your gitweb configuration file:</p> <div class="literalblock"> <div class="content"> <pre data-language="shell-session">$known_snapshot_formats{'zip'}{'disabled'} = 1; +$known_snapshot_formats{'tgz'}{'compressor'} = ['gzip','-6'];</pre> </div> </div> </div> <h2 id="_bugs">Bugs</h2> <div class="sectionbody"> <p>Debugging would be easier if the fallback configuration file (<code>/etc/gitweb.conf</code>) and environment variable to override its location (<code>GITWEB_CONFIG_SYSTEM</code>) had names reflecting their "fallback" role. The current names are kept to avoid breaking working setups.</p> </div> <h2 id="_environment">Environment</h2> <div class="sectionbody"> <p>The location of per-instance and system-wide configuration files can be overridden using the following environment variables:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-GITWEBCONFIG"> GITWEB_CONFIG </dt> <dd> <p>Sets location of per-instance configuration file.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-GITWEBCONFIGSYSTEM"> GITWEB_CONFIG_SYSTEM </dt> <dd> <p>Sets location of fallback system-wide configuration file. This file is read only if per-instance one does not exist.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-GITWEBCONFIGCOMMON"> GITWEB_CONFIG_COMMON </dt> <dd> <p>Sets location of common system-wide configuration file.</p> </dd> </dl> </div> </div> <h2 id="_files">Files</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-gitwebconfigperl"> gitweb_config.perl </dt> <dd> <p>This is default name of per-instance configuration file. The format of this file is described above.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-etcgitwebconf"> /etc/gitweb.conf </dt> <dd> <p>This is default name of fallback system-wide configuration file. This file is used only if per-instance configuration variable is not found.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.conf.txt-etcgitweb-commonconf"> /etc/gitweb-common.conf </dt> <dd> <p>This is default name of common system-wide configuration file.</p> </dd> </dl> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gitweb">gitweb[1]</a>, <a href="git-instaweb">git-instaweb[1]</a></p> <p><code>gitweb/README</code>, <code>gitweb/INSTALL</code></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitweb.conf" class="_attribution-link">https://git-scm.com/docs/gitweb.conf</a> + </p> +</div> diff --git a/devdocs/git/gitweb.html b/devdocs/git/gitweb.html new file mode 100644 index 00000000..0c1e6651 --- /dev/null +++ b/devdocs/git/gitweb.html @@ -0,0 +1,142 @@ +<h1>gitweb</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitweb - Git web interface (web frontend to Git repositories)</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <p>To get started with gitweb, run <a href="git-instaweb">git-instaweb[1]</a> from a Git repository. This will configure and start your web server, and run a web browser pointing to gitweb.</p> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Gitweb provides a web interface to Git repositories. Its features include:</p> <div class="ulist"> <ul> <li> <p>Viewing multiple Git repositories with common root.</p> </li> <li> <p>Browsing every revision of the repository.</p> </li> <li> <p>Viewing the contents of files in the repository at any revision.</p> </li> <li> <p>Viewing the revision log of branches, history of files and directories, seeing what was changed, when, and by whom.</p> </li> <li> <p>Viewing the blame/annotation details of any file (if enabled).</p> </li> <li> <p>Generating RSS and Atom feeds of commits, for any branch. The feeds are auto-discoverable in modern web browsers.</p> </li> <li> <p>Viewing everything that was changed in a revision, and stepping through revisions one at a time, viewing the history of the repository.</p> </li> <li> <p>Finding commits whose commit messages match a given search term.</p> </li> </ul> </div> <p>See <a href="https://repo.or.cz/w/git.git/tree/HEAD:/gitweb/" class="bare">https://repo.or.cz/w/git.git/tree/HEAD:/gitweb/</a> for gitweb source code, browsed using gitweb itself.</p> </div> <h2 id="_configuration">Configuration</h2> <div class="sectionbody"> <p>Various aspects of gitweb’s behavior can be controlled through the configuration file <code>gitweb_config.perl</code> or <code>/etc/gitweb.conf</code>. See the <a href="gitweb.conf">gitweb.conf[5]</a> for details.</p> <div class="sect2"> <h3 id="_repositories"> +Repositories</h3> <p>Gitweb can show information from one or more Git repositories. These repositories have to be all on local filesystem, and have to share a common repository root, i.e. be all under a single parent repository (but see also the "Advanced web server setup" section, "Webserver configuration with multiple projects' root" subsection).</p> <div class="listingblock"> <div class="content"> <pre>our $projectroot = '/path/to/parent/directory';</pre> </div> </div> <p>The default value for <code>$projectroot</code> is <code>/pub/git</code>. You can change it during building gitweb via the <code>GITWEB_PROJECTROOT</code> build configuration variable.</p> <p>By default all Git repositories under <code>$projectroot</code> are visible and available to gitweb. The list of projects is generated by default by scanning the <code>$projectroot</code> directory for Git repositories (for object databases to be more exact; gitweb is not interested in a working area, and is best suited to showing "bare" repositories).</p> <p>The name of the repository in gitweb is the path to its <code>$GIT_DIR</code> (its object database) relative to <code>$projectroot</code>. Therefore the repository $repo can be found at "$projectroot/$repo".</p> </div> <div class="sect2"> <h3 id="_projects_list_file_format"> +Projects list file format</h3> <p>Instead of having gitweb find repositories by scanning the filesystem starting from $projectroot, you can provide a pre-generated list of visible projects by setting <code>$projects_list</code> to point to a plain text file with a list of projects (with some additional info).</p> <p>This file uses the following format:</p> <div class="ulist"> <ul> <li> <p>One record (for project / repository) per line; does not support line continuation (newline escaping).</p> </li> <li> <p>Leading and trailing whitespace are ignored.</p> </li> <li> <p>Whitespace separated fields; any run of whitespace can be used as field separator (rules for Perl’s "<code>split(" ", $line)</code>").</p> </li> <li> <p>Fields use modified URI encoding, defined in RFC 3986, section 2.1 (Percent-Encoding), or rather "Query string encoding" (see <a href="https://en.wikipedia.org/wiki/Query_string#URL_encoding" class="bare">https://en.wikipedia.org/wiki/Query_string#URL_encoding</a>), the difference being that SP (" ") can be encoded as "+" (and therefore "+" has to be also percent-encoded).</p> <p>Reserved characters are: "%" (used for encoding), "+" (can be used to encode SPACE), all whitespace characters as defined in Perl, including SP, TAB and LF, (used to separate fields in a record).</p> </li> <li> <p>Currently recognized fields are:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.txt-ltrepositorypathgt"> <repository path> </dt> <dd> <p>path to repository GIT_DIR, relative to <code>$projectroot</code></p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-ltrepositoryownergt"> <repository owner> </dt> <dd> <p>displayed as repository owner, preferably full name, or email, or both</p> </dd> </dl> </div> </li> </ul> </div> <p>You can generate the projects list index file using the project_index action (the <code>TXT</code> link on projects list page) directly from gitweb; see also "Generating projects list using gitweb" section below.</p> <p>Example contents:</p> <div class="listingblock"> <div class="content"> <pre>foo.git Joe+R+Hacker+<joe@example.com> +foo/bar.git O+W+Ner+<owner@example.org></pre> </div> </div> <p>By default this file controls only which projects are <strong>visible</strong> on projects list page (note that entries that do not point to correctly recognized Git repositories won’t be displayed by gitweb). Even if a project is not visible on projects list page, you can view it nevertheless by hand-crafting a gitweb URL. By setting <code>$strict_export</code> configuration variable (see <a href="gitweb.conf">gitweb.conf[5]</a>) to true value you can allow viewing only of repositories also shown on the overview page (i.e. only projects explicitly listed in projects list file will be accessible).</p> </div> <div class="sect2"> <h3 id="_generating_projects_list_using_gitweb"> +Generating projects list using gitweb</h3> <p>We assume that GITWEB_CONFIG has its default Makefile value, namely <code>gitweb_config.perl</code>. Put the following in <code>gitweb_make_index.perl</code> file:</p> <div class="listingblock"> <div class="content"> <pre>read_config_file("gitweb_config.perl"); +$projects_list = $projectroot;</pre> </div> </div> <p>Then create the following script to get list of project in the format suitable for GITWEB_LIST build configuration variable (or <code>$projects_list</code> variable in gitweb config):</p> <div class="listingblock"> <div class="content"> <pre>#!/bin/sh + +export GITWEB_CONFIG="gitweb_make_index.perl" +export GATEWAY_INTERFACE="CGI/1.1" +export HTTP_ACCEPT="*/*" +export REQUEST_METHOD="GET" +export QUERY_STRING="a=project_index" + +perl -- /var/www/cgi-bin/gitweb.cgi</pre> </div> </div> <p>Run this script and save its output to a file. This file could then be used as projects list file, which means that you can set <code>$projects_list</code> to its filename.</p> </div> <div class="sect2"> <h3 id="_controlling_access_to_git_repositories"> +Controlling access to Git repositories</h3> <p>By default all Git repositories under <code>$projectroot</code> are visible and available to gitweb. You can however configure how gitweb controls access to repositories.</p> <div class="ulist"> <ul> <li> <p>As described in "Projects list file format" section, you can control which projects are <strong>visible</strong> by selectively including repositories in projects list file, and setting <code>$projects_list</code> gitweb configuration variable to point to it. With <code>$strict_export</code> set, projects list file can be used to control which repositories are <strong>available</strong> as well.</p> </li> <li> <p>You can configure gitweb to only list and allow viewing of the explicitly exported repositories, via <code>$export_ok</code> variable in gitweb config file; see <a href="gitweb.conf">gitweb.conf[5]</a> manpage. If it evaluates to true, gitweb shows repositories only if this file named by <code>$export_ok</code> exists in its object database (if directory has the magic file named <code>$export_ok</code>).</p> <p>For example <a href="git-daemon">git-daemon[1]</a> by default (unless <code>--export-all</code> option is used) allows pulling only for those repositories that have <code>git-daemon-export-ok</code> file. Adding</p> <div class="listingblock"> <div class="content"> <pre>our $export_ok = "git-daemon-export-ok";</pre> </div> </div> <p>makes gitweb show and allow access only to those repositories that can be fetched from via <code>git://</code> protocol.</p> </li> <li> <p>Finally, it is possible to specify an arbitrary perl subroutine that will be called for each repository to determine if it can be exported. The subroutine receives an absolute path to the project (repository) as its only parameter (i.e. "$projectroot/$project").</p> <p>For example, if you use mod_perl to run the script, and have dumb HTTP protocol authentication configured for your repositories, you can use the following hook to allow access only if the user is authorized to read the files:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$export_auth_hook = sub { + use Apache2::SubRequest (); + use Apache2::Const -compile => qw(HTTP_OK); + my $path = "$_[0]/HEAD"; + my $r = Apache2::RequestUtil->request; + my $sub = $r->lookup_file($path); + return $sub->filename eq $path + && $sub->status == Apache2::Const::HTTP_OK; +};</pre> </div> </div> </li> </ul> </div> </div> <div class="sect2"> <h3 id="_per_repository_gitweb_configuration"> +Per-repository gitweb configuration</h3> <p>You can configure individual repositories shown in gitweb by creating file in the <code>GIT_DIR</code> of Git repository, or by setting some repo configuration variable (in <code>GIT_DIR/config</code>, see <a href="git-config">git-config[1]</a>).</p> <p>You can use the following files in repository:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.txt-READMEhtml"> README.html </dt> <dd> <p>A html file (HTML fragment) which is included on the gitweb project "summary" page inside <code><div></code> block element. You can use it for longer description of a project, to provide links (for example to project’s homepage), etc. This is recognized only if XSS prevention is off (<code>$prevent_xss</code> is false, see <a href="gitweb.conf">gitweb.conf[5]</a>); a way to include a README safely when XSS prevention is on may be worked out in the future.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-descriptionorcodegitwebdescriptioncode"> description (or <code>gitweb.description</code>) </dt> <dd> <p>Short (shortened to <code>$projects_list_description_width</code> in the projects list page, which is 25 characters by default; see <a href="gitweb.conf">gitweb.conf[5]</a>) single line description of a project (of a repository). Plain text file; HTML will be escaped. By default set to</p> <div class="listingblock"> <div class="content"> <pre>Unnamed repository; edit this file to name it for gitweb.</pre> </div> </div> <p>from the template during repository creation, usually installed in <code>/usr/share/git-core/templates/</code>. You can use the <code>gitweb.description</code> repo configuration variable, but the file takes precedence.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-categoryorcodegitwebcategorycode"> category (or <code>gitweb.category</code>) </dt> <dd> <p>Singe line category of a project, used to group projects if <code>$projects_list_group_categories</code> is enabled. By default (file and configuration variable absent), uncategorized projects are put in the <code>$project_list_default_category</code> category. You can use the <code>gitweb.category</code> repo configuration variable, but the file takes precedence.</p> <p>The configuration variables <code>$projects_list_group_categories</code> and <code>$project_list_default_category</code> are described in <a href="gitweb.conf">gitweb.conf[5]</a></p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-cloneurlormultiple-valuedcodegitweburlcode"> cloneurl (or multiple-valued <code>gitweb.url</code>) </dt> <dd> <p>File with repository URL (used for clone and fetch), one per line. Displayed in the project summary page. You can use multiple-valued <code>gitweb.url</code> repository configuration variable for that, but the file takes precedence.</p> <p>This is per-repository enhancement / version of global prefix-based <code>@git_base_url_list</code> gitweb configuration variable (see <a href="gitweb.conf">gitweb.conf[5]</a>).</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-gitwebowner"> gitweb.owner </dt> <dd> <p>You can use the <code>gitweb.owner</code> repository configuration variable to set repository’s owner. It is displayed in the project list and summary page.</p> <p>If it’s not set, filesystem directory’s owner is used (via GECOS field, i.e. real name field from <strong>getpwuid</strong>(3)) if <code>$projects_list</code> is unset (gitweb scans <code>$projectroot</code> for repositories); if <code>$projects_list</code> points to file with list of repositories, then project owner defaults to value from this file for given repository.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-variouscodegitwebcodeconfigvariablesinconfig"> various <code>gitweb.*</code> config variables (in config) </dt> <dd> <p>Read description of <code>%feature</code> hash for detailed list, and descriptions. See also "Configuring gitweb features" section in <a href="gitweb.conf">gitweb.conf[5]</a></p> </dd> </dl> </div> </div> </div> <h2 id="_actions_and_urls">Actions, and urls</h2> <div class="sectionbody"> <p>Gitweb can use path_info (component) based URLs, or it can pass all necessary information via query parameters. The typical gitweb URLs are broken down in to five components:</p> <div class="listingblock"> <div class="content"> <pre>.../gitweb.cgi/<repo>/<action>/<revision>:/<path>?<arguments></pre> </div> </div> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.txt-repo"> repo </dt> <dd> <p>The repository the action will be performed on.</p> <p>All actions except for those that list all available projects, in whatever form, require this parameter.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-action"> action </dt> <dd> <p>The action that will be run. Defaults to <code>projects_list</code> if repo is not set, and to <code>summary</code> otherwise.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-revision"> revision </dt> <dd> <p>Revision shown. Defaults to HEAD.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-path"> path </dt> <dd> <p>The path within the <repository> that the action is performed on, for those actions that require it.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-arguments"> arguments </dt> <dd> <p>Any arguments that control the behaviour of the action.</p> </dd> </dl> </div> <p>Some actions require or allow to specify two revisions, and sometimes even two pathnames. In most general form such path_info (component) based gitweb URL looks like this:</p> <div class="listingblock"> <div class="content"> <pre>.../gitweb.cgi/<repo>/<action>/<revision_from>:/<path_from>..<revision_to>:/<path_to>?<arguments></pre> </div> </div> <p>Each action is implemented as a subroutine, and must be present in %actions hash. Some actions are disabled by default, and must be turned on via feature mechanism. For example to enable <code>blame</code> view add the following to gitweb configuration file:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$feature{'blame'}{'default'} = [1];</pre> </div> </div> <div class="sect2"> <h3 id="_actions"> +Actions:</h3> <p>The standard actions are:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/gitweb.txt-projectlist"> project_list </dt> <dd> <p>Lists the available Git repositories. This is the default command if no repository is specified in the URL.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-summary"> summary </dt> <dd> <p>Displays summary about given repository. This is the default command if no action is specified in URL, and only repository is specified.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-heads"> heads </dt> <dt class="hdlist1" id="Documentation/gitweb.txt-remotes"> remotes </dt> <dd> <p>Lists all local or all remote-tracking branches in given repository.</p> <p>The latter is not available by default, unless configured.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-tags"> tags </dt> <dd> <p>List all tags (lightweight and annotated) in given repository.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-blob"> blob </dt> <dt class="hdlist1" id="Documentation/gitweb.txt-tree"> tree </dt> <dd> <p>Shows the files and directories in a given repository path, at given revision. This is default command if no action is specified in the URL, and path is given.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-blobplain"> blob_plain </dt> <dd> <p>Returns the raw data for the file in given repository, at given path and revision. Links to this action are marked <code>raw</code>.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-blobdiff"> blobdiff </dt> <dd> <p>Shows the difference between two revisions of the same file.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-blame"> blame </dt> <dt class="hdlist1" id="Documentation/gitweb.txt-blameincremental"> blame_incremental </dt> <dd> <p>Shows the blame (also called annotation) information for a file. On a per line basis it shows the revision in which that line was last changed and the user that committed the change. The incremental version (which if configured is used automatically when JavaScript is enabled) uses Ajax to incrementally add blame info to the contents of given file.</p> <p>This action is disabled by default for performance reasons.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-commit"> commit </dt> <dt class="hdlist1" id="Documentation/gitweb.txt-commitdiff"> commitdiff </dt> <dd> <p>Shows information about a specific commit in a repository. The <code>commit</code> view shows information about commit in more detail, the <code>commitdiff</code> action shows changeset for given commit.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-patch"> patch </dt> <dd> <p>Returns the commit in plain text mail format, suitable for applying with <a href="git-am">git-am[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-tag"> tag </dt> <dd> <p>Display specific annotated tag (tag object).</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-log"> log </dt> <dt class="hdlist1" id="Documentation/gitweb.txt-shortlog"> shortlog </dt> <dd> <p>Shows log information (commit message or just commit subject) for a given branch (starting from given revision).</p> <p>The <code>shortlog</code> view is more compact; it shows one commit per line.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-history"> history </dt> <dd> <p>Shows history of the file or directory in a given repository path, starting from given revision (defaults to HEAD, i.e. default branch).</p> <p>This view is similar to <code>shortlog</code> view.</p> </dd> <dt class="hdlist1" id="Documentation/gitweb.txt-rss"> rss </dt> <dt class="hdlist1" id="Documentation/gitweb.txt-atom"> atom </dt> <dd> <p>Generates an RSS (or Atom) feed of changes to repository.</p> </dd> </dl> </div> </div> </div> <h2 id="_webserver_configuration">Webserver configuration</h2> <div class="sectionbody"> <p>This section explains how to configure some common webservers to run gitweb. In all cases, <code>/path/to/gitweb</code> in the examples is the directory you ran installed gitweb in, and contains <code>gitweb_config.perl</code>.</p> <p>If you’ve configured a web server that isn’t listed here for gitweb, please send in the instructions so they can be included in a future release.</p> <div class="sect2"> <h3 id="_apache_as_cgi"> +Apache as CGI</h3> <p>Apache must be configured to support CGI scripts in the directory in which gitweb is installed. Let’s assume that it is <code>/var/www/cgi-bin</code> directory.</p> <div class="listingblock"> <div class="content"> <pre>ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" + +<Directory "/var/www/cgi-bin"> + Options Indexes FollowSymlinks ExecCGI + AllowOverride None + Order allow,deny + Allow from all +</Directory></pre> </div> </div> <p>With that configuration the full path to browse repositories would be:</p> <div class="literalblock"> <div class="content"> <pre>http://server/cgi-bin/gitweb.cgi</pre> </div> </div> </div> <div class="sect2"> <h3 id="_apache_with_mod_perl_via_modperlregistry"> +Apache with mod_perl, via ModPerl::Registry</h3> <p>You can use mod_perl with gitweb. You must install Apache::Registry (for mod_perl 1.x) or ModPerl::Registry (for mod_perl 2.x) to enable this support.</p> <p>Assuming that gitweb is installed to <code>/var/www/perl</code>, the following Apache configuration (for mod_perl 2.x) is suitable.</p> <div class="listingblock"> <div class="content"> <pre>Alias /perl "/var/www/perl" + +<Directory "/var/www/perl"> + SetHandler perl-script + PerlResponseHandler ModPerl::Registry + PerlOptions +ParseHeaders + Options Indexes FollowSymlinks +ExecCGI + AllowOverride None + Order allow,deny + Allow from all +</Directory></pre> </div> </div> <p>With that configuration the full path to browse repositories would be:</p> <div class="literalblock"> <div class="content"> <pre>http://server/perl/gitweb.cgi</pre> </div> </div> </div> <div class="sect2"> <h3 id="_apache_with_fastcgi"> +Apache with FastCGI</h3> <p>Gitweb works with Apache and FastCGI. First you need to rename, copy or symlink gitweb.cgi to gitweb.fcgi. Let’s assume that gitweb is installed in <code>/usr/share/gitweb</code> directory. The following Apache configuration is suitable (UNTESTED!)</p> <div class="listingblock"> <div class="content"> <pre>FastCgiServer /usr/share/gitweb/gitweb.cgi +ScriptAlias /gitweb /usr/share/gitweb/gitweb.cgi + +Alias /gitweb/static /usr/share/gitweb/static +<Directory /usr/share/gitweb/static> + SetHandler default-handler +</Directory></pre> </div> </div> <p>With that configuration the full path to browse repositories would be:</p> <div class="literalblock"> <div class="content"> <pre>http://server/gitweb</pre> </div> </div> </div> </div> <h2 id="_advanced_web_server_setup">Advanced web server setup</h2> <div class="sectionbody"> <p>All of those examples use request rewriting, and need <code>mod_rewrite</code> (or equivalent; examples below are written for Apache).</p> <div class="sect2"> <h3 id="_single_url_for_gitweb_and_for_fetching"> +Single URL for gitweb and for fetching</h3> <p>If you want to have one URL for both gitweb and your <code>http://</code> repositories, you can configure Apache like this:</p> <div class="listingblock"> <div class="content"> <pre><VirtualHost *:80> + ServerName git.example.org + DocumentRoot /pub/git + SetEnv GITWEB_CONFIG /etc/gitweb.conf + + # turning on mod rewrite + RewriteEngine on + + # make the front page an internal rewrite to the gitweb script + RewriteRule ^/$ /cgi-bin/gitweb.cgi + + # make access for "dumb clients" work + RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ \ + /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT] +</VirtualHost></pre> </div> </div> <p>The above configuration expects your public repositories to live under <code>/pub/git</code> and will serve them as <code>http://git.domain.org/dir-under-pub-git</code>, both as clonable Git URL and as browsable gitweb interface. If you then start your <a href="git-daemon">git-daemon[1]</a> with <code>--base-path=/pub/git --export-all</code> then you can even use the <code>git://</code> URL with exactly the same path.</p> <p>Setting the environment variable <code>GITWEB_CONFIG</code> will tell gitweb to use the named file (i.e. in this example <code>/etc/gitweb.conf</code>) as a configuration for gitweb. You don’t really need it in above example; it is required only if your configuration file is in different place than built-in (during compiling gitweb) <code>gitweb_config.perl</code> or <code>/etc/gitweb.conf</code>. See <a href="gitweb.conf">gitweb.conf[5]</a> for details, especially information about precedence rules.</p> <p>If you use the rewrite rules from the example you <strong>might</strong> also need something like the following in your gitweb configuration file (<code>/etc/gitweb.conf</code> following example):</p> <div class="listingblock"> <div class="content"> <pre>@stylesheets = ("/some/absolute/path/gitweb.css"); +$my_uri = "/"; +$home_link = "/"; +$per_request_config = 1;</pre> </div> </div> <p>Nowadays though gitweb should create HTML base tag when needed (to set base URI for relative links), so it should work automatically.</p> </div> <div class="sect2"> <h3 id="_webserver_configuration_with_multiple_projects_root"> +Webserver configuration with multiple projects' root</h3> <p>If you want to use gitweb with several project roots you can edit your Apache virtual host and gitweb configuration files in the following way.</p> <p>The virtual host configuration (in Apache configuration file) should look like this:</p> <div class="listingblock"> <div class="content"> <pre><VirtualHost *:80> + ServerName git.example.org + DocumentRoot /pub/git + SetEnv GITWEB_CONFIG /etc/gitweb.conf + + # turning on mod rewrite + RewriteEngine on + + # make the front page an internal rewrite to the gitweb script + RewriteRule ^/$ /cgi-bin/gitweb.cgi [QSA,L,PT] + + # look for a public_git directory in unix users' home + # http://git.example.org/~<user>/ + RewriteRule ^/\~([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \ + [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT] + + # http://git.example.org/+<user>/ + #RewriteRule ^/\+([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \ + [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT] + + # http://git.example.org/user/<user>/ + #RewriteRule ^/user/([^\/]+)/(gitweb.cgi)?$ /cgi-bin/gitweb.cgi \ + [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT] + + # defined list of project roots + RewriteRule ^/scm(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \ + [QSA,E=GITWEB_PROJECTROOT:/pub/scm/,L,PT] + RewriteRule ^/var(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \ + [QSA,E=GITWEB_PROJECTROOT:/var/git/,L,PT] + + # make access for "dumb clients" work + RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ \ + /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT] +</VirtualHost></pre> </div> </div> <p>Here actual project root is passed to gitweb via <code>GITWEB_PROJECT_ROOT</code> environment variable from a web server, so you need to put the following line in gitweb configuration file (<code>/etc/gitweb.conf</code> in above example):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$projectroot = $ENV{'GITWEB_PROJECTROOT'} || "/pub/git";</pre> </div> </div> <p><strong>Note</strong> that this requires to be set for each request, so either <code>$per_request_config</code> must be false, or the above must be put in code referenced by <code>$per_request_config</code>;</p> <p>These configurations enable two things. First, each unix user (<code><user></code>) of the server will be able to browse through gitweb Git repositories found in <code>~/public_git/</code> with the following url:</p> <div class="literalblock"> <div class="content"> <pre>http://git.example.org/~<user>/</pre> </div> </div> <p>If you do not want this feature on your server just remove the second rewrite rule.</p> <p>If you already use <code>mod_userdir</code> in your virtual host or you don’t want to use the '~' as first character, just comment or remove the second rewrite rule, and uncomment one of the following according to what you want.</p> <p>Second, repositories found in <code>/pub/scm/</code> and <code>/var/git/</code> will be accessible through <code>http://git.example.org/scm/</code> and <code>http://git.example.org/var/</code>. You can add as many project roots as you want by adding rewrite rules like the third and the fourth.</p> </div> <div class="sect2"> <h3 id="_path_info_usage"> +PATH_INFO usage</h3> <p>If you enable PATH_INFO usage in gitweb by putting</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$feature{'pathinfo'}{'default'} = [1];</pre> </div> </div> <p>in your gitweb configuration file, it is possible to set up your server so that it consumes and produces URLs in the form</p> <div class="literalblock"> <div class="content"> <pre>http://git.example.com/project.git/shortlog/sometag</pre> </div> </div> <p>i.e. without <code>gitweb.cgi</code> part, by using a configuration such as the following. This configuration assumes that <code>/var/www/gitweb</code> is the DocumentRoot of your webserver, contains the gitweb.cgi script and complementary static files (stylesheet, favicon, JavaScript):</p> <div class="listingblock"> <div class="content"> <pre><VirtualHost *:80> + ServerAlias git.example.com + + DocumentRoot /var/www/gitweb + + <Directory /var/www/gitweb> + Options ExecCGI + AddHandler cgi-script cgi + + DirectoryIndex gitweb.cgi + + RewriteEngine On + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^.* /gitweb.cgi/$0 [L,PT] + </Directory> +</VirtualHost></pre> </div> </div> <p>The rewrite rule guarantees that existing static files will be properly served, whereas any other URL will be passed to gitweb as PATH_INFO parameter.</p> <p><strong>Notice</strong> that in this case you don’t need special settings for <code>@stylesheets</code>, <code>$my_uri</code> and <code>$home_link</code>, but you lose "dumb client" access to your project .git dirs (described in "Single URL for gitweb and for fetching" section). A possible workaround for the latter is the following: in your project root dir (e.g. <code>/pub/git</code>) have the projects named <strong>without</strong> a .git extension (e.g. <code>/pub/git/project</code> instead of <code>/pub/git/project.git</code>) and configure Apache as follows:</p> <div class="listingblock"> <div class="content"> <pre><VirtualHost *:80> + ServerAlias git.example.com + + DocumentRoot /var/www/gitweb + + AliasMatch ^(/.*?)(\.git)(/.*)?$ /pub/git$1$3 + <Directory /var/www/gitweb> + Options ExecCGI + AddHandler cgi-script cgi + + DirectoryIndex gitweb.cgi + + RewriteEngine On + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^.* /gitweb.cgi/$0 [L,PT] + </Directory> +</VirtualHost></pre> </div> </div> <p>The additional AliasMatch makes it so that</p> <div class="literalblock"> <div class="content"> <pre>http://git.example.com/project.git</pre> </div> </div> <p>will give raw access to the project’s Git dir (so that the project can be cloned), while</p> <div class="literalblock"> <div class="content"> <pre>http://git.example.com/project</pre> </div> </div> <p>will provide human-friendly gitweb access.</p> <p>This solution is not 100% bulletproof, in the sense that if some project has a named ref (branch, tag) starting with <code>git/</code>, then paths such as</p> <div class="literalblock"> <div class="content"> <pre>http://git.example.com/project/command/abranch..git/abranch</pre> </div> </div> <p>will fail with a 404 error.</p> </div> </div> <h2 id="_bugs">Bugs</h2> <div class="sectionbody"> <p>Please report any bugs or feature requests to <a href="mailto:git@vger.kernel.org">git@vger.kernel.org</a>, putting "gitweb" in the subject of email.</p> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gitweb.conf">gitweb.conf[5]</a>, <a href="git-instaweb">git-instaweb[1]</a></p> <p><code>gitweb/README</code>, <code>gitweb/INSTALL</code></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitweb" class="_attribution-link">https://git-scm.com/docs/gitweb</a> + </p> +</div> diff --git a/devdocs/git/gitworkflows.html b/devdocs/git/gitworkflows.html new file mode 100644 index 00000000..d7292646 --- /dev/null +++ b/devdocs/git/gitworkflows.html @@ -0,0 +1,17 @@ +<h1>gitworkflows</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>gitworkflows - An overview of recommended workflows with Git</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git *</pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>This document attempts to write down and motivate some of the workflow elements used for <code>git.git</code> itself. Many ideas apply in general, though the full workflow is rarely required for smaller projects with fewer people involved.</p> <p>We formulate a set of <code>rules</code> for quick reference, while the prose tries to motivate each of them. Do not always take them literally; you should value good reasons for your actions higher than manpages such as this one.</p> </div> <h2 id="_separate_changes">Separate changes</h2> <div class="sectionbody"> <p>As a general rule, you should try to split your changes into small logical steps, and commit each of them. They should be consistent, working independently of any later commits, pass the test suite, etc. This makes the review process much easier, and the history much more useful for later inspection and analysis, for example with <a href="git-blame">git-blame[1]</a> and <a href="git-bisect">git-bisect[1]</a>.</p> <p>To achieve this, try to split your work into small steps from the very beginning. It is always easier to squash a few commits together than to split one big commit into several. Don’t be afraid of making too small or imperfect steps along the way. You can always go back later and edit the commits with <code>git rebase --interactive</code> before you publish them. You can use <code>git stash push --keep-index</code> to run the test suite independent of other uncommitted changes; see the EXAMPLES section of <a href="git-stash">git-stash[1]</a>.</p> </div> <h2 id="_managing_branches">Managing branches</h2> <div class="sectionbody"> <p>There are two main tools that can be used to include changes from one branch on another: <a href="git-merge">git-merge[1]</a> and <a href="git-cherry-pick">git-cherry-pick[1]</a>.</p> <p>Merges have many advantages, so we try to solve as many problems as possible with merges alone. Cherry-picking is still occasionally useful; see "Merging upwards" below for an example.</p> <p>Most importantly, merging works at the branch level, while cherry-picking works at the commit level. This means that a merge can carry over the changes from 1, 10, or 1000 commits with equal ease, which in turn means the workflow scales much better to a large number of contributors (and contributions). Merges are also easier to understand because a merge commit is a "promise" that all changes from all its parents are now included.</p> <p>There is a tradeoff of course: merges require a more careful branch management. The following subsections discuss the important points.</p> <div class="sect2"> <h3 id="_graduation"> +Graduation</h3> <p>As a given feature goes from experimental to stable, it also "graduates" between the corresponding branches of the software. <code>git.git</code> uses the following <code>integration branches</code>:</p> <div class="ulist"> <ul> <li> <p><code>maint</code> tracks the commits that should go into the next "maintenance release", i.e., update of the last released stable version;</p> </li> <li> <p><code>master</code> tracks the commits that should go into the next release;</p> </li> <li> <p><code>next</code> is intended as a testing branch for topics being tested for stability for master.</p> </li> </ul> </div> <p>There is a fourth official branch that is used slightly differently:</p> <div class="ulist"> <ul> <li> <p><code>seen</code> (patches seen by the maintainer) is an integration branch for things that are not quite ready for inclusion yet (see "Integration Branches" below).</p> </li> </ul> </div> <p>Each of the four branches is usually a direct descendant of the one above it.</p> <p>Conceptually, the feature enters at an unstable branch (usually <code>next</code> or <code>seen</code>), and "graduates" to <code>master</code> for the next release once it is considered stable enough.</p> </div> <div class="sect2"> <h3 id="_merging_upwards"> +Merging upwards</h3> <p>The "downwards graduation" discussed above cannot be done by actually merging downwards, however, since that would merge <code>all</code> changes on the unstable branch into the stable one. Hence the following:</p> <div class="exampleblock"> <div class="title">Rule: Merge upwards</div> <div class="content"> <p>Always commit your fixes to the oldest supported branch that requires them. Then (periodically) merge the integration branches upwards into each other.</p> </div> </div> <p>This gives a very controlled flow of fixes. If you notice that you have applied a fix to e.g. <code>master</code> that is also required in <code>maint</code>, you will need to cherry-pick it (using <a href="git-cherry-pick">git-cherry-pick[1]</a>) downwards. This will happen a few times and is nothing to worry about unless you do it very frequently.</p> </div> <div class="sect2"> <h3 id="_topic_branches"> +Topic branches</h3> <p>Any nontrivial feature will require several patches to implement, and may get extra bugfixes or improvements during its lifetime.</p> <p>Committing everything directly on the integration branches leads to many problems: Bad commits cannot be undone, so they must be reverted one by one, which creates confusing histories and further error potential when you forget to revert part of a group of changes. Working in parallel mixes up the changes, creating further confusion.</p> <p>Use of "topic branches" solves these problems. The name is pretty self explanatory, with a caveat that comes from the "merge upwards" rule above:</p> <div class="exampleblock"> <div class="title">Rule: Topic branches</div> <div class="content"> <p>Make a side branch for every topic (feature, bugfix, …). Fork it off at the oldest integration branch that you will eventually want to merge it into.</p> </div> </div> <p>Many things can then be done very naturally:</p> <div class="ulist"> <ul> <li> <p>To get the feature/bugfix into an integration branch, simply merge it. If the topic has evolved further in the meantime, merge again. (Note that you do not necessarily have to merge it to the oldest integration branch first. For example, you can first merge a bugfix to <code>next</code>, give it some testing time, and merge to <code>maint</code> when you know it is stable.)</p> </li> <li> <p>If you find you need new features from the branch <code>other</code> to continue working on your topic, merge <code>other</code> to <code>topic</code>. (However, do not do this "just habitually", see below.)</p> </li> <li> <p>If you find you forked off the wrong branch and want to move it "back in time", use <a href="git-rebase">git-rebase[1]</a>.</p> </li> </ul> </div> <p>Note that the last point clashes with the other two: a topic that has been merged elsewhere should not be rebased. See the section on RECOVERING FROM UPSTREAM REBASE in <a href="git-rebase">git-rebase[1]</a>.</p> <p>We should point out that "habitually" (regularly for no real reason) merging an integration branch into your topics — and by extension, merging anything upstream into anything downstream on a regular basis — is frowned upon:</p> <div class="exampleblock"> <div class="title">Rule: Merge to downstream only at well-defined points</div> <div class="content"> <p>Do not merge to downstream except with a good reason: upstream API changes affect your branch; your branch no longer merges to upstream cleanly; etc.</p> </div> </div> <p>Otherwise, the topic that was merged to suddenly contains more than a single (well-separated) change. The many resulting small merges will greatly clutter up history. Anyone who later investigates the history of a file will have to find out whether that merge affected the topic in development. An upstream might even inadvertently be merged into a "more stable" branch. And so on.</p> </div> <div class="sect2"> <h3 id="_throw_away_integration"> +Throw-away integration</h3> <p>If you followed the last paragraph, you will now have many small topic branches, and occasionally wonder how they interact. Perhaps the result of merging them does not even work? But on the other hand, we want to avoid merging them anywhere "stable" because such merges cannot easily be undone.</p> <p>The solution, of course, is to make a merge that we can undo: merge into a throw-away branch.</p> <div class="exampleblock"> <div class="title">Rule: Throw-away integration branches</div> <div class="content"> <p>To test the interaction of several topics, merge them into a throw-away branch. You must never base any work on such a branch!</p> </div> </div> <p>If you make it (very) clear that this branch is going to be deleted right after the testing, you can even publish this branch, for example to give the testers a chance to work with it, or other developers a chance to see if their in-progress work will be compatible. <code>git.git</code> has such an official throw-away integration branch called <code>seen</code>.</p> </div> <div class="sect2"> <h3 id="_branch_management_for_a_release"> +Branch management for a release</h3> <p>Assuming you are using the merge approach discussed above, when you are releasing your project you will need to do some additional branch management work.</p> <p>A feature release is created from the <code>master</code> branch, since <code>master</code> tracks the commits that should go into the next feature release.</p> <p>The <code>master</code> branch is supposed to be a superset of <code>maint</code>. If this condition does not hold, then <code>maint</code> contains some commits that are not included on <code>master</code>. The fixes represented by those commits will therefore not be included in your feature release.</p> <p>To verify that <code>master</code> is indeed a superset of <code>maint</code>, use git log:</p> <div class="exampleblock"> <div class="title">Recipe: Verify <em>master</em> is a superset of <em>maint</em> +</div> <div class="content"> <p><code>git log master..maint</code></p> </div> </div> <p>This command should not list any commits. Otherwise, check out <code>master</code> and merge <code>maint</code> into it.</p> <p>Now you can proceed with the creation of the feature release. Apply a tag to the tip of <code>master</code> indicating the release version:</p> <div class="exampleblock"> <div class="title">Recipe: Release tagging</div> <div class="content"> <p><code>git tag -s -m "Git X.Y.Z" vX.Y.Z master</code></p> </div> </div> <p>You need to push the new tag to a public Git server (see "DISTRIBUTED WORKFLOWS" below). This makes the tag available to others tracking your project. The push could also trigger a post-update hook to perform release-related items such as building release tarballs and preformatted documentation pages.</p> <p>Similarly, for a maintenance release, <code>maint</code> is tracking the commits to be released. Therefore, in the steps above simply tag and push <code>maint</code> rather than <code>master</code>.</p> </div> <div class="sect2"> <h3 id="_maintenance_branch_management_after_a_feature_release"> +Maintenance branch management after a feature release</h3> <p>After a feature release, you need to manage your maintenance branches.</p> <p>First, if you wish to continue to release maintenance fixes for the feature release made before the recent one, then you must create another branch to track commits for that previous release.</p> <p>To do this, the current maintenance branch is copied to another branch named with the previous release version number (e.g. maint-X.Y.(Z-1) where X.Y.Z is the current release).</p> <div class="exampleblock"> <div class="title">Recipe: Copy maint</div> <div class="content"> <p><code>git branch maint-X.Y.(Z-1) maint</code></p> </div> </div> <p>The <code>maint</code> branch should now be fast-forwarded to the newly released code so that maintenance fixes can be tracked for the current release:</p> <div class="exampleblock"> <div class="title">Recipe: Update maint to new release</div> <div class="content"> <div class="ulist"> <ul> <li> <p><code>git checkout maint</code></p> </li> <li> <p><code>git merge --ff-only master</code></p> </li> </ul> </div> </div> </div> <p>If the merge fails because it is not a fast-forward, then it is possible some fixes on <code>maint</code> were missed in the feature release. This will not happen if the content of the branches was verified as described in the previous section.</p> </div> <div class="sect2"> <h3 id="_branch_management_for_next_and_seen_after_a_feature_release"> +Branch management for next and seen after a feature release</h3> <p>After a feature release, the integration branch <code>next</code> may optionally be rewound and rebuilt from the tip of <code>master</code> using the surviving topics on <code>next</code>:</p> <div class="exampleblock"> <div class="title">Recipe: Rewind and rebuild next</div> <div class="content"> <div class="ulist"> <ul> <li> <p><code>git switch -C next master</code></p> </li> <li> <p><code>git merge ai/topic_in_next1</code></p> </li> <li> <p><code>git merge ai/topic_in_next2</code></p> </li> <li> <p>…</p> </li> </ul> </div> </div> </div> <p>The advantage of doing this is that the history of <code>next</code> will be clean. For example, some topics merged into <code>next</code> may have initially looked promising, but were later found to be undesirable or premature. In such a case, the topic is reverted out of <code>next</code> but the fact remains in the history that it was once merged and reverted. By recreating <code>next</code>, you give another incarnation of such topics a clean slate to retry, and a feature release is a good point in history to do so.</p> <p>If you do this, then you should make a public announcement indicating that <code>next</code> was rewound and rebuilt.</p> <p>The same rewind and rebuild process may be followed for <code>seen</code>. A public announcement is not necessary since <code>seen</code> is a throw-away branch, as described above.</p> </div> </div> <h2 id="_distributed_workflows">Distributed workflows</h2> <div class="sectionbody"> <p>After the last section, you should know how to manage topics. In general, you will not be the only person working on the project, so you will have to share your work.</p> <p>Roughly speaking, there are two important workflows: merge and patch. The important difference is that the merge workflow can propagate full history, including merges, while patches cannot. Both workflows can be used in parallel: in <code>git.git</code>, only subsystem maintainers use the merge workflow, while everyone else sends patches.</p> <p>Note that the maintainer(s) may impose restrictions, such as "Signed-off-by" requirements, that all commits/patches submitted for inclusion must adhere to. Consult your project’s documentation for more information.</p> <div class="sect2"> <h3 id="_merge_workflow"> +Merge workflow</h3> <p>The merge workflow works by copying branches between upstream and downstream. Upstream can merge contributions into the official history; downstream base their work on the official history.</p> <p>There are three main tools that can be used for this:</p> <div class="ulist"> <ul> <li> <p><a href="git-push">git-push[1]</a> copies your branches to a remote repository, usually to one that can be read by all involved parties;</p> </li> <li> <p><a href="git-fetch">git-fetch[1]</a> that copies remote branches to your repository; and</p> </li> <li> <p><a href="git-pull">git-pull[1]</a> that does fetch and merge in one go.</p> </li> </ul> </div> <p>Note the last point. Do <code>not</code> use <code>git pull</code> unless you actually want to merge the remote branch.</p> <p>Getting changes out is easy:</p> <div class="exampleblock"> <div class="title">Recipe: Push/pull: Publishing branches/topics</div> <div class="content"> <p><code>git push <remote> <branch></code> and tell everyone where they can fetch from.</p> </div> </div> <p>You will still have to tell people by other means, such as mail. (Git provides the <a href="git-request-pull">git-request-pull[1]</a> to send preformatted pull requests to upstream maintainers to simplify this task.)</p> <p>If you just want to get the newest copies of the integration branches, staying up to date is easy too:</p> <div class="exampleblock"> <div class="title">Recipe: Push/pull: Staying up to date</div> <div class="content"> <p>Use <code>git fetch <remote></code> or <code>git remote update</code> to stay up to date.</p> </div> </div> <p>Then simply fork your topic branches from the stable remotes as explained earlier.</p> <p>If you are a maintainer and would like to merge other people’s topic branches to the integration branches, they will typically send a request to do so by mail. Such a request looks like</p> <div class="listingblock"> <div class="content"> <pre>Please pull from + <URL> <branch></pre> </div> </div> <p>In that case, <code>git pull</code> can do the fetch and merge in one go, as follows.</p> <div class="exampleblock"> <div class="title">Recipe: Push/pull: Merging remote topics</div> <div class="content"> <p><code>git pull <URL> <branch></code></p> </div> </div> <p>Occasionally, the maintainer may get merge conflicts when they try to pull changes from downstream. In this case, they can ask downstream to do the merge and resolve the conflicts themselves (perhaps they will know better how to resolve them). It is one of the rare cases where downstream <code>should</code> merge from upstream.</p> </div> <div class="sect2"> <h3 id="_patch_workflow"> +Patch workflow</h3> <p>If you are a contributor that sends changes upstream in the form of emails, you should use topic branches as usual (see above). Then use <a href="git-format-patch">git-format-patch[1]</a> to generate the corresponding emails (highly recommended over manually formatting them because it makes the maintainer’s life easier).</p> <div class="exampleblock"> <div class="title">Recipe: format-patch/am: Publishing branches/topics</div> <div class="content"> <div class="ulist"> <ul> <li> <p><code>git format-patch -M upstream..topic</code> to turn them into preformatted patch files</p> </li> <li> <p><code>git send-email --to=<recipient> <patches></code></p> </li> </ul> </div> </div> </div> <p>See the <a href="git-format-patch">git-format-patch[1]</a> and <a href="git-send-email">git-send-email[1]</a> manpages for further usage notes.</p> <p>If the maintainer tells you that your patch no longer applies to the current upstream, you will have to rebase your topic (you cannot use a merge because you cannot format-patch merges):</p> <div class="exampleblock"> <div class="title">Recipe: format-patch/am: Keeping topics up to date</div> <div class="content"> <p><code>git pull --rebase <URL> <branch></code></p> </div> </div> <p>You can then fix the conflicts during the rebase. Presumably you have not published your topic other than by mail, so rebasing it is not a problem.</p> <p>If you receive such a patch series (as maintainer, or perhaps as a reader of the mailing list it was sent to), save the mails to files, create a new topic branch and use <code>git am</code> to import the commits:</p> <div class="exampleblock"> <div class="title">Recipe: format-patch/am: Importing patches</div> <div class="content"> <p><code>git am < patch</code></p> </div> </div> <p>One feature worth pointing out is the three-way merge, which can help if you get conflicts: <code>git am -3</code> will use index information contained in patches to figure out the merge base. See <a href="git-am">git-am[1]</a> for other options.</p> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="gittutorial">gittutorial[7]</a>, <a href="git-push">git-push[1]</a>, <a href="git-pull">git-pull[1]</a>, <a href="git-merge">git-merge[1]</a>, <a href="git-rebase">git-rebase[1]</a>, <a href="git-format-patch">git-format-patch[1]</a>, <a href="git-send-email">git-send-email[1]</a>, <a href="git-am">git-am[1]</a></p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/gitworkflows" class="_attribution-link">https://git-scm.com/docs/gitworkflows</a> + </p> +</div> diff --git a/devdocs/git/howto-index.html b/devdocs/git/howto-index.html new file mode 100644 index 00000000..476eb15f --- /dev/null +++ b/devdocs/git/howto-index.html @@ -0,0 +1,6 @@ +<h1>Reference</h1> <p> Quick reference guides: <a href="https://github.github.com/training-kit/">GitHub Cheat Sheet</a> | <a href="https://ndpsoftware.com/git-cheatsheet.html">Visual Git Cheat Sheet</a> </p> <a href="git#_git_commands">Complete list of all commands</a> <div class="two-column"> <div class="column-left"> <h3 class="setup">Setup and Config</h3> <ul class="unstyled"> <li><a href="git">git</a></li> <li><a href="git-config">config</a></li> <li><a href="git-help">help</a></li> <li><a href="git-bugreport">bugreport</a></li> <a href="https://git-scm.com/doc/credential-helpers">Credential helpers</a> </ul> <h3 class="projects">Getting and Creating Projects</h3> <ul class="unstyled"> <li><a href="git-init">init</a></li> <li><a href="git-clone">clone</a></li> </ul> <h3 class="snapshotting">Basic Snapshotting</h3> <ul class="unstyled"> <li><a href="git-add">add</a></li> <li><a href="git-status">status</a></li> <li><a href="git-diff">diff</a></li> <li><a href="git-commit">commit</a></li> <li><a href="git-notes">notes</a></li> <li><a href="git-restore">restore</a></li> <li><a href="git-reset">reset</a></li> <li><a href="git-rm">rm</a></li> <li><a href="git-mv">mv</a></li> </ul> <h3 class="branching">Branching and Merging</h3> <ul class="unstyled"> <li><a href="git-branch">branch</a></li> <li><a href="git-checkout">checkout</a></li> <li><a href="git-switch">switch</a></li> <li><a href="git-merge">merge</a></li> <li><a href="git-mergetool">mergetool</a></li> <li><a href="git-log">log</a></li> <li><a href="git-stash">stash</a></li> <li><a href="git-tag">tag</a></li> <li><a href="git-worktree">worktree</a></li> </ul> <h3 class="sharing">Sharing and Updating Projects</h3> <ul class="unstyled"> <li><a href="git-fetch">fetch</a></li> <li><a href="git-pull">pull</a></li> <li><a href="git-push">push</a></li> <li><a href="git-remote">remote</a></li> <li><a href="git-submodule">submodule</a></li> </ul> <h3 class="inspection">Inspection and Comparison</h3> <ul class="unstyled"> <li><a href="git-show">show</a></li> <li><a href="git-log">log</a></li> <li><a href="git-diff">diff</a></li> <li><a href="git-difftool">difftool</a></li> <li><a href="git-range-diff">range-diff</a></li> <li><a href="git-shortlog">shortlog</a></li> <li><a href="git-describe">describe</a></li> </ul> <h3 class="patching">Patching</h3> <ul class="unstyled"> <li><a href="git-apply">apply</a></li> <li><a href="git-cherry-pick">cherry-pick</a></li> <li><a href="git-diff">diff</a></li> <li><a href="git-rebase">rebase</a></li> <li><a href="git-revert">revert</a></li> </ul> <h3 class="debugging">Debugging</h3> <ul class="unstyled"> <li><a href="git-bisect">bisect</a></li> <li><a href="git-blame">blame</a></li> <li><a href="git-grep">grep</a></li> </ul> </div> <div class="column-right"> <h3 class="guides">Guides</h3> <ul class="unstyled"> <li><a href="gitattributes">gitattributes</a></li> <li><a href="gitcli">Command-line interface conventions</a></li> <li><a href="giteveryday">Everyday Git</a></li> <li><a href="gitfaq">Frequently Asked Questions (FAQ)</a></li> <li><a href="gitglossary">Glossary</a></li> <li><a href="githooks">Hooks</a></li> <li><a href="gitignore">gitignore</a></li> <li><a href="gitmodules">gitmodules</a></li> <li><a href="gitrevisions">Revisions</a></li> <li><a href="gitsubmodules">Submodules</a></li> <li><a href="gittutorial">Tutorial</a></li> <li><a href="gitworkflows">Workflows</a></li> <li><a href="git#_guides">All guides...</a></li> </ul> <h3 class="email">Email</h3> <ul class="unstyled"> <li><a href="git-am">am</a></li> <li><a href="git-apply">apply</a></li> <li><a href="git-format-patch">format-patch</a></li> <li><a href="git-send-email">send-email</a></li> <li><a href="git-request-pull">request-pull</a></li> </ul> <h3 class="external">External Systems</h3> <ul class="unstyled"> <li><a href="git-svn">svn</a></li> <li><a href="git-fast-import">fast-import</a></li> </ul> <h3 class="admin">Administration</h3> <ul class="unstyled"> <li><a href="git-clean">clean</a></li> <li><a href="git-gc">gc</a></li> <li><a href="git-fsck">fsck</a></li> <li><a href="git-reflog">reflog</a></li> <li><a href="git-filter-branch">filter-branch</a></li> <li><a href="git-instaweb">instaweb</a></li> <li><a href="git-archive">archive</a></li> <li><a href="git-bundle">bundle</a></li> </ul> <h3 class="server-admin">Server Admin</h3> <ul class="unstyled"> <li><a href="git-daemon">daemon</a></li> <li><a href="git-update-server-info">update-server-info</a></li> </ul> <h3 class="plumbing">Plumbing Commands</h3> <ul class="unstyled"> <li><a href="git-cat-file">cat-file</a></li> <li><a href="git-check-ignore">check-ignore</a></li> <li><a href="git-checkout-index">checkout-index</a></li> <li><a href="git-commit-tree">commit-tree</a></li> <li><a href="git-count-objects">count-objects</a></li> <li><a href="git-diff-index">diff-index</a></li> <li><a href="git-for-each-ref">for-each-ref</a></li> <li><a href="git-hash-object">hash-object</a></li> <li><a href="git-ls-files">ls-files</a></li> <li><a href="git-ls-tree">ls-tree</a></li> <li><a href="git-merge-base">merge-base</a></li> <li><a href="git-read-tree">read-tree</a></li> <li><a href="git-rev-list">rev-list</a></li> <li><a href="git-rev-parse">rev-parse</a></li> <li><a href="git-show-ref">show-ref</a></li> <li><a href="git-symbolic-ref">symbolic-ref</a></li> <li><a href="git-update-index">update-index</a></li> <li><a href="git-update-ref">update-ref</a></li> <li><a href="git-verify-pack">verify-pack</a></li> <li><a href="git-write-tree">write-tree</a></li> </ul> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/howto-index" class="_attribution-link">https://git-scm.com/docs/howto-index</a> + </p> +</div> diff --git a/devdocs/git/index b/devdocs/git/index new file mode 100644 index 00000000..aa3b306c --- /dev/null +++ b/devdocs/git/index @@ -0,0 +1 @@ +((pages . ["index" "git-add" "git-commit" "git-config" "git-restore" "git-reset" "git-rm" "git-switch" "git" "git-help" "git-bugreport" "git-init" "git-clone" "git-status" "git-diff" "git-notes" "git-mv" "git-branch" "git-checkout" "git-merge" "git-mergetool" "git-log" "git-stash" "git-tag" "git-worktree" "git-fetch" "git-pull" "git-push" "git-remote" "git-describe" "git-apply" "git-cherry-pick" "git-rebase" "git-revert" "git-bisect" "gitattributes" "git-submodule" "git-show" "git-difftool" "git-range-diff" "git-shortlog" "git-blame" "git-grep" "gitcli" "giteveryday" "gitglossary" "gitfaq" "githooks" "gitignore" "gitmodules" "gitrevisions" "gitsubmodules" "gittutorial" "gitworkflows" "git-am" "git-format-patch" "git-send-email" "git-request-pull" "git-clean" "git-gc" "git-reflog" "git-filter-branch" "git-instaweb" "git-svn" "git-fast-import" "git-fsck" "git-bundle" "git-daemon" "git-update-server-info" "git-checkout-index" "git-commit-tree" "git-count-objects" "git-ls-tree" "git-merge-base" "git-rev-list" "git-archive" "git-cat-file" "git-check-ignore" "git-diff-index" "git-for-each-ref" "git-hash-object" "git-ls-files" "git-read-tree" "git-show-ref" "git-symbolic-ref" "git-rev-parse" "git-update-ref" "git-write-tree" "git-interpret-trailers" "git-var" "git-fsmonitor--daemon" "git-update-index" "git-verify-pack" "git-sparse-checkout" "git-index-pack" "git-unpack-objects" "git-commit-graph" "gitcredentials" "git-replace" "git-multi-pack-index" "git-mailsplit" "git-web--browse" "bundle-uri" "git-show-branch" "git-fetch-pack" "gitrepository-layout" "git-diff-files" "git-whatchanged" "git-repack" "git-rerere" "git-cvsserver" "gitweb" "gitweb.conf" "gitformat-signature" "git-gui" "gitk" "git-mailinfo" "gitprotocol-v2" "gitnamespaces" "git-version" "git-pack-objects" "gitformat-pack" "git-receive-pack" "git-credential" "git-upload-archive" "user-manual" "scalar" "git-pack-refs" "git-prune" "git-citool" "git-maintenance" "git-fast-export" "git-annotate" "git-diagnose" "git-merge-tree" "git-verify-commit" "git-verify-tag" "git-archimport" "git-cvsexportcommit" "git-cvsimport" "git-mktree" "git-cherry" "git-p4" "git-imap-send" "git-merge-file" "git-mktag" "git-quiltimport" "git-merge-index" "git-prune-packed" "git-name-rev" "git-pack-redundant" "git-http-fetch" "git-shell" "git-http-push" "git-unpack-file" "git-upload-pack" "git-for-each-repo" "git-ls-remote" "git-show-index" "git-send-pack" "git-diff-tree" "git-get-tar-commit-id" "git-http-backend" "git-check-attr" "git-check-ref-format" "git-check-mailmap" "git-column" "git-credential-cache" "git-credential-store" "git-fmt-merge-msg" "git-patch-id" "git-sh-i18n" "gitcvs-migration" "git-hook" "git-merge-one-file" "git-sh-setup" "git-stripspace" "gitcore-tutorial" "gitdiffcore" "gitremote-helpers" "gittutorial-2" "gitformat-commit-graph" "gitformat-chunk" "gitmailmap" "gitformat-bundle" "gitprotocol-capabilities" "gitprotocol-common" "gitprotocol-pack" "api-trace2" "gitformat-index" "gitprotocol-http" "howto-index" "api-index" "api-simple-ipc" "git-remote-ext" "git-remote-fd" "partial-clone" "multi-pack-index" "git-sh-i18n--envsubst" "git-bisect-lk2009"]) (entries . [((name . "api index") (path . "api-index") (type . "Miscellaneous")) ((name . "api simple-ipc") (path . "api-simple-ipc") (type . "Miscellaneous")) ((name . "api trace2") (path . "api-trace2") (type . "Miscellaneous")) ((name . "bundle uri") (path . "bundle-uri") (type . "Miscellaneous")) ((name . "git") (path . "git") (type . "Setup and Config")) ((name . "git add") (path . "git-add") (type . "Basic Snapshotting")) ((name . "git am") (path . "git-am") (type . "Email")) ((name . "git annotate") (path . "git-annotate") (type . "Git")) ((name . "git apply") (path . "git-apply") (type . "Patching")) ((name . "git archimport") (path . "git-archimport") (type . "Git")) ((name . "git archive") (path . "git-archive") (type . "Administration")) ((name . "git bisect") (path . "git-bisect") (type . "Debugging")) ((name . "git bisect-lk2009") (path . "git-bisect-lk2009") (type . "Git")) ((name . "git blame") (path . "git-blame") (type . "Debugging")) ((name . "git branch") (path . "git-branch") (type . "Branching and Merging")) ((name . "git bugreport") (path . "git-bugreport") (type . "Setup and Config")) ((name . "git bundle") (path . "git-bundle") (type . "Administration")) ((name . "git cat-file") (path . "git-cat-file") (type . "Plumbing Commands")) ((name . "git check-attr") (path . "git-check-attr") (type . "Git")) ((name . "git check-ignore") (path . "git-check-ignore") (type . "Plumbing Commands")) ((name . "git check-mailmap") (path . "git-check-mailmap") (type . "Git")) ((name . "git check-ref-format") (path . "git-check-ref-format") (type . "Git")) ((name . "git checkout") (path . "git-checkout") (type . "Branching and Merging")) ((name . "git checkout-index") (path . "git-checkout-index") (type . "Plumbing Commands")) ((name . "git cherry") (path . "git-cherry") (type . "Git")) ((name . "git cherry-pick") (path . "git-cherry-pick") (type . "Patching")) ((name . "git citool") (path . "git-citool") (type . "Git")) ((name . "git clean") (path . "git-clean") (type . "Administration")) ((name . "git clone") (path . "git-clone") (type . "Getting and Creating Projects")) ((name . "git column") (path . "git-column") (type . "Git")) ((name . "git commit") (path . "git-commit") (type . "Basic Snapshotting")) ((name . "git commit-graph") (path . "git-commit-graph") (type . "Git")) ((name . "git commit-tree") (path . "git-commit-tree") (type . "Plumbing Commands")) ((name . "git config") (path . "git-config") (type . "Setup and Config")) ((name . "git count-objects") (path . "git-count-objects") (type . "Plumbing Commands")) ((name . "git credential") (path . "git-credential") (type . "Git")) ((name . "git credential-cache") (path . "git-credential-cache") (type . "Git")) ((name . "git credential-store") (path . "git-credential-store") (type . "Git")) ((name . "git cvsexportcommit") (path . "git-cvsexportcommit") (type . "Git")) ((name . "git cvsimport") (path . "git-cvsimport") (type . "Git")) ((name . "git cvsserver") (path . "git-cvsserver") (type . "Git")) ((name . "git daemon") (path . "git-daemon") (type . "Server Admin")) ((name . "git describe") (path . "git-describe") (type . "Inspection and Comparison")) ((name . "git diagnose") (path . "git-diagnose") (type . "Git")) ((name . "git diff") (path . "git-diff") (type . "Basic Snapshotting")) ((name . "git diff-files") (path . "git-diff-files") (type . "Git")) ((name . "git diff-index") (path . "git-diff-index") (type . "Plumbing Commands")) ((name . "git diff-tree") (path . "git-diff-tree") (type . "Git")) ((name . "git difftool") (path . "git-difftool") (type . "Inspection and Comparison")) ((name . "git fast-export") (path . "git-fast-export") (type . "Git")) ((name . "git fast-import") (path . "git-fast-import") (type . "External Systems")) ((name . "git fetch") (path . "git-fetch") (type . "Sharing and Updating Projects")) ((name . "git fetch-pack") (path . "git-fetch-pack") (type . "Git")) ((name . "git filter-branch") (path . "git-filter-branch") (type . "Administration")) ((name . "git fmt-merge-msg") (path . "git-fmt-merge-msg") (type . "Git")) ((name . "git for-each-ref") (path . "git-for-each-ref") (type . "Plumbing Commands")) ((name . "git for-each-repo") (path . "git-for-each-repo") (type . "Git")) ((name . "git format-patch") (path . "git-format-patch") (type . "Email")) ((name . "git fsck") (path . "git-fsck") (type . "Administration")) ((name . "git fsmonitor--daemon") (path . "git-fsmonitor--daemon") (type . "Git")) ((name . "git gc") (path . "git-gc") (type . "Administration")) ((name . "git get-tar-commit-id") (path . "git-get-tar-commit-id") (type . "Git")) ((name . "git grep") (path . "git-grep") (type . "Debugging")) ((name . "git gui") (path . "git-gui") (type . "Git")) ((name . "git hash-object") (path . "git-hash-object") (type . "Plumbing Commands")) ((name . "git help") (path . "git-help") (type . "Setup and Config")) ((name . "git hook") (path . "git-hook") (type . "Git")) ((name . "git http-backend") (path . "git-http-backend") (type . "Git")) ((name . "git http-fetch") (path . "git-http-fetch") (type . "Git")) ((name . "git http-push") (path . "git-http-push") (type . "Git")) ((name . "git imap-send") (path . "git-imap-send") (type . "Git")) ((name . "git index-pack") (path . "git-index-pack") (type . "Git")) ((name . "git init") (path . "git-init") (type . "Getting and Creating Projects")) ((name . "git instaweb") (path . "git-instaweb") (type . "Administration")) ((name . "git interpret-trailers") (path . "git-interpret-trailers") (type . "Git")) ((name . "git log") (path . "git-log") (type . "Branching and Merging")) ((name . "git ls-files") (path . "git-ls-files") (type . "Plumbing Commands")) ((name . "git ls-remote") (path . "git-ls-remote") (type . "Git")) ((name . "git ls-tree") (path . "git-ls-tree") (type . "Plumbing Commands")) ((name . "git mailinfo") (path . "git-mailinfo") (type . "Git")) ((name . "git mailsplit") (path . "git-mailsplit") (type . "Git")) ((name . "git maintenance") (path . "git-maintenance") (type . "Git")) ((name . "git merge") (path . "git-merge") (type . "Branching and Merging")) ((name . "git merge-base") (path . "git-merge-base") (type . "Plumbing Commands")) ((name . "git merge-file") (path . "git-merge-file") (type . "Git")) ((name . "git merge-index") (path . "git-merge-index") (type . "Git")) ((name . "git merge-one-file") (path . "git-merge-one-file") (type . "Git")) ((name . "git merge-tree") (path . "git-merge-tree") (type . "Git")) ((name . "git mergetool") (path . "git-mergetool") (type . "Branching and Merging")) ((name . "git mktag") (path . "git-mktag") (type . "Git")) ((name . "git mktree") (path . "git-mktree") (type . "Git")) ((name . "git multi-pack-index") (path . "git-multi-pack-index") (type . "Git")) ((name . "git mv") (path . "git-mv") (type . "Basic Snapshotting")) ((name . "git name-rev") (path . "git-name-rev") (type . "Git")) ((name . "git notes") (path . "git-notes") (type . "Basic Snapshotting")) ((name . "git p4") (path . "git-p4") (type . "Git")) ((name . "git pack-objects") (path . "git-pack-objects") (type . "Git")) ((name . "git pack-redundant") (path . "git-pack-redundant") (type . "Git")) ((name . "git pack-refs") (path . "git-pack-refs") (type . "Git")) ((name . "git patch-id") (path . "git-patch-id") (type . "Git")) ((name . "git prune") (path . "git-prune") (type . "Git")) ((name . "git prune-packed") (path . "git-prune-packed") (type . "Git")) ((name . "git pull") (path . "git-pull") (type . "Sharing and Updating Projects")) ((name . "git push") (path . "git-push") (type . "Sharing and Updating Projects")) ((name . "git quiltimport") (path . "git-quiltimport") (type . "Git")) ((name . "git range-diff") (path . "git-range-diff") (type . "Inspection and Comparison")) ((name . "git read-tree") (path . "git-read-tree") (type . "Plumbing Commands")) ((name . "git rebase") (path . "git-rebase") (type . "Patching")) ((name . "git receive-pack") (path . "git-receive-pack") (type . "Git")) ((name . "git reflog") (path . "git-reflog") (type . "Administration")) ((name . "git remote") (path . "git-remote") (type . "Sharing and Updating Projects")) ((name . "git remote-ext") (path . "git-remote-ext") (type . "Git")) ((name . "git remote-fd") (path . "git-remote-fd") (type . "Git")) ((name . "git repack") (path . "git-repack") (type . "Git")) ((name . "git replace") (path . "git-replace") (type . "Git")) ((name . "git request-pull") (path . "git-request-pull") (type . "Email")) ((name . "git rerere") (path . "git-rerere") (type . "Git")) ((name . "git reset") (path . "git-reset") (type . "Basic Snapshotting")) ((name . "git restore") (path . "git-restore") (type . "Basic Snapshotting")) ((name . "git rev-list") (path . "git-rev-list") (type . "Plumbing Commands")) ((name . "git rev-parse") (path . "git-rev-parse") (type . "Plumbing Commands")) ((name . "git revert") (path . "git-revert") (type . "Patching")) ((name . "git rm") (path . "git-rm") (type . "Basic Snapshotting")) ((name . "git send-email") (path . "git-send-email") (type . "Email")) ((name . "git send-pack") (path . "git-send-pack") (type . "Git")) ((name . "git sh-i18n") (path . "git-sh-i18n") (type . "Git")) ((name . "git sh-i18n--envsubst") (path . "git-sh-i18n--envsubst") (type . "Git")) ((name . "git sh-setup") (path . "git-sh-setup") (type . "Git")) ((name . "git shell") (path . "git-shell") (type . "Git")) ((name . "git shortlog") (path . "git-shortlog") (type . "Inspection and Comparison")) ((name . "git show") (path . "git-show") (type . "Inspection and Comparison")) ((name . "git show-branch") (path . "git-show-branch") (type . "Git")) ((name . "git show-index") (path . "git-show-index") (type . "Git")) ((name . "git show-ref") (path . "git-show-ref") (type . "Plumbing Commands")) ((name . "git sparse-checkout") (path . "git-sparse-checkout") (type . "Git")) ((name . "git stash") (path . "git-stash") (type . "Branching and Merging")) ((name . "git status") (path . "git-status") (type . "Basic Snapshotting")) ((name . "git stripspace") (path . "git-stripspace") (type . "Git")) ((name . "git submodule") (path . "git-submodule") (type . "Sharing and Updating Projects")) ((name . "git svn") (path . "git-svn") (type . "External Systems")) ((name . "git switch") (path . "git-switch") (type . "Branching and Merging")) ((name . "git symbolic-ref") (path . "git-symbolic-ref") (type . "Plumbing Commands")) ((name . "git tag") (path . "git-tag") (type . "Branching and Merging")) ((name . "git unpack-file") (path . "git-unpack-file") (type . "Git")) ((name . "git unpack-objects") (path . "git-unpack-objects") (type . "Git")) ((name . "git update-index") (path . "git-update-index") (type . "Plumbing Commands")) ((name . "git update-ref") (path . "git-update-ref") (type . "Plumbing Commands")) ((name . "git update-server-info") (path . "git-update-server-info") (type . "Server Admin")) ((name . "git upload-archive") (path . "git-upload-archive") (type . "Git")) ((name . "git upload-pack") (path . "git-upload-pack") (type . "Git")) ((name . "git var") (path . "git-var") (type . "Git")) ((name . "git verify-commit") (path . "git-verify-commit") (type . "Git")) ((name . "git verify-pack") (path . "git-verify-pack") (type . "Plumbing Commands")) ((name . "git verify-tag") (path . "git-verify-tag") (type . "Git")) ((name . "git version") (path . "git-version") (type . "Git")) ((name . "git web--browse") (path . "git-web--browse") (type . "Git")) ((name . "git whatchanged") (path . "git-whatchanged") (type . "Git")) ((name . "git worktree") (path . "git-worktree") (type . "Branching and Merging")) ((name . "git write-tree") (path . "git-write-tree") (type . "Plumbing Commands")) ((name . "gitattributes") (path . "gitattributes") (type . "Guides")) ((name . "gitcli") (path . "gitcli") (type . "Guides")) ((name . "gitcore tutorial") (path . "gitcore-tutorial") (type . "Miscellaneous")) ((name . "gitcredentials") (path . "gitcredentials") (type . "Miscellaneous")) ((name . "gitcvs migration") (path . "gitcvs-migration") (type . "Miscellaneous")) ((name . "gitdiffcore") (path . "gitdiffcore") (type . "Miscellaneous")) ((name . "giteveryday") (path . "giteveryday") (type . "Guides")) ((name . "gitfaq") (path . "gitfaq") (type . "Guides")) ((name . "gitformat bundle") (path . "gitformat-bundle") (type . "Miscellaneous")) ((name . "gitformat chunk") (path . "gitformat-chunk") (type . "Miscellaneous")) ((name . "gitformat commit-graph") (path . "gitformat-commit-graph") (type . "Miscellaneous")) ((name . "gitformat index") (path . "gitformat-index") (type . "Miscellaneous")) ((name . "gitformat pack") (path . "gitformat-pack") (type . "Miscellaneous")) ((name . "gitformat signature") (path . "gitformat-signature") (type . "Miscellaneous")) ((name . "gitglossary") (path . "gitglossary") (type . "Guides")) ((name . "githooks") (path . "githooks") (type . "Guides")) ((name . "gitignore") (path . "gitignore") (type . "Guides")) ((name . "gitk") (path . "gitk") (type . "Miscellaneous")) ((name . "gitmailmap") (path . "gitmailmap") (type . "Miscellaneous")) ((name . "gitmodules") (path . "gitmodules") (type . "Guides")) ((name . "gitnamespaces") (path . "gitnamespaces") (type . "Miscellaneous")) ((name . "gitprotocol capabilities") (path . "gitprotocol-capabilities") (type . "Miscellaneous")) ((name . "gitprotocol common") (path . "gitprotocol-common") (type . "Miscellaneous")) ((name . "gitprotocol http") (path . "gitprotocol-http") (type . "Miscellaneous")) ((name . "gitprotocol pack") (path . "gitprotocol-pack") (type . "Miscellaneous")) ((name . "gitprotocol v2") (path . "gitprotocol-v2") (type . "Miscellaneous")) ((name . "gitremote helpers") (path . "gitremote-helpers") (type . "Miscellaneous")) ((name . "gitrepository layout") (path . "gitrepository-layout") (type . "Miscellaneous")) ((name . "gitrevisions") (path . "gitrevisions") (type . "Guides")) ((name . "gitsubmodules") (path . "gitsubmodules") (type . "Guides")) ((name . "gittutorial") (path . "gittutorial") (type . "Guides")) ((name . "gittutorial 2") (path . "gittutorial-2") (type . "Miscellaneous")) ((name . "gitweb") (path . "gitweb") (type . "Miscellaneous")) ((name . "gitweb.conf") (path . "gitweb.conf") (type . "Miscellaneous")) ((name . "gitworkflows") (path . "gitworkflows") (type . "Guides")) ((name . "howto index") (path . "howto-index") (type . "Miscellaneous")) ((name . "multi pack-index") (path . "multi-pack-index") (type . "Miscellaneous")) ((name . "partial clone") (path . "partial-clone") (type . "Miscellaneous")) ((name . "scalar") (path . "scalar") (type . "Miscellaneous")) ((name . "User Manual") (path . "user-manual") (type . "Miscellaneous"))]) (types . [((name . "Administration") (count . 8) (slug . "administration")) ((name . "Basic Snapshotting") (count . 9) (slug . "basic-snapshotting")) ((name . "Branching and Merging") (count . 9) (slug . "branching-and-merging")) ((name . "Debugging") (count . 3) (slug . "debugging")) ((name . "Email") (count . 4) (slug . "email")) ((name . "External Systems") (count . 2) (slug . "external-systems")) ((name . "Getting and Creating Projects") (count . 2) (slug . "getting-and-creating-projects")) ((name . "Git") (count . 78) (slug . "git")) ((name . "Guides") (count . 12) (slug . "guides")) ((name . "Inspection and Comparison") (count . 5) (slug . "inspection-and-comparison")) ((name . "Miscellaneous") (count . 32) (slug . "miscellaneous")) ((name . "Patching") (count . 4) (slug . "patching")) ((name . "Plumbing Commands") (count . 20) (slug . "plumbing-commands")) ((name . "Server Admin") (count . 2) (slug . "server-admin")) ((name . "Setup and Config") (count . 4) (slug . "setup-and-config")) ((name . "Sharing and Updating Projects") (count . 5) (slug . "sharing-and-updating-projects"))]))
\ No newline at end of file diff --git a/devdocs/git/index.html b/devdocs/git/index.html new file mode 100644 index 00000000..b62163fe --- /dev/null +++ b/devdocs/git/index.html @@ -0,0 +1,6 @@ +<h1>Git</h1> <div class="callout quickref"> <p> Quick reference guides: <a href="https://github.github.com/training-kit/">GitHub Cheat Sheet</a> | <a href="https://ndpsoftware.com/git-cheatsheet.html">Visual Git Cheat Sheet</a> </p> </div> <div class="callout all-commands"> <a href="git#_git_commands">Complete list of all commands</a> </div> <div class="reference-menu"> <div class="two-column"> <div class="column-left"> <h3 class="setup">Setup and Config</h3> <ul class="unstyled"> <li><a href="git">git</a></li> <li><a href="git-config">config</a></li> <li><a href="git-help">help</a></li> <li><a href="git-bugreport">bugreport</a></li> <a href="https://git-scm.com/doc/credential-helpers">Credential helpers</a> </ul> <h3 class="projects">Getting and Creating Projects</h3> <ul class="unstyled"> <li><a href="git-init">init</a></li> <li><a href="git-clone">clone</a></li> </ul> <h3 class="snapshotting">Basic Snapshotting</h3> <ul class="unstyled"> <li><a href="git-add">add</a></li> <li><a href="git-status">status</a></li> <li><a href="git-diff">diff</a></li> <li><a href="git-commit">commit</a></li> <li><a href="git-notes">notes</a></li> <li><a href="git-restore">restore</a></li> <li><a href="git-reset">reset</a></li> <li><a href="git-rm">rm</a></li> <li><a href="git-mv">mv</a></li> </ul> <h3 class="branching">Branching and Merging</h3> <ul class="unstyled"> <li><a href="git-branch">branch</a></li> <li><a href="git-checkout">checkout</a></li> <li><a href="git-switch">switch</a></li> <li><a href="git-merge">merge</a></li> <li><a href="git-mergetool">mergetool</a></li> <li><a href="git-log">log</a></li> <li><a href="git-stash">stash</a></li> <li><a href="git-tag">tag</a></li> <li><a href="git-worktree">worktree</a></li> </ul> <h3 class="sharing">Sharing and Updating Projects</h3> <ul class="unstyled"> <li><a href="git-fetch">fetch</a></li> <li><a href="git-pull">pull</a></li> <li><a href="git-push">push</a></li> <li><a href="git-remote">remote</a></li> <li><a href="git-submodule">submodule</a></li> </ul> <h3 class="inspection">Inspection and Comparison</h3> <ul class="unstyled"> <li><a href="git-show">show</a></li> <li><a href="git-log">log</a></li> <li><a href="git-diff">diff</a></li> <li><a href="git-difftool">difftool</a></li> <li><a href="git-range-diff">range-diff</a></li> <li><a href="git-shortlog">shortlog</a></li> <li><a href="git-describe">describe</a></li> </ul> <h3 class="patching">Patching</h3> <ul class="unstyled"> <li><a href="git-apply">apply</a></li> <li><a href="git-cherry-pick">cherry-pick</a></li> <li><a href="git-diff">diff</a></li> <li><a href="git-rebase">rebase</a></li> <li><a href="git-revert">revert</a></li> </ul> <h3 class="debugging">Debugging</h3> <ul class="unstyled"> <li><a href="git-bisect">bisect</a></li> <li><a href="git-blame">blame</a></li> <li><a href="git-grep">grep</a></li> </ul> </div> <div class="column-right"> <h3 class="guides">Guides</h3> <ul class="unstyled"> <li><a href="gitattributes">gitattributes</a></li> <li><a href="gitcli">Command-line interface conventions</a></li> <li><a href="giteveryday">Everyday Git</a></li> <li><a href="gitfaq">Frequently Asked Questions (FAQ)</a></li> <li><a href="gitglossary">Glossary</a></li> <li><a href="githooks">Hooks</a></li> <li><a href="gitignore">gitignore</a></li> <li><a href="gitmodules">gitmodules</a></li> <li><a href="gitrevisions">Revisions</a></li> <li><a href="gitsubmodules">Submodules</a></li> <li><a href="gittutorial">Tutorial</a></li> <li><a href="gitworkflows">Workflows</a></li> <li><a href="git#_guides">All guides...</a></li> </ul> <h3 class="email">Email</h3> <ul class="unstyled"> <li><a href="git-am">am</a></li> <li><a href="git-apply">apply</a></li> <li><a href="git-format-patch">format-patch</a></li> <li><a href="git-send-email">send-email</a></li> <li><a href="git-request-pull">request-pull</a></li> </ul> <h3 class="external">External Systems</h3> <ul class="unstyled"> <li><a href="git-svn">svn</a></li> <li><a href="git-fast-import">fast-import</a></li> </ul> <h3 class="admin">Administration</h3> <ul class="unstyled"> <li><a href="git-clean">clean</a></li> <li><a href="git-gc">gc</a></li> <li><a href="git-fsck">fsck</a></li> <li><a href="git-reflog">reflog</a></li> <li><a href="git-filter-branch">filter-branch</a></li> <li><a href="git-instaweb">instaweb</a></li> <li><a href="git-archive">archive</a></li> <li><a href="git-bundle">bundle</a></li> </ul> <h3 class="server-admin">Server Admin</h3> <ul class="unstyled"> <li><a href="git-daemon">daemon</a></li> <li><a href="git-update-server-info">update-server-info</a></li> </ul> <h3 class="plumbing">Plumbing Commands</h3> <ul class="unstyled"> <li><a href="git-cat-file">cat-file</a></li> <li><a href="git-check-ignore">check-ignore</a></li> <li><a href="git-checkout-index">checkout-index</a></li> <li><a href="git-commit-tree">commit-tree</a></li> <li><a href="git-count-objects">count-objects</a></li> <li><a href="git-diff-index">diff-index</a></li> <li><a href="git-for-each-ref">for-each-ref</a></li> <li><a href="git-hash-object">hash-object</a></li> <li><a href="git-ls-files">ls-files</a></li> <li><a href="git-ls-tree">ls-tree</a></li> <li><a href="git-merge-base">merge-base</a></li> <li><a href="git-read-tree">read-tree</a></li> <li><a href="git-rev-list">rev-list</a></li> <li><a href="git-rev-parse">rev-parse</a></li> <li><a href="git-show-ref">show-ref</a></li> <li><a href="git-symbolic-ref">symbolic-ref</a></li> <li><a href="git-update-index">update-index</a></li> <li><a href="git-update-ref">update-ref</a></li> <li><a href="git-verify-pack">verify-pack</a></li> <li><a href="git-write-tree">write-tree</a></li> </ul> </div> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs" class="_attribution-link">https://git-scm.com/docs</a> + </p> +</div> diff --git a/devdocs/git/metadata b/devdocs/git/metadata new file mode 100644 index 00000000..c067017a --- /dev/null +++ b/devdocs/git/metadata @@ -0,0 +1,2 @@ +(1 (name . "Git") (slug . "git") (type . "git") (links (home . "https://git-scm.com/") (code . "https://github.com/git/git")) (release . "2.43.1") (mtime . 1707592340) (db_size . 4606248) (attribution . "© 2012–2024 Scott Chacon and others<br> + Licensed under the MIT License."))
\ No newline at end of file diff --git a/devdocs/git/multi-pack-index.html b/devdocs/git/multi-pack-index.html new file mode 100644 index 00000000..b65672b7 --- /dev/null +++ b/devdocs/git/multi-pack-index.html @@ -0,0 +1,6 @@ +<h1>multi-pack-index</h1> <div class="sectionbody"> <p>The Git object directory contains a <code>pack</code> directory containing packfiles (with suffix ".pack") and pack-indexes (with suffix ".idx"). The pack-indexes provide a way to lookup objects and navigate to their offset within the pack, but these must come in pairs with the packfiles. This pairing depends on the file names, as the pack-index differs only in suffix with its pack- file. While the pack-indexes provide fast lookup per packfile, this performance degrades as the number of packfiles increases, because abbreviations need to inspect every packfile and we are more likely to have a miss on our most-recently-used packfile. For some large repositories, repacking into a single packfile is not feasible due to storage space or excessive repack times.</p> <p>The multi-pack-index (MIDX for short) stores a list of objects and their offsets into multiple packfiles. It contains:</p> <div class="ulist"> <ul> <li> <p>A list of packfile names.</p> </li> <li> <p>A sorted list of object IDs.</p> </li> <li> <p>A list of metadata for the ith object ID including:</p> <div class="ulist"> <ul> <li> <p>A value j referring to the jth packfile.</p> </li> <li> <p>An offset within the jth packfile for the object.</p> </li> </ul> </div> </li> <li> <p>If large offsets are required, we use another list of large offsets similar to version 2 pack-indexes.</p> <div class="ulist"> <ul> <li> <p>An optional list of objects in pseudo-pack order (used with MIDX bitmaps).</p> </li> </ul> </div> </li> </ul> </div> <p>Thus, we can provide O(log N) lookup time for any number of packfiles.</p> </div> <h2 id="_design_details">Design details</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>The MIDX is stored in a file named <code>multi-pack-index</code> in the .git/objects/pack directory. This could be stored in the pack directory of an alternate. It refers only to packfiles in that same directory.</p> </li> <li> <p>The core.multiPackIndex config setting must be on (which is the default) to consume MIDX files. Setting it to <code>false</code> prevents Git from reading a MIDX file, even if one exists.</p> </li> <li> <p>The file format includes parameters for the object ID hash function, so a future change of hash algorithm does not require a change in format.</p> </li> <li> <p>The MIDX keeps only one record per object ID. If an object appears in multiple packfiles, then the MIDX selects the copy in the preferred packfile, otherwise selecting from the most-recently modified packfile.</p> </li> <li> <p>If there exist packfiles in the pack directory not registered in the MIDX, then those packfiles are loaded into the <code>packed_git</code> list and <code>packed_git_mru</code> cache.</p> </li> <li> <p>The pack-indexes (.idx files) remain in the pack directory so we can delete the MIDX file, set core.midx to false, or downgrade without any loss of information.</p> </li> <li> <p>The MIDX file format uses a chunk-based approach (similar to the commit-graph file) that allows optional data to be added.</p> </li> </ul> </div> </div> <h2 id="_future_work">Future work</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>The multi-pack-index allows many packfiles, especially in a context where repacking is expensive (such as a very large repo), or unexpected maintenance time is unacceptable (such as a high-demand build machine). However, the multi-pack-index needs to be rewritten in full every time. We can extend the format to be incremental, so writes are fast. By storing a small "tip" multi-pack-index that points to large "base" MIDX files, we can keep writes fast while still reducing the number of binary searches required for object lookups.</p> </li> <li> <p>If the multi-pack-index is extended to store a "stable object order" (a function Order(hash) = integer that is constant for a given hash, even as the multi-pack-index is updated) then MIDX bitmaps could be updated independently of the MIDX.</p> </li> <li> <p>Packfiles can be marked as "special" using empty files that share the initial name but replace ".pack" with ".keep" or ".promisor". We can add an optional chunk of data to the multi-pack-index that records flags of information about the packfiles. This allows new states, such as <code>repacked</code> or <code>redeltified</code>, that can help with pack maintenance in a multi-pack environment. It may also be helpful to organize packfiles by object type (commit, tree, blob, etc.) and use this metadata to help that maintenance.</p> </li> </ul> </div> </div> <h2 id="_related_links">Related links</h2> <div class="sectionbody"> <p>[0] <a href="https://bugs.chromium.org/p/git/issues/detail?id=6" class="bare">https://bugs.chromium.org/p/git/issues/detail?id=6</a> Chromium work item for: Multi-Pack Index (MIDX)</p> <p>[1] <a href="https://lore.kernel.org/git/20180107181459.222909-1-dstolee@microsoft.com/" class="bare">https://lore.kernel.org/git/20180107181459.222909-1-dstolee@microsoft.com/</a> An earlier RFC for the multi-pack-index feature</p> <p>[2] <a href="https://lore.kernel.org/git/alpine.DEB.2.20.1803091557510.23109@alexmv-linux/" class="bare">https://lore.kernel.org/git/alpine.DEB.2.20.1803091557510.23109@alexmv-linux/</a> Git Merge 2018 Contributor’s summit notes (includes discussion of MIDX)</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/multi-pack-index" class="_attribution-link">https://git-scm.com/docs/multi-pack-index</a> + </p> +</div> diff --git a/devdocs/git/partial-clone.html b/devdocs/git/partial-clone.html new file mode 100644 index 00000000..86efc285 --- /dev/null +++ b/devdocs/git/partial-clone.html @@ -0,0 +1,6 @@ +<h1>partial-clone</h1> <div class="sectionbody"> <p>The "Partial Clone" feature is a performance optimization for Git that allows Git to function without having a complete copy of the repository. The goal of this work is to allow Git to better handle extremely large repositories.</p> <p>During clone and fetch operations, Git downloads the complete contents and history of the repository. This includes all commits, trees, and blobs for the complete life of the repository. For extremely large repositories, clones can take hours (or days) and consume 100+GiB of disk space.</p> <p>Often in these repositories there are many blobs and trees that the user does not need such as:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>files outside of the user’s work area in the tree. For example, in a repository with 500K directories and 3.5M files in every commit, we can avoid downloading many objects if the user only needs a narrow "cone" of the source tree.</p> </li> <li> <p>large binary assets. For example, in a repository where large build artifacts are checked into the tree, we can avoid downloading all previous versions of these non-mergeable binary assets and only download versions that are actually referenced.</p> </li> </ol> </div> <p>Partial clone allows us to avoid downloading such unneeded objects <strong>in advance</strong> during clone and fetch operations and thereby reduce download times and disk usage. Missing objects can later be "demand fetched" if/when needed.</p> <p>A remote that can later provide the missing objects is called a promisor remote, as it promises to send the objects when requested. Initially Git supported only one promisor remote, the origin remote from which the user cloned and that was configured in the "extensions.partialClone" config option. Later support for more than one promisor remote has been implemented.</p> <p>Use of partial clone requires that the user be online and the origin remote or other promisor remotes be available for on-demand fetching of missing objects. This may or may not be problematic for the user. For example, if the user can stay within the pre-selected subset of the source tree, they may not encounter any missing objects. Alternatively, the user could try to pre-fetch various objects if they know that they are going offline.</p> </div> <h2 id="_non_goals">Non-goals</h2> <div class="sectionbody"> <p>Partial clone is a mechanism to limit the number of blobs and trees downloaded <strong>within</strong> a given range of commits — and is therefore independent of and not intended to conflict with existing DAG-level mechanisms to limit the set of requested commits (i.e. shallow clone, single branch, or fetch <code><refspec></code>).</p> </div> <h2 id="_design_overview">Design overview</h2> <div class="sectionbody"> <p>Partial clone logically consists of the following parts:</p> <div class="ulist"> <ul> <li> <p>A mechanism for the client to describe unneeded or unwanted objects to the server.</p> </li> <li> <p>A mechanism for the server to omit such unwanted objects from packfiles sent to the client.</p> </li> <li> <p>A mechanism for the client to gracefully handle missing objects (that were previously omitted by the server).</p> </li> <li> <p>A mechanism for the client to backfill missing objects as needed.</p> </li> </ul> </div> </div> <h2 id="_design_details">Design details</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>A new pack-protocol capability "filter" is added to the fetch-pack and upload-pack negotiation.</p> <p>This uses the existing capability discovery mechanism. See "filter" in <a href="gitprotocol-pack">gitprotocol-pack[5]</a>.</p> </li> <li> <p>Clients pass a "filter-spec" to clone and fetch which is passed to the server to request filtering during packfile construction.</p> <p>There are various filters available to accommodate different situations. See "--filter=<filter-spec>" in Documentation/rev-list-options.txt.</p> </li> <li> <p>On the server pack-objects applies the requested filter-spec as it creates "filtered" packfiles for the client.</p> <p>These filtered packfiles are <strong>incomplete</strong> in the traditional sense because they may contain objects that reference objects not contained in the packfile and that the client doesn’t already have. For example, the filtered packfile may contain trees or tags that reference missing blobs or commits that reference missing trees.</p> </li> <li> <p>On the client these incomplete packfiles are marked as "promisor packfiles" and treated differently by various commands.</p> </li> <li> <p>On the client a repository extension is added to the local config to prevent older versions of git from failing mid-operation because of missing objects that they cannot handle. See "extensions.partialClone" in Documentation/technical/repository-version.txt"</p> </li> </ul> </div> </div> <h2 id="_handling_missing_objects">Handling missing objects</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>An object may be missing due to a partial clone or fetch, or missing due to repository corruption. To differentiate these cases, the local repository specially indicates such filtered packfiles obtained from promisor remotes as "promisor packfiles".</p> <p>These promisor packfiles consist of a "<name>.promisor" file with arbitrary contents (like the "<name>.keep" files), in addition to their "<name>.pack" and "<name>.idx" files.</p> </li> <li> <p>The local repository considers a "promisor object" to be an object that it knows (to the best of its ability) that promisor remotes have promised that they have, either because the local repository has that object in one of its promisor packfiles, or because another promisor object refers to it.</p> <p>When Git encounters a missing object, Git can see if it is a promisor object and handle it appropriately. If not, Git can report a corruption.</p> <p>This means that there is no need for the client to explicitly maintain an expensive-to-modify list of missing objects.[a]</p> </li> <li> <p>Since almost all Git code currently expects any referenced object to be present locally and because we do not want to force every command to do a dry-run first, a fallback mechanism is added to allow Git to attempt to dynamically fetch missing objects from promisor remotes.</p> <p>When the normal object lookup fails to find an object, Git invokes promisor_remote_get_direct() to try to get the object from a promisor remote and then retry the object lookup. This allows objects to be "faulted in" without complicated prediction algorithms.</p> <p>For efficiency reasons, no check as to whether the missing object is actually a promisor object is performed.</p> <p>Dynamic object fetching tends to be slow as objects are fetched one at a time.</p> </li> <li> <p><code>checkout</code> (and any other command using <code>unpack-trees</code>) has been taught to bulk pre-fetch all required missing blobs in a single batch.</p> </li> <li> <p><code>rev-list</code> has been taught to print missing objects.</p> <p>This can be used by other commands to bulk prefetch objects. For example, a "git log -p A..B" may internally want to first do something like "git rev-list --objects --quiet --missing=print A..B" and prefetch those objects in bulk.</p> </li> <li> <p><code>fsck</code> has been updated to be fully aware of promisor objects.</p> </li> <li> <p><code>repack</code> in GC has been updated to not touch promisor packfiles at all, and to only repack other objects.</p> </li> <li> <p>The global variable "fetch_if_missing" is used to control whether an object lookup will attempt to dynamically fetch a missing object or report an error.</p> <p>We are not happy with this global variable and would like to remove it, but that requires significant refactoring of the object code to pass an additional flag.</p> </li> </ul> </div> </div> <h2 id="_fetching_missing_objects">Fetching missing objects</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Fetching of objects is done by invoking a "git fetch" subprocess.</p> </li> <li> <p>The local repository sends a request with the hashes of all requested objects, and does not perform any packfile negotiation. It then receives a packfile.</p> </li> <li> <p>Because we are reusing the existing fetch mechanism, fetching currently fetches all objects referred to by the requested objects, even though they are not necessary.</p> </li> <li> <p>Fetching with <code>--refetch</code> will request a complete new filtered packfile from the remote, which can be used to change a filter without needing to dynamically fetch missing objects.</p> </li> </ul> </div> </div> <h2 id="_using_many_promisor_remotes">Using many promisor remotes</h2> <div class="sectionbody"> <p>Many promisor remotes can be configured and used.</p> <p>This allows for example a user to have multiple geographically-close cache servers for fetching missing blobs while continuing to do filtered <code>git-fetch</code> commands from the central server.</p> <p>When fetching objects, promisor remotes are tried one after the other until all the objects have been fetched.</p> <p>Remotes that are considered "promisor" remotes are those specified by the following configuration variables:</p> <div class="ulist"> <ul> <li> <p><code>extensions.partialClone = <name></code></p> </li> <li> <p><code>remote.<name>.promisor = true</code></p> </li> <li> <p><code>remote.<name>.partialCloneFilter = ...</code></p> </li> </ul> </div> <p>Only one promisor remote can be configured using the <code>extensions.partialClone</code> config variable. This promisor remote will be the last one tried when fetching objects.</p> <p>We decided to make it the last one we try, because it is likely that someone using many promisor remotes is doing so because the other promisor remotes are better for some reason (maybe they are closer or faster for some kind of objects) than the origin, and the origin is likely to be the remote specified by extensions.partialClone.</p> <p>This justification is not very strong, but one choice had to be made, and anyway the long term plan should be to make the order somehow fully configurable.</p> <p>For now though the other promisor remotes will be tried in the order they appear in the config file.</p> </div> <h2 id="_current_limitations">Current limitations</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>It is not possible to specify the order in which the promisor remotes are tried in other ways than the order in which they appear in the config file.</p> <p>It is also not possible to specify an order to be used when fetching from one remote and a different order when fetching from another remote.</p> </li> <li> <p>It is not possible to push only specific objects to a promisor remote.</p> <p>It is not possible to push at the same time to multiple promisor remote in a specific order.</p> </li> <li> <p>Dynamic object fetching will only ask promisor remotes for missing objects. We assume that promisor remotes have a complete view of the repository and can satisfy all such requests.</p> </li> <li> <p>Repack essentially treats promisor and non-promisor packfiles as 2 distinct partitions and does not mix them.</p> </li> <li> <p>Dynamic object fetching invokes fetch-pack once <strong>for each item</strong> because most algorithms stumble upon a missing object and need to have it resolved before continuing their work. This may incur significant overhead — and multiple authentication requests — if many objects are needed.</p> </li> <li> <p>Dynamic object fetching currently uses the existing pack protocol V0 which means that each object is requested via fetch-pack. The server will send a full set of info/refs when the connection is established. If there are a large number of refs, this may incur significant overhead.</p> </li> </ul> </div> </div> <h2 id="_future_work">Future work</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Improve the way to specify the order in which promisor remotes are tried.</p> <p>For example this could allow specifying explicitly something like: "When fetching from this remote, I want to use these promisor remotes in this order, though, when pushing or fetching to that remote, I want to use those promisor remotes in that order."</p> </li> <li> <p>Allow pushing to promisor remotes.</p> <p>The user might want to work in a triangular work flow with multiple promisor remotes that each have an incomplete view of the repository.</p> </li> <li> <p>Allow non-pathname-based filters to make use of packfile bitmaps (when present). This was just an omission during the initial implementation.</p> </li> <li> <p>Investigate use of a long-running process to dynamically fetch a series of objects, such as proposed in [5,6] to reduce process startup and overhead costs.</p> <p>It would be nice if pack protocol V2 could allow that long-running process to make a series of requests over a single long-running connection.</p> </li> <li> <p>Investigate pack protocol V2 to avoid the info/refs broadcast on each connection with the server to dynamically fetch missing objects.</p> </li> <li> <p>Investigate the need to handle loose promisor objects.</p> <p>Objects in promisor packfiles are allowed to reference missing objects that can be dynamically fetched from the server. An assumption was made that loose objects are only created locally and therefore should not reference a missing object. We may need to revisit that assumption if, for example, we dynamically fetch a missing tree and store it as a loose object rather than a single object packfile.</p> <p>This does not necessarily mean we need to mark loose objects as promisor; it may be sufficient to relax the object lookup or is-promisor functions.</p> </li> </ul> </div> </div> <h2 id="_non_tasks">Non-tasks</h2> <div class="sectionbody"> <div class="ulist"> <ul> <li> <p>Every time the subject of "demand loading blobs" comes up it seems that someone suggests that the server be allowed to "guess" and send additional objects that may be related to the requested objects.</p> <p>No work has gone into actually doing that; we’re just documenting that it is a common suggestion. We’re not sure how it would work and have no plans to work on it.</p> <p>It is valid for the server to send more objects than requested (even for a dynamic object fetch), but we are not building on that.</p> </li> </ul> </div> </div> <h2 id="_footnotes">Footnotes</h2> <div class="sectionbody"> <p>[a] expensive-to-modify list of missing objects: Earlier in the design of partial clone we discussed the need for a single list of missing objects. This would essentially be a sorted linear list of OIDs that were omitted by the server during a clone or subsequent fetches.</p> <p>This file would need to be loaded into memory on every object lookup. It would need to be read, updated, and re-written (like the .git/index) on every explicit "git fetch" command <strong>and</strong> on any dynamic object fetch.</p> <p>The cost to read, update, and write this file could add significant overhead to every command if there are many missing objects. For example, if there are 100M missing blobs, this file would be at least 2GiB on disk.</p> <p>With the "promisor" concept, we <strong>infer</strong> a missing object based upon the type of packfile that references it.</p> </div> <h2 id="_related_links">Related links</h2> <div class="sectionbody"> <p>[0] <a href="https://crbug.com/git/2" class="bare">https://crbug.com/git/2</a> Bug#2: Partial Clone</p> <p>[1] <a href="https://lore.kernel.org/git/20170113155253.1644-1-benpeart@microsoft.com/" class="bare">https://lore.kernel.org/git/20170113155253.1644-1-benpeart@microsoft.com/</a><br> Subject: [RFC] Add support for downloading blobs on demand<br> Date: Fri, 13 Jan 2017 10:52:53 -0500</p> <p>[2] <a href="https://lore.kernel.org/git/cover.1506714999.git.jonathantanmy@google.com/" class="bare">https://lore.kernel.org/git/cover.1506714999.git.jonathantanmy@google.com/</a><br> Subject: [PATCH 00/18] Partial clone (from clone to lazy fetch in 18 patches)<br> Date: Fri, 29 Sep 2017 13:11:36 -0700</p> <p>[3] <a href="https://lore.kernel.org/git/20170426221346.25337-1-jonathantanmy@google.com/" class="bare">https://lore.kernel.org/git/20170426221346.25337-1-jonathantanmy@google.com/</a><br> Subject: Proposal for missing blob support in Git repos<br> Date: Wed, 26 Apr 2017 15:13:46 -0700</p> <p>[4] <a href="https://lore.kernel.org/git/1488999039-37631-1-git-send-email-git@jeffhostetler.com/" class="bare">https://lore.kernel.org/git/1488999039-37631-1-git-send-email-git@jeffhostetler.com/</a><br> Subject: [PATCH 00/10] RFC Partial Clone and Fetch<br> Date: Wed, 8 Mar 2017 18:50:29 +0000</p> <p>[5] <a href="https://lore.kernel.org/git/20170505152802.6724-1-benpeart@microsoft.com/" class="bare">https://lore.kernel.org/git/20170505152802.6724-1-benpeart@microsoft.com/</a><br> Subject: [PATCH v7 00/10] refactor the filter process code into a reusable module<br> Date: Fri, 5 May 2017 11:27:52 -0400</p> <p>[6] <a href="https://lore.kernel.org/git/20170714132651.170708-1-benpeart@microsoft.com/" class="bare">https://lore.kernel.org/git/20170714132651.170708-1-benpeart@microsoft.com/</a><br> Subject: [RFC/PATCH v2 0/1] Add support for downloading blobs on demand<br> Date: Fri, 14 Jul 2017 09:26:50 -0400</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/partial-clone" class="_attribution-link">https://git-scm.com/docs/partial-clone</a> + </p> +</div> diff --git a/devdocs/git/scalar.html b/devdocs/git/scalar.html new file mode 100644 index 00000000..5b1f2102 --- /dev/null +++ b/devdocs/git/scalar.html @@ -0,0 +1,23 @@ +<h1>scalar</h1> <h2 id="_name">Name</h2> <div class="sectionbody"> <p>scalar - A tool for managing large Git repositories</p> </div> <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content">scalar clone [--single-branch] [--branch <main-branch>] [--full-clone] + [--[no-]src] <url> [<enlistment>] +scalar list +scalar register [<enlistment>] +scalar unregister [<enlistment>] +scalar run ( all | config | commit-graph | fetch | loose-objects | pack-files ) [<enlistment>] +scalar reconfigure [ --all | <enlistment> ] +scalar diagnose [<enlistment>] +scalar delete <enlistment></pre> </div> </div> <h2 id="_description">Description</h2> <div class="sectionbody"> <p>Scalar is a repository management tool that optimizes Git for use in large repositories. Scalar improves performance by configuring advanced Git settings, maintaining repositories in the background, and helping to reduce data sent across the network.</p> <p>An important Scalar concept is the enlistment: this is the top-level directory of the project. It usually contains the subdirectory <code>src/</code> which is a Git worktree. This encourages the separation between tracked files (inside <code>src/</code>) and untracked files, such as build artifacts (outside <code>src/</code>). When registering an existing Git worktree with Scalar whose name is not <code>src</code>, the enlistment will be identical to the worktree.</p> <p>The <code>scalar</code> command implements various subcommands, and different options depending on the subcommand. With the exception of <code>clone</code>, <code>list</code> and <code>reconfigure --all</code>, all subcommands expect to be run in an enlistment.</p> <p>The following options can be specified <code>before</code> the subcommand:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/scalar.txt--Cltdirectorygt"> -C <directory> </dt> <dd> <p>Before running the subcommand, change the working directory. This option imitates the same option of <a href="git">git[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/scalar.txt--cltkeygtltvaluegt"> -c <key>=<value> </dt> <dd> <p>For the duration of running the specified subcommand, configure this setting. This option imitates the same option of <a href="git">git[1]</a>.</p> </dd> </dl> </div> </div> <h2 id="_commands">Commands</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="_clone"> +Clone</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/scalar.txt-cloneltoptionsgtlturlgtltenlistmentgt"> clone [<options>] <url> [<enlistment>] </dt> <dd> <p>Clones the specified repository, similar to <a href="git-clone">git-clone[1]</a>. By default, only commit and tree objects are cloned. Once finished, the worktree is located at <code><enlistment>/src</code>.</p> <p>The sparse-checkout feature is enabled (except when run with <code>--full-clone</code>) and the only files present are those in the top-level directory. Use <code>git sparse-checkout set</code> to expand the set of directories you want to see, or <code>git sparse-checkout disable</code> to expand to all files (see <a href="git-sparse-checkout">git-sparse-checkout[1]</a> for more details). You can explore the subdirectories outside your sparse-checkout by using <code>git ls-tree +HEAD[:<directory>]</code>.</p> </dd> <dt class="hdlist1" id="Documentation/scalar.txt--bltnamegt"> -b <name> </dt> <dt class="hdlist1" id="Documentation/scalar.txt---branchltnamegt"> --branch <name> </dt> <dd> <p>Instead of checking out the branch pointed to by the cloned repository’s HEAD, check out the <code><name></code> branch instead.</p> </dd> <dt class="hdlist1" id="Documentation/scalar.txt---no-single-branch"> --[no-]single-branch </dt> <dd> <p>Clone only the history leading to the tip of a single branch, either specified by the <code>--branch</code> option or the primary branch remote’s <code>HEAD</code> points at.</p> <p>Further fetches into the resulting repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If the HEAD at the remote did not point at any branch when <code>--single-branch</code> clone was made, no remote-tracking branch is created.</p> </dd> <dt class="hdlist1" id="Documentation/scalar.txt---no-src"> --[no-]src </dt> <dd> <p>By default, <code>scalar clone</code> places the cloned repository within a <code><entlistment>/src</code> directory. Use <code>--no-src</code> to place the cloned repository directly in the <code><enlistment></code> directory.</p> </dd> <dt class="hdlist1" id="Documentation/scalar.txt---no-full-clone"> --[no-]full-clone </dt> <dd> <p>A sparse-checkout is initialized by default. This behavior can be turned off via <code>--full-clone</code>.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_list"> +List</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/scalar.txt-list"> list </dt> <dd> <p>List enlistments that are currently registered by Scalar. This subcommand does not need to be run inside an enlistment.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_register"> +Register</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/scalar.txt-registerltenlistmentgt"> register [<enlistment>] </dt> <dd> <p>Adds the enlistment’s repository to the list of registered repositories and starts background maintenance. If <code><enlistment></code> is not provided, then the enlistment associated with the current working directory is registered.</p> <p>Note: when this subcommand is called in a worktree that is called <code>src/</code>, its parent directory is considered to be the Scalar enlistment. If the worktree is <code>not</code> called <code>src/</code>, it itself will be considered to be the Scalar enlistment.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_unregister"> +Unregister</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/scalar.txt-unregisterltenlistmentgt"> unregister [<enlistment>] </dt> <dd> <p>Remove the specified repository from the list of repositories registered with Scalar and stop the scheduled background maintenance.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_run"> +Run</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/scalar.txt-scalarrunallconfigcommit-graphfetchloose-objectspack-filesltenlistmentgt"> scalar run ( all | config | commit-graph | fetch | loose-objects | pack-files ) [<enlistment>] </dt> <dd> <p>Run the given maintenance task (or all tasks, if <code>all</code> was specified). Except for <code>all</code> and <code>config</code>, this subcommand simply hands off to <a href="git-maintenance">git-maintenance[1]</a> (mapping <code>fetch</code> to <code>prefetch</code> and <code>pack-files</code> to <code>incremental-repack</code>).</p> <p>These tasks are run automatically as part of the scheduled maintenance, as soon as the repository is registered with Scalar. It should therefore not be necessary to run this subcommand manually.</p> <p>The <code>config</code> task is specific to Scalar and configures all those opinionated default settings that make Git work more efficiently with large repositories. As this task is run as part of <code>scalar clone</code> automatically, explicit invocations of this task are rarely needed.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_reconfigure"> +Reconfigure</h3> <p>After a Scalar upgrade, or when the configuration of a Scalar enlistment was somehow corrupted or changed by mistake, this subcommand allows to reconfigure the enlistment.</p> <p>With the <code>--all</code> option, all enlistments currently registered with Scalar will be reconfigured. Use this option after each Scalar upgrade.</p> </div> <div class="sect2"> <h3 id="_diagnose"> +Diagnose</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/scalar.txt-diagnoseltenlistmentgt"> diagnose [<enlistment>] </dt> <dd> <p>When reporting issues with Scalar, it is often helpful to provide the information gathered by this command, including logs and certain statistics describing the data shape of the current enlistment.</p> <p>The output of this command is a <code>.zip</code> file that is written into a directory adjacent to the worktree in the <code>src</code> directory.</p> </dd> </dl> </div> </div> <div class="sect2"> <h3 id="_delete"> +Delete</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/scalar.txt-deleteltenlistmentgt"> delete <enlistment> </dt> <dd> <p>This subcommand lets you delete an existing Scalar enlistment from your local file system, unregistering the repository.</p> </dd> </dl> </div> </div> </div> <h2 id="_see_also">See also</h2> <div class="sectionbody"> <p><a href="git-clone">git-clone[1]</a>, <a href="git-maintenance">git-maintenance[1]</a>.</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/scalar" class="_attribution-link">https://git-scm.com/docs/scalar</a> + </p> +</div> diff --git a/devdocs/git/user-manual.html b/devdocs/git/user-manual.html new file mode 100644 index 00000000..8b6752ed --- /dev/null +++ b/devdocs/git/user-manual.html @@ -0,0 +1,794 @@ +<h1>user-manual</h1> <h2 id="_introduction">Introduction</h2> <div class="sectionbody"> <p>Git is a fast distributed revision control system.</p> <p>This manual is designed to be readable by someone with basic UNIX command-line skills, but no previous knowledge of Git.</p> <p><a href="#repositories-and-branches">Repositories and Branches</a> and <a href="#exploring-git-history">Exploring Git history</a> explain how to fetch and study a project using git—read these chapters to learn how to build and test a particular version of a software project, search for regressions, and so on.</p> <p>People needing to do actual development will also want to read <a href="#Developing-With-git">Developing with Git</a> and <a href="#sharing-development">Sharing development with others</a>.</p> <p>Further chapters cover more specialized topics.</p> <p>Comprehensive reference documentation is available through the man pages, or <a href="git-help">git-help[1]</a> command. For example, for the command <code>git clone <repo></code>, you can either use:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ man git-clone</pre> </div> </div> <p>or:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git help clone</pre> </div> </div> <p>With the latter, you can use the manual viewer of your choice; see <a href="git-help">git-help[1]</a> for more information.</p> <p>See also <a href="#git-quick-start">Git Quick Reference</a> for a brief overview of Git commands, without any explanation.</p> <p>Finally, see <a href="#todo">Notes and todo list for this manual</a> for ways that you can help make this manual more complete.</p> </div> <h2 id="repositories-and-branches">Repositories and branches</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="how-to-get-a-git-repository"> +How to get a Git repository</h3> <p>It will be useful to have a Git repository to experiment with as you read this manual.</p> <p>The best way to get one is by using the <a href="git-clone">git-clone[1]</a> command to download a copy of an existing repository. If you don’t already have a project in mind, here are some interesting examples:</p> <div class="listingblock"> <div class="content"> <pre> # Git itself (approx. 40MB download): +$ git clone git://git.kernel.org/pub/scm/git/git.git + # the Linux kernel (approx. 640MB download): +$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git</pre> </div> </div> <p>The initial clone may be time-consuming for a large project, but you will only need to clone once.</p> <p>The clone command creates a new directory named after the project (<code>git</code> or <code>linux</code> in the examples above). After you cd into this directory, you will see that it contains a copy of the project files, called the <a href="#def_working_tree">working tree</a>, together with a special top-level directory named <code>.git</code>, which contains all the information about the history of the project.</p> </div> <div class="sect2"> <h3 id="how-to-check-out"> +How to check out a different version of a project</h3> <p>Git is best thought of as a tool for storing the history of a collection of files. It stores the history as a compressed collection of interrelated snapshots of the project’s contents. In Git each such version is called a <a href="#def_commit">commit</a>.</p> <p>Those snapshots aren’t necessarily all arranged in a single line from oldest to newest; instead, work may simultaneously proceed along parallel lines of development, called <a href="#def_branch">branches</a>, which may merge and diverge.</p> <p>A single Git repository can track development on multiple branches. It does this by keeping a list of <a href="#def_head">heads</a> which reference the latest commit on each branch; the <a href="git-branch">git-branch[1]</a> command shows you the list of branch heads:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch +* master</pre> </div> </div> <p>A freshly cloned repository contains a single branch head, by default named "master", with the working directory initialized to the state of the project referred to by that branch head.</p> <p>Most projects also use <a href="#def_tag">tags</a>. Tags, like heads, are references into the project’s history, and can be listed using the <a href="git-tag">git-tag[1]</a> command:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git tag -l +v2.6.11 +v2.6.11-tree +v2.6.12 +v2.6.12-rc2 +v2.6.12-rc3 +v2.6.12-rc4 +v2.6.12-rc5 +v2.6.12-rc6 +v2.6.13 +...</pre> </div> </div> <p>Tags are expected to always point at the same version of a project, while heads are expected to advance as development progresses.</p> <p>Create a new branch head pointing to one of these versions and check it out using <a href="git-switch">git-switch[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -c new v2.6.13</pre> </div> </div> <p>The working directory then reflects the contents that the project had when it was tagged v2.6.13, and <a href="git-branch">git-branch[1]</a> shows two branches, with an asterisk marking the currently checked-out branch:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch + master +* new</pre> </div> </div> <p>If you decide that you’d rather see version 2.6.17, you can modify the current branch to point at v2.6.17 instead, with</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git reset --hard v2.6.17</pre> </div> </div> <p>Note that if the current branch head was your only reference to a particular point in history, then resetting that branch may leave you with no way to find the history it used to point to; so use this command carefully.</p> </div> <div class="sect2"> <h3 id="understanding-commits"> +Understanding History: Commits</h3> <p>Every change in the history of a project is represented by a commit. The <a href="git-show">git-show[1]</a> command shows the most recent commit on the current branch:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show +commit 17cf781661e6d38f737f15f53ab552f1e95960d7 +Author: Linus Torvalds <torvalds@ppc970.osdl.org.(none)> +Date: Tue Apr 19 14:11:06 2005 -0700 + + Remove duplicate getenv(DB_ENVIRONMENT) call + + Noted by Tony Luck. + +diff --git a/init-db.c b/init-db.c +index 65898fa..b002dc6 100644 +--- a/init-db.c ++++ b/init-db.c +@@ -7,7 +7,7 @@ + + int main(int argc, char **argv) + { +- char *sha1_dir = getenv(DB_ENVIRONMENT), *path; ++ char *sha1_dir, *path; + int len, i; + + if (mkdir(".git", 0755) < 0) {</pre> </div> </div> <p>As you can see, a commit shows who made the latest change, what they did, and why.</p> <p>Every commit has a 40-hexdigit id, sometimes called the "object name" or the "SHA-1 id", shown on the first line of the <code>git show</code> output. You can usually refer to a commit by a shorter name, such as a tag or a branch name, but this longer name can also be useful. Most importantly, it is a globally unique name for this commit: so if you tell somebody else the object name (for example in email), then you are guaranteed that name will refer to the same commit in their repository that it does in yours (assuming their repository has that commit at all). Since the object name is computed as a hash over the contents of the commit, you are guaranteed that the commit can never change without its name also changing.</p> <p>In fact, in <a href="#git-concepts">Git concepts</a> we shall see that everything stored in Git history, including file data and directory contents, is stored in an object with a name that is a hash of its contents.</p> <div class="sect3"> <h4 id="understanding-reachability"> +Understanding history: commits, parents, and reachability</h4> <p>Every commit (except the very first commit in a project) also has a parent commit which shows what happened before this commit. Following the chain of parents will eventually take you back to the beginning of the project.</p> <p>However, the commits do not form a simple list; Git allows lines of development to diverge and then reconverge, and the point where two lines of development reconverge is called a "merge". The commit representing a merge can therefore have more than one parent, with each parent representing the most recent commit on one of the lines of development leading to that point.</p> <p>The best way to see how this works is using the <a href="gitk">gitk[1]</a> command; running gitk now on a Git repository and looking for merge commits will help understand how Git organizes history.</p> <p>In the following, we say that commit X is "reachable" from commit Y if commit X is an ancestor of commit Y. Equivalently, you could say that Y is a descendant of X, or that there is a chain of parents leading from commit Y to commit X.</p> </div> <div class="sect3"> <h4 id="history-diagrams"> +Understanding history: History diagrams</h4> <p>We will sometimes represent Git history using diagrams like the one below. Commits are shown as "o", and the links between them with lines drawn with - / and \. Time goes left to right:</p> <div class="literalblock"> <div class="content"> <pre> o--o--o <-- Branch A + / + o--o--o <-- master + \ + o--o--o <-- Branch B</pre> </div> </div> <p>If we need to talk about a particular commit, the character "o" may be replaced with another letter or number.</p> </div> <div class="sect3"> <h4 id="what-is-a-branch"> +Understanding history: What is a branch?</h4> <p>When we need to be precise, we will use the word "branch" to mean a line of development, and "branch head" (or just "head") to mean a reference to the most recent commit on a branch. In the example above, the branch head named "A" is a pointer to one particular commit, but we refer to the line of three commits leading up to that point as all being part of "branch A".</p> <p>However, when no confusion will result, we often just use the term "branch" both for branches and for branch heads.</p> </div> </div> <div class="sect2"> <h3 id="manipulating-branches"> +Manipulating branches</h3> <p>Creating, deleting, and modifying branches is quick and easy; here’s a summary of the commands:</p> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/user-manual.txt-codegitbranchcode"> <code>git branch</code> </dt> <dd> <p>list all branches.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-codegitbranchltbranchgtcode"> <code>git branch <branch></code> </dt> <dd> <p>create a new branch named <code><branch></code>, referencing the same point in history as the current branch.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-codegitbranchltbranchgtltstart-pointgtcode"> <code>git branch <branch> <start-point></code> </dt> <dd> <p>create a new branch named <code><branch></code>, referencing <code><start-point></code>, which may be specified any way you like, including using a branch name or a tag name.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-codegitbranch-dltbranchgtcode"> <code>git branch -d <branch></code> </dt> <dd> <p>delete the branch <code><branch></code>; if the branch is not fully merged in its upstream branch or contained in the current branch, this command will fail with a warning.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-codegitbranch-Dltbranchgtcode"> <code>git branch -D <branch></code> </dt> <dd> <p>delete the branch <code><branch></code> irrespective of its merged status.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-codegitswitchltbranchgtcode"> <code>git switch <branch></code> </dt> <dd> <p>make the current branch <code><branch></code>, updating the working directory to reflect the version referenced by <code><branch></code>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-codegitswitch-cltnewgtltstart-pointgtcode"> <code>git switch -c <new> <start-point></code> </dt> <dd> <p>create a new branch <code><new></code> referencing <code><start-point></code>, and check it out.</p> </dd> </dl> </div> <p>The special symbol "HEAD" can always be used to refer to the current branch. In fact, Git uses a file named <code>HEAD</code> in the <code>.git</code> directory to remember which branch is current:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat .git/HEAD +ref: refs/heads/master</pre> </div> </div> </div> <div class="sect2"> <h3 id="detached-head"> +Examining an old version without creating a new branch</h3> <p>The <code>git switch</code> command normally expects a branch head, but will also accept an arbitrary commit when invoked with --detach; for example, you can check out the commit referenced by a tag:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch --detach v2.6.17 +Note: checking out 'v2.6.17'. + +You are in 'detached HEAD' state. You can look around, make experimental +changes and commit them, and you can discard any commits you make in this +state without impacting any branches by performing another switch. + +If you want to create a new branch to retain commits you create, you may +do so (now or later) by using -c with the switch command again. Example: + + git switch -c new_branch_name + +HEAD is now at 427abfa Linux v2.6.17</pre> </div> </div> <p>The HEAD then refers to the SHA-1 of the commit instead of to a branch, and git branch shows that you are no longer on a branch:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat .git/HEAD +427abfa28afedffadfca9dd8b067eb6d36bac53f +$ git branch +* (detached from v2.6.17) + master</pre> </div> </div> <p>In this case we say that the HEAD is "detached".</p> <p>This is an easy way to check out a particular version without having to make up a name for the new branch. You can still create a new branch (or tag) for this version later if you decide to.</p> </div> <div class="sect2"> <h3 id="examining-remote-branches"> +Examining branches from a remote repository</h3> <p>The "master" branch that was created at the time you cloned is a copy of the HEAD in the repository that you cloned from. That repository may also have had other branches, though, and your local repository keeps branches which track each of those remote branches, called remote-tracking branches, which you can view using the <code>-r</code> option to <a href="git-branch">git-branch[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch -r + origin/HEAD + origin/html + origin/maint + origin/man + origin/master + origin/next + origin/seen + origin/todo</pre> </div> </div> <p>In this example, "origin" is called a remote repository, or "remote" for short. The branches of this repository are called "remote branches" from our point of view. The remote-tracking branches listed above were created based on the remote branches at clone time and will be updated by <code>git fetch</code> (hence <code>git pull</code>) and <code>git push</code>. See <a href="#Updating-a-repository-With-git-fetch">Updating a repository with git fetch</a> for details.</p> <p>You might want to build on one of these remote-tracking branches on a branch of your own, just as you would for a tag:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -c my-todo-copy origin/todo</pre> </div> </div> <p>You can also check out <code>origin/todo</code> directly to examine it or write a one-off patch. See <a href="#detached-head">detached head</a>.</p> <p>Note that the name "origin" is just the name that Git uses by default to refer to the repository that you cloned from.</p> </div> <div class="sect2"> <h3 id="how-git-stores-references"> +Naming branches, tags, and other references</h3> <p>Branches, remote-tracking branches, and tags are all references to commits. All references are named with a slash-separated path name starting with <code>refs</code>; the names we’ve been using so far are actually shorthand:</p> <div class="ulist"> <ul> <li> <p>The branch <code>test</code> is short for <code>refs/heads/test</code>.</p> </li> <li> <p>The tag <code>v2.6.18</code> is short for <code>refs/tags/v2.6.18</code>.</p> </li> <li> <p><code>origin/master</code> is short for <code>refs/remotes/origin/master</code>.</p> </li> </ul> </div> <p>The full name is occasionally useful if, for example, there ever exists a tag and a branch with the same name.</p> <p>(Newly created refs are actually stored in the <code>.git/refs</code> directory, under the path given by their name. However, for efficiency reasons they may also be packed together in a single file; see <a href="git-pack-refs">git-pack-refs[1]</a>).</p> <p>As another useful shortcut, the "HEAD" of a repository can be referred to just using the name of that repository. So, for example, "origin" is usually a shortcut for the HEAD branch in the repository "origin".</p> <p>For the complete list of paths which Git checks for references, and the order it uses to decide which to choose when there are multiple references with the same shorthand name, see the "SPECIFYING REVISIONS" section of <a href="gitrevisions">gitrevisions[7]</a>.</p> </div> <div class="sect2"> <h3 id="Updating-a-repository-With-git-fetch"> +Updating a repository with git fetch</h3> <p>After you clone a repository and commit a few changes of your own, you may wish to check the original repository for updates.</p> <p>The <code>git-fetch</code> command, with no arguments, will update all of the remote-tracking branches to the latest version found in the original repository. It will not touch any of your own branches—not even the "master" branch that was created for you on clone.</p> </div> <div class="sect2"> <h3 id="fetching-branches"> +Fetching branches from other repositories</h3> <p>You can also track branches from repositories other than the one you cloned from, using <a href="git-remote">git-remote[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git remote add staging git://git.kernel.org/.../gregkh/staging.git +$ git fetch staging +... +From git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging + * [new branch] master -> staging/master + * [new branch] staging-linus -> staging/staging-linus + * [new branch] staging-next -> staging/staging-next</pre> </div> </div> <p>New remote-tracking branches will be stored under the shorthand name that you gave <code>git remote add</code>, in this case <code>staging</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch -r + origin/HEAD -> origin/master + origin/master + staging/master + staging/staging-linus + staging/staging-next</pre> </div> </div> <p>If you run <code>git fetch <remote></code> later, the remote-tracking branches for the named <code><remote></code> will be updated.</p> <p>If you examine the file <code>.git/config</code>, you will see that Git has added a new stanza:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat .git/config +... +[remote "staging"] + url = git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git + fetch = +refs/heads/*:refs/remotes/staging/* +...</pre> </div> </div> <p>This is what causes Git to track the remote’s branches; you may modify or delete these configuration options by editing <code>.git/config</code> with a text editor. (See the "CONFIGURATION FILE" section of <a href="git-config">git-config[1]</a> for details.)</p> </div> </div> <h2 id="exploring-git-history">Exploring git history</h2> <div class="sectionbody"> <p>Git is best thought of as a tool for storing the history of a collection of files. It does this by storing compressed snapshots of the contents of a file hierarchy, together with "commits" which show the relationships between these snapshots.</p> <p>Git provides extremely flexible and fast tools for exploring the history of a project.</p> <p>We start with one specialized tool that is useful for finding the commit that introduced a bug into a project.</p> <div class="sect2"> <h3 id="using-bisect"> +How to use bisect to find a regression</h3> <p>Suppose version 2.6.18 of your project worked, but the version at "master" crashes. Sometimes the best way to find the cause of such a regression is to perform a brute-force search through the project’s history to find the particular commit that caused the problem. The <a href="git-bisect">git-bisect[1]</a> command can help you do this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start +$ git bisect good v2.6.18 +$ git bisect bad master +Bisecting: 3537 revisions left to test after this +[65934a9a028b88e83e2b0f8b36618fe503349f8e] BLOCK: Make USB storage depend on SCSI rather than selecting it [try #6]</pre> </div> </div> <p>If you run <code>git branch</code> at this point, you’ll see that Git has temporarily moved you in "(no branch)". HEAD is now detached from any branch and points directly to a commit (with commit id 65934) that is reachable from "master" but not from v2.6.18. Compile and test it, and see whether it crashes. Assume it does crash. Then:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect bad +Bisecting: 1769 revisions left to test after this +[7eff82c8b1511017ae605f0c99ac275a7e21b867] i2c-core: Drop useless bitmaskings</pre> </div> </div> <p>checks out an older version. Continue like this, telling Git at each stage whether the version it gives you is good or bad, and notice that the number of revisions left to test is cut approximately in half each time.</p> <p>After about 13 tests (in this case), it will output the commit id of the guilty commit. You can then examine the commit with <a href="git-show">git-show[1]</a>, find out who wrote it, and mail them your bug report with the commit id. Finally, run</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect reset</pre> </div> </div> <p>to return you to the branch you were on before.</p> <p>Note that the version which <code>git bisect</code> checks out for you at each point is just a suggestion, and you’re free to try a different version if you think it would be a good idea. For example, occasionally you may land on a commit that broke something unrelated; run</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect visualize</pre> </div> </div> <p>which will run gitk and label the commit it chose with a marker that says "bisect". Choose a safe-looking commit nearby, note its commit id, and check it out with:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git reset --hard fb47ddb2db</pre> </div> </div> <p>then test, run <code>bisect good</code> or <code>bisect bad</code> as appropriate, and continue.</p> <p>Instead of <code>git bisect visualize</code> and then <code>git reset --hard +fb47ddb2db</code>, you might just want to tell Git that you want to skip the current commit:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect skip</pre> </div> </div> <p>In this case, though, Git may not eventually be able to tell the first bad one between some first skipped commits and a later bad commit.</p> <p>There are also ways to automate the bisecting process if you have a test script that can tell a good from a bad commit. See <a href="git-bisect">git-bisect[1]</a> for more information about this and other <code>git +bisect</code> features.</p> </div> <div class="sect2"> <h3 id="naming-commits"> +Naming commits</h3> <p>We have seen several ways of naming commits already:</p> <div class="ulist"> <ul> <li> <p>40-hexdigit object name</p> </li> <li> <p>branch name: refers to the commit at the head of the given branch</p> </li> <li> <p>tag name: refers to the commit pointed to by the given tag (we’ve seen branches and tags are special cases of <a href="#how-git-stores-references">references</a>).</p> </li> <li> <p>HEAD: refers to the head of the current branch</p> </li> </ul> </div> <p>There are many more; see the "SPECIFYING REVISIONS" section of the <a href="gitrevisions">gitrevisions[7]</a> man page for the complete list of ways to name revisions. Some examples:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show fb47ddb2 # the first few characters of the object name + # are usually enough to specify it uniquely +$ git show HEAD^ # the parent of the HEAD commit +$ git show HEAD^^ # the grandparent +$ git show HEAD~4 # the great-great-grandparent</pre> </div> </div> <p>Recall that merge commits may have more than one parent; by default, <code>^</code> and <code>~</code> follow the first parent listed in the commit, but you can also choose:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show HEAD^1 # show the first parent of HEAD +$ git show HEAD^2 # show the second parent of HEAD</pre> </div> </div> <p>In addition to HEAD, there are several other special names for commits:</p> <p>Merges (to be discussed later), as well as operations such as <code>git reset</code>, which change the currently checked-out commit, generally set ORIG_HEAD to the value HEAD had before the current operation.</p> <p>The <code>git fetch</code> operation always stores the head of the last fetched branch in FETCH_HEAD. For example, if you run <code>git fetch</code> without specifying a local branch as the target of the operation</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch git://example.com/proj.git theirbranch</pre> </div> </div> <p>the fetched commits will still be available from FETCH_HEAD.</p> <p>When we discuss merges we’ll also see the special name MERGE_HEAD, which refers to the other branch that we’re merging in to the current branch.</p> <p>The <a href="git-rev-parse">git-rev-parse[1]</a> command is a low-level command that is occasionally useful for translating some name for a commit to the object name for that commit:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rev-parse origin +e05db0fd4f31dde7005f075a84f96b360d05984b</pre> </div> </div> </div> <div class="sect2"> <h3 id="creating-tags"> +Creating tags</h3> <p>We can also create a tag to refer to a particular commit; after running</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git tag stable-1 1b2e1d63ff</pre> </div> </div> <p>You can use <code>stable-1</code> to refer to the commit 1b2e1d63ff.</p> <p>This creates a "lightweight" tag. If you would also like to include a comment with the tag, and possibly sign it cryptographically, then you should create a tag object instead; see the <a href="git-tag">git-tag[1]</a> man page for details.</p> </div> <div class="sect2"> <h3 id="browsing-revisions"> +Browsing revisions</h3> <p>The <a href="git-log">git-log[1]</a> command can show lists of commits. On its own, it shows all commits reachable from the parent commit; but you can also make more specific requests:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log v2.5.. # commits since (not reachable from) v2.5 +$ git log test..master # commits reachable from master but not test +$ git log master..test # ...reachable from test but not master +$ git log master...test # ...reachable from either test or master, + # but not both +$ git log --since="2 weeks ago" # commits from the last 2 weeks +$ git log Makefile # commits which modify Makefile +$ git log fs/ # ... which modify any file under fs/ +$ git log -S'foo()' # commits which add or remove any file data + # matching the string 'foo()'</pre> </div> </div> <p>And of course you can combine all of these; the following finds commits since v2.5 which touch the <code>Makefile</code> or any file under <code>fs</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log v2.5.. Makefile fs/</pre> </div> </div> <p>You can also ask git log to show patches:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log -p</pre> </div> </div> <p>See the <code>--pretty</code> option in the <a href="git-log">git-log[1]</a> man page for more display options.</p> <p>Note that git log starts with the most recent commit and works backwards through the parents; however, since Git history can contain multiple independent lines of development, the particular order that commits are listed in may be somewhat arbitrary.</p> </div> <div class="sect2"> <h3 id="generating-diffs"> +Generating diffs</h3> <p>You can generate diffs between any two versions using <a href="git-diff">git-diff[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff master..test</pre> </div> </div> <p>That will produce the diff between the tips of the two branches. If you’d prefer to find the diff from their common ancestor to test, you can use three dots instead of two:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff master...test</pre> </div> </div> <p>Sometimes what you want instead is a set of patches; for this you can use <a href="git-format-patch">git-format-patch[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git format-patch master..test</pre> </div> </div> <p>will generate a file with a patch for each commit reachable from test but not from master.</p> </div> <div class="sect2"> <h3 id="viewing-old-file-versions"> +Viewing old file versions</h3> <p>You can always view an old version of a file by just checking out the correct revision first. But sometimes it is more convenient to be able to view an old version of a single file without checking anything out; this command does that:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show v2.5:fs/locks.c</pre> </div> </div> <p>Before the colon may be anything that names a commit, and after it may be any path to a file tracked by Git.</p> </div> <div class="sect2"> <h3 id="history-examples"> +Examples</h3> <div class="sect3"> <h4 id="counting-commits-on-a-branch"> +Counting the number of commits on a branch</h4> <p>Suppose you want to know how many commits you’ve made on <code>mybranch</code> since it diverged from <code>origin</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log --pretty=oneline origin..mybranch | wc -l</pre> </div> </div> <p>Alternatively, you may often see this sort of thing done with the lower-level command <a href="git-rev-list">git-rev-list[1]</a>, which just lists the SHA-1’s of all the given commits:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rev-list origin..mybranch | wc -l</pre> </div> </div> </div> <div class="sect3"> <h4 id="checking-for-equal-branches"> +Check whether two branches point at the same history</h4> <p>Suppose you want to check whether two branches point at the same point in history.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff origin..master</pre> </div> </div> <p>will tell you whether the contents of the project are the same at the two branches; in theory, however, it’s possible that the same project contents could have been arrived at by two different historical routes. You could compare the object names:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rev-list origin +e05db0fd4f31dde7005f075a84f96b360d05984b +$ git rev-list master +e05db0fd4f31dde7005f075a84f96b360d05984b</pre> </div> </div> <p>Or you could recall that the <code>...</code> operator selects all commits reachable from either one reference or the other but not both; so</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log origin...master</pre> </div> </div> <p>will return no commits when the two branches are equal.</p> </div> <div class="sect3"> <h4 id="finding-tagged-descendants"> +Find first tagged version including a given fix</h4> <p>Suppose you know that the commit e05db0fd fixed a certain problem. You’d like to find the earliest tagged release that contains that fix.</p> <p>Of course, there may be more than one answer—if the history branched after commit e05db0fd, then there could be multiple "earliest" tagged releases.</p> <p>You could just visually inspect the commits since e05db0fd:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ gitk e05db0fd..</pre> </div> </div> <p>or you can use <a href="git-name-rev">git-name-rev[1]</a>, which will give the commit a name based on any tag it finds pointing to one of the commit’s descendants:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git name-rev --tags e05db0fd +e05db0fd tags/v1.5.0-rc1^0~23</pre> </div> </div> <p>The <a href="git-describe">git-describe[1]</a> command does the opposite, naming the revision using a tag on which the given commit is based:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git describe e05db0fd +v1.5.0-rc0-260-ge05db0f</pre> </div> </div> <p>but that may sometimes help you guess which tags might come after the given commit.</p> <p>If you just want to verify whether a given tagged version contains a given commit, you could use <a href="git-merge-base">git-merge-base[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git merge-base e05db0fd v1.5.0-rc1 +e05db0fd4f31dde7005f075a84f96b360d05984b</pre> </div> </div> <p>The merge-base command finds a common ancestor of the given commits, and always returns one or the other in the case where one is a descendant of the other; so the above output shows that e05db0fd actually is an ancestor of v1.5.0-rc1.</p> <p>Alternatively, note that</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log v1.5.0-rc1..e05db0fd</pre> </div> </div> <p>will produce empty output if and only if v1.5.0-rc1 includes e05db0fd, because it outputs only commits that are not reachable from v1.5.0-rc1.</p> <p>As yet another alternative, the <a href="git-show-branch">git-show-branch[1]</a> command lists the commits reachable from its arguments with a display on the left-hand side that indicates which arguments that commit is reachable from. So, if you run something like</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show-branch e05db0fd v1.5.0-rc0 v1.5.0-rc1 v1.5.0-rc2 +! [e05db0fd] Fix warnings in sha1_file.c - use C99 printf format if +available + ! [v1.5.0-rc0] GIT v1.5.0 preview + ! [v1.5.0-rc1] GIT v1.5.0-rc1 + ! [v1.5.0-rc2] GIT v1.5.0-rc2 +...</pre> </div> </div> <p>then a line like</p> <div class="listingblock"> <div class="content"> <pre>+ ++ [e05db0fd] Fix warnings in sha1_file.c - use C99 printf format if +available</pre> </div> </div> <p>shows that e05db0fd is reachable from itself, from v1.5.0-rc1, and from v1.5.0-rc2, and not from v1.5.0-rc0.</p> </div> <div class="sect3"> <h4 id="showing-commits-unique-to-a-branch"> +Showing commits unique to a given branch</h4> <p>Suppose you would like to see all the commits reachable from the branch head named <code>master</code> but not from any other head in your repository.</p> <p>We can list all the heads in this repository with <a href="git-show-ref">git-show-ref[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show-ref --heads +bf62196b5e363d73353a9dcf094c59595f3153b7 refs/heads/core-tutorial +db768d5504c1bb46f63ee9d6e1772bd047e05bf9 refs/heads/maint +a07157ac624b2524a059a3414e99f6f44bebc1e7 refs/heads/master +24dbc180ea14dc1aebe09f14c8ecf32010690627 refs/heads/tutorial-2 +1e87486ae06626c2f31eaa63d26fc0fd646c8af2 refs/heads/tutorial-fixes</pre> </div> </div> <p>We can get just the branch-head names, and remove <code>master</code>, with the help of the standard utilities cut and grep:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show-ref --heads | cut -d' ' -f2 | grep -v '^refs/heads/master' +refs/heads/core-tutorial +refs/heads/maint +refs/heads/tutorial-2 +refs/heads/tutorial-fixes</pre> </div> </div> <p>And then we can ask to see all the commits reachable from master but not from these other heads:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ gitk master --not $( git show-ref --heads | cut -d' ' -f2 | + grep -v '^refs/heads/master' )</pre> </div> </div> <p>Obviously, endless variations are possible; for example, to see all commits reachable from some head but not from any tag in the repository:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ gitk $( git show-ref --heads ) --not $( git show-ref --tags )</pre> </div> </div> <p>(See <a href="gitrevisions">gitrevisions[7]</a> for explanations of commit-selecting syntax such as <code>--not</code>.)</p> </div> <div class="sect3"> <h4 id="making-a-release"> +Creating a changelog and tarball for a software release</h4> <p>The <a href="git-archive">git-archive[1]</a> command can create a tar or zip archive from any version of a project; for example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git archive -o latest.tar.gz --prefix=project/ HEAD</pre> </div> </div> <p>will use HEAD to produce a gzipped tar archive in which each filename is preceded by <code>project/</code>. The output file format is inferred from the output file extension if possible, see <a href="git-archive">git-archive[1]</a> for details.</p> <p>Versions of Git older than 1.7.7 don’t know about the <code>tar.gz</code> format, you’ll need to use gzip explicitly:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git archive --format=tar --prefix=project/ HEAD | gzip >latest.tar.gz</pre> </div> </div> <p>If you’re releasing a new version of a software project, you may want to simultaneously make a changelog to include in the release announcement.</p> <p>Linus Torvalds, for example, makes new kernel releases by tagging them, then running:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ release-script 2.6.12 2.6.13-rc6 2.6.13-rc7</pre> </div> </div> <p>where release-script is a shell script that looks like:</p> <div class="listingblock"> <div class="content"> <pre>#!/bin/sh +stable="$1" +last="$2" +new="$3" +echo "# git tag v$new" +echo "git archive --prefix=linux-$new/ v$new | gzip -9 > ../linux-$new.tar.gz" +echo "git diff v$stable v$new | gzip -9 > ../patch-$new.gz" +echo "git log --no-merges v$new ^v$last > ../ChangeLog-$new" +echo "git shortlog --no-merges v$new ^v$last > ../ShortLog" +echo "git diff --stat --summary -M v$last v$new > ../diffstat-$new"</pre> </div> </div> <p>and then he just cut-and-pastes the output commands after verifying that they look OK.</p> </div> <div class="sect3"> <h4 id="Finding-commits-With-given-Content"> +Finding commits referencing a file with given content</h4> <p>Somebody hands you a copy of a file, and asks which commits modified a file such that it contained the given content either before or after the commit. You can find out with this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log --raw --abbrev=40 --pretty=oneline | + grep -B 1 `git hash-object filename`</pre> </div> </div> <p>Figuring out why this works is left as an exercise to the (advanced) student. The <a href="git-log">git-log[1]</a>, <a href="git-diff-tree">git-diff-tree[1]</a>, and <a href="git-hash-object">git-hash-object[1]</a> man pages may prove helpful.</p> </div> </div> </div> <h2 id="Developing-With-git">Developing with git</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="telling-git-your-name"> +Telling Git your name</h3> <p>Before creating any commits, you should introduce yourself to Git. The easiest way to do so is to use <a href="git-config">git-config[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config --global user.name 'Your Name Comes Here' +$ git config --global user.email 'you@yourdomain.example.com'</pre> </div> </div> <p>Which will add the following to a file named <code>.gitconfig</code> in your home directory:</p> <div class="listingblock"> <div class="content"> <pre>[user] + name = Your Name Comes Here + email = you@yourdomain.example.com</pre> </div> </div> <p>See the "CONFIGURATION FILE" section of <a href="git-config">git-config[1]</a> for details on the configuration file. The file is plain text, so you can also edit it with your favorite editor.</p> </div> <div class="sect2"> <h3 id="creating-a-new-repository"> +Creating a new repository</h3> <p>Creating a new repository from scratch is very easy:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ mkdir project +$ cd project +$ git init</pre> </div> </div> <p>If you have some initial content (say, a tarball):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ tar xzvf project.tar.gz +$ cd project +$ git init +$ git add . # include everything below ./ in the first commit: +$ git commit</pre> </div> </div> </div> <div class="sect2"> <h3 id="how-to-make-a-commit"> +How to make a commit</h3> <p>Creating a new commit takes three steps:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Making some changes to the working directory using your favorite editor.</p> </li> <li> <p>Telling Git about your changes.</p> </li> <li> <p>Creating the commit using the content you told Git about in step 2.</p> </li> </ol> </div> <p>In practice, you can interleave and repeat steps 1 and 2 as many times as you want: in order to keep track of what you want committed at step 3, Git maintains a snapshot of the tree’s contents in a special staging area called "the index."</p> <p>At the beginning, the content of the index will be identical to that of the HEAD. The command <code>git diff --cached</code>, which shows the difference between the HEAD and the index, should therefore produce no output at that point.</p> <p>Modifying the index is easy:</p> <p>To update the index with the contents of a new or modified file, use</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git add path/to/file</pre> </div> </div> <p>To remove a file from the index and from the working tree, use</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rm path/to/file</pre> </div> </div> <p>After each step you can verify that</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff --cached</pre> </div> </div> <p>always shows the difference between the HEAD and the index file—this is what you’d commit if you created the commit now—and that</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff</pre> </div> </div> <p>shows the difference between the working tree and the index file.</p> <p>Note that <code>git add</code> always adds just the current contents of a file to the index; further changes to the same file will be ignored unless you run <code>git add</code> on the file again.</p> <p>When you’re ready, just run</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit</pre> </div> </div> <p>and Git will prompt you for a commit message and then create the new commit. Check to make sure it looks like what you expected with</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show</pre> </div> </div> <p>As a special shortcut,</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit -a</pre> </div> </div> <p>will update the index with any files that you’ve modified or removed and create a commit, all in one step.</p> <p>A number of commands are useful for keeping track of what you’re about to commit:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff --cached # difference between HEAD and the index; what + # would be committed if you ran "commit" now. +$ git diff # difference between the index file and your + # working directory; changes that would not + # be included if you ran "commit" now. +$ git diff HEAD # difference between HEAD and working tree; what + # would be committed if you ran "commit -a" now. +$ git status # a brief per-file summary of the above.</pre> </div> </div> <p>You can also use <a href="git-gui">git-gui[1]</a> to create commits, view changes in the index and the working tree files, and individually select diff hunks for inclusion in the index (by right-clicking on the diff hunk and choosing "Stage Hunk For Commit").</p> </div> <div class="sect2"> <h3 id="creating-good-commit-messages"> +Creating good commit messages</h3> <p>Though not required, it’s a good idea to begin the commit message with a single short (no more than 50 characters) line summarizing the change, followed by a blank line and then a more thorough description. The text up to the first blank line in a commit message is treated as the commit title, and that title is used throughout Git. For example, <a href="git-format-patch">git-format-patch[1]</a> turns a commit into email, and it uses the title on the Subject line and the rest of the commit in the body.</p> </div> <div class="sect2"> <h3 id="ignoring-files"> +Ignoring files</h3> <p>A project will often generate files that you do <code>not</code> want to track with Git. This typically includes files generated by a build process or temporary backup files made by your editor. Of course, <code>not</code> tracking files with Git is just a matter of <code>not</code> calling <code>git add</code> on them. But it quickly becomes annoying to have these untracked files lying around; e.g. they make <code>git add .</code> practically useless, and they keep showing up in the output of <code>git status</code>.</p> <p>You can tell Git to ignore certain files by creating a file called <code>.gitignore</code> in the top level of your working directory, with contents such as:</p> <div class="listingblock"> <div class="content"> <pre># Lines starting with '#' are considered comments. +# Ignore any file named foo.txt. +foo.txt +# Ignore (generated) html files, +*.html +# except foo.html which is maintained by hand. +!foo.html +# Ignore objects and archives. +*.[oa]</pre> </div> </div> <p>See <a href="gitignore">gitignore[5]</a> for a detailed explanation of the syntax. You can also place .gitignore files in other directories in your working tree, and they will apply to those directories and their subdirectories. The <code>.gitignore</code> files can be added to your repository like any other files (just run <code>git add +.gitignore</code> and <code>git commit</code>, as usual), which is convenient when the exclude patterns (such as patterns matching build output files) would also make sense for other users who clone your repository.</p> <p>If you wish the exclude patterns to affect only certain repositories (instead of every repository for a given project), you may instead put them in a file in your repository named <code>.git/info/exclude</code>, or in any file specified by the <code>core.excludesFile</code> configuration variable. Some Git commands can also take exclude patterns directly on the command line. See <a href="gitignore">gitignore[5]</a> for the details.</p> </div> <div class="sect2"> <h3 id="how-to-merge"> +How to merge</h3> <p>You can rejoin two diverging branches of development using <a href="git-merge">git-merge[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git merge branchname</pre> </div> </div> <p>merges the development in the branch <code>branchname</code> into the current branch.</p> <p>A merge is made by combining the changes made in <code>branchname</code> and the changes made up to the latest commit in your current branch since their histories forked. The work tree is overwritten by the result of the merge when this combining is done cleanly, or overwritten by a half-merged results when this combining results in conflicts. Therefore, if you have uncommitted changes touching the same files as the ones impacted by the merge, Git will refuse to proceed. Most of the time, you will want to commit your changes before you can merge, and if you don’t, then <a href="git-stash">git-stash[1]</a> can take these changes away while you’re doing the merge, and reapply them afterwards.</p> <p>If the changes are independent enough, Git will automatically complete the merge and commit the result (or reuse an existing commit in case of <a href="#fast-forwards">fast-forward</a>, see below). On the other hand, if there are conflicts—for example, if the same file is modified in two different ways in the remote branch and the local branch—then you are warned; the output may look something like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git merge next + 100% (4/4) done +Auto-merged file.txt +CONFLICT (content): Merge conflict in file.txt +Automatic merge failed; fix conflicts and then commit the result.</pre> </div> </div> <p>Conflict markers are left in the problematic files, and after you resolve the conflicts manually, you can update the index with the contents and run Git commit, as you normally would when creating a new file.</p> <p>If you examine the resulting commit using gitk, you will see that it has two parents, one pointing to the top of the current branch, and one to the top of the other branch.</p> </div> <div class="sect2"> <h3 id="resolving-a-merge"> +Resolving a merge</h3> <p>When a merge isn’t resolved automatically, Git leaves the index and the working tree in a special state that gives you all the information you need to help resolve the merge.</p> <p>Files with conflicts are marked specially in the index, so until you resolve the problem and update the index, <a href="git-commit">git-commit[1]</a> will fail:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit +file.txt: needs merge</pre> </div> </div> <p>Also, <a href="git-status">git-status[1]</a> will list those files as "unmerged", and the files with conflicts will have conflict markers added, like this:</p> <div class="listingblock"> <div class="content"> <pre><<<<<<< HEAD:file.txt +Hello world +======= +Goodbye +>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt</pre> </div> </div> <p>All you need to do is edit the files to resolve the conflicts, and then</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git add file.txt +$ git commit</pre> </div> </div> <p>Note that the commit message will already be filled in for you with some information about the merge. Normally you can just use this default message unchanged, but you may add additional commentary of your own if desired.</p> <p>The above is all you need to know to resolve a simple merge. But Git also provides more information to help resolve conflicts:</p> <div class="sect3"> <h4 id="conflict-resolution"> +Getting conflict-resolution help during a merge</h4> <p>All of the changes that Git was able to merge automatically are already added to the index file, so <a href="git-diff">git-diff[1]</a> shows only the conflicts. It uses an unusual syntax:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff +diff --cc file.txt +index 802992c,2b60207..0000000 +--- a/file.txt ++++ b/file.txt +@@@ -1,1 -1,1 +1,5 @@@ +++<<<<<<< HEAD:file.txt + +Hello world +++======= ++ Goodbye +++>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt</pre> </div> </div> <p>Recall that the commit which will be committed after we resolve this conflict will have two parents instead of the usual one: one parent will be HEAD, the tip of the current branch; the other will be the tip of the other branch, which is stored temporarily in MERGE_HEAD.</p> <p>During the merge, the index holds three versions of each file. Each of these three "file stages" represents a different version of the file:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show :1:file.txt # the file in a common ancestor of both branches +$ git show :2:file.txt # the version from HEAD. +$ git show :3:file.txt # the version from MERGE_HEAD.</pre> </div> </div> <p>When you ask <a href="git-diff">git-diff[1]</a> to show the conflicts, it runs a three-way diff between the conflicted merge results in the work tree with stages 2 and 3 to show only hunks whose contents come from both sides, mixed (in other words, when a hunk’s merge results come only from stage 2, that part is not conflicting and is not shown. Same for stage 3).</p> <p>The diff above shows the differences between the working-tree version of file.txt and the stage 2 and stage 3 versions. So instead of preceding each line by a single <code>+</code> or <code>-</code>, it now uses two columns: the first column is used for differences between the first parent and the working directory copy, and the second for differences between the second parent and the working directory copy. (See the "COMBINED DIFF FORMAT" section of <a href="git-diff-files">git-diff-files[1]</a> for a details of the format.)</p> <p>After resolving the conflict in the obvious way (but before updating the index), the diff will look like:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff +diff --cc file.txt +index 802992c,2b60207..0000000 +--- a/file.txt ++++ b/file.txt +@@@ -1,1 -1,1 +1,1 @@@ +- Hello world + -Goodbye +++Goodbye world</pre> </div> </div> <p>This shows that our resolved version deleted "Hello world" from the first parent, deleted "Goodbye" from the second parent, and added "Goodbye world", which was previously absent from both.</p> <p>Some special diff options allow diffing the working directory against any of these stages:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff -1 file.txt # diff against stage 1 +$ git diff --base file.txt # same as the above +$ git diff -2 file.txt # diff against stage 2 +$ git diff --ours file.txt # same as the above +$ git diff -3 file.txt # diff against stage 3 +$ git diff --theirs file.txt # same as the above.</pre> </div> </div> <p>When using the <code>ort</code> merge strategy (the default), before updating the working tree with the result of the merge, Git writes a ref named AUTO_MERGE reflecting the state of the tree it is about to write. Conflicted paths with textual conflicts that could not be automatically merged are written to this tree with conflict markers, just as in the working tree. AUTO_MERGE can thus be used with <a href="git-diff">git-diff[1]</a> to show the changes you’ve made so far to resolve conflicts. Using the same example as above, after resolving the conflict we get:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff AUTO_MERGE +diff --git a/file.txt b/file.txt +index cd10406..8bf5ae7 100644 +--- a/file.txt ++++ b/file.txt +@@ -1,5 +1 @@ +-<<<<<<< HEAD:file.txt +-Hello world +-======= +-Goodbye +->>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt ++Goodbye world</pre> </div> </div> <p>Notice that the diff shows we deleted the conflict markers and both versions of the content line, and wrote "Goodbye world" instead.</p> <p>The <a href="git-log">git-log[1]</a> and <a href="gitk">gitk[1]</a> commands also provide special help for merges:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log --merge +$ gitk --merge</pre> </div> </div> <p>These will display all commits which exist only on HEAD or on MERGE_HEAD, and which touch an unmerged file.</p> <p>You may also use <a href="git-mergetool">git-mergetool[1]</a>, which lets you merge the unmerged files using external tools such as Emacs or kdiff3.</p> <p>Each time you resolve the conflicts in a file and update the index:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git add file.txt</pre> </div> </div> <p>the different stages of that file will be "collapsed", after which <code>git diff</code> will (by default) no longer show diffs for that file.</p> </div> </div> <div class="sect2"> <h3 id="undoing-a-merge"> +Undoing a merge</h3> <p>If you get stuck and decide to just give up and throw the whole mess away, you can always return to the pre-merge state with</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git merge --abort</pre> </div> </div> <p>Or, if you’ve already committed the merge that you want to throw away,</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git reset --hard ORIG_HEAD</pre> </div> </div> <p>However, this last command can be dangerous in some cases—never throw away a commit you have already committed if that commit may itself have been merged into another branch, as doing so may confuse further merges.</p> </div> <div class="sect2"> <h3 id="fast-forwards"> +Fast-forward merges</h3> <p>There is one special case not mentioned above, which is treated differently. Normally, a merge results in a merge commit, with two parents, one pointing at each of the two lines of development that were merged.</p> <p>However, if the current branch is an ancestor of the other—so every commit present in the current branch is already contained in the other branch—then Git just performs a "fast-forward"; the head of the current branch is moved forward to point at the head of the merged-in branch, without any new commits being created.</p> </div> <div class="sect2"> <h3 id="fixing-mistakes"> +Fixing mistakes</h3> <p>If you’ve messed up the working tree, but haven’t yet committed your mistake, you can return the entire working tree to the last committed state with</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git restore --staged --worktree :/</pre> </div> </div> <p>If you make a commit that you later wish you hadn’t, there are two fundamentally different ways to fix the problem:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>You can create a new commit that undoes whatever was done by the old commit. This is the correct thing if your mistake has already been made public.</p> </li> <li> <p>You can go back and modify the old commit. You should never do this if you have already made the history public; Git does not normally expect the "history" of a project to change, and cannot correctly perform repeated merges from a branch that has had its history changed.</p> </li> </ol> </div> <div class="sect3"> <h4 id="reverting-a-commit"> +Fixing a mistake with a new commit</h4> <p>Creating a new commit that reverts an earlier change is very easy; just pass the <a href="git-revert">git-revert[1]</a> command a reference to the bad commit; for example, to revert the most recent commit:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git revert HEAD</pre> </div> </div> <p>This will create a new commit which undoes the change in HEAD. You will be given a chance to edit the commit message for the new commit.</p> <p>You can also revert an earlier change, for example, the next-to-last:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git revert HEAD^</pre> </div> </div> <p>In this case Git will attempt to undo the old change while leaving intact any changes made since then. If more recent changes overlap with the changes to be reverted, then you will be asked to fix conflicts manually, just as in the case of <a href="#resolving-a-merge">resolving a merge</a>.</p> </div> <div class="sect3"> <h4 id="fixing-a-mistake-by-rewriting-history"> +Fixing a mistake by rewriting history</h4> <p>If the problematic commit is the most recent commit, and you have not yet made that commit public, then you may just <a href="#undoing-a-merge">destroy it using <code>git reset</code></a>.</p> <p>Alternatively, you can edit the working directory and update the index to fix your mistake, just as if you were going to <a href="#how-to-make-a-commit">create a new commit</a>, then run</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit --amend</pre> </div> </div> <p>which will replace the old commit by a new commit incorporating your changes, giving you a chance to edit the old commit message first.</p> <p>Again, you should never do this to a commit that may already have been merged into another branch; use <a href="git-revert">git-revert[1]</a> instead in that case.</p> <p>It is also possible to replace commits further back in the history, but this is an advanced topic to be left for <a href="#cleaning-up-history">another chapter</a>.</p> </div> <div class="sect3"> <h4 id="checkout-of-path"> +Checking out an old version of a file</h4> <p>In the process of undoing a previous bad change, you may find it useful to check out an older version of a particular file using <a href="git-restore">git-restore[1]</a>. The command</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git restore --source=HEAD^ path/to/file</pre> </div> </div> <p>replaces path/to/file by the contents it had in the commit HEAD^, and also updates the index to match. It does not change branches.</p> <p>If you just want to look at an old version of the file, without modifying the working directory, you can do that with <a href="git-show">git-show[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show HEAD^:path/to/file</pre> </div> </div> <p>which will display the given version of the file.</p> </div> <div class="sect3"> <h4 id="interrupted-work"> +Temporarily setting aside work in progress</h4> <p>While you are in the middle of working on something complicated, you find an unrelated but obvious and trivial bug. You would like to fix it before continuing. You can use <a href="git-stash">git-stash[1]</a> to save the current state of your work, and after fixing the bug (or, optionally after doing so on a different branch and then coming back), unstash the work-in-progress changes.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git stash push -m "work in progress for foo feature"</pre> </div> </div> <p>This command will save your changes away to the <code>stash</code>, and reset your working tree and the index to match the tip of your current branch. Then you can make your fix as usual.</p> <div class="listingblock"> <div class="content"> <pre>... edit and test ... +$ git commit -a -m "blorpl: typofix"</pre> </div> </div> <p>After that, you can go back to what you were working on with <code>git stash pop</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git stash pop</pre> </div> </div> </div> </div> <div class="sect2"> <h3 id="ensuring-good-performance"> +Ensuring good performance</h3> <p>On large repositories, Git depends on compression to keep the history information from taking up too much space on disk or in memory. Some Git commands may automatically run <a href="git-gc">git-gc[1]</a>, so you don’t have to worry about running it manually. However, compressing a large repository may take a while, so you may want to call <code>gc</code> explicitly to avoid automatic compression kicking in when it is not convenient.</p> </div> <div class="sect2"> <h3 id="ensuring-reliability"> +Ensuring reliability</h3> <div class="sect3"> <h4 id="checking-for-corruption"> +Checking the repository for corruption</h4> <p>The <a href="git-fsck">git-fsck[1]</a> command runs a number of self-consistency checks on the repository, and reports on any problems. This may take some time.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fsck +dangling commit 7281251ddd2a61e38657c827739c57015671a6b3 +dangling commit 2706a059f258c6b245f298dc4ff2ccd30ec21a63 +dangling commit 13472b7c4b80851a1bc551779171dcb03655e9b5 +dangling blob 218761f9d90712d37a9c5e36f406f92202db07eb +dangling commit bf093535a34a4d35731aa2bd90fe6b176302f14f +dangling commit 8e4bec7f2ddaa268bef999853c25755452100f8e +dangling tree d50bb86186bf27b681d25af89d3b5b68382e4085 +dangling tree b24c2473f1fd3d91352a624795be026d64c8841f +...</pre> </div> </div> <p>You will see informational messages on dangling objects. They are objects that still exist in the repository but are no longer referenced by any of your branches, and can (and will) be removed after a while with <code>gc</code>. You can run <code>git fsck --no-dangling</code> to suppress these messages, and still view real errors.</p> </div> <div class="sect3"> <h4 id="recovering-lost-changes"> +Recovering lost changes</h4> <div class="sect4"> <h5 id="reflogs"> +Reflogs</h5> <p>Say you modify a branch with <a href="#fixing-mistakes"><code>git reset --hard</code></a>, and then realize that the branch was the only reference you had to that point in history.</p> <p>Fortunately, Git also keeps a log, called a "reflog", of all the previous values of each branch. So in this case you can still find the old history using, for example,</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log master@{1}</pre> </div> </div> <p>This lists the commits reachable from the previous version of the <code>master</code> branch head. This syntax can be used with any Git command that accepts a commit, not just with <code>git log</code>. Some other examples:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show master@{2} # See where the branch pointed 2, +$ git show master@{3} # 3, ... changes ago. +$ gitk master@{yesterday} # See where it pointed yesterday, +$ gitk master@{"1 week ago"} # ... or last week +$ git log --walk-reflogs master # show reflog entries for master</pre> </div> </div> <p>A separate reflog is kept for the HEAD, so</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show HEAD@{"1 week ago"}</pre> </div> </div> <p>will show what HEAD pointed to one week ago, not what the current branch pointed to one week ago. This allows you to see the history of what you’ve checked out.</p> <p>The reflogs are kept by default for 30 days, after which they may be pruned. See <a href="git-reflog">git-reflog[1]</a> and <a href="git-gc">git-gc[1]</a> to learn how to control this pruning, and see the "SPECIFYING REVISIONS" section of <a href="gitrevisions">gitrevisions[7]</a> for details.</p> <p>Note that the reflog history is very different from normal Git history. While normal history is shared by every repository that works on the same project, the reflog history is not shared: it tells you only about how the branches in your local repository have changed over time.</p> </div> <div class="sect4"> <h5 id="dangling-object-recovery"> +Examining dangling objects</h5> <p>In some situations the reflog may not be able to save you. For example, suppose you delete a branch, then realize you need the history it contained. The reflog is also deleted; however, if you have not yet pruned the repository, then you may still be able to find the lost commits in the dangling objects that <code>git fsck</code> reports. See <a href="#dangling-objects">Dangling objects</a> for the details.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fsck +dangling commit 7281251ddd2a61e38657c827739c57015671a6b3 +dangling commit 2706a059f258c6b245f298dc4ff2ccd30ec21a63 +dangling commit 13472b7c4b80851a1bc551779171dcb03655e9b5 +...</pre> </div> </div> <p>You can examine one of those dangling commits with, for example,</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ gitk 7281251ddd --not --all</pre> </div> </div> <p>which does what it sounds like: it says that you want to see the commit history that is described by the dangling commit(s), but not the history that is described by all your existing branches and tags. Thus you get exactly the history reachable from that commit that is lost. (And notice that it might not be just one commit: we only report the "tip of the line" as being dangling, but there might be a whole deep and complex commit history that was dropped.)</p> <p>If you decide you want the history back, you can always create a new reference pointing to it, for example, a new branch:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch recovered-branch 7281251ddd</pre> </div> </div> <p>Other types of dangling objects (blobs and trees) are also possible, and dangling objects can arise in other situations.</p> </div> </div> </div> </div> <h2 id="sharing-development">Sharing development with others</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="getting-updates-With-git-pull"> +Getting updates with git pull</h3> <p>After you clone a repository and commit a few changes of your own, you may wish to check the original repository for updates and merge them into your own work.</p> <p>We have already seen <a href="#Updating-a-repository-With-git-fetch">how to keep remote-tracking branches up to date</a> with <a href="git-fetch">git-fetch[1]</a>, and how to merge two branches. So you can merge in changes from the original repository’s master branch with:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch +$ git merge origin/master</pre> </div> </div> <p>However, the <a href="git-pull">git-pull[1]</a> command provides a way to do this in one step:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git pull origin master</pre> </div> </div> <p>In fact, if you have <code>master</code> checked out, then this branch has been configured by <code>git clone</code> to get changes from the HEAD branch of the origin repository. So often you can accomplish the above with just a simple</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git pull</pre> </div> </div> <p>This command will fetch changes from the remote branches to your remote-tracking branches <code>origin/*</code>, and merge the default branch into the current branch.</p> <p>More generally, a branch that is created from a remote-tracking branch will pull by default from that branch. See the descriptions of the <code>branch.<name>.remote</code> and <code>branch.<name>.merge</code> options in <a href="git-config">git-config[1]</a>, and the discussion of the <code>--track</code> option in <a href="git-checkout">git-checkout[1]</a>, to learn how to control these defaults.</p> <p>In addition to saving you keystrokes, <code>git pull</code> also helps you by producing a default commit message documenting the branch and repository that you pulled from.</p> <p>(But note that no such commit will be created in the case of a <a href="#fast-forwards">fast-forward</a>; instead, your branch will just be updated to point to the latest commit from the upstream branch.)</p> <p>The <code>git pull</code> command can also be given <code>.</code> as the "remote" repository, in which case it just merges in a branch from the current repository; so the commands</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git pull . branch +$ git merge branch</pre> </div> </div> <p>are roughly equivalent.</p> </div> <div class="sect2"> <h3 id="submitting-patches"> +Submitting patches to a project</h3> <p>If you just have a few changes, the simplest way to submit them may just be to send them as patches in email:</p> <p>First, use <a href="git-format-patch">git-format-patch[1]</a>; for example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git format-patch origin</pre> </div> </div> <p>will produce a numbered series of files in the current directory, one for each patch in the current branch but not in <code>origin/HEAD</code>.</p> <p><code>git format-patch</code> can include an initial "cover letter". You can insert commentary on individual patches after the three dash line which <code>format-patch</code> places after the commit message but before the patch itself. If you use <code>git notes</code> to track your cover letter material, <code>git format-patch --notes</code> will include the commit’s notes in a similar manner.</p> <p>You can then import these into your mail client and send them by hand. However, if you have a lot to send at once, you may prefer to use the <a href="git-send-email">git-send-email[1]</a> script to automate the process. Consult the mailing list for your project first to determine their requirements for submitting patches.</p> </div> <div class="sect2"> <h3 id="importing-patches"> +Importing patches to a project</h3> <p>Git also provides a tool called <a href="git-am">git-am[1]</a> (am stands for "apply mailbox"), for importing such an emailed series of patches. Just save all of the patch-containing messages, in order, into a single mailbox file, say <code>patches.mbox</code>, then run</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git am -3 patches.mbox</pre> </div> </div> <p>Git will apply each patch in order; if any conflicts are found, it will stop, and you can fix the conflicts as described in "<a href="#resolving-a-merge">Resolving a merge</a>". (The <code>-3</code> option tells Git to perform a merge; if you would prefer it just to abort and leave your tree and index untouched, you may omit that option.)</p> <p>Once the index is updated with the results of the conflict resolution, instead of creating a new commit, just run</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git am --continue</pre> </div> </div> <p>and Git will create the commit for you and continue applying the remaining patches from the mailbox.</p> <p>The final result will be a series of commits, one for each patch in the original mailbox, with authorship and commit log message each taken from the message containing each patch.</p> </div> <div class="sect2"> <h3 id="public-repositories"> +Public Git repositories</h3> <p>Another way to submit changes to a project is to tell the maintainer of that project to pull the changes from your repository using <a href="git-pull">git-pull[1]</a>. In the section "<a href="#getting-updates-With-git-pull">Getting updates with <code>git pull</code></a>" we described this as a way to get updates from the "main" repository, but it works just as well in the other direction.</p> <p>If you and the maintainer both have accounts on the same machine, then you can just pull changes from each other’s repositories directly; commands that accept repository URLs as arguments will also accept a local directory name:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git clone /path/to/repository +$ git pull /path/to/other/repository</pre> </div> </div> <p>or an ssh URL:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git clone ssh://yourhost/~you/repository</pre> </div> </div> <p>For projects with few developers, or for synchronizing a few private repositories, this may be all you need.</p> <p>However, the more common way to do this is to maintain a separate public repository (usually on a different host) for others to pull changes from. This is usually more convenient, and allows you to cleanly separate private work in progress from publicly visible work.</p> <p>You will continue to do your day-to-day work in your personal repository, but periodically "push" changes from your personal repository into your public repository, allowing other developers to pull from that repository. So the flow of changes, in a situation where there is one other developer with a public repository, looks like this:</p> <div class="literalblock"> <div class="content"> <pre> you push +your personal repo ------------------> your public repo + ^ | + | | + | you pull | they pull + | | + | | + | they push V +their public repo <------------------- their repo</pre> </div> </div> <p>We explain how to do this in the following sections.</p> <div class="sect3"> <h4 id="setting-up-a-public-repository"> +Setting up a public repository</h4> <p>Assume your personal repository is in the directory <code>~/proj</code>. We first create a new clone of the repository and tell <code>git daemon</code> that it is meant to be public:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git clone --bare ~/proj proj.git +$ touch proj.git/git-daemon-export-ok</pre> </div> </div> <p>The resulting directory proj.git contains a "bare" git repository—it is just the contents of the <code>.git</code> directory, without any files checked out around it.</p> <p>Next, copy <code>proj.git</code> to the server where you plan to host the public repository. You can use scp, rsync, or whatever is most convenient.</p> </div> <div class="sect3"> <h4 id="exporting-via-git"> +Exporting a Git repository via the Git protocol</h4> <p>This is the preferred method.</p> <p>If someone else administers the server, they should tell you what directory to put the repository in, and what <code>git://</code> URL it will appear at. You can then skip to the section "<a href="#pushing-changes-to-a-public-repository">Pushing changes to a public repository</a>", below.</p> <p>Otherwise, all you need to do is start <a href="git-daemon">git-daemon[1]</a>; it will listen on port 9418. By default, it will allow access to any directory that looks like a Git directory and contains the magic file git-daemon-export-ok. Passing some directory paths as <code>git daemon</code> arguments will further restrict the exports to those paths.</p> <p>You can also run <code>git daemon</code> as an inetd service; see the <a href="git-daemon">git-daemon[1]</a> man page for details. (See especially the examples section.)</p> </div> <div class="sect3"> <h4 id="exporting-via-http"> +Exporting a git repository via HTTP</h4> <p>The Git protocol gives better performance and reliability, but on a host with a web server set up, HTTP exports may be simpler to set up.</p> <p>All you need to do is place the newly created bare Git repository in a directory that is exported by the web server, and make some adjustments to give web clients some extra information they need:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ mv proj.git /home/you/public_html/proj.git +$ cd proj.git +$ git --bare update-server-info +$ mv hooks/post-update.sample hooks/post-update</pre> </div> </div> <p>(For an explanation of the last two lines, see <a href="git-update-server-info">git-update-server-info[1]</a> and <a href="githooks">githooks[5]</a>.)</p> <p>Advertise the URL of <code>proj.git</code>. Anybody else should then be able to clone or pull from that URL, for example with a command line like:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git clone http://yourserver.com/~you/proj.git</pre> </div> </div> <p>(See also <a href="https://git-scm.com/docs/howto/setup-git-server-over-http">setup-git-server-over-http</a> for a slightly more sophisticated setup using WebDAV which also allows pushing over HTTP.)</p> </div> <div class="sect3"> <h4 id="pushing-changes-to-a-public-repository"> +Pushing changes to a public repository</h4> <p>Note that the two techniques outlined above (exporting via <a href="#exporting-via-http">http</a> or <a href="#exporting-via-git">git</a>) allow other maintainers to fetch your latest changes, but they do not allow write access, which you will need to update the public repository with the latest changes created in your private repository.</p> <p>The simplest way to do this is using <a href="git-push">git-push[1]</a> and ssh; to update the remote branch named <code>master</code> with the latest state of your branch named <code>master</code>, run</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git push ssh://yourserver.com/~you/proj.git master:master</pre> </div> </div> <p>or just</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git push ssh://yourserver.com/~you/proj.git master</pre> </div> </div> <p>As with <code>git fetch</code>, <code>git push</code> will complain if this does not result in a <a href="#fast-forwards">fast-forward</a>; see the following section for details on handling this case.</p> <p>Note that the target of a <code>push</code> is normally a <a href="#def_bare_repository">bare</a> repository. You can also push to a repository that has a checked-out working tree, but a push to update the currently checked-out branch is denied by default to prevent confusion. See the description of the receive.denyCurrentBranch option in <a href="git-config">git-config[1]</a> for details.</p> <p>As with <code>git fetch</code>, you may also set up configuration options to save typing; so, for example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git remote add public-repo ssh://yourserver.com/~you/proj.git</pre> </div> </div> <p>adds the following to <code>.git/config</code>:</p> <div class="listingblock"> <div class="content"> <pre>[remote "public-repo"] + url = yourserver.com:proj.git + fetch = +refs/heads/*:refs/remotes/example/*</pre> </div> </div> <p>which lets you do the same push with just</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git push public-repo master</pre> </div> </div> <p>See the explanations of the <code>remote.<name>.url</code>, <code>branch.<name>.remote</code>, and <code>remote.<name>.push</code> options in <a href="git-config">git-config[1]</a> for details.</p> </div> <div class="sect3"> <h4 id="forcing-push"> +What to do when a push fails</h4> <p>If a push would not result in a <a href="#fast-forwards">fast-forward</a> of the remote branch, then it will fail with an error like:</p> <div class="listingblock"> <div class="content"> <pre> ! [rejected] master -> master (non-fast-forward) +error: failed to push some refs to '...' +hint: Updates were rejected because the tip of your current branch is behind +hint: its remote counterpart. Integrate the remote changes (e.g. +hint: 'git pull ...') before pushing again. +hint: See the 'Note about fast-forwards' in 'git push --help' for details.</pre> </div> </div> <p>This can happen, for example, if you:</p> <div class="ulist"> <ul> <li> <p>use <code>git reset --hard</code> to remove already-published commits, or</p> </li> <li> <p>use <code>git commit --amend</code> to replace already-published commits (as in <a href="#fixing-a-mistake-by-rewriting-history">Fixing a mistake by rewriting history</a>), or</p> </li> <li> <p>use <code>git rebase</code> to rebase any already-published commits (as in <a href="#using-git-rebase">Keeping a patch series up to date using git rebase</a>).</p> </li> </ul> </div> <p>You may force <code>git push</code> to perform the update anyway by preceding the branch name with a plus sign:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git push ssh://yourserver.com/~you/proj.git +master</pre> </div> </div> <p>Note the addition of the <code>+</code> sign. Alternatively, you can use the <code>-f</code> flag to force the remote update, as in:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git push -f ssh://yourserver.com/~you/proj.git master</pre> </div> </div> <p>Normally whenever a branch head in a public repository is modified, it is modified to point to a descendant of the commit that it pointed to before. By forcing a push in this situation, you break that convention. (See <a href="#problems-With-rewriting-history">Problems with rewriting history</a>.)</p> <p>Nevertheless, this is a common practice for people that need a simple way to publish a work-in-progress patch series, and it is an acceptable compromise as long as you warn other developers that this is how you intend to manage the branch.</p> <p>It’s also possible for a push to fail in this way when other people have the right to push to the same repository. In that case, the correct solution is to retry the push after first updating your work: either by a pull, or by a fetch followed by a rebase; see the <a href="#setting-up-a-shared-repository">next section</a> and <a href="gitcvs-migration">gitcvs-migration[7]</a> for more.</p> </div> <div class="sect3"> <h4 id="setting-up-a-shared-repository"> +Setting up a shared repository</h4> <p>Another way to collaborate is by using a model similar to that commonly used in CVS, where several developers with special rights all push to and pull from a single shared repository. See <a href="gitcvs-migration">gitcvs-migration[7]</a> for instructions on how to set this up.</p> <p>However, while there is nothing wrong with Git’s support for shared repositories, this mode of operation is not generally recommended, simply because the mode of collaboration that Git supports—by exchanging patches and pulling from public repositories—has so many advantages over the central shared repository:</p> <div class="ulist"> <ul> <li> <p>Git’s ability to quickly import and merge patches allows a single maintainer to process incoming changes even at very high rates. And when that becomes too much, <code>git pull</code> provides an easy way for that maintainer to delegate this job to other maintainers while still allowing optional review of incoming changes.</p> </li> <li> <p>Since every developer’s repository has the same complete copy of the project history, no repository is special, and it is trivial for another developer to take over maintenance of a project, either by mutual agreement, or because a maintainer becomes unresponsive or difficult to work with.</p> </li> <li> <p>The lack of a central group of "committers" means there is less need for formal decisions about who is "in" and who is "out".</p> </li> </ul> </div> </div> <div class="sect3"> <h4 id="setting-up-gitweb"> +Allowing web browsing of a repository</h4> <p>The gitweb cgi script provides users an easy way to browse your project’s revisions, file contents and logs without having to install Git. Features like RSS/Atom feeds and blame/annotation details may optionally be enabled.</p> <p>The <a href="git-instaweb">git-instaweb[1]</a> command provides a simple way to start browsing the repository using gitweb. The default server when using instaweb is lighttpd.</p> <p>See the file gitweb/INSTALL in the Git source tree and <a href="gitweb">gitweb[1]</a> for instructions on details setting up a permanent installation with a CGI or Perl capable server.</p> </div> </div> <div class="sect2"> <h3 id="how-to-get-a-git-repository-with-minimal-history"> +How to get a Git repository with minimal history</h3> <p>A <a href="#def_shallow_clone">shallow clone</a>, with its truncated history, is useful when one is interested only in recent history of a project and getting full history from the upstream is expensive.</p> <p>A <a href="#def_shallow_clone">shallow clone</a> is created by specifying the <a href="git-clone">git-clone[1]</a> <code>--depth</code> switch. The depth can later be changed with the <a href="git-fetch">git-fetch[1]</a> <code>--depth</code> switch, or full history restored with <code>--unshallow</code>.</p> <p>Merging inside a <a href="#def_shallow_clone">shallow clone</a> will work as long as a merge base is in the recent history. Otherwise, it will be like merging unrelated histories and may have to result in huge conflicts. This limitation may make such a repository unsuitable to be used in merge based workflows.</p> </div> <div class="sect2"> <h3 id="sharing-development-examples"> +Examples</h3> <div class="sect3"> <h4 id="maintaining-topic-branches"> +Maintaining topic branches for a Linux subsystem maintainer</h4> <p>This describes how Tony Luck uses Git in his role as maintainer of the IA64 architecture for the Linux kernel.</p> <p>He uses two public branches:</p> <div class="ulist"> <ul> <li> <p>A "test" tree into which patches are initially placed so that they can get some exposure when integrated with other ongoing development. This tree is available to Andrew for pulling into -mm whenever he wants.</p> </li> <li> <p>A "release" tree into which tested patches are moved for final sanity checking, and as a vehicle to send them upstream to Linus (by sending him a "please pull" request.)</p> </li> </ul> </div> <p>He also uses a set of temporary branches ("topic branches"), each containing a logical grouping of patches.</p> <p>To set this up, first create your work tree by cloning Linus’s public tree:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git work +$ cd work</pre> </div> </div> <p>Linus’s tree will be stored in the remote-tracking branch named origin/master, and can be updated using <a href="git-fetch">git-fetch[1]</a>; you can track other public trees using <a href="git-remote">git-remote[1]</a> to set up a "remote" and <a href="git-fetch">git-fetch[1]</a> to keep them up to date; see <a href="#repositories-and-branches">Repositories and Branches</a>.</p> <p>Now create the branches in which you are going to work; these start out at the current tip of origin/master branch, and should be set up (using the <code>--track</code> option to <a href="git-branch">git-branch[1]</a>) to merge changes in from Linus by default.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch --track test origin/master +$ git branch --track release origin/master</pre> </div> </div> <p>These can be easily kept up to date using <a href="git-pull">git-pull[1]</a>.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch test && git pull +$ git switch release && git pull</pre> </div> </div> <p>Important note! If you have any local changes in these branches, then this merge will create a commit object in the history (with no local changes Git will simply do a "fast-forward" merge). Many people dislike the "noise" that this creates in the Linux history, so you should avoid doing this capriciously in the <code>release</code> branch, as these noisy commits will become part of the permanent history when you ask Linus to pull from the release branch.</p> <p>A few configuration variables (see <a href="git-config">git-config[1]</a>) can make it easy to push both branches to your public tree. (See <a href="#setting-up-a-public-repository">Setting up a public repository</a>.)</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat >> .git/config <<EOF +[remote "mytree"] + url = master.kernel.org:/pub/scm/linux/kernel/git/aegl/linux.git + push = release + push = test +EOF</pre> </div> </div> <p>Then you can push both the test and release trees using <a href="git-push">git-push[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git push mytree</pre> </div> </div> <p>or push just one of the test and release branches using:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git push mytree test</pre> </div> </div> <p>or</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git push mytree release</pre> </div> </div> <p>Now to apply some patches from the community. Think of a short snappy name for a branch to hold this patch (or related group of patches), and create a new branch from a recent stable tag of Linus’s branch. Picking a stable base for your branch will: 1) help you: by avoiding inclusion of unrelated and perhaps lightly tested changes 2) help future bug hunters that use <code>git bisect</code> to find problems</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -c speed-up-spinlocks v2.6.35</pre> </div> </div> <p>Now you apply the patch(es), run some tests, and commit the change(s). If the patch is a multi-part series, then you should apply each as a separate commit to this branch.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ ... patch ... test ... commit [ ... patch ... test ... commit ]*</pre> </div> </div> <p>When you are happy with the state of this change, you can merge it into the "test" branch in preparation to make it public:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch test && git merge speed-up-spinlocks</pre> </div> </div> <p>It is unlikely that you would have any conflicts here … but you might if you spent a while on this step and had also pulled new versions from upstream.</p> <p>Sometime later when enough time has passed and testing done, you can pull the same branch into the <code>release</code> tree ready to go upstream. This is where you see the value of keeping each patch (or patch series) in its own branch. It means that the patches can be moved into the <code>release</code> tree in any order.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch release && git merge speed-up-spinlocks</pre> </div> </div> <p>After a while, you will have a number of branches, and despite the well chosen names you picked for each of them, you may forget what they are for, or what status they are in. To get a reminder of what changes are in a specific branch, use:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log linux..branchname | git shortlog</pre> </div> </div> <p>To see whether it has already been merged into the test or release branches, use:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log test..branchname</pre> </div> </div> <p>or</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log release..branchname</pre> </div> </div> <p>(If this branch has not yet been merged, you will see some log entries. If it has been merged, then there will be no output.)</p> <p>Once a patch completes the great cycle (moving from test to release, then pulled by Linus, and finally coming back into your local <code>origin/master</code> branch), the branch for this change is no longer needed. You detect this when the output from:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log origin..branchname</pre> </div> </div> <p>is empty. At this point the branch can be deleted:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch -d branchname</pre> </div> </div> <p>Some changes are so trivial that it is not necessary to create a separate branch and then merge into each of the test and release branches. For these changes, just apply directly to the <code>release</code> branch, and then merge that into the <code>test</code> branch.</p> <p>After pushing your work to <code>mytree</code>, you can use <a href="git-request-pull">git-request-pull[1]</a> to prepare a "please pull" request message to send to Linus:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git push mytree +$ git request-pull origin mytree release</pre> </div> </div> <p>Here are some of the scripts that simplify all this even further.</p> <div class="listingblock"> <div class="content"> <pre>==== update script ==== +# Update a branch in my Git tree. If the branch to be updated +# is origin, then pull from kernel.org. Otherwise merge +# origin/master branch into test|release branch + +case "$1" in +test|release) + git checkout $1 && git pull . origin + ;; +origin) + before=$(git rev-parse refs/remotes/origin/master) + git fetch origin + after=$(git rev-parse refs/remotes/origin/master) + if [ $before != $after ] + then + git log $before..$after | git shortlog + fi + ;; +*) + echo "usage: $0 origin|test|release" 1>&2 + exit 1 + ;; +esac</pre> </div> </div> <div class="listingblock"> <div class="content"> <pre>==== merge script ==== +# Merge a branch into either the test or release branch + +pname=$0 + +usage() +{ + echo "usage: $pname branch test|release" 1>&2 + exit 1 +} + +git show-ref -q --verify -- refs/heads/"$1" || { + echo "Can't see branch <$1>" 1>&2 + usage +} + +case "$2" in +test|release) + if [ $(git log $2..$1 | wc -c) -eq 0 ] + then + echo $1 already merged into $2 1>&2 + exit 1 + fi + git checkout $2 && git pull . $1 + ;; +*) + usage + ;; +esac</pre> </div> </div> <div class="listingblock"> <div class="content"> <pre>==== status script ==== +# report on status of my ia64 Git tree + +gb=$(tput setab 2) +rb=$(tput setab 1) +restore=$(tput setab 9) + +if [ `git rev-list test..release | wc -c` -gt 0 ] +then + echo $rb Warning: commits in release that are not in test $restore + git log test..release +fi + +for branch in `git show-ref --heads | sed 's|^.*/||'` +do + if [ $branch = test -o $branch = release ] + then + continue + fi + + echo -n $gb ======= $branch ====== $restore " " + status= + for ref in test release origin/master + do + if [ `git rev-list $ref..$branch | wc -c` -gt 0 ] + then + status=$status${ref:0:1} + fi + done + case $status in + trl) + echo $rb Need to pull into test $restore + ;; + rl) + echo "In test" + ;; + l) + echo "Waiting for linus" + ;; + "") + echo $rb All done $restore + ;; + *) + echo $rb "<$status>" $restore + ;; + esac + git log origin/master..$branch | git shortlog +done</pre> </div> </div> </div> </div> </div> <h2 id="cleaning-up-history">Rewriting history and maintaining patch series</h2> <div class="sectionbody"> <p>Normally commits are only added to a project, never taken away or replaced. Git is designed with this assumption, and violating it will cause Git’s merge machinery (for example) to do the wrong thing.</p> <p>However, there is a situation in which it can be useful to violate this assumption.</p> <div class="sect2"> <h3 id="patch-series"> +Creating the perfect patch series</h3> <p>Suppose you are a contributor to a large project, and you want to add a complicated feature, and to present it to the other developers in a way that makes it easy for them to read your changes, verify that they are correct, and understand why you made each change.</p> <p>If you present all of your changes as a single patch (or commit), they may find that it is too much to digest all at once.</p> <p>If you present them with the entire history of your work, complete with mistakes, corrections, and dead ends, they may be overwhelmed.</p> <p>So the ideal is usually to produce a series of patches such that:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>Each patch can be applied in order.</p> </li> <li> <p>Each patch includes a single logical change, together with a message explaining the change.</p> </li> <li> <p>No patch introduces a regression: after applying any initial part of the series, the resulting project still compiles and works, and has no bugs that it didn’t have before.</p> </li> <li> <p>The complete series produces the same end result as your own (probably much messier!) development process did.</p> </li> </ol> </div> <p>We will introduce some tools that can help you do this, explain how to use them, and then explain some of the problems that can arise because you are rewriting history.</p> </div> <div class="sect2"> <h3 id="using-git-rebase"> +Keeping a patch series up to date using git rebase</h3> <p>Suppose that you create a branch <code>mywork</code> on a remote-tracking branch <code>origin</code>, and create some commits on top of it:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -c mywork origin +$ vi file.txt +$ git commit +$ vi otherfile.txt +$ git commit +...</pre> </div> </div> <p>You have performed no merges into mywork, so it is just a simple linear sequence of patches on top of <code>origin</code>:</p> <div class="literalblock"> <div class="content"> <pre> o--o--O <-- origin + \ + a--b--c <-- mywork</pre> </div> </div> <p>Some more interesting work has been done in the upstream project, and <code>origin</code> has advanced:</p> <div class="literalblock"> <div class="content"> <pre> o--o--O--o--o--o <-- origin + \ + a--b--c <-- mywork</pre> </div> </div> <p>At this point, you could use <code>pull</code> to merge your changes back in; the result would create a new merge commit, like this:</p> <div class="literalblock"> <div class="content"> <pre> o--o--O--o--o--o <-- origin + \ \ + a--b--c--m <-- mywork</pre> </div> </div> <p>However, if you prefer to keep the history in mywork a simple series of commits without any merges, you may instead choose to use <a href="git-rebase">git-rebase[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch mywork +$ git rebase origin</pre> </div> </div> <p>This will remove each of your commits from mywork, temporarily saving them as patches (in a directory named <code>.git/rebase-apply</code>), update mywork to point at the latest version of origin, then apply each of the saved patches to the new mywork. The result will look like:</p> <div class="literalblock"> <div class="content"> <pre> o--o--O--o--o--o <-- origin + \ + a'--b'--c' <-- mywork</pre> </div> </div> <p>In the process, it may discover conflicts. In that case it will stop and allow you to fix the conflicts; after fixing conflicts, use <code>git add</code> to update the index with those contents, and then, instead of running <code>git commit</code>, just run</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rebase --continue</pre> </div> </div> <p>and Git will continue applying the rest of the patches.</p> <p>At any point you may use the <code>--abort</code> option to abort this process and return mywork to the state it had before you started the rebase:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rebase --abort</pre> </div> </div> <p>If you need to reorder or edit a number of commits in a branch, it may be easier to use <code>git rebase -i</code>, which allows you to reorder and squash commits, as well as marking them for individual editing during the rebase. See <a href="#interactive-rebase">Using interactive rebases</a> for details, and <a href="#reordering-patch-series">Reordering or selecting from a patch series</a> for alternatives.</p> </div> <div class="sect2"> <h3 id="rewriting-one-commit"> +Rewriting a single commit</h3> <p>We saw in <a href="#fixing-a-mistake-by-rewriting-history">Fixing a mistake by rewriting history</a> that you can replace the most recent commit using</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit --amend</pre> </div> </div> <p>which will replace the old commit by a new commit incorporating your changes, giving you a chance to edit the old commit message first. This is useful for fixing typos in your last commit, or for adjusting the patch contents of a poorly staged commit.</p> <p>If you need to amend commits from deeper in your history, you can use <a href="#interactive-rebase">interactive rebase’s <code>edit</code> instruction</a>.</p> </div> <div class="sect2"> <h3 id="reordering-patch-series"> +Reordering or selecting from a patch series</h3> <p>Sometimes you want to edit a commit deeper in your history. One approach is to use <code>git format-patch</code> to create a series of patches and then reset the state to before the patches:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git format-patch origin +$ git reset --hard origin</pre> </div> </div> <p>Then modify, reorder, or eliminate patches as needed before applying them again with <a href="git-am">git-am[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git am *.patch</pre> </div> </div> </div> <div class="sect2"> <h3 id="interactive-rebase"> +Using interactive rebases</h3> <p>You can also edit a patch series with an interactive rebase. This is the same as <a href="#reordering-patch-series">reordering a patch series using <code>format-patch</code></a>, so use whichever interface you like best.</p> <p>Rebase your current HEAD on the last commit you want to retain as-is. For example, if you want to reorder the last 5 commits, use:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git rebase -i HEAD~5</pre> </div> </div> <p>This will open your editor with a list of steps to be taken to perform your rebase.</p> <div class="listingblock"> <div class="content"> <pre>pick deadbee The oneline of this commit +pick fa1afe1 The oneline of the next commit +... + +# Rebase c0ffeee..deadbee onto c0ffeee +# +# Commands: +# p, pick = use commit +# r, reword = use commit, but edit the commit message +# e, edit = use commit, but stop for amending +# s, squash = use commit, but meld into previous commit +# f, fixup = like "squash", but discard this commit's log message +# x, exec = run command (the rest of the line) using shell +# +# These lines can be re-ordered; they are executed from top to bottom. +# +# If you remove a line here THAT COMMIT WILL BE LOST. +# +# However, if you remove everything, the rebase will be aborted. +# +# Note that empty commits are commented out</pre> </div> </div> <p>As explained in the comments, you can reorder commits, squash them together, edit commit messages, etc. by editing the list. Once you are satisfied, save the list and close your editor, and the rebase will begin.</p> <p>The rebase will stop where <code>pick</code> has been replaced with <code>edit</code> or when a step in the list fails to mechanically resolve conflicts and needs your help. When you are done editing and/or resolving conflicts you can continue with <code>git rebase --continue</code>. If you decide that things are getting too hairy, you can always bail out with <code>git rebase +--abort</code>. Even after the rebase is complete, you can still recover the original branch by using the <a href="#reflogs">reflog</a>.</p> <p>For a more detailed discussion of the procedure and additional tips, see the "INTERACTIVE MODE" section of <a href="git-rebase">git-rebase[1]</a>.</p> </div> <div class="sect2"> <h3 id="patch-series-tools"> +Other tools</h3> <p>There are numerous other tools, such as StGit, which exist for the purpose of maintaining a patch series. These are outside of the scope of this manual.</p> </div> <div class="sect2"> <h3 id="problems-With-rewriting-history"> +Problems with rewriting history</h3> <p>The primary problem with rewriting the history of a branch has to do with merging. Suppose somebody fetches your branch and merges it into their branch, with a result something like this:</p> <div class="literalblock"> <div class="content"> <pre> o--o--O--o--o--o <-- origin + \ \ + t--t--t--m <-- their branch:</pre> </div> </div> <p>Then suppose you modify the last three commits:</p> <div class="literalblock"> <div class="content"> <pre> o--o--o <-- new head of origin + / + o--o--O--o--o--o <-- old head of origin</pre> </div> </div> <p>If we examined all this history together in one repository, it will look like:</p> <div class="literalblock"> <div class="content"> <pre> o--o--o <-- new head of origin + / + o--o--O--o--o--o <-- old head of origin + \ \ + t--t--t--m <-- their branch:</pre> </div> </div> <p>Git has no way of knowing that the new head is an updated version of the old head; it treats this situation exactly the same as it would if two developers had independently done the work on the old and new heads in parallel. At this point, if someone attempts to merge the new head in to their branch, Git will attempt to merge together the two (old and new) lines of development, instead of trying to replace the old by the new. The results are likely to be unexpected.</p> <p>You may still choose to publish branches whose history is rewritten, and it may be useful for others to be able to fetch those branches in order to examine or test them, but they should not attempt to pull such branches into their own work.</p> <p>For true distributed development that supports proper merging, published branches should never be rewritten.</p> </div> <div class="sect2"> <h3 id="bisect-merges"> +Why bisecting merge commits can be harder than bisecting linear history</h3> <p>The <a href="git-bisect">git-bisect[1]</a> command correctly handles history that includes merge commits. However, when the commit that it finds is a merge commit, the user may need to work harder than usual to figure out why that commit introduced a problem.</p> <p>Imagine this history:</p> <div class="literalblock"> <div class="content"> <pre> ---Z---o---X---...---o---A---C---D + \ / + o---o---Y---...---o---B</pre> </div> </div> <p>Suppose that on the upper line of development, the meaning of one of the functions that exists at Z is changed at commit X. The commits from Z leading to A change both the function’s implementation and all calling sites that exist at Z, as well as new calling sites they add, to be consistent. There is no bug at A.</p> <p>Suppose that in the meantime on the lower line of development somebody adds a new calling site for that function at commit Y. The commits from Z leading to B all assume the old semantics of that function and the callers and the callee are consistent with each other. There is no bug at B, either.</p> <p>Suppose further that the two development lines merge cleanly at C, so no conflict resolution is required.</p> <p>Nevertheless, the code at C is broken, because the callers added on the lower line of development have not been converted to the new semantics introduced on the upper line of development. So if all you know is that D is bad, that Z is good, and that <a href="git-bisect">git-bisect[1]</a> identifies C as the culprit, how will you figure out that the problem is due to this change in semantics?</p> <p>When the result of a <code>git bisect</code> is a non-merge commit, you should normally be able to discover the problem by examining just that commit. Developers can make this easy by breaking their changes into small self-contained commits. That won’t help in the case above, however, because the problem isn’t obvious from examination of any single commit; instead, a global view of the development is required. To make matters worse, the change in semantics in the problematic function may be just one small part of the changes in the upper line of development.</p> <p>On the other hand, if instead of merging at C you had rebased the history between Z to B on top of A, you would have gotten this linear history:</p> <div class="literalblock"> <div class="content"> <pre> ---Z---o---X--...---o---A---o---o---Y*--...---o---B*--D*</pre> </div> </div> <p>Bisecting between Z and D* would hit a single culprit commit Y*, and understanding why Y* was broken would probably be easier.</p> <p>Partly for this reason, many experienced Git users, even when working on an otherwise merge-heavy project, keep the history linear by rebasing against the latest upstream version before publishing.</p> </div> </div> <h2 id="advanced-branch-management">Advanced branch management</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="fetching-individual-branches"> +Fetching individual branches</h3> <p>Instead of using <a href="git-remote">git-remote[1]</a>, you can also choose just to update one branch at a time, and to store it locally under an arbitrary name:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch origin todo:my-todo-work</pre> </div> </div> <p>The first argument, <code>origin</code>, just tells Git to fetch from the repository you originally cloned from. The second argument tells Git to fetch the branch named <code>todo</code> from the remote repository, and to store it locally under the name <code>refs/heads/my-todo-work</code>.</p> <p>You can also fetch branches from other repositories; so</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch git://example.com/proj.git master:example-master</pre> </div> </div> <p>will create a new branch named <code>example-master</code> and store in it the branch named <code>master</code> from the repository at the given URL. If you already have a branch named example-master, it will attempt to <a href="#fast-forwards">fast-forward</a> to the commit given by example.com’s master branch. In more detail:</p> </div> <div class="sect2"> <h3 id="fetch-fast-forwards"> +git fetch and fast-forwards</h3> <p>In the previous example, when updating an existing branch, <code>git fetch</code> checks to make sure that the most recent commit on the remote branch is a descendant of the most recent commit on your copy of the branch before updating your copy of the branch to point at the new commit. Git calls this process a <a href="#fast-forwards">fast-forward</a>.</p> <p>A fast-forward looks something like this:</p> <div class="literalblock"> <div class="content"> <pre> o--o--o--o <-- old head of the branch + \ + o--o--o <-- new head of the branch</pre> </div> </div> <p>In some cases it is possible that the new head will <strong>not</strong> actually be a descendant of the old head. For example, the developer may have realized a serious mistake was made and decided to backtrack, resulting in a situation like:</p> <div class="literalblock"> <div class="content"> <pre> o--o--o--o--a--b <-- old head of the branch + \ + o--o--o <-- new head of the branch</pre> </div> </div> <p>In this case, <code>git fetch</code> will fail, and print out a warning.</p> <p>In that case, you can still force Git to update to the new head, as described in the following section. However, note that in the situation above this may mean losing the commits labeled <code>a</code> and <code>b</code>, unless you’ve already created a reference of your own pointing to them.</p> </div> <div class="sect2"> <h3 id="forcing-fetch"> +Forcing git fetch to do non-fast-forward updates</h3> <p>If git fetch fails because the new head of a branch is not a descendant of the old head, you may force the update with:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch git://example.com/proj.git +master:refs/remotes/example/master</pre> </div> </div> <p>Note the addition of the <code>+</code> sign. Alternatively, you can use the <code>-f</code> flag to force updates of all the fetched branches, as in:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch -f origin</pre> </div> </div> <p>Be aware that commits that the old version of example/master pointed at may be lost, as we saw in the previous section.</p> </div> <div class="sect2"> <h3 id="remote-branch-configuration"> +Configuring remote-tracking branches</h3> <p>We saw above that <code>origin</code> is just a shortcut to refer to the repository that you originally cloned from. This information is stored in Git configuration variables, which you can see using <a href="git-config">git-config[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git config -l +core.repositoryformatversion=0 +core.filemode=true +core.logallrefupdates=true +remote.origin.url=git://git.kernel.org/pub/scm/git/git.git +remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* +branch.master.remote=origin +branch.master.merge=refs/heads/master</pre> </div> </div> <p>If there are other repositories that you also use frequently, you can create similar configuration options to save typing; for example,</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git remote add example git://example.com/proj.git</pre> </div> </div> <p>adds the following to <code>.git/config</code>:</p> <div class="listingblock"> <div class="content"> <pre>[remote "example"] + url = git://example.com/proj.git + fetch = +refs/heads/*:refs/remotes/example/*</pre> </div> </div> <p>Also note that the above configuration can be performed by directly editing the file <code>.git/config</code> instead of using <a href="git-remote">git-remote[1]</a>.</p> <p>After configuring the remote, the following three commands will do the same thing:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch git://example.com/proj.git +refs/heads/*:refs/remotes/example/* +$ git fetch example +refs/heads/*:refs/remotes/example/* +$ git fetch example</pre> </div> </div> <p>See <a href="git-config">git-config[1]</a> for more details on the configuration options mentioned above and <a href="git-fetch">git-fetch[1]</a> for more details on the refspec syntax.</p> </div> </div> <h2 id="git-concepts">Git concepts</h2> <div class="sectionbody"> <p>Git is built on a small number of simple but powerful ideas. While it is possible to get things done without understanding them, you will find Git much more intuitive if you do.</p> <p>We start with the most important, the <a href="#def_object_database">object database</a> and the <a href="#def_index">index</a>.</p> <div class="sect2"> <h3 id="the-object-database"> +The Object Database</h3> <p>We already saw in <a href="#understanding-commits">Understanding History: Commits</a> that all commits are stored under a 40-digit "object name". In fact, all the information needed to represent the history of a project is stored in objects with such names. In each case the name is calculated by taking the SHA-1 hash of the contents of the object. The SHA-1 hash is a cryptographic hash function. What that means to us is that it is impossible to find two different objects with the same name. This has a number of advantages; among others:</p> <div class="ulist"> <ul> <li> <p>Git can quickly determine whether two objects are identical or not, just by comparing names.</p> </li> <li> <p>Since object names are computed the same way in every repository, the same content stored in two repositories will always be stored under the same name.</p> </li> <li> <p>Git can detect errors when it reads an object, by checking that the object’s name is still the SHA-1 hash of its contents.</p> </li> </ul> </div> <p>(See <a href="#object-details">Object storage format</a> for the details of the object formatting and SHA-1 calculation.)</p> <p>There are four different types of objects: "blob", "tree", "commit", and "tag".</p> <div class="ulist"> <ul> <li> <p>A <a href="#def_blob_object">"blob" object</a> is used to store file data.</p> </li> <li> <p>A <a href="#def_tree_object">"tree" object</a> ties one or more "blob" objects into a directory structure. In addition, a tree object can refer to other tree objects, thus creating a directory hierarchy.</p> </li> <li> <p>A <a href="#def_commit_object">"commit" object</a> ties such directory hierarchies together into a <a href="#def_DAG">directed acyclic graph</a> of revisions—each commit contains the object name of exactly one tree designating the directory hierarchy at the time of the commit. In addition, a commit refers to "parent" commit objects that describe the history of how we arrived at that directory hierarchy.</p> </li> <li> <p>A <a href="#def_tag_object">"tag" object</a> symbolically identifies and can be used to sign other objects. It contains the object name and type of another object, a symbolic name (of course!) and, optionally, a signature.</p> </li> </ul> </div> <p>The object types in some more detail:</p> <div class="sect3"> <h4 id="commit-object"> +Commit Object</h4> <p>The "commit" object links a physical state of a tree with a description of how we got there and why. Use the <code>--pretty=raw</code> option to <a href="git-show">git-show[1]</a> or <a href="git-log">git-log[1]</a> to examine your favorite commit:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show -s --pretty=raw 2be7fcb476 +commit 2be7fcb4764f2dbcee52635b91fedb1b3dcf7ab4 +tree fb3a8bdd0ceddd019615af4d57a53f43d8cee2bf +parent 257a84d9d02e90447b149af58b271c19405edb6a +author Dave Watson <dwatson@mimvista.com> 1187576872 -0400 +committer Junio C Hamano <gitster@pobox.com> 1187591163 -0700 + + Fix misspelling of 'suppress' in docs + + Signed-off-by: Junio C Hamano <gitster@pobox.com></pre> </div> </div> <p>As you can see, a commit is defined by:</p> <div class="ulist"> <ul> <li> <p>a tree: The SHA-1 name of a tree object (as defined below), representing the contents of a directory at a certain point in time.</p> </li> <li> <p>parent(s): The SHA-1 name(s) of some number of commits which represent the immediately previous step(s) in the history of the project. The example above has one parent; merge commits may have more than one. A commit with no parents is called a "root" commit, and represents the initial revision of a project. Each project must have at least one root. A project can also have multiple roots, though that isn’t common (or necessarily a good idea).</p> </li> <li> <p>an author: The name of the person responsible for this change, together with its date.</p> </li> <li> <p>a committer: The name of the person who actually created the commit, with the date it was done. This may be different from the author, for example, if the author was someone who wrote a patch and emailed it to the person who used it to create the commit.</p> </li> <li> <p>a comment describing this commit.</p> </li> </ul> </div> <p>Note that a commit does not itself contain any information about what actually changed; all changes are calculated by comparing the contents of the tree referred to by this commit with the trees associated with its parents. In particular, Git does not attempt to record file renames explicitly, though it can identify cases where the existence of the same file data at changing paths suggests a rename. (See, for example, the <code>-M</code> option to <a href="git-diff">git-diff[1]</a>).</p> <p>A commit is usually created by <a href="git-commit">git-commit[1]</a>, which creates a commit whose parent is normally the current HEAD, and whose tree is taken from the content currently stored in the index.</p> </div> <div class="sect3"> <h4 id="tree-object"> +Tree Object</h4> <p>The ever-versatile <a href="git-show">git-show[1]</a> command can also be used to examine tree objects, but <a href="git-ls-tree">git-ls-tree[1]</a> will give you more details:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-tree fb3a8bdd0ce +100644 blob 63c918c667fa005ff12ad89437f2fdc80926e21c .gitignore +100644 blob 5529b198e8d14decbe4ad99db3f7fb632de0439d .mailmap +100644 blob 6ff87c4664981e4397625791c8ea3bbb5f2279a3 COPYING +040000 tree 2fb783e477100ce076f6bf57e4a6f026013dc745 Documentation +100755 blob 3c0032cec592a765692234f1cba47dfdcc3a9200 GIT-VERSION-GEN +100644 blob 289b046a443c0647624607d471289b2c7dcd470b INSTALL +100644 blob 4eb463797adc693dc168b926b6932ff53f17d0b1 Makefile +100644 blob 548142c327a6790ff8821d67c2ee1eff7a656b52 README +...</pre> </div> </div> <p>As you can see, a tree object contains a list of entries, each with a mode, object type, SHA-1 name, and name, sorted by name. It represents the contents of a single directory tree.</p> <p>The object type may be a blob, representing the contents of a file, or another tree, representing the contents of a subdirectory. Since trees and blobs, like all other objects, are named by the SHA-1 hash of their contents, two trees have the same SHA-1 name if and only if their contents (including, recursively, the contents of all subdirectories) are identical. This allows Git to quickly determine the differences between two related tree objects, since it can ignore any entries with identical object names.</p> <p>(Note: in the presence of submodules, trees may also have commits as entries. See <a href="#submodules">Submodules</a> for documentation.)</p> <p>Note that the files all have mode 644 or 755: Git actually only pays attention to the executable bit.</p> </div> <div class="sect3"> <h4 id="blob-object"> +Blob Object</h4> <p>You can use <a href="git-show">git-show[1]</a> to examine the contents of a blob; take, for example, the blob in the entry for <code>COPYING</code> from the tree above:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show 6ff87c4664 + + Note that the only valid version of the GPL as far as this project + is concerned is _this_ particular version of the license (ie v2, not + v2.2 or v3.x or whatever), unless explicitly otherwise stated. +...</pre> </div> </div> <p>A "blob" object is nothing but a binary blob of data. It doesn’t refer to anything else or have attributes of any kind.</p> <p>Since the blob is entirely defined by its data, if two files in a directory tree (or in multiple different versions of the repository) have the same contents, they will share the same blob object. The object is totally independent of its location in the directory tree, and renaming a file does not change the object that file is associated with.</p> <p>Note that any tree or blob object can be examined using <a href="git-show">git-show[1]</a> with the <revision>:<path> syntax. This can sometimes be useful for browsing the contents of a tree that is not currently checked out.</p> </div> <div class="sect3"> <h4 id="trust"> +Trust</h4> <p>If you receive the SHA-1 name of a blob from one source, and its contents from another (possibly untrusted) source, you can still trust that those contents are correct as long as the SHA-1 name agrees. This is because the SHA-1 is designed so that it is infeasible to find different contents that produce the same hash.</p> <p>Similarly, you need only trust the SHA-1 name of a top-level tree object to trust the contents of the entire directory that it refers to, and if you receive the SHA-1 name of a commit from a trusted source, then you can easily verify the entire history of commits reachable through parents of that commit, and all of those contents of the trees referred to by those commits.</p> <p>So to introduce some real trust in the system, the only thing you need to do is to digitally sign just <code>one</code> special note, which includes the name of a top-level commit. Your digital signature shows others that you trust that commit, and the immutability of the history of commits tells others that they can trust the whole history.</p> <p>In other words, you can easily validate a whole archive by just sending out a single email that tells the people the name (SHA-1 hash) of the top commit, and digitally sign that email using something like GPG/PGP.</p> <p>To assist in this, Git also provides the tag object…</p> </div> <div class="sect3"> <h4 id="tag-object"> +Tag Object</h4> <p>A tag object contains an object, object type, tag name, the name of the person ("tagger") who created the tag, and a message, which may contain a signature, as can be seen using <a href="git-cat-file">git-cat-file[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cat-file tag v1.5.0 +object 437b1b20df4b356c9342dac8d38849f24ef44f27 +type commit +tag v1.5.0 +tagger Junio C Hamano <junkio@cox.net> 1171411200 +0000 + +GIT 1.5.0 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQBF0lGqwMbZpPMRm5oRAuRiAJ9ohBLd7s2kqjkKlq1qqC57SbnmzQCdG4ui +nLE/L9aUXdWeTFPron96DLA= +=2E+0 +-----END PGP SIGNATURE-----</pre> </div> </div> <p>See the <a href="git-tag">git-tag[1]</a> command to learn how to create and verify tag objects. (Note that <a href="git-tag">git-tag[1]</a> can also be used to create "lightweight tags", which are not tag objects at all, but just simple references whose names begin with <code>refs/tags/</code>).</p> </div> <div class="sect3"> <h4 id="pack-files"> +How Git stores objects efficiently: pack files</h4> <p>Newly created objects are initially created in a file named after the object’s SHA-1 hash (stored in <code>.git/objects</code>).</p> <p>Unfortunately this system becomes inefficient once a project has a lot of objects. Try this on an old project:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git count-objects +6930 objects, 47620 kilobytes</pre> </div> </div> <p>The first number is the number of objects which are kept in individual files. The second is the amount of space taken up by those "loose" objects.</p> <p>You can save space and make Git faster by moving these loose objects in to a "pack file", which stores a group of objects in an efficient compressed format; the details of how pack files are formatted can be found in <a href="gitformat-pack">gitformat-pack[5]</a>.</p> <p>To put the loose objects into a pack, just run git repack:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git repack +Counting objects: 6020, done. +Delta compression using up to 4 threads. +Compressing objects: 100% (6020/6020), done. +Writing objects: 100% (6020/6020), done. +Total 6020 (delta 4070), reused 0 (delta 0)</pre> </div> </div> <p>This creates a single "pack file" in .git/objects/pack/ containing all currently unpacked objects. You can then run</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git prune</pre> </div> </div> <p>to remove any of the "loose" objects that are now contained in the pack. This will also remove any unreferenced objects (which may be created when, for example, you use <code>git reset</code> to remove a commit). You can verify that the loose objects are gone by looking at the <code>.git/objects</code> directory or by running</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git count-objects +0 objects, 0 kilobytes</pre> </div> </div> <p>Although the object files are gone, any commands that refer to those objects will work exactly as they did before.</p> <p>The <a href="git-gc">git-gc[1]</a> command performs packing, pruning, and more for you, so is normally the only high-level command you need.</p> </div> <div class="sect3"> <h4 id="dangling-objects"> +Dangling objects</h4> <p>The <a href="git-fsck">git-fsck[1]</a> command will sometimes complain about dangling objects. They are not a problem.</p> <p>The most common cause of dangling objects is that you’ve rebased a branch, or you have pulled from somebody else who rebased a branch—see <a href="#cleaning-up-history">Rewriting history and maintaining patch series</a>. In that case, the old head of the original branch still exists, as does everything it pointed to. The branch pointer itself just doesn’t, since you replaced it with another one.</p> <p>There are also other situations that cause dangling objects. For example, a "dangling blob" may arise because you did a <code>git add</code> of a file, but then, before you actually committed it and made it part of the bigger picture, you changed something else in that file and committed that <strong>updated</strong> thing—the old state that you added originally ends up not being pointed to by any commit or tree, so it’s now a dangling blob object.</p> <p>Similarly, when the "ort" merge strategy runs, and finds that there are criss-cross merges and thus more than one merge base (which is fairly unusual, but it does happen), it will generate one temporary midway tree (or possibly even more, if you had lots of criss-crossing merges and more than two merge bases) as a temporary internal merge base, and again, those are real objects, but the end result will not end up pointing to them, so they end up "dangling" in your repository.</p> <p>Generally, dangling objects aren’t anything to worry about. They can even be very useful: if you screw something up, the dangling objects can be how you recover your old tree (say, you did a rebase, and realized that you really didn’t want to—you can look at what dangling objects you have, and decide to reset your head to some old dangling state).</p> <p>For commits, you can just use:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ gitk <dangling-commit-sha-goes-here> --not --all</pre> </div> </div> <p>This asks for all the history reachable from the given commit but not from any branch, tag, or other reference. If you decide it’s something you want, you can always create a new reference to it, e.g.,</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch recovered-branch <dangling-commit-sha-goes-here></pre> </div> </div> <p>For blobs and trees, you can’t do the same, but you can still examine them. You can just do</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show <dangling-blob/tree-sha-goes-here></pre> </div> </div> <p>to show what the contents of the blob were (or, for a tree, basically what the <code>ls</code> for that directory was), and that may give you some idea of what the operation was that left that dangling object.</p> <p>Usually, dangling blobs and trees aren’t very interesting. They’re almost always the result of either being a half-way mergebase (the blob will often even have the conflict markers from a merge in it, if you have had conflicting merges that you fixed up by hand), or simply because you interrupted a <code>git fetch</code> with ^C or something like that, leaving <code>some</code> of the new objects in the object database, but just dangling and useless.</p> <p>Anyway, once you are sure that you’re not interested in any dangling state, you can just prune all unreachable objects:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git prune</pre> </div> </div> <p>and they’ll be gone. (You should only run <code>git prune</code> on a quiescent repository—it’s kind of like doing a filesystem fsck recovery: you don’t want to do that while the filesystem is mounted. <code>git prune</code> is designed not to cause any harm in such cases of concurrent accesses to a repository but you might receive confusing or scary messages.)</p> </div> <div class="sect3"> <h4 id="recovering-from-repository-corruption"> +Recovering from repository corruption</h4> <p>By design, Git treats data trusted to it with caution. However, even in the absence of bugs in Git itself, it is still possible that hardware or operating system errors could corrupt data.</p> <p>The first defense against such problems is backups. You can back up a Git directory using clone, or just using cp, tar, or any other backup mechanism.</p> <p>As a last resort, you can search for the corrupted objects and attempt to replace them by hand. Back up your repository before attempting this in case you corrupt things even more in the process.</p> <p>We’ll assume that the problem is a single missing or corrupted blob, which is sometimes a solvable problem. (Recovering missing trees and especially commits is <strong>much</strong> harder).</p> <p>Before starting, verify that there is corruption, and figure out where it is with <a href="git-fsck">git-fsck[1]</a>; this may be time-consuming.</p> <p>Assume the output looks like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fsck --full --no-dangling +broken link from tree 2d9263c6d23595e7cb2a21e5ebbb53655278dff8 + to blob 4b9458b3786228369c63936db65827de3cc06200 +missing blob 4b9458b3786228369c63936db65827de3cc06200</pre> </div> </div> <p>Now you know that blob 4b9458b3 is missing, and that the tree 2d9263c6 points to it. If you could find just one copy of that missing blob object, possibly in some other repository, you could move it into <code>.git/objects/4b/9458b3...</code> and be done. Suppose you can’t. You can still examine the tree that pointed to it with <a href="git-ls-tree">git-ls-tree[1]</a>, which might output something like:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-tree 2d9263c6d23595e7cb2a21e5ebbb53655278dff8 +100644 blob 8d14531846b95bfa3564b58ccfb7913a034323b8 .gitignore +100644 blob ebf9bf84da0aab5ed944264a5db2a65fe3a3e883 .mailmap +100644 blob ca442d313d86dc67e0a2e5d584b465bd382cbf5c COPYING +... +100644 blob 4b9458b3786228369c63936db65827de3cc06200 myfile +...</pre> </div> </div> <p>So now you know that the missing blob was the data for a file named <code>myfile</code>. And chances are you can also identify the directory—let’s say it’s in <code>somedirectory</code>. If you’re lucky the missing copy might be the same as the copy you have checked out in your working tree at <code>somedirectory/myfile</code>; you can test whether that’s right with <a href="git-hash-object">git-hash-object[1]</a>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git hash-object -w somedirectory/myfile</pre> </div> </div> <p>which will create and store a blob object with the contents of somedirectory/myfile, and output the SHA-1 of that object. if you’re extremely lucky it might be 4b9458b3786228369c63936db65827de3cc06200, in which case you’ve guessed right, and the corruption is fixed!</p> <p>Otherwise, you need more information. How do you tell which version of the file has been lost?</p> <p>The easiest way to do this is with:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log --raw --all --full-history -- somedirectory/myfile</pre> </div> </div> <p>Because you’re asking for raw output, you’ll now get something like</p> <div class="listingblock"> <div class="content"> <pre>commit abc +Author: +Date: +... +:100644 100644 4b9458b newsha M somedirectory/myfile + + +commit xyz +Author: +Date: + +... +:100644 100644 oldsha 4b9458b M somedirectory/myfile</pre> </div> </div> <p>This tells you that the immediately following version of the file was "newsha", and that the immediately preceding version was "oldsha". You also know the commit messages that went with the change from oldsha to 4b9458b and with the change from 4b9458b to newsha.</p> <p>If you’ve been committing small enough changes, you may now have a good shot at reconstructing the contents of the in-between state 4b9458b.</p> <p>If you can do that, you can now recreate the missing object with</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git hash-object -w <recreated-file></pre> </div> </div> <p>and your repository is good again!</p> <p>(Btw, you could have ignored the <code>fsck</code>, and started with doing a</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log --raw --all</pre> </div> </div> <p>and just looked for the sha of the missing object (4b9458b) in that whole thing. It’s up to you—Git does <strong>have</strong> a lot of information, it is just missing one particular blob version.</p> </div> </div> <div class="sect2"> <h3 id="the-index"> +The index</h3> <p>The index is a binary file (generally kept in <code>.git/index</code>) containing a sorted list of path names, each with permissions and the SHA-1 of a blob object; <a href="git-ls-files">git-ls-files[1]</a> can show you the contents of the index:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git ls-files --stage +100644 63c918c667fa005ff12ad89437f2fdc80926e21c 0 .gitignore +100644 5529b198e8d14decbe4ad99db3f7fb632de0439d 0 .mailmap +100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0 COPYING +100644 a37b2152bd26be2c2289e1f57a292534a51a93c7 0 Documentation/.gitignore +100644 fbefe9a45b00a54b58d94d06eca48b03d40a50e0 0 Documentation/Makefile +... +100644 2511aef8d89ab52be5ec6a5e46236b4b6bcd07ea 0 xdiff/xtypes.h +100644 2ade97b2574a9f77e7ae4002a4e07a6a38e46d07 0 xdiff/xutils.c +100644 d5de8292e05e7c36c4b68857c1cf9855e3d2f70a 0 xdiff/xutils.h</pre> </div> </div> <p>Note that in older documentation you may see the index called the "current directory cache" or just the "cache". It has three important properties:</p> <div class="olist arabic"> <ol class="arabic"> <li> <p>The index contains all the information necessary to generate a single (uniquely determined) tree object.</p> <p>For example, running <a href="git-commit">git-commit[1]</a> generates this tree object from the index, stores it in the object database, and uses it as the tree object associated with the new commit.</p> </li> <li> <p>The index enables fast comparisons between the tree object it defines and the working tree.</p> <p>It does this by storing some additional data for each entry (such as the last modified time). This data is not displayed above, and is not stored in the created tree object, but it can be used to determine quickly which files in the working directory differ from what was stored in the index, and thus save Git from having to read all of the data from such files to look for changes.</p> </li> <li> <p>It can efficiently represent information about merge conflicts between different tree objects, allowing each pathname to be associated with sufficient information about the trees involved that you can create a three-way merge between them.</p> <p>We saw in <a href="#conflict-resolution">Getting conflict-resolution help during a merge</a> that during a merge the index can store multiple versions of a single file (called "stages"). The third column in the <a href="git-ls-files">git-ls-files[1]</a> output above is the stage number, and will take on values other than 0 for files with merge conflicts.</p> </li> </ol> </div> <p>The index is thus a sort of temporary staging area, which is filled with a tree which you are in the process of working on.</p> <p>If you blow the index away entirely, you generally haven’t lost any information as long as you have the name of the tree that it described.</p> </div> </div> <h2 id="submodules">Submodules</h2> <div class="sectionbody"> <p>Large projects are often composed of smaller, self-contained modules. For example, an embedded Linux distribution’s source tree would include every piece of software in the distribution with some local modifications; a movie player might need to build against a specific, known-working version of a decompression library; several independent programs might all share the same build scripts.</p> <p>With centralized revision control systems this is often accomplished by including every module in one single repository. Developers can check out all modules or only the modules they need to work with. They can even modify files across several modules in a single commit while moving things around or updating APIs and translations.</p> <p>Git does not allow partial checkouts, so duplicating this approach in Git would force developers to keep a local copy of modules they are not interested in touching. Commits in an enormous checkout would be slower than you’d expect as Git would have to scan every directory for changes. If modules have a lot of local history, clones would take forever.</p> <p>On the plus side, distributed revision control systems can much better integrate with external sources. In a centralized model, a single arbitrary snapshot of the external project is exported from its own revision control and then imported into the local revision control on a vendor branch. All the history is hidden. With distributed revision control you can clone the entire external history and much more easily follow development and re-merge local changes.</p> <p>Git’s submodule support allows a repository to contain, as a subdirectory, a checkout of an external project. Submodules maintain their own identity; the submodule support just stores the submodule repository location and commit ID, so other developers who clone the containing project ("superproject") can easily clone all the submodules at the same revision. Partial checkouts of the superproject are possible: you can tell Git to clone none, some or all of the submodules.</p> <p>The <a href="git-submodule">git-submodule[1]</a> command is available since Git 1.5.3. Users with Git 1.5.2 can look up the submodule commits in the repository and manually check them out; earlier versions won’t recognize the submodules at all.</p> <p>To see how submodule support works, create four example repositories that can be used later as a submodule:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ mkdir ~/git +$ cd ~/git +$ for i in a b c d +do + mkdir $i + cd $i + git init + echo "module $i" > $i.txt + git add $i.txt + git commit -m "Initial commit, submodule $i" + cd .. +done</pre> </div> </div> <p>Now create the superproject and add all the submodules:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ mkdir super +$ cd super +$ git init +$ for i in a b c d +do + git submodule add ~/git/$i $i +done</pre> </div> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> Do not use local URLs here if you plan to publish your superproject! </td> </tr> </table> </div> <p>See what files <code>git submodule</code> created:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ ls -a +. .. .git .gitmodules a b c d</pre> </div> </div> <p>The <code>git submodule add <repo> <path></code> command does a couple of things:</p> <div class="ulist"> <ul> <li> <p>It clones the submodule from <code><repo></code> to the given <code><path></code> under the current directory and by default checks out the master branch.</p> </li> <li> <p>It adds the submodule’s clone path to the <a href="gitmodules">gitmodules[5]</a> file and adds this file to the index, ready to be committed.</p> </li> <li> <p>It adds the submodule’s current commit ID to the index, ready to be committed.</p> </li> </ul> </div> <p>Commit the superproject:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit -m "Add submodules a, b, c and d."</pre> </div> </div> <p>Now clone the superproject:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cd .. +$ git clone super cloned +$ cd cloned</pre> </div> </div> <p>The submodule directories are there, but they’re empty:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ ls -a a +. .. +$ git submodule status +-d266b9873ad50488163457f025db7cdd9683d88b a +-e81d457da15309b4fef4249aba9b50187999670d b +-c1536a972b9affea0f16e0680ba87332dc059146 c +-d96249ff5d57de5de093e6baff9e0aafa5276a74 d</pre> </div> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> The commit object names shown above would be different for you, but they should match the HEAD commit object names of your repositories. You can check it by running <code>git ls-remote ../a</code>. </td> </tr> </table> </div> <p>Pulling down the submodules is a two-step process. First run <code>git submodule +init</code> to add the submodule repository URLs to <code>.git/config</code>:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git submodule init</pre> </div> </div> <p>Now use <code>git submodule update</code> to clone the repositories and check out the commits specified in the superproject:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git submodule update +$ cd a +$ ls -a +. .. .git a.txt</pre> </div> </div> <p>One major difference between <code>git submodule update</code> and <code>git submodule add</code> is that <code>git submodule update</code> checks out a specific commit, rather than the tip of a branch. It’s like checking out a tag: the head is detached, so you’re not working on a branch.</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch +* (detached from d266b98) + master</pre> </div> </div> <p>If you want to make a change within a submodule and you have a detached head, then you should create or checkout a branch, make your changes, publish the change within the submodule, and then update the superproject to reference the new commit:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch master</pre> </div> </div> <p>or</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -c fix-up</pre> </div> </div> <p>then</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ echo "adding a line again" >> a.txt +$ git commit -a -m "Updated the submodule from within the superproject." +$ git push +$ cd .. +$ git diff +diff --git a/a b/a +index d266b98..261dfac 160000 +--- a/a ++++ b/a +@@ -1 +1 @@ +-Subproject commit d266b9873ad50488163457f025db7cdd9683d88b ++Subproject commit 261dfac35cb99d380eb966e102c1197139f7fa24 +$ git add a +$ git commit -m "Updated submodule a." +$ git push</pre> </div> </div> <p>You have to run <code>git submodule update</code> after <code>git pull</code> if you want to update submodules, too.</p> <div class="sect2"> <h3 id="pitfalls-with-submodules"> +Pitfalls with submodules</h3> <p>Always publish the submodule change before publishing the change to the superproject that references it. If you forget to publish the submodule change, others won’t be able to clone the repository:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cd ~/git/super/a +$ echo i added another line to this file >> a.txt +$ git commit -a -m "doing it wrong this time" +$ cd .. +$ git add a +$ git commit -m "Updated submodule a again." +$ git push +$ cd ~/git/cloned +$ git pull +$ git submodule update +error: pathspec '261dfac35cb99d380eb966e102c1197139f7fa24' did not match any file(s) known to git. +Did you forget to 'git add'? +Unable to checkout '261dfac35cb99d380eb966e102c1197139f7fa24' in submodule path 'a'</pre> </div> </div> <p>In older Git versions it could be easily forgotten to commit new or modified files in a submodule, which silently leads to similar problems as not pushing the submodule changes. Starting with Git 1.7.0 both <code>git status</code> and <code>git diff</code> in the superproject show submodules as modified when they contain new or modified files to protect against accidentally committing such a state. <code>git +diff</code> will also add a <code>-dirty</code> to the work tree side when generating patch output or used with the <code>--submodule</code> option:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git diff +diff --git a/sub b/sub +--- a/sub ++++ b/sub +@@ -1 +1 @@ +-Subproject commit 3f356705649b5d566d97ff843cf193359229a453 ++Subproject commit 3f356705649b5d566d97ff843cf193359229a453-dirty +$ git diff --submodule +Submodule sub 3f35670..3f35670-dirty:</pre> </div> </div> <p>You also should not rewind branches in a submodule beyond commits that were ever recorded in any superproject.</p> <p>It’s not safe to run <code>git submodule update</code> if you’ve made and committed changes within a submodule without checking out a branch first. They will be silently overwritten:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat a.txt +module a +$ echo line added from private2 >> a.txt +$ git commit -a -m "line added inside private2" +$ cd .. +$ git submodule update +Submodule path 'a': checked out 'd266b9873ad50488163457f025db7cdd9683d88b' +$ cd a +$ cat a.txt +module a</pre> </div> </div> <div class="admonitionblock note"> <table> <tr> <td class="icon"> <div class="title">Note</div> </td> <td class="content"> The changes are still visible in the submodule’s reflog. </td> </tr> </table> </div> <p>If you have uncommitted changes in your submodule working tree, <code>git +submodule update</code> will not overwrite them. Instead, you get the usual warning about not being able switch from a dirty branch.</p> </div> </div> <h2 id="low-level-operations">Low-level git operations</h2> <div class="sectionbody"> <p>Many of the higher-level commands were originally implemented as shell scripts using a smaller core of low-level Git commands. These can still be useful when doing unusual things with Git, or just as a way to understand its inner workings.</p> <div class="sect2"> <h3 id="object-manipulation"> +Object access and manipulation</h3> <p>The <a href="git-cat-file">git-cat-file[1]</a> command can show the contents of any object, though the higher-level <a href="git-show">git-show[1]</a> is usually more useful.</p> <p>The <a href="git-commit-tree">git-commit-tree[1]</a> command allows constructing commits with arbitrary parents and trees.</p> <p>A tree can be created with <a href="git-write-tree">git-write-tree[1]</a> and its data can be accessed by <a href="git-ls-tree">git-ls-tree[1]</a>. Two trees can be compared with <a href="git-diff-tree">git-diff-tree[1]</a>.</p> <p>A tag is created with <a href="git-mktag">git-mktag[1]</a>, and the signature can be verified by <a href="git-verify-tag">git-verify-tag[1]</a>, though it is normally simpler to use <a href="git-tag">git-tag[1]</a> for both.</p> </div> <div class="sect2"> <h3 id="the-workflow"> +The Workflow</h3> <p>High-level operations such as <a href="git-commit">git-commit[1]</a> and <a href="git-restore">git-restore[1]</a> work by moving data between the working tree, the index, and the object database. Git provides low-level operations which perform each of these steps individually.</p> <p>Generally, all Git operations work on the index file. Some operations work <strong>purely</strong> on the index file (showing the current state of the index), but most operations move data between the index file and either the database or the working directory. Thus there are four main combinations:</p> <div class="sect3"> <h4 id="working-directory-to-index"> +working directory → index</h4> <p>The <a href="git-update-index">git-update-index[1]</a> command updates the index with information from the working directory. You generally update the index information by just specifying the filename you want to update, like so:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git update-index filename</pre> </div> </div> <p>but to avoid common mistakes with filename globbing etc., the command will not normally add totally new entries or remove old entries, i.e. it will normally just update existing cache entries.</p> <p>To tell Git that yes, you really do realize that certain files no longer exist, or that new files should be added, you should use the <code>--remove</code> and <code>--add</code> flags respectively.</p> <p>NOTE! A <code>--remove</code> flag does <code>not</code> mean that subsequent filenames will necessarily be removed: if the files still exist in your directory structure, the index will be updated with their new status, not removed. The only thing <code>--remove</code> means is that update-index will be considering a removed file to be a valid thing, and if the file really does not exist any more, it will update the index accordingly.</p> <p>As a special case, you can also do <code>git update-index --refresh</code>, which will refresh the "stat" information of each index to match the current stat information. It will <code>not</code> update the object status itself, and it will only update the fields that are used to quickly test whether an object still matches its old backing store object.</p> <p>The previously introduced <a href="git-add">git-add[1]</a> is just a wrapper for <a href="git-update-index">git-update-index[1]</a>.</p> </div> <div class="sect3"> <h4 id="index-to-object-database"> +index → object database</h4> <p>You write your current index file to a "tree" object with the program</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git write-tree</pre> </div> </div> <p>that doesn’t come with any options—it will just write out the current index into the set of tree objects that describe that state, and it will return the name of the resulting top-level tree. You can use that tree to re-generate the index at any time by going in the other direction:</p> </div> <div class="sect3"> <h4 id="object-database-to-index"> +object database → index</h4> <p>You read a "tree" file from the object database, and use that to populate (and overwrite—don’t do this if your index contains any unsaved state that you might want to restore later!) your current index. Normal operation is just</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git read-tree <SHA-1 of tree></pre> </div> </div> <p>and your index file will now be equivalent to the tree that you saved earlier. However, that is only your <code>index</code> file: your working directory contents have not been modified.</p> </div> <div class="sect3"> <h4 id="index-to-working-directory"> +index → working directory</h4> <p>You update your working directory from the index by "checking out" files. This is not a very common operation, since normally you’d just keep your files updated, and rather than write to your working directory, you’d tell the index files about the changes in your working directory (i.e. <code>git update-index</code>).</p> <p>However, if you decide to jump to a new version, or check out somebody else’s version, or just restore a previous tree, you’d populate your index file with read-tree, and then you need to check out the result with</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git checkout-index filename</pre> </div> </div> <p>or, if you want to check out all of the index, use <code>-a</code>.</p> <p>NOTE! <code>git checkout-index</code> normally refuses to overwrite old files, so if you have an old version of the tree already checked out, you will need to use the <code>-f</code> flag (<code>before</code> the <code>-a</code> flag or the filename) to <code>force</code> the checkout.</p> <p>Finally, there are a few odds and ends which are not purely moving from one representation to the other:</p> </div> <div class="sect3"> <h4 id="tying-it-all-together"> +Tying it all together</h4> <p>To commit a tree you have instantiated with <code>git write-tree</code>, you’d create a "commit" object that refers to that tree and the history behind it—most notably the "parent" commits that preceded it in history.</p> <p>Normally a "commit" has one parent: the previous state of the tree before a certain change was made. However, sometimes it can have two or more parent commits, in which case we call it a "merge", due to the fact that such a commit brings together ("merges") two or more previous states represented by other commits.</p> <p>In other words, while a "tree" represents a particular directory state of a working directory, a "commit" represents that state in time, and explains how we got there.</p> <p>You create a commit object by giving it the tree that describes the state at the time of the commit, and a list of parents:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit-tree <tree> -p <parent> [(-p <parent2>)...]</pre> </div> </div> <p>and then giving the reason for the commit on stdin (either through redirection from a pipe or file, or by just typing it at the tty).</p> <p><code>git commit-tree</code> will return the name of the object that represents that commit, and you should save it away for later use. Normally, you’d commit a new <code>HEAD</code> state, and while Git doesn’t care where you save the note about that state, in practice we tend to just write the result to the file pointed at by <code>.git/HEAD</code>, so that we can always see what the last committed state was.</p> <p>Here is a picture that illustrates how various pieces fit together:</p> <div class="listingblock"> <div class="content"> <pre> commit-tree + commit obj + +----+ + | | + | | + V V + +-----------+ + | Object DB | + | Backing | + | Store | + +-----------+ + ^ + write-tree | | + tree obj | | + | | read-tree + | | tree obj + V + +-----------+ + | Index | + | "cache" | + +-----------+ + update-index ^ + blob obj | | + | | + checkout-index -u | | checkout-index + stat | | blob obj + V + +-----------+ + | Working | + | Directory | + +-----------+</pre> </div> </div> </div> </div> <div class="sect2"> <h3 id="examining-the-data"> +Examining the data</h3> <p>You can examine the data represented in the object database and the index with various helper tools. For every object, you can use <a href="git-cat-file">git-cat-file[1]</a> to examine details about the object:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cat-file -t <objectname></pre> </div> </div> <p>shows the type of the object, and once you have the type (which is usually implicit in where you find the object), you can use</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cat-file blob|tree|commit|tag <objectname></pre> </div> </div> <p>to show its contents. NOTE! Trees have binary content, and as a result there is a special helper for showing that content, called <code>git ls-tree</code>, which turns the binary content into a more easily readable form.</p> <p>It’s especially instructive to look at "commit" objects, since those tend to be small and fairly self-explanatory. In particular, if you follow the convention of having the top commit name in <code>.git/HEAD</code>, you can do</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cat-file commit HEAD</pre> </div> </div> <p>to see what the top commit was.</p> </div> <div class="sect2"> <h3 id="merging-multiple-trees"> +Merging multiple trees</h3> <p>Git can help you perform a three-way merge, which can in turn be used for a many-way merge by repeating the merge procedure several times. The usual situation is that you only do one three-way merge (reconciling two lines of history) and commit the result, but if you like to, you can merge several branches in one go.</p> <p>To perform a three-way merge, you start with the two commits you want to merge, find their closest common parent (a third commit), and compare the trees corresponding to these three commits.</p> <p>To get the "base" for the merge, look up the common parent of two commits:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git merge-base <commit1> <commit2></pre> </div> </div> <p>This prints the name of a commit they are both based on. You should now look up the tree objects of those commits, which you can easily do with</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cat-file commit <commitname> | head -1</pre> </div> </div> <p>since the tree object information is always the first line in a commit object.</p> <p>Once you know the three trees you are going to merge (the one "original" tree, aka the common tree, and the two "result" trees, aka the branches you want to merge), you do a "merge" read into the index. This will complain if it has to throw away your old index contents, so you should make sure that you’ve committed those—in fact you would normally always do a merge against your last commit (which should thus match what you have in your current index anyway).</p> <p>To do the merge, do</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git read-tree -m -u <origtree> <yourtree> <targettree></pre> </div> </div> <p>which will do all trivial merge operations for you directly in the index file, and you can just write the result out with <code>git write-tree</code>.</p> </div> <div class="sect2"> <h3 id="merging-multiple-trees-2"> +Merging multiple trees, continued</h3> <p>Sadly, many merges aren’t trivial. If there are files that have been added, moved or removed, or if both branches have modified the same file, you will be left with an index tree that contains "merge entries" in it. Such an index tree can <code>NOT</code> be written out to a tree object, and you will have to resolve any such merge clashes using other tools before you can write out the result.</p> <p>You can examine such index state with <code>git ls-files --unmerged</code> command. An example:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git read-tree -m $orig HEAD $target +$ git ls-files --unmerged +100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1 hello.c +100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2 hello.c +100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello.c</pre> </div> </div> <p>Each line of the <code>git ls-files --unmerged</code> output begins with the blob mode bits, blob SHA-1, <code>stage number</code>, and the filename. The <code>stage number</code> is Git’s way to say which tree it came from: stage 1 corresponds to the <code>$orig</code> tree, stage 2 to the <code>HEAD</code> tree, and stage 3 to the <code>$target</code> tree.</p> <p>Earlier we said that trivial merges are done inside <code>git read-tree -m</code>. For example, if the file did not change from <code>$orig</code> to <code>HEAD</code> or <code>$target</code>, or if the file changed from <code>$orig</code> to <code>HEAD</code> and <code>$orig</code> to <code>$target</code> the same way, obviously the final outcome is what is in <code>HEAD</code>. What the above example shows is that file <code>hello.c</code> was changed from <code>$orig</code> to <code>HEAD</code> and <code>$orig</code> to <code>$target</code> in a different way. You could resolve this by running your favorite 3-way merge program, e.g. <code>diff3</code>, <code>merge</code>, or Git’s own merge-file, on the blob objects from these three stages yourself, like this:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git cat-file blob 263414f >hello.c~1 +$ git cat-file blob 06fa6a2 >hello.c~2 +$ git cat-file blob cc44c73 >hello.c~3 +$ git merge-file hello.c~2 hello.c~1 hello.c~3</pre> </div> </div> <p>This would leave the merge result in <code>hello.c~2</code> file, along with conflict markers if there are conflicts. After verifying the merge result makes sense, you can tell Git what the final merge result for this file is by:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ mv -f hello.c~2 hello.c +$ git update-index hello.c</pre> </div> </div> <p>When a path is in the "unmerged" state, running <code>git update-index</code> for that path tells Git to mark the path resolved.</p> <p>The above is the description of a Git merge at the lowest level, to help you understand what conceptually happens under the hood. In practice, nobody, not even Git itself, runs <code>git cat-file</code> three times for this. There is a <code>git merge-index</code> program that extracts the stages to temporary files and calls a "merge" script on it:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git merge-index git-merge-one-file hello.c</pre> </div> </div> <p>and that is what higher level <code>git merge -s resolve</code> is implemented with.</p> </div> </div> <h2 id="hacking-git">Hacking git</h2> <div class="sectionbody"> <p>This chapter covers internal details of the Git implementation which probably only Git developers need to understand.</p> <div class="sect2"> <h3 id="object-details"> +Object storage format</h3> <p>All objects have a statically determined "type" which identifies the format of the object (i.e. how it is used, and how it can refer to other objects). There are currently four different object types: "blob", "tree", "commit", and "tag".</p> <p>Regardless of object type, all objects share the following characteristics: they are all deflated with zlib, and have a header that not only specifies their type, but also provides size information about the data in the object. It’s worth noting that the SHA-1 hash that is used to name the object is the hash of the original data plus this header, so <code>sha1sum</code> <code>file</code> does not match the object name for <code>file</code>.</p> <p>As a result, the general consistency of an object can always be tested independently of the contents or the type of the object: all objects can be validated by verifying that (a) their hashes match the content of the file and (b) the object successfully inflates to a stream of bytes that forms a sequence of <code><ascii type without space> + <space> + <ascii decimal size> + +<byte\0> + <binary object data></code>.</p> <p>The structured objects can further have their structure and connectivity to other objects verified. This is generally done with the <code>git fsck</code> program, which generates a full dependency graph of all objects, and verifies their internal consistency (in addition to just verifying their superficial consistency through the hash).</p> </div> <div class="sect2"> <h3 id="birdview-on-the-source-code"> +A birds-eye view of Git’s source code</h3> <p>It is not always easy for new developers to find their way through Git’s source code. This section gives you a little guidance to show where to start.</p> <p>A good place to start is with the contents of the initial commit, with:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch --detach e83c5163</pre> </div> </div> <p>The initial revision lays the foundation for almost everything Git has today, but is small enough to read in one sitting.</p> <p>Note that terminology has changed since that revision. For example, the README in that revision uses the word "changeset" to describe what we now call a <a href="#def_commit_object">commit</a>.</p> <p>Also, we do not call it "cache" any more, but rather "index"; however, the file is still called <code>read-cache.h</code>.</p> <p>If you grasp the ideas in that initial commit, you should check out a more recent version and skim <code>read-cache-ll.h</code>, <code>object.h</code> and <code>commit.h</code>.</p> <p>In the early days, Git (in the tradition of UNIX) was a bunch of programs which were extremely simple, and which you used in scripts, piping the output of one into another. This turned out to be good for initial development, since it was easier to test new things. However, recently many of these parts have become builtins, and some of the core has been "libified", i.e. put into libgit.a for performance, portability reasons, and to avoid code duplication.</p> <p>By now, you know what the index is (and find the corresponding data structures in <code>read-cache-ll.h</code>), and that there are just a couple of object types (blobs, trees, commits and tags) which inherit their common structure from <code>struct object</code>, which is their first member (and thus, you can cast e.g. <code>(struct object *)commit</code> to achieve the <code>same</code> as <code>&commit->object</code>, i.e. get at the object name and flags).</p> <p>Now is a good point to take a break to let this information sink in.</p> <p>Next step: get familiar with the object naming. Read <a href="#naming-commits">Naming commits</a>. There are quite a few ways to name an object (and not only revisions!). All of these are handled in <code>sha1_name.c</code>. Just have a quick look at the function <code>get_sha1()</code>. A lot of the special handling is done by functions like <code>get_sha1_basic()</code> or the likes.</p> <p>This is just to get you into the groove for the most libified part of Git: the revision walker.</p> <p>Basically, the initial version of <code>git log</code> was a shell script:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git-rev-list --pretty $(git-rev-parse --default HEAD "$@") | \ + LESS=-S ${PAGER:-less}</pre> </div> </div> <p>What does this mean?</p> <p><code>git rev-list</code> is the original version of the revision walker, which <code>always</code> printed a list of revisions to stdout. It is still functional, and needs to, since most new Git commands start out as scripts using <code>git rev-list</code>.</p> <p><code>git rev-parse</code> is not as important any more; it was only used to filter out options that were relevant for the different plumbing commands that were called by the script.</p> <p>Most of what <code>git rev-list</code> did is contained in <code>revision.c</code> and <code>revision.h</code>. It wraps the options in a struct named <code>rev_info</code>, which controls how and what revisions are walked, and more.</p> <p>The original job of <code>git rev-parse</code> is now taken by the function <code>setup_revisions()</code>, which parses the revisions and the common command-line options for the revision walker. This information is stored in the struct <code>rev_info</code> for later consumption. You can do your own command-line option parsing after calling <code>setup_revisions()</code>. After that, you have to call <code>prepare_revision_walk()</code> for initialization, and then you can get the commits one by one with the function <code>get_revision()</code>.</p> <p>If you are interested in more details of the revision walking process, just have a look at the first implementation of <code>cmd_log()</code>; call <code>git show v1.3.0~155^2~4</code> and scroll down to that function (note that you no longer need to call <code>setup_pager()</code> directly).</p> <p>Nowadays, <code>git log</code> is a builtin, which means that it is <code>contained</code> in the command <code>git</code>. The source side of a builtin is</p> <div class="ulist"> <ul> <li> <p>a function called <code>cmd_<bla></code>, typically defined in <code>builtin/<bla.c></code> (note that older versions of Git used to have it in <code>builtin-<bla>.c</code> instead), and declared in <code>builtin.h</code>.</p> </li> <li> <p>an entry in the <code>commands[]</code> array in <code>git.c</code>, and</p> </li> <li> <p>an entry in <code>BUILTIN_OBJECTS</code> in the <code>Makefile</code>.</p> </li> </ul> </div> <p>Sometimes, more than one builtin is contained in one source file. For example, <code>cmd_whatchanged()</code> and <code>cmd_log()</code> both reside in <code>builtin/log.c</code>, since they share quite a bit of code. In that case, the commands which are <code>not</code> named like the <code>.c</code> file in which they live have to be listed in <code>BUILT_INS</code> in the <code>Makefile</code>.</p> <p><code>git log</code> looks more complicated in C than it does in the original script, but that allows for a much greater flexibility and performance.</p> <p>Here again it is a good point to take a pause.</p> <p>Lesson three is: study the code. Really, it is the best way to learn about the organization of Git (after you know the basic concepts).</p> <p>So, think about something which you are interested in, say, "how can I access a blob just knowing the object name of it?". The first step is to find a Git command with which you can do it. In this example, it is either <code>git show</code> or <code>git cat-file</code>.</p> <p>For the sake of clarity, let’s stay with <code>git cat-file</code>, because it</p> <div class="ulist"> <ul> <li> <p>is plumbing, and</p> </li> <li> <p>was around even in the initial commit (it literally went only through some 20 revisions as <code>cat-file.c</code>, was renamed to <code>builtin/cat-file.c</code> when made a builtin, and then saw less than 10 versions).</p> </li> </ul> </div> <p>So, look into <code>builtin/cat-file.c</code>, search for <code>cmd_cat_file()</code> and look what it does.</p> <div class="listingblock"> <div class="content"> <pre> git_config(git_default_config); + if (argc != 3) + usage("git cat-file [-t|-s|-e|-p|<type>] <sha1>"); + if (get_sha1(argv[2], sha1)) + die("Not a valid object name %s", argv[2]);</pre> </div> </div> <p>Let’s skip over the obvious details; the only really interesting part here is the call to <code>get_sha1()</code>. It tries to interpret <code>argv[2]</code> as an object name, and if it refers to an object which is present in the current repository, it writes the resulting SHA-1 into the variable <code>sha1</code>.</p> <p>Two things are interesting here:</p> <div class="ulist"> <ul> <li> <p><code>get_sha1()</code> returns 0 on <code>success</code>. This might surprise some new Git hackers, but there is a long tradition in UNIX to return different negative numbers in case of different errors—and 0 on success.</p> </li> <li> <p>the variable <code>sha1</code> in the function signature of <code>get_sha1()</code> is <code>unsigned +char *</code>, but is actually expected to be a pointer to <code>unsigned +char[20]</code>. This variable will contain the 160-bit SHA-1 of the given commit. Note that whenever a SHA-1 is passed as <code>unsigned char *</code>, it is the binary representation, as opposed to the ASCII representation in hex characters, which is passed as <code>char *</code>.</p> </li> </ul> </div> <p>You will see both of these things throughout the code.</p> <p>Now, for the meat:</p> <div class="listingblock"> <div class="content"> <pre> case 0: + buf = read_object_with_reference(sha1, argv[1], &size, NULL);</pre> </div> </div> <p>This is how you read a blob (actually, not only a blob, but any type of object). To know how the function <code>read_object_with_reference()</code> actually works, find the source code for it (something like <code>git grep +read_object_with | grep ":[a-z]"</code> in the Git repository), and read the source.</p> <p>To find out how the result can be used, just read on in <code>cmd_cat_file()</code>:</p> <div class="listingblock"> <div class="content"> <pre> write_or_die(1, buf, size);</pre> </div> </div> <p>Sometimes, you do not know where to look for a feature. In many such cases, it helps to search through the output of <code>git log</code>, and then <code>git show</code> the corresponding commit.</p> <p>Example: If you know that there was some test case for <code>git bundle</code>, but do not remember where it was (yes, you <code>could</code> <code>git grep bundle t/</code>, but that does not illustrate the point!):</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log --no-merges t/</pre> </div> </div> <p>In the pager (<code>less</code>), just search for "bundle", go a few lines back, and see that it is in commit 18449ab0. Now just copy this object name, and paste it into the command line</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git show 18449ab0</pre> </div> </div> <p>Voila.</p> <p>Another example: Find out what to do in order to make some script a builtin:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git log --no-merges --diff-filter=A builtin/*.c</pre> </div> </div> <p>You see, Git is actually the best tool to find out about the source of Git itself!</p> </div> </div> <h2 id="glossary">Git glossary</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="git-explained"> +Git explained</h3> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefalternateobjectdatabaseaalternateobjectdatabase"> alternate object database </dt> <dd> <p>Via the alternates mechanism, a <a href="#def_repository">repository</a> can inherit part of its <a href="#def_object_database">object database</a> from another object database, which is called an "alternate".</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefbarerepositoryabarerepository"> bare repository </dt> <dd> <p>A bare repository is normally an appropriately named <a href="#def_directory">directory</a> with a <code>.git</code> suffix that does not have a locally checked-out copy of any of the files under revision control. That is, all of the Git administrative and control files that would normally be present in the hidden <code>.git</code> sub-directory are directly present in the <code>repository.git</code> directory instead, and no other files are present and checked out. Usually publishers of public repositories make bare repositories available.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefblobobjectablobobject"> blob object </dt> <dd> <p>Untyped <a href="#def_object">object</a>, e.g. the contents of a file.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefbranchabranch"> branch </dt> <dd> <p>A "branch" is a line of development. The most recent <a href="#def_commit">commit</a> on a branch is referred to as the tip of that branch. The tip of the branch is <a href="#def_ref">referenced</a> by a branch <a href="#def_head">head</a>, which moves forward as additional development is done on the branch. A single Git <a href="#def_repository">repository</a> can track an arbitrary number of branches, but your <a href="#def_working_tree">working tree</a> is associated with just one of them (the "current" or "checked out" branch), and <a href="#def_HEAD">HEAD</a> points to that branch.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefcacheacache"> cache </dt> <dd> <p>Obsolete for: <a href="#def_index">index</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefchainachain"> chain </dt> <dd> <p>A list of objects, where each <a href="#def_object">object</a> in the list contains a reference to its successor (for example, the successor of a <a href="#def_commit">commit</a> could be one of its <a href="#def_parent">parents</a>).</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefchangesetachangeset"> changeset </dt> <dd> <p>BitKeeper/cvsps speak for "<a href="#def_commit">commit</a>". Since Git does not store changes, but states, it really does not make sense to use the term "changesets" with Git.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefcheckoutacheckout"> checkout </dt> <dd> <p>The action of updating all or part of the <a href="#def_working_tree">working tree</a> with a <a href="#def_tree_object">tree object</a> or <a href="#def_blob_object">blob</a> from the <a href="#def_object_database">object database</a>, and updating the <a href="#def_index">index</a> and <a href="#def_HEAD">HEAD</a> if the whole working tree has been pointed at a new <a href="#def_branch">branch</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefcherry-pickingacherry-picking"> cherry-picking </dt> <dd> <p>In <a href="#def_SCM">SCM</a> jargon, "cherry pick" means to choose a subset of changes out of a series of changes (typically commits) and record them as a new series of changes on top of a different codebase. In Git, this is performed by the "git cherry-pick" command to extract the change introduced by an existing <a href="#def_commit">commit</a> and to record it based on the tip of the current <a href="#def_branch">branch</a> as a new commit.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefcleanaclean"> clean </dt> <dd> <p>A <a href="#def_working_tree">working tree</a> is clean, if it corresponds to the <a href="#def_revision">revision</a> referenced by the current <a href="#def_head">head</a>. Also see "<a href="#def_dirty">dirty</a>".</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefcommitacommit"> commit </dt> <dd> <p>As a noun: A single point in the Git history; the entire history of a project is represented as a set of interrelated commits. The word "commit" is often used by Git in the same places other revision control systems use the words "revision" or "version". Also used as a short hand for <a href="#def_commit_object">commit object</a>.</p> <p>As a verb: The action of storing a new snapshot of the project’s state in the Git history, by creating a new commit representing the current state of the <a href="#def_index">index</a> and advancing <a href="#def_HEAD">HEAD</a> to point at the new commit.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefcommitgraphgeneralacommitgraphconceptrepresentationsandusage"> commit graph concept, representations and usage </dt> <dd> <p>A synonym for the <a href="#def_DAG">DAG</a> structure formed by the commits in the object database, <a href="#def_ref">referenced</a> by branch tips, using their <a href="#def_chain">chain</a> of linked commits. This structure is the definitive commit graph. The graph can be represented in other ways, e.g. the <a href="#def_commit_graph_file">"commit-graph" file</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefcommitgraphfileacommit-graphfile"> commit-graph file </dt> <dd> <p>The "commit-graph" (normally hyphenated) file is a supplemental representation of the <a href="#def_commit_graph_general">commit graph</a> which accelerates commit graph walks. The "commit-graph" file is stored either in the .git/objects/info directory or in the info directory of an alternate object database.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefcommitobjectacommitobject"> commit object </dt> <dd> <p>An <a href="#def_object">object</a> which contains the information about a particular <a href="#def_revision">revision</a>, such as <a href="#def_parent">parents</a>, committer, author, date and the <a href="#def_tree_object">tree object</a> which corresponds to the top <a href="#def_directory">directory</a> of the stored revision.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefcommit-ishacommit-ishalsocommittish"> commit-ish (also committish) </dt> <dd> <p>A <a href="#def_commit_object">commit object</a> or an <a href="#def_object">object</a> that can be recursively <a href="#def_dereference">dereferenced</a> to a commit object. The following are all commit-ishes: a commit object, a <a href="#def_tag_object">tag object</a> that points to a commit object, a tag object that points to a tag object that points to a commit object, etc.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefcoregitacoreGit"> core Git </dt> <dd> <p>Fundamental data structures and utilities of Git. Exposes only limited source code management tools.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefDAGaDAG"> DAG </dt> <dd> <p>Directed acyclic graph. The <a href="#def_commit_object">commit objects</a> form a directed acyclic graph, because they have parents (directed), and the graph of commit objects is acyclic (there is no <a href="#def_chain">chain</a> which begins and ends with the same <a href="#def_object">object</a>).</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefdanglingobjectadanglingobject"> dangling object </dt> <dd> <p>An <a href="#def_unreachable_object">unreachable object</a> which is not <a href="#def_reachable">reachable</a> even from other unreachable objects; a dangling object has no references to it from any reference or <a href="#def_object">object</a> in the <a href="#def_repository">repository</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefdereferenceadereference"> dereference </dt> <dd> <p>Referring to a <a href="#def_symref">symbolic ref</a>: the action of accessing the <a href="#def_ref">reference</a> pointed at by a symbolic ref. Recursive dereferencing involves repeating the aforementioned process on the resulting ref until a non-symbolic reference is found.</p> <p>Referring to a <a href="#def_tag_object">tag object</a>: the action of accessing the <a href="#def_object">object</a> a tag points at. Tags are recursively dereferenced by repeating the operation on the result object until the result has either a specified <a href="#def_object_type">object type</a> (where applicable) or any non-"tag" object type. A synonym for "recursive dereference" in the context of tags is "<a href="#def_peel">peel</a>".</p> <p>Referring to a <a href="#def_commit_object">commit object</a>: the action of accessing the commit’s tree object. Commits cannot be dereferenced recursively.</p> <p>Unless otherwise specified, "dereferencing" as it used in the context of Git commands or protocols is implicitly recursive.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefdetachedHEADadetachedHEAD"> detached HEAD </dt> <dd> <p>Normally the <a href="#def_HEAD">HEAD</a> stores the name of a <a href="#def_branch">branch</a>, and commands that operate on the history HEAD represents operate on the history leading to the tip of the branch the HEAD points at. However, Git also allows you to <a href="#def_checkout">check out</a> an arbitrary <a href="#def_commit">commit</a> that isn’t necessarily the tip of any particular branch. The HEAD in such a state is called "detached".</p> <p>Note that commands that operate on the history of the current branch (e.g. <code>git commit</code> to build a new history on top of it) still work while the HEAD is detached. They update the HEAD to point at the tip of the updated history without affecting any branch. Commands that update or inquire information <code>about</code> the current branch (e.g. <code>git +branch --set-upstream-to</code> that sets what remote-tracking branch the current branch integrates with) obviously do not work, as there is no (real) current branch to ask about in this state.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefdirectoryadirectory"> directory </dt> <dd> <p>The list you get with "ls" :-)</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefdirtyadirty"> dirty </dt> <dd> <p>A <a href="#def_working_tree">working tree</a> is said to be "dirty" if it contains modifications which have not been <a href="#def_commit">committed</a> to the current <a href="#def_branch">branch</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefevilmergeaevilmerge"> evil merge </dt> <dd> <p>An evil merge is a <a href="#def_merge">merge</a> that introduces changes that do not appear in any <a href="#def_parent">parent</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddeffastforwardafast-forward"> fast-forward </dt> <dd> <p>A fast-forward is a special type of <a href="#def_merge">merge</a> where you have a <a href="#def_revision">revision</a> and you are "merging" another <a href="#def_branch">branch</a>'s changes that happen to be a descendant of what you have. In such a case, you do not make a new <a href="#def_merge">merge</a> <a href="#def_commit">commit</a> but instead just update your branch to point at the same revision as the branch you are merging. This will happen frequently on a <a href="#def_remote_tracking_branch">remote-tracking branch</a> of a remote <a href="#def_repository">repository</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddeffetchafetch"> fetch </dt> <dd> <p>Fetching a <a href="#def_branch">branch</a> means to get the branch’s <a href="#def_head_ref">head ref</a> from a remote <a href="#def_repository">repository</a>, to find out which objects are missing from the local <a href="#def_object_database">object database</a>, and to get them, too. See also <a href="git-fetch">git-fetch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddeffilesystemafilesystem"> file system </dt> <dd> <p>Linus Torvalds originally designed Git to be a user space file system, i.e. the infrastructure to hold files and directories. That ensured the efficiency and speed of Git.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefgitarchiveaGitarchive"> Git archive </dt> <dd> <p>Synonym for <a href="#def_repository">repository</a> (for arch people).</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefgitfileagitfile"> gitfile </dt> <dd> <p>A plain file <code>.git</code> at the root of a working tree that points at the directory that is the real repository. For proper use see <a href="git-worktree">git-worktree[1]</a> or <a href="git-submodule">git-submodule[1]</a>. For syntax see <a href="gitrepository-layout">gitrepository-layout[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefgraftsagrafts"> grafts </dt> <dd> <p>Grafts enable two otherwise different lines of development to be joined together by recording fake ancestry information for commits. This way you can make Git pretend the set of <a href="#def_parent">parents</a> a <a href="#def_commit">commit</a> has is different from what was recorded when the commit was created. Configured via the <code>.git/info/grafts</code> file.</p> <p>Note that the grafts mechanism is outdated and can lead to problems transferring objects between repositories; see <a href="git-replace">git-replace[1]</a> for a more flexible and robust system to do the same thing.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefhashahash"> hash </dt> <dd> <p>In Git’s context, synonym for <a href="#def_object_name">object name</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefheadahead"> head </dt> <dd> <p>A <a href="#def_ref">named reference</a> to the <a href="#def_commit">commit</a> at the tip of a <a href="#def_branch">branch</a>. Heads are stored in a file in <code>$GIT_DIR/refs/heads/</code> directory, except when using packed refs. (See <a href="git-pack-refs">git-pack-refs[1]</a>.)</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefHEADaHEAD"> HEAD </dt> <dd> <p>The current <a href="#def_branch">branch</a>. In more detail: Your <a href="#def_working_tree">working tree</a> is normally derived from the state of the tree referred to by HEAD. HEAD is a reference to one of the <a href="#def_head">heads</a> in your repository, except when using a <a href="#def_detached_HEAD">detached HEAD</a>, in which case it directly references an arbitrary commit.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefheadrefaheadref"> head ref </dt> <dd> <p>A synonym for <a href="#def_head">head</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefhookahook"> hook </dt> <dd> <p>During the normal execution of several Git commands, call-outs are made to optional scripts that allow a developer to add functionality or checking. Typically, the hooks allow for a command to be pre-verified and potentially aborted, and allow for a post-notification after the operation is done. The hook scripts are found in the <code>$GIT_DIR/hooks/</code> directory, and are enabled by simply removing the <code>.sample</code> suffix from the filename. In earlier versions of Git you had to make them executable.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefindexaindex"> index </dt> <dd> <p>A collection of files with stat information, whose contents are stored as objects. The index is a stored version of your <a href="#def_working_tree">working tree</a>. Truth be told, it can also contain a second, and even a third version of a working tree, which are used when <a href="#def_merge">merging</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefindexentryaindexentry"> index entry </dt> <dd> <p>The information regarding a particular file, stored in the <a href="#def_index">index</a>. An index entry can be unmerged, if a <a href="#def_merge">merge</a> was started, but not yet finished (i.e. if the index contains multiple versions of that file).</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefmasteramaster"> master </dt> <dd> <p>The default development <a href="#def_branch">branch</a>. Whenever you create a Git <a href="#def_repository">repository</a>, a branch named "master" is created, and becomes the active branch. In most cases, this contains the local development, though that is purely by convention and is not required.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefmergeamerge"> merge </dt> <dd> <p>As a verb: To bring the contents of another <a href="#def_branch">branch</a> (possibly from an external <a href="#def_repository">repository</a>) into the current branch. In the case where the merged-in branch is from a different repository, this is done by first <a href="#def_fetch">fetching</a> the remote branch and then merging the result into the current branch. This combination of fetch and merge operations is called a <a href="#def_pull">pull</a>. Merging is performed by an automatic process that identifies changes made since the branches diverged, and then applies all those changes together. In cases where changes conflict, manual intervention may be required to complete the merge.</p> <p>As a noun: unless it is a <a href="#def_fast_forward">fast-forward</a>, a successful merge results in the creation of a new <a href="#def_commit">commit</a> representing the result of the merge, and having as <a href="#def_parent">parents</a> the tips of the merged <a href="#def_branch">branches</a>. This commit is referred to as a "merge commit", or sometimes just a "merge".</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefobjectaobject"> object </dt> <dd> <p>The unit of storage in Git. It is uniquely identified by the <a href="#def_SHA1">SHA-1</a> of its contents. Consequently, an object cannot be changed.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefobjectdatabaseaobjectdatabase"> object database </dt> <dd> <p>Stores a set of "objects", and an individual <a href="#def_object">object</a> is identified by its <a href="#def_object_name">object name</a>. The objects usually live in <code>$GIT_DIR/objects/</code>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefobjectidentifieraobjectidentifieroid"> object identifier (oid) </dt> <dd> <p>Synonym for <a href="#def_object_name">object name</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefobjectnameaobjectname"> object name </dt> <dd> <p>The unique identifier of an <a href="#def_object">object</a>. The object name is usually represented by a 40 character hexadecimal string. Also colloquially called <a href="#def_SHA1">SHA-1</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefobjecttypeaobjecttype"> object type </dt> <dd> <p>One of the identifiers "<a href="#def_commit_object">commit</a>", "<a href="#def_tree_object">tree</a>", "<a href="#def_tag_object">tag</a>" or "<a href="#def_blob_object">blob</a>" describing the type of an <a href="#def_object">object</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefoctopusaoctopus"> octopus </dt> <dd> <p>To <a href="#def_merge">merge</a> more than two <a href="#def_branch">branches</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddeforphanaorphan"> orphan </dt> <dd> <p>The act of getting on a <a href="#def_branch">branch</a> that does not exist yet (i.e., an <a href="#def_unborn">unborn</a> branch). After such an operation, the commit first created becomes a commit without a parent, starting a new history.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddeforiginaorigin"> origin </dt> <dd> <p>The default upstream <a href="#def_repository">repository</a>. Most projects have at least one upstream project which they track. By default <code>origin</code> is used for that purpose. New upstream updates will be fetched into <a href="#def_remote_tracking_branch">remote-tracking branches</a> named origin/name-of-upstream-branch, which you can see using <code>git branch -r</code>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefoverlayaoverlay"> overlay </dt> <dd> <p>Only update and add files to the working directory, but don’t delete them, similar to how <code>cp -R</code> would update the contents in the destination directory. This is the default mode in a <a href="#def_checkout">checkout</a> when checking out files from the <a href="#def_index">index</a> or a <a href="#def_tree-ish">tree-ish</a>. In contrast, no-overlay mode also deletes tracked files not present in the source, similar to <code>rsync --delete</code>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefpackapack"> pack </dt> <dd> <p>A set of objects which have been compressed into one file (to save space or to transmit them efficiently).</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefpackindexapackindex"> pack index </dt> <dd> <p>The list of identifiers, and other information, of the objects in a <a href="#def_pack">pack</a>, to assist in efficiently accessing the contents of a pack.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefpathspecapathspec"> pathspec </dt> <dd> <p>Pattern used to limit paths in Git commands.</p> <p>Pathspecs are used on the command line of "git ls-files", "git ls-tree", "git add", "git grep", "git diff", "git checkout", and many other commands to limit the scope of operations to some subset of the tree or working tree. See the documentation of each command for whether paths are relative to the current directory or toplevel. The pathspec syntax is as follows:</p> <div class="openblock"> <div class="content"> <div class="ulist"> <ul> <li> <p>any path matches itself</p> </li> <li> <p>the pathspec up to the last slash represents a directory prefix. The scope of that pathspec is limited to that subtree.</p> </li> <li> <p>the rest of the pathspec is a pattern for the remainder of the pathname. Paths relative to the directory prefix will be matched against that pattern using fnmatch(3); in particular, <code>*</code> and <code>?</code> <code>can</code> match directory separators.</p> </li> </ul> </div> </div> </div> <p>For example, Documentation/*.jpg will match all .jpg files in the Documentation subtree, including Documentation/chapter_1/figure_1.jpg.</p> <p>A pathspec that begins with a colon <code>:</code> has special meaning. In the short form, the leading colon <code>:</code> is followed by zero or more "magic signature" letters (which optionally is terminated by another colon <code>:</code>), and the remainder is the pattern to match against the path. The "magic signature" consists of ASCII symbols that are neither alphanumeric, glob, regex special characters nor colon. The optional colon that terminates the "magic signature" can be omitted if the pattern begins with a character that does not belong to "magic signature" symbol set and is not a colon.</p> <p>In the long form, the leading colon <code>:</code> is followed by an open parenthesis <code>(</code>, a comma-separated list of zero or more "magic words", and a close parentheses <code>)</code>, and the remainder is the pattern to match against the path.</p> <p>A pathspec with only a colon means "there is no pathspec". This form should not be combined with other pathspec.</p> <div class="openblock"> <div class="content"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/user-manual.txt-top"> top </dt> <dd> <p>The magic word <code>top</code> (magic signature: <code>/</code>) makes the pattern match from the root of the working tree, even when you are running the command from inside a subdirectory.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-literal"> literal </dt> <dd> <p>Wildcards in the pattern such as <code>*</code> or <code>?</code> are treated as literal characters.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-icase"> icase </dt> <dd> <p>Case insensitive match.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-glob"> glob </dt> <dd> <p>Git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname. For example, "Documentation/*.html" matches "Documentation/git.html" but not "Documentation/ppc/ppc.html" or "tools/perf/Documentation/perf.html".</p> <p>Two consecutive asterisks ("<code>**</code>") in patterns matched against full pathname may have special meaning:</p> <div class="ulist"> <ul> <li> <p>A leading "<code>**</code>" followed by a slash means match in all directories. For example, "<code>**/foo</code>" matches file or directory "<code>foo</code>" anywhere, the same as pattern "<code>foo</code>". "<code>**/foo/bar</code>" matches file or directory "<code>bar</code>" anywhere that is directly under directory "<code>foo</code>".</p> </li> <li> <p>A trailing "<code>/**</code>" matches everything inside. For example, "<code>abc/**</code>" matches all files inside directory "abc", relative to the location of the <code>.gitignore</code> file, with infinite depth.</p> </li> <li> <p>A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "<code>a/**/b</code>" matches "<code>a/b</code>", "<code>a/x/b</code>", "<code>a/x/y/b</code>" and so on.</p> </li> <li> <p>Other consecutive asterisks are considered invalid.</p> <p>Glob magic is incompatible with literal magic.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-attr"> attr </dt> <dd> <p>After <code>attr:</code> comes a space separated list of "attribute requirements", all of which must be met in order for the path to be considered a match; this is in addition to the usual non-magic pathspec pattern matching. See <a href="gitattributes">gitattributes[5]</a>.</p> <p>Each of the attribute requirements for the path takes one of these forms:</p> <div class="ulist"> <ul> <li> <p>"<code>ATTR</code>" requires that the attribute <code>ATTR</code> be set.</p> </li> <li> <p>"<code>-ATTR</code>" requires that the attribute <code>ATTR</code> be unset.</p> </li> <li> <p>"<code>ATTR=VALUE</code>" requires that the attribute <code>ATTR</code> be set to the string <code>VALUE</code>.</p> </li> <li> <p>"<code>!ATTR</code>" requires that the attribute <code>ATTR</code> be unspecified.</p> <p>Note that when matching against a tree object, attributes are still obtained from working tree, not from the given tree object.</p> </li> </ul> </div> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-exclude"> exclude </dt> <dd> <p>After a path matches any non-exclude pathspec, it will be run through all exclude pathspecs (magic signature: <code>!</code> or its synonym <code>^</code>). If it matches, the path is ignored. When there is no non-exclude pathspec, the exclusion is applied to the result set as if invoked without any pathspec.</p> </dd> </dl> </div> </div> </div> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefparentaparent"> parent </dt> <dd> <p>A <a href="#def_commit_object">commit object</a> contains a (possibly empty) list of the logical predecessor(s) in the line of development, i.e. its parents.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefpeelapeel"> peel </dt> <dd> <p>The action of recursively <a href="#def_dereference">dereferencing</a> a <a href="#def_tag_object">tag object</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefpickaxeapickaxe"> pickaxe </dt> <dd> <p>The term <a href="#def_pickaxe">pickaxe</a> refers to an option to the diffcore routines that help select changes that add or delete a given text string. With the <code>--pickaxe-all</code> option, it can be used to view the full <a href="#def_changeset">changeset</a> that introduced or removed, say, a particular line of text. See <a href="git-diff">git-diff[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefplumbingaplumbing"> plumbing </dt> <dd> <p>Cute name for <a href="#def_core_git">core Git</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefporcelainaporcelain"> porcelain </dt> <dd> <p>Cute name for programs and program suites depending on <a href="#def_core_git">core Git</a>, presenting a high level access to core Git. Porcelains expose more of a <a href="#def_SCM">SCM</a> interface than the <a href="#def_plumbing">plumbing</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefperworktreerefaper-worktreeref"> per-worktree ref </dt> <dd> <p>Refs that are per-<a href="#def_worktree">worktree</a>, rather than global. This is presently only <a href="#def_HEAD">HEAD</a> and any refs that start with <code>refs/bisect/</code>, but might later include other unusual refs.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefpseudorefapseudoref"> pseudoref </dt> <dd> <p>Pseudorefs are a class of files under <code>$GIT_DIR</code> which behave like refs for the purposes of rev-parse, but which are treated specially by git. Pseudorefs both have names that are all-caps, and always start with a line consisting of a <a href="#def_SHA1">SHA-1</a> followed by whitespace. So, HEAD is not a pseudoref, because it is sometimes a symbolic ref. They might optionally contain some additional data. <code>MERGE_HEAD</code> and <code>CHERRY_PICK_HEAD</code> are examples. Unlike <a href="#def_per_worktree_ref">per-worktree refs</a>, these files cannot be symbolic refs, and never have reflogs. They also cannot be updated through the normal ref update machinery. Instead, they are updated by directly writing to the files. However, they can be read as if they were refs, so <code>git rev-parse +MERGE_HEAD</code> will work.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefpullapull"> pull </dt> <dd> <p>Pulling a <a href="#def_branch">branch</a> means to <a href="#def_fetch">fetch</a> it and <a href="#def_merge">merge</a> it. See also <a href="git-pull">git-pull[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefpushapush"> push </dt> <dd> <p>Pushing a <a href="#def_branch">branch</a> means to get the branch’s <a href="#def_head_ref">head ref</a> from a remote <a href="#def_repository">repository</a>, find out if it is an ancestor to the branch’s local head ref, and in that case, putting all objects, which are <a href="#def_reachable">reachable</a> from the local head ref, and which are missing from the remote repository, into the remote <a href="#def_object_database">object database</a>, and updating the remote head ref. If the remote <a href="#def_head">head</a> is not an ancestor to the local head, the push fails.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefreachableareachable"> reachable </dt> <dd> <p>All of the ancestors of a given <a href="#def_commit">commit</a> are said to be "reachable" from that commit. More generally, one <a href="#def_object">object</a> is reachable from another if we can reach the one from the other by a <a href="#def_chain">chain</a> that follows <a href="#def_tag">tags</a> to whatever they tag, <a href="#def_commit_object">commits</a> to their parents or trees, and <a href="#def_tree_object">trees</a> to the trees or <a href="#def_blob_object">blobs</a> that they contain.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefreachabilitybitmapareachabilitybitmaps"> reachability bitmaps </dt> <dd> <p>Reachability bitmaps store information about the <a href="#def_reachable">reachability</a> of a selected set of commits in a packfile, or a multi-pack index (MIDX), to speed up object search. The bitmaps are stored in a ".bitmap" file. A repository may have at most one bitmap file in use. The bitmap file may belong to either one pack, or the repository’s multi-pack index (if it exists).</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefrebasearebase"> rebase </dt> <dd> <p>To reapply a series of changes from a <a href="#def_branch">branch</a> to a different base, and reset the <a href="#def_head">head</a> of that branch to the result.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefrefaref"> ref </dt> <dd> <p>A name that begins with <code>refs/</code> (e.g. <code>refs/heads/master</code>) that points to an <a href="#def_object_name">object name</a> or another ref (the latter is called a <a href="#def_symref">symbolic ref</a>). For convenience, a ref can sometimes be abbreviated when used as an argument to a Git command; see <a href="gitrevisions">gitrevisions[7]</a> for details. Refs are stored in the <a href="#def_repository">repository</a>.</p> <p>The ref namespace is hierarchical. Different subhierarchies are used for different purposes (e.g. the <code>refs/heads/</code> hierarchy is used to represent local branches).</p> <p>There are a few special-purpose refs that do not begin with <code>refs/</code>. The most notable example is <code>HEAD</code>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefreflogareflog"> reflog </dt> <dd> <p>A reflog shows the local "history" of a ref. In other words, it can tell you what the 3rd last revision in <code>this</code> repository was, and what was the current state in <code>this</code> repository, yesterday 9:14pm. See <a href="git-reflog">git-reflog[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefrefspecarefspec"> refspec </dt> <dd> <p>A "refspec" is used by <a href="#def_fetch">fetch</a> and <a href="#def_push">push</a> to describe the mapping between remote <a href="#def_ref">ref</a> and local ref.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefremotearemoterepository"> remote repository </dt> <dd> <p>A <a href="#def_repository">repository</a> which is used to track the same project but resides somewhere else. To communicate with remotes, see <a href="#def_fetch">fetch</a> or <a href="#def_push">push</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefremotetrackingbrancharemote-trackingbranch"> remote-tracking branch </dt> <dd> <p>A <a href="#def_ref">ref</a> that is used to follow changes from another <a href="#def_repository">repository</a>. It typically looks like <code>refs/remotes/foo/bar</code> (indicating that it tracks a branch named <code>bar</code> in a remote named <code>foo</code>), and matches the right-hand-side of a configured fetch <a href="#def_refspec">refspec</a>. A remote-tracking branch should not contain direct modifications or have local commits made to it.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefrepositoryarepository"> repository </dt> <dd> <p>A collection of <a href="#def_ref">refs</a> together with an <a href="#def_object_database">object database</a> containing all objects which are <a href="#def_reachable">reachable</a> from the refs, possibly accompanied by meta data from one or more <a href="#def_porcelain">porcelains</a>. A repository can share an object database with other repositories via <a href="#def_alternate_object_database">alternates mechanism</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefresolvearesolve"> resolve </dt> <dd> <p>The action of fixing up manually what a failed automatic <a href="#def_merge">merge</a> left behind.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefrevisionarevision"> revision </dt> <dd> <p>Synonym for <a href="#def_commit">commit</a> (the noun).</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefrewindarewind"> rewind </dt> <dd> <p>To throw away part of the development, i.e. to assign the <a href="#def_head">head</a> to an earlier <a href="#def_revision">revision</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefSCMaSCM"> SCM </dt> <dd> <p>Source code management (tool).</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefSHA1aSHA-1"> SHA-1 </dt> <dd> <p>"Secure Hash Algorithm 1"; a cryptographic hash function. In the context of Git used as a synonym for <a href="#def_object_name">object name</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefshallowcloneashallowclone"> shallow clone </dt> <dd> <p>Mostly a synonym to <a href="#def_shallow_repository">shallow repository</a> but the phrase makes it more explicit that it was created by running <code>git clone --depth=...</code> command.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefshallowrepositoryashallowrepository"> shallow repository </dt> <dd> <p>A shallow <a href="#def_repository">repository</a> has an incomplete history some of whose <a href="#def_commit">commits</a> have <a href="#def_parent">parents</a> cauterized away (in other words, Git is told to pretend that these commits do not have the parents, even though they are recorded in the <a href="#def_commit_object">commit object</a>). This is sometimes useful when you are interested only in the recent history of a project even though the real history recorded in the upstream is much larger. A shallow repository is created by giving the <code>--depth</code> option to <a href="git-clone">git-clone[1]</a>, and its history can be later deepened with <a href="git-fetch">git-fetch[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefstashastashentry"> stash entry </dt> <dd> <p>An <a href="#def_object">object</a> used to temporarily store the contents of a <a href="#def_dirty">dirty</a> working directory and the index for future reuse.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefsubmoduleasubmodule"> submodule </dt> <dd> <p>A <a href="#def_repository">repository</a> that holds the history of a separate project inside another repository (the latter of which is called <a href="#def_superproject">superproject</a>).</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefsuperprojectasuperproject"> superproject </dt> <dd> <p>A <a href="#def_repository">repository</a> that references repositories of other projects in its working tree as <a href="#def_submodule">submodules</a>. The superproject knows about the names of (but does not hold copies of) commit objects of the contained submodules.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefsymrefasymref"> symref </dt> <dd> <p>Symbolic reference: instead of containing the <a href="#def_SHA1">SHA-1</a> id itself, it is of the format <code>ref: refs/some/thing</code> and when referenced, it recursively <a href="#def_dereference">dereferences</a> to this reference. <code><a href="#def_HEAD">HEAD</a></code> is a prime example of a symref. Symbolic references are manipulated with the <a href="git-symbolic-ref">git-symbolic-ref[1]</a> command.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddeftagatag"> tag </dt> <dd> <p>A <a href="#def_ref">ref</a> under <code>refs/tags/</code> namespace that points to an object of an arbitrary type (typically a tag points to either a <a href="#def_tag_object">tag</a> or a <a href="#def_commit_object">commit object</a>). In contrast to a <a href="#def_head">head</a>, a tag is not updated by the <code>commit</code> command. A Git tag has nothing to do with a Lisp tag (which would be called an <a href="#def_object_type">object type</a> in Git’s context). A tag is most typically used to mark a particular point in the commit ancestry <a href="#def_chain">chain</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddeftagobjectatagobject"> tag object </dt> <dd> <p>An <a href="#def_object">object</a> containing a <a href="#def_ref">ref</a> pointing to another object, which can contain a message just like a <a href="#def_commit_object">commit object</a>. It can also contain a (PGP) signature, in which case it is called a "signed tag object".</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddeftopicbranchatopicbranch"> topic branch </dt> <dd> <p>A regular Git <a href="#def_branch">branch</a> that is used by a developer to identify a conceptual line of development. Since branches are very easy and inexpensive, it is often desirable to have several small branches that each contain very well defined concepts or small incremental yet related changes.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddeftreeatree"> tree </dt> <dd> <p>Either a <a href="#def_working_tree">working tree</a>, or a <a href="#def_tree_object">tree object</a> together with the dependent <a href="#def_blob_object">blob</a> and tree objects (i.e. a stored representation of a working tree).</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddeftreeobjectatreeobject"> tree object </dt> <dd> <p>An <a href="#def_object">object</a> containing a list of file names and modes along with refs to the associated blob and/or tree objects. A <a href="#def_tree">tree</a> is equivalent to a <a href="#def_directory">directory</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddeftree-ishatree-ishalsotreeish"> tree-ish (also treeish) </dt> <dd> <p>A <a href="#def_tree_object">tree object</a> or an <a href="#def_object">object</a> that can be recursively <a href="#def_dereference">dereferenced</a> to a tree object. Dereferencing a <a href="#def_commit_object">commit object</a> yields the tree object corresponding to the <a href="#def_revision">revision</a>'s top <a href="#def_directory">directory</a>. The following are all tree-ishes: a <a href="#def_commit-ish">commit-ish</a>, a tree object, a <a href="#def_tag_object">tag object</a> that points to a tree object, a tag object that points to a tag object that points to a tree object, etc.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefunbornaunborn"> unborn </dt> <dd> <p>The <a href="#def_HEAD">HEAD</a> can point at a <a href="#def_branch">branch</a> that does not yet exist and that does not have any commit on it yet, and such a branch is called an unborn branch. The most typical way users encounter an unborn branch is by creating a repository anew without cloning from elsewhere. The HEAD would point at the <code>main</code> (or <code>master</code>, depending on your configuration) branch that is yet to be born. Also some operations can get you on an unborn branch with their <a href="#def_orphan">orphan</a> option.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefunmergedindexaunmergedindex"> unmerged index </dt> <dd> <p>An <a href="#def_index">index</a> which contains unmerged <a href="#def_index_entry">index entries</a>.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefunreachableobjectaunreachableobject"> unreachable object </dt> <dd> <p>An <a href="#def_object">object</a> which is not <a href="#def_reachable">reachable</a> from a <a href="#def_branch">branch</a>, <a href="#def_tag">tag</a>, or any other reference.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefupstreambranchaupstreambranch"> upstream branch </dt> <dd> <p>The default <a href="#def_branch">branch</a> that is merged into the branch in question (or the branch in question is rebased onto). It is configured via branch.<name>.remote and branch.<name>.merge. If the upstream branch of <code>A</code> is <code>origin/B</code> sometimes we say "<code>A</code> is tracking <code>origin/B</code>".</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefworkingtreeaworkingtree"> working tree </dt> <dd> <p>The tree of actual checked out files. The working tree normally contains the contents of the <a href="#def_HEAD">HEAD</a> commit’s tree, plus any local changes that you have made but not yet committed.</p> </dd> <dt class="hdlist1" id="Documentation/user-manual.txt-aiddefworktreeaworktree"> worktree </dt> <dd> <p>A repository can have zero (i.e. bare repository) or one or more worktrees attached to it. One "worktree" consists of a "working tree" and repository metadata, most of which are shared among other worktrees of a single repository, and some of which are maintained separately per worktree (e.g. the index, HEAD and pseudorefs like MERGE_HEAD, per-worktree refs and per-worktree configuration file).</p> </dd> </dl> </div> </div> </div> <h2 id="git-quick-start">Appendix a: git quick reference</h2> <div class="sectionbody"> <p>This is a quick summary of the major commands; the previous chapters explain how these work in more detail.</p> <div class="sect2"> <h3 id="quick-creating-a-new-repository"> +Creating a new repository</h3> <p>From a tarball:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ tar xzf project.tar.gz +$ cd project +$ git init +Initialized empty Git repository in .git/ +$ git add . +$ git commit</pre> </div> </div> <p>From a remote repository:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git clone git://example.com/pub/project.git +$ cd project</pre> </div> </div> </div> <div class="sect2"> <h3 id="managing-branches"> +Managing branches</h3> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch # list all local branches in this repo +$ git switch test # switch working directory to branch "test" +$ git branch new # create branch "new" starting at current HEAD +$ git branch -d new # delete branch "new"</pre> </div> </div> <p>Instead of basing a new branch on current HEAD (the default), use:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git branch new test # branch named "test" +$ git branch new v2.6.15 # tag named v2.6.15 +$ git branch new HEAD^ # commit before the most recent +$ git branch new HEAD^^ # commit before that +$ git branch new test~10 # ten commits before tip of branch "test"</pre> </div> </div> <p>Create and switch to a new branch at the same time:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git switch -c new v2.6.15</pre> </div> </div> <p>Update and examine branches from the repository you cloned from:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch # update +$ git branch -r # list + origin/master + origin/next + ... +$ git switch -c masterwork origin/master</pre> </div> </div> <p>Fetch a branch from a different repository, and give it a new name in your repository:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fetch git://example.com/project.git theirbranch:mybranch +$ git fetch git://example.com/project.git v2.6.15:mybranch</pre> </div> </div> <p>Keep a list of repositories you work with regularly:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git remote add example git://example.com/project.git +$ git remote # list remote repositories +example +origin +$ git remote show example # get details +* remote example + URL: git://example.com/project.git + Tracked remote branches + master + next + ... +$ git fetch example # update branches from example +$ git branch -r # list all remote branches</pre> </div> </div> </div> <div class="sect2"> <h3 id="exploring-history"> +Exploring history</h3> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ gitk # visualize and browse history +$ git log # list all commits +$ git log src/ # ...modifying src/ +$ git log v2.6.15..v2.6.16 # ...in v2.6.16, not in v2.6.15 +$ git log master..test # ...in branch test, not in branch master +$ git log test..master # ...in branch master, but not in test +$ git log test...master # ...in one branch, not in both +$ git log -S'foo()' # ...where difference contain "foo()" +$ git log --since="2 weeks ago" +$ git log -p # show patches as well +$ git show # most recent commit +$ git diff v2.6.15..v2.6.16 # diff between two tagged versions +$ git diff v2.6.15..HEAD # diff with current head +$ git grep "foo()" # search working directory for "foo()" +$ git grep v2.6.15 "foo()" # search old tree for "foo()" +$ git show v2.6.15:a.txt # look at old version of a.txt</pre> </div> </div> <p>Search for regressions:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git bisect start +$ git bisect bad # current version is bad +$ git bisect good v2.6.13-rc2 # last known good revision +Bisecting: 675 revisions left to test after this + # test here, then: +$ git bisect good # if this revision is good, or +$ git bisect bad # if this revision is bad. + # repeat until done.</pre> </div> </div> </div> <div class="sect2"> <h3 id="making-changes"> +Making changes</h3> <p>Make sure Git knows who to blame:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ cat >>~/.gitconfig <<\EOF +[user] + name = Your Name Comes Here + email = you@yourdomain.example.com +EOF</pre> </div> </div> <p>Select file contents to include in the next commit, then make the commit:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git add a.txt # updated file +$ git add b.txt # new file +$ git rm c.txt # old file +$ git commit</pre> </div> </div> <p>Or, prepare and create the commit in one step:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git commit d.txt # use latest content only of d.txt +$ git commit -a # use latest content of all tracked files</pre> </div> </div> </div> <div class="sect2"> <h3 id="merging"> +Merging</h3> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git merge test # merge branch "test" into the current branch +$ git pull git://example.com/project.git master + # fetch and merge in remote branch +$ git pull . test # equivalent to git merge test</pre> </div> </div> </div> <div class="sect2"> <h3 id="sharing-your-changes"> +Sharing your changes</h3> <p>Importing or exporting patches:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git format-patch origin..HEAD # format a patch for each commit + # in HEAD but not in origin +$ git am mbox # import patches from the mailbox "mbox"</pre> </div> </div> <p>Fetch a branch in a different Git repository, then merge into the current branch:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git pull git://example.com/project.git theirbranch</pre> </div> </div> <p>Store the fetched branch into a local branch before merging into the current branch:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git pull git://example.com/project.git theirbranch:mybranch</pre> </div> </div> <p>After creating commits on a local branch, update the remote branch with your commits:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git push ssh://example.com/project.git mybranch:theirbranch</pre> </div> </div> <p>When remote and local branch are both named "test":</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git push ssh://example.com/project.git test</pre> </div> </div> <p>Shortcut version for a frequently used remote repository:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git remote add example ssh://example.com/project.git +$ git push example test</pre> </div> </div> </div> <div class="sect2"> <h3 id="repository-maintenance"> +Repository maintenance</h3> <p>Check for corruption:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git fsck</pre> </div> </div> <p>Recompress, remove unused cruft:</p> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git gc</pre> </div> </div> </div> </div> <h2 id="todo">Appendix b: notes and todo list for this manual</h2> <div class="sectionbody"> <div class="sect2"> <h3 id="todo-list"> +Todo list</h3> <p>This is a work in progress.</p> <p>The basic requirements:</p> <div class="ulist"> <ul> <li> <p>It must be readable in order, from beginning to end, by someone intelligent with a basic grasp of the UNIX command line, but without any special knowledge of Git. If necessary, any other prerequisites should be specifically mentioned as they arise.</p> </li> <li> <p>Whenever possible, section headings should clearly describe the task they explain how to do, in language that requires no more knowledge than necessary: for example, "importing patches into a project" rather than "the <code>git am</code> command"</p> </li> </ul> </div> <p>Think about how to create a clear chapter dependency graph that will allow people to get to important topics without necessarily reading everything in between.</p> <p>Scan <code>Documentation/</code> for other stuff left out; in particular:</p> <div class="ulist"> <ul> <li> <p>howto’s</p> </li> <li> <p>some of <code>technical/</code>?</p> </li> <li> <p>hooks</p> </li> <li> <p>list of commands in <a href="git">git[1]</a></p> </li> </ul> </div> <p>Scan email archives for other stuff left out</p> <p>Scan man pages to see if any assume more background than this manual provides.</p> <p>Add more good examples. Entire sections of just cookbook examples might be a good idea; maybe make an "advanced examples" section a standard end-of-chapter section?</p> <p>Include cross-references to the glossary, where appropriate.</p> <p>Add a section on working with other version control systems, including CVS, Subversion, and just imports of series of release tarballs.</p> <p>Write a chapter on using plumbing and writing scripts.</p> <p>Alternates, clone -reference, etc.</p> <p>More on recovery from repository corruption. See: <a href="https://lore.kernel.org/git/Pine.LNX.4.64.0702272039540.12485@woody.linux-foundation.org/" class="bare">https://lore.kernel.org/git/Pine.LNX.4.64.0702272039540.12485@woody.linux-foundation.org/</a> <a href="https://lore.kernel.org/git/Pine.LNX.4.64.0702141033400.3604@woody.linux-foundation.org/" class="bare">https://lore.kernel.org/git/Pine.LNX.4.64.0702141033400.3604@woody.linux-foundation.org/</a></p> </div> </div><div class="_attribution"> + <p class="_attribution-p"> + © 2012–2024 Scott Chacon and others<br>Licensed under the MIT License.<br> + <a href="https://git-scm.com/docs/user-manual" class="_attribution-link">https://git-scm.com/docs/user-manual</a> + </p> +</div> |
