literate-dotfiles/docs/git.html

322 lines
16 KiB
HTML
Raw Permalink 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>
2021-01-08 01:43:48 +01:00
<!-- 2021-01-08 ven. 01:40 -->
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="generator" content="Org mode" />
<meta name="author" content="Dehaeze Thomas" />
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>
</div><div id="content">
<h1 class="title">Git Configuration</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
2021-01-01 20:12:34 +01:00
<li><a href="#org5614967"><code>~/.gitconfig</code></a>
2020-01-11 22:04:45 +01:00
<ul>
2021-01-01 20:12:34 +01:00
<li><a href="#orgf8c42c0">Aliases</a></li>
<li><a href="#org68a5de1">Apply</a></li>
<li><a href="#org9b46df2">Colors</a></li>
<li><a href="#org5369e22">Default Remote</a></li>
<li><a href="#orgf523602">Push Configuration</a></li>
<li><a href="#org72a2b70">User</a></li>
<li><a href="#orgf768784">Core configuration</a></li>
<li><a href="#org5cda35d">Credentials using pass</a></li>
<li><a href="#orgae60316">Diff-so-fancy</a></li>
<li><a href="#orgdcb66f1">Github</a></li>
2020-01-11 22:04:45 +01:00
</ul>
</li>
2021-01-01 20:12:34 +01:00
<li><a href="#orgf329fb1"><code>~/.gitignore_global</code> - Global Git Ignore</a></li>
<li><a href="#org5af3f72"><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>
2021-01-01 20:12:34 +01:00
<div id="outline-container-org5614967" class="outline-2">
<h2 id="org5614967"><code>~/.gitconfig</code></h2>
<div class="outline-text-2" id="text-org5614967">
2020-01-11 22:04:45 +01:00
</div>
2021-01-01 20:12:34 +01:00
<div id="outline-container-orgf8c42c0" class="outline-3">
<h3 id="orgf8c42c0">Aliases</h3>
<div class="outline-text-3" id="text-orgf8c42c0">
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>
2021-01-01 20:12:34 +01:00
<div id="outline-container-org68a5de1" class="outline-3">
<h3 id="org68a5de1">Apply</h3>
<div class="outline-text-3" id="text-org68a5de1">
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>
2021-01-01 20:12:34 +01:00
<div id="outline-container-org9b46df2" class="outline-3">
<h3 id="org9b46df2">Colors</h3>
<div class="outline-text-3" id="text-org9b46df2">
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>
2021-01-01 20:12:34 +01:00
<div id="outline-container-org5369e22" class="outline-3">
<h3 id="org5369e22">Default Remote</h3>
<div class="outline-text-3" id="text-org5369e22">
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>
2021-01-01 20:12:34 +01:00
<div id="outline-container-orgf523602" class="outline-3">
<h3 id="orgf523602">Push Configuration</h3>
<div class="outline-text-3" id="text-orgf523602">
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>
2021-01-01 20:12:34 +01:00
<div id="outline-container-org72a2b70" class="outline-3">
<h3 id="org72a2b70">User</h3>
<div class="outline-text-3" id="text-org72a2b70">
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>
2021-01-01 20:12:34 +01:00
<div id="outline-container-orgf768784" class="outline-3">
<h3 id="orgf768784">Core configuration</h3>
<div class="outline-text-3" id="text-orgf768784">
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>
2021-01-01 20:12:34 +01:00
<div id="outline-container-org5cda35d" class="outline-3">
<h3 id="org5cda35d">Credentials using pass</h3>
<div class="outline-text-3" id="text-org5cda35d">
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>
2021-01-01 20:12:34 +01:00
<div id="outline-container-orgae60316" class="outline-3">
<h3 id="orgae60316">Diff-so-fancy</h3>
<div class="outline-text-3" id="text-orgae60316">
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>
2021-01-01 20:12:34 +01:00
<div id="outline-container-orgdcb66f1" class="outline-3">
<h3 id="orgdcb66f1">Github</h3>
<div class="outline-text-3" id="text-orgdcb66f1">
2020-01-11 22:04:45 +01:00
<div class="org-src-container">
<pre class="src src-conf">[<span class="org-type">github</span>]
<span class="org-variable-name">user</span> = tdehaeze
<span class="org-variable-name">oauth-token</span> = 8cc5b41120f7e9a869c24fa3678667d3d8422e6f
</pre>
</div>
</div>
</div>
</div>
2021-01-01 20:12:34 +01:00
<div id="outline-container-orgf329fb1" class="outline-2">
<h2 id="orgf329fb1"><code>~/.gitignore_global</code> - Global Git Ignore</h2>
<div class="outline-text-2" id="text-orgf329fb1">
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
2021-01-01 20:12:34 +01:00
<div id="outline-container-org5af3f72" class="outline-2">
<h2 id="org5af3f72"><code>pass-git-helper</code> - Use <code>pass</code> for git passwords</h2>
<div class="outline-text-2" id="text-org5af3f72">
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>
2021-01-08 01:43:48 +01:00
<p class="date">Created: 2021-01-08 ven. 01:40</p>
2020-01-11 22:04:45 +01:00
</div>
</body>
</html>