literate-dotfiles/docs/git.html

309 lines
15 KiB
HTML
Raw Normal View History

2020-01-11 22:04:45 +01:00
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
2022-05-09 10:05:23 +02:00
<!-- 2022-05-09 lun. 10:04 -->
2020-01-11 22:04:45 +01:00
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Git Configuration</title>
<meta name="author" content="Dehaeze Thomas" />
2022-05-09 10:05:23 +02:00
<meta name="generator" content="Org Mode" />
2021-01-01 20:12:34 +01:00
<link rel="stylesheet" type="text/css" href="./dist/style.css"/>
<script type="text/javascript" src="./dist/script.js"></script>
2020-01-11 22:04:45 +01:00
</head>
<body>
<div id="org-div-home-and-up">
<a accesskey="h" href="./index.html"> UP </a>
|
<a accesskey="H" href="./index.html"> HOME </a>
2022-05-09 10:05:23 +02:00
</div><div id="content" class="content">
2020-01-11 22:04:45 +01:00
<h1 class="title">Git Configuration</h1>
2022-05-09 10:05:23 +02:00
<div id="table-of-contents" role="doc-toc">
2020-01-11 22:04:45 +01:00
<h2>Table of Contents</h2>
2022-05-09 10:05:23 +02:00
<div id="text-table-of-contents" role="doc-toc">
2020-01-11 22:04:45 +01:00
<ul>
2022-05-09 10:05:23 +02:00
<li><a href="#org836117e"><code>~/.gitconfig</code></a>
2020-01-11 22:04:45 +01:00
<ul>
2022-05-09 10:05:23 +02:00
<li><a href="#orga7a7f60">Aliases</a></li>
<li><a href="#org6ae31ef">Apply</a></li>
<li><a href="#org4179953">Colors</a></li>
<li><a href="#org5698b3f">Default Remote</a></li>
<li><a href="#org5a10a0b">Push Configuration</a></li>
<li><a href="#org5171f9e">User</a></li>
<li><a href="#org7473c0a">Core configuration</a></li>
<li><a href="#orgd5aad26">Credentials using pass</a></li>
<li><a href="#orgf01d4f7">Diff-so-fancy</a></li>
2020-01-11 22:04:45 +01:00
</ul>
</li>
2022-05-09 10:05:23 +02:00
<li><a href="#org7e471aa"><code>~/.gitignore_global</code> - Global Git Ignore</a></li>
<li><a href="#orga7108ef"><code>pass-git-helper</code> - Use <code>pass</code> for git passwords</a></li>
2020-01-11 22:04:45 +01:00
</ul>
</div>
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-org836117e" class="outline-2">
<h2 id="org836117e"><code>~/.gitconfig</code></h2>
<div class="outline-text-2" id="text-org836117e">
2020-01-11 22:04:45 +01:00
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-orga7a7f60" class="outline-3">
<h3 id="orga7a7f60">Aliases</h3>
<div class="outline-text-3" id="text-orga7a7f60">
2020-01-11 22:04:45 +01:00
<div class="org-src-container">
<pre class="src src-conf">[<span class="org-type">alias</span>]
<span class="org-comment-delimiter"># </span><span class="org-comment">View abbreviated SHA, description, and history graph of the latest 20 commits</span>
<span class="org-variable-name">l</span> = log --pretty=oneline -n <span class="org-highlight-numbers-number">20</span> --graph --abbrev-commit
<span class="org-comment-delimiter"># </span><span class="org-comment">View the current working tree status using the short format</span>
<span class="org-variable-name">s</span> = status -s
<span class="org-comment-delimiter"># </span><span class="org-comment">Show the diff between the latest commit and the current state</span>
<span class="org-variable-name">d</span> = !<span class="org-string">"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"</span>
<span class="org-variable-name">di</span> = diff --cached --ignore-all-space
<span class="org-comment-delimiter"># </span><span class="org-comment">Pull in remote changes for the current repository and all its submodules</span>
<span class="org-variable-name">p</span> = !<span class="org-string">"git pull; git submodule foreach git pull origin master"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">Clone a repository including all submodules</span>
<span class="org-variable-name">c</span> = clone --recursive
<span class="org-comment-delimiter"># </span><span class="org-comment">Commit all changes</span>
<span class="org-variable-name">ca</span> = !git add -A &amp;&amp; git commit -av
<span class="org-comment-delimiter"># </span><span class="org-comment">Switch to a branch, creating it if necessary</span>
<span class="org-variable-name">go</span> = <span class="org-string">"!f() { git checkout -b \"$1\" 2&gt; /dev/null || git checkout \"$1\"; }; f"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">Show verbose output about tags, branches or remotes</span>
<span class="org-variable-name">tags</span> = tag -l
<span class="org-variable-name">branches</span> = branch -a
<span class="org-variable-name">remotes</span> = remote -v
<span class="org-comment-delimiter"># </span><span class="org-comment">Amend the currently staged files to the latest commit</span>
<span class="org-variable-name">amend</span> = commit --amend --reuse-message=HEAD
<span class="org-comment-delimiter"># </span><span class="org-comment">Credit an author on the latest commit</span>
<span class="org-variable-name">credit</span> = <span class="org-string">"!f() { git commit --amend --author \"$1 &lt;$2&gt;\" -C HEAD; }; f"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">Interactive rebase with the given number of latest commits</span>
<span class="org-variable-name">reb</span> = <span class="org-string">"!r() { git rebase -i HEAD~$1; }; r"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">Remove the old tag with this name and tag the latest commit with it.</span>
<span class="org-variable-name">retag</span> = <span class="org-string">"!r() { git tag -d $1 &amp;&amp; git push origin :refs/tags/$1 &amp;&amp; git tag $1; }; r"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">Find branches containing commit</span>
<span class="org-variable-name">fb</span> = <span class="org-string">"!f() { git branch -a --contains $1; }; f"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">Find tags containing commit</span>
<span class="org-variable-name">ft</span> = <span class="org-string">"!f() { git describe --always --contains $1; }; f"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">Find commits by source code</span>
<span class="org-variable-name">fc</span> = <span class="org-string">"!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short -S$1; }; f"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">Find commits by commit message</span>
<span class="org-variable-name">fm</span> = <span class="org-string">"!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short --grep=$1; }; f"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">Remove branches that have already been merged with master</span>
<span class="org-variable-name">dm</span> = <span class="org-string">"!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">List contributors with number of commits</span>
<span class="org-variable-name">contributors</span> = shortlog --summary --numbered
<span class="org-variable-name">ec</span> = config --global -e
<span class="org-comment-delimiter"># </span><span class="org-comment">Pretty log output</span>
<span class="org-variable-name">hist</span> = log --graph --pretty=format:<span class="org-string">'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)&lt;%an&gt;%Creset'</span> --abbrev-commit --all
<span class="org-variable-name">pp</span> = pull origin $(git_current_branch)
<span class="org-variable-name">gg</span> = push origin $(git_current_branch)
<span class="org-variable-name">rhh</span> = reset HEAD --hard
<span class="org-variable-name">unstage</span> = reset HEAD --
<span class="org-variable-name">last</span> = log -1 HEAD
</pre>
</div>
</div>
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-org6ae31ef" class="outline-3">
<h3 id="org6ae31ef">Apply</h3>
<div class="outline-text-3" id="text-org6ae31ef">
2020-01-11 22:04:45 +01:00
<div class="org-src-container">
<pre class="src src-conf">[<span class="org-type">apply</span>]
<span class="org-comment-delimiter"># </span><span class="org-comment">Detect whitespace errors when applying a patch</span>
<span class="org-variable-name">whitespace</span> = fix
</pre>
</div>
</div>
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-org4179953" class="outline-3">
<h3 id="org4179953">Colors</h3>
<div class="outline-text-3" id="text-org4179953">
2020-01-11 22:04:45 +01:00
<div class="org-src-container">
<pre class="src src-conf">[<span class="org-type">color</span>]
<span class="org-comment-delimiter"># </span><span class="org-comment">Use colors in Git commands that are capable of colored output when outputting to the terminal</span>
<span class="org-variable-name">ui</span> = true
[color <span class="org-string">"branch"</span>]
<span class="org-variable-name">current</span> = yellow reverse
<span class="org-variable-name">local</span> = yellow
<span class="org-variable-name">remote</span> = green
<span class="org-variable-name">HEAD</span> = red bold
[color <span class="org-string">"diff"</span>]
<span class="org-variable-name">meta</span> = yellow bold
<span class="org-variable-name">frag</span> = magenta bold <span class="org-comment-delimiter"># </span><span class="org-comment">line info</span>
<span class="org-variable-name">old</span> = red <span class="org-comment-delimiter"># </span><span class="org-comment">deletions</span>
<span class="org-variable-name">new</span> = green <span class="org-comment-delimiter"># </span><span class="org-comment">additions</span>
[color <span class="org-string">"status"</span>]
<span class="org-variable-name">added</span> = green
<span class="org-variable-name">changed</span> = yellow
<span class="org-variable-name">untracked</span> = cyan
[color <span class="org-string">"decorate"</span>]
<span class="org-variable-name">HEAD</span> = red bold
<span class="org-variable-name">branch</span> = green
<span class="org-variable-name">remoteBranch</span> = cyan
<span class="org-variable-name">tag</span> = yellow
<span class="org-variable-name">stash</span> = bold yellow
</pre>
</div>
</div>
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-org5698b3f" class="outline-3">
<h3 id="org5698b3f">Default Remote</h3>
<div class="outline-text-3" id="text-org5698b3f">
2020-01-11 22:04:45 +01:00
<div class="org-src-container">
<pre class="src src-conf"><span class="org-comment-delimiter"># </span><span class="org-comment">Use `origin` as the default remote on the `master` branch in all cases</span>
[branch <span class="org-string">"master"</span>]
<span class="org-variable-name">remote</span> = origin
<span class="org-variable-name">merge</span> = refs/heads/master
</pre>
</div>
</div>
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-org5a10a0b" class="outline-3">
<h3 id="org5a10a0b">Push Configuration</h3>
<div class="outline-text-3" id="text-org5a10a0b">
2020-01-11 22:04:45 +01:00
<div class="org-src-container">
<pre class="src src-conf">[<span class="org-type">push</span>]
<span class="org-variable-name">default</span> = matching
<span class="org-comment-delimiter"># </span><span class="org-comment">Make `git push` push relevant annotated tags when pushing branches out.</span>
<span class="org-variable-name">followTags</span> = true
</pre>
</div>
</div>
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-org5171f9e" class="outline-3">
<h3 id="org5171f9e">User</h3>
<div class="outline-text-3" id="text-org5171f9e">
2020-01-11 22:04:45 +01:00
<div class="org-src-container">
<pre class="src src-conf">[<span class="org-type">user</span>]
<span class="org-variable-name">name</span> = Thomas Dehaeze
<span class="org-variable-name">email</span> = dehaeze.thomas@gmail.com
</pre>
</div>
</div>
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-org7473c0a" class="outline-3">
<h3 id="org7473c0a">Core configuration</h3>
<div class="outline-text-3" id="text-org7473c0a">
2020-01-11 22:04:45 +01:00
<div class="org-src-container">
<pre class="src src-conf">[<span class="org-type">core</span>]
<span class="org-comment-delimiter"># </span><span class="org-comment">Use custom `.gitignore` and `.gitattributes`</span>
<span class="org-variable-name">excludesfile</span> = ~/.gitignore_global
<span class="org-comment-delimiter"># </span><span class="org-comment">Treat spaces before tabs and all kinds of trailing whitespace as an error</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">[default] trailing-space: looks for spaces at the end of a line</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">[default] space-before-tab: looks for spaces before tabs at the beginning of a line</span>
<span class="org-variable-name">whitespace</span> = space-before-tab,-indent-with-non-tab,trailing-space
<span class="org-comment-delimiter"># </span><span class="org-comment">Prevent showing files whose names contain non-ASCII symbols as unversioned.</span>
<span class="org-comment-delimiter"># </span><span class="org-comment">http://michael-kuehnel.de/git/2014/11/21/git-mac-osx-and-german-umlaute.html</span>
<span class="org-variable-name">precomposeunicode</span> = false
<span class="org-variable-name">pager</span> = diff-so-fancy | less --tabs=<span class="org-highlight-numbers-number">4</span> -RFX
<span class="org-variable-name">autocrlf</span> = input
<span class="org-comment-delimiter"># </span><span class="org-comment">Open vim, start Goyo and enter insert mode on the first line</span>
<span class="org-variable-name">editor</span> = <span class="org-string">"nvim -c ':Goyo' -c 'goto 1' -c 'startinsert'"</span>
</pre>
</div>
</div>
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-orgd5aad26" class="outline-3">
<h3 id="orgd5aad26">Credentials using pass</h3>
<div class="outline-text-3" id="text-orgd5aad26">
2020-01-11 22:04:45 +01:00
<div class="org-src-container">
<pre class="src src-conf">[<span class="org-type">credential</span>]
<span class="org-variable-name">helper</span> = !pass-git-helper $@
[credential <span class="org-string">"https://github.com"</span>]
<span class="org-variable-name">username</span> = tdehaeze
2020-11-03 16:27:09 +01:00
[credential <span class="org-string">"https://git.tdehaeze.xyz"</span>]
<span class="org-variable-name">username</span> = tdehaeze
2021-01-01 20:12:34 +01:00
[credential <span class="org-string">"https://gitlab.esrf.fr"</span>]
<span class="org-variable-name">username</span> = dehaeze
2020-01-11 22:04:45 +01:00
</pre>
</div>
</div>
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-orgf01d4f7" class="outline-3">
<h3 id="orgf01d4f7">Diff-so-fancy</h3>
<div class="outline-text-3" id="text-orgf01d4f7">
2020-01-11 22:04:45 +01:00
<div class="org-src-container">
<pre class="src src-conf">[<span class="org-type">diff-so-fancy</span>]
<span class="org-variable-name">markEmptyLines</span> = false
</pre>
</div>
</div>
</div>
</div>
2022-05-09 10:05:23 +02:00
<div id="outline-container-org7e471aa" class="outline-2">
<h2 id="org7e471aa"><code>~/.gitignore_global</code> - Global Git Ignore</h2>
<div class="outline-text-2" id="text-org7e471aa">
2020-01-11 22:04:45 +01:00
<div class="org-src-container">
<pre class="src src-conf">*~
.DS_Store
Session.vim
</pre>
</div>
</div>
</div>
2020-11-03 16:27:09 +01:00
2022-05-09 10:05:23 +02:00
<div id="outline-container-orga7108ef" class="outline-2">
<h2 id="orga7108ef"><code>pass-git-helper</code> - Use <code>pass</code> for git passwords</h2>
<div class="outline-text-2" id="text-orga7108ef">
2020-11-03 16:27:09 +01:00
<div class="org-src-container">
<pre class="src src-conf">[<span class="org-type">github.com*</span>]
<span class="org-variable-name">target</span>=github.com/tdehaeze
[<span class="org-type">git.tdehaeze.xyz*</span>]
<span class="org-variable-name">target</span>=git.tdehaeze.xyz/tdehaeze
[<span class="org-type">gitlab.esrf.fr*</span>]
<span class="org-variable-name">target</span>=gitlab.esrf.fr/dehaeze
</pre>
</div>
</div>
</div>
2020-01-11 22:04:45 +01:00
</div>
<div id="postamble" class="status">
<p class="author">Author: Dehaeze Thomas</p>
2022-05-09 10:05:23 +02:00
<p class="date">Created: 2022-05-09 lun. 10:04</p>
2020-01-11 22:04:45 +01:00
</div>
</body>
</html>