literate-dotfiles/git.org
Thomas Dehaeze bb14d8239c Change indentation of all blocks.
Use (setq org-src-preserve-indentation t) for Emacs.
2021-01-08 01:26:27 +01:00

224 lines
5.6 KiB
Org Mode

#+TITLE: Git Configuration
#+SETUPFILE: ./setup/org-setup-file.org
* =~/.gitconfig=
:PROPERTIES:
:header-args:conf: :tangle ~/.gitconfig
:header-args:conf+: :comments both :mkdirp yes
:END:
** Aliases
#+BEGIN_SRC conf
[alias]
# View abbreviated SHA, description, and history graph of the latest 20 commits
l = log --pretty=oneline -n 20 --graph --abbrev-commit
# View the current working tree status using the short format
s = status -s
# Show the diff between the latest commit and the current state
d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"
di = diff --cached --ignore-all-space
# Pull in remote changes for the current repository and all its submodules
p = !"git pull; git submodule foreach git pull origin master"
# Clone a repository including all submodules
c = clone --recursive
# Commit all changes
ca = !git add -A && git commit -av
# Switch to a branch, creating it if necessary
go = "!f() { git checkout -b \"$1\" 2> /dev/null || git checkout \"$1\"; }; f"
# Show verbose output about tags, branches or remotes
tags = tag -l
branches = branch -a
remotes = remote -v
# Amend the currently staged files to the latest commit
amend = commit --amend --reuse-message=HEAD
# Credit an author on the latest commit
credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f"
# Interactive rebase with the given number of latest commits
reb = "!r() { git rebase -i HEAD~$1; }; r"
# Remove the old tag with this name and tag the latest commit with it.
retag = "!r() { git tag -d $1 && git push origin :refs/tags/$1 && git tag $1; }; r"
# Find branches containing commit
fb = "!f() { git branch -a --contains $1; }; f"
# Find tags containing commit
ft = "!f() { git describe --always --contains $1; }; f"
# Find commits by source code
fc = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short -S$1; }; f"
# Find commits by commit message
fm = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short --grep=$1; }; f"
# Remove branches that have already been merged with master
dm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
# List contributors with number of commits
contributors = shortlog --summary --numbered
ec = config --global -e
# Pretty log output
hist = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all
pp = pull origin $(git_current_branch)
gg = push origin $(git_current_branch)
rhh = reset HEAD --hard
unstage = reset HEAD --
last = log -1 HEAD
#+END_SRC
** Apply
#+BEGIN_SRC conf
[apply]
# Detect whitespace errors when applying a patch
whitespace = fix
#+END_SRC
** Colors
#+BEGIN_SRC conf
[color]
# Use colors in Git commands that are capable of colored output when outputting to the terminal
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
HEAD = red bold
[color "diff"]
meta = yellow bold
frag = magenta bold # line info
old = red # deletions
new = green # additions
[color "status"]
added = green
changed = yellow
untracked = cyan
[color "decorate"]
HEAD = red bold
branch = green
remoteBranch = cyan
tag = yellow
stash = bold yellow
#+END_SRC
** Default Remote
#+BEGIN_SRC conf
# Use `origin` as the default remote on the `master` branch in all cases
[branch "master"]
remote = origin
merge = refs/heads/master
#+END_SRC
** Push Configuration
#+BEGIN_SRC conf
[push]
default = matching
# Make `git push` push relevant annotated tags when pushing branches out.
followTags = true
#+END_SRC
** User
#+BEGIN_SRC conf
[user]
name = Thomas Dehaeze
email = dehaeze.thomas@gmail.com
#+END_SRC
** Core configuration
#+BEGIN_SRC conf
[core]
# Use custom `.gitignore` and `.gitattributes`
excludesfile = ~/.gitignore_global
# Treat spaces before tabs and all kinds of trailing whitespace as an error
# [default] trailing-space: looks for spaces at the end of a line
# [default] space-before-tab: looks for spaces before tabs at the beginning of a line
whitespace = space-before-tab,-indent-with-non-tab,trailing-space
# Prevent showing files whose names contain non-ASCII symbols as unversioned.
# http://michael-kuehnel.de/git/2014/11/21/git-mac-osx-and-german-umlaute.html
precomposeunicode = false
pager = diff-so-fancy | less --tabs=4 -RFX
autocrlf = input
# Open vim, start Goyo and enter insert mode on the first line
editor = "nvim -c ':Goyo' -c 'goto 1' -c 'startinsert'"
#+END_SRC
** Credentials using pass
#+BEGIN_SRC conf
[credential]
helper = !pass-git-helper $@
[credential "https://github.com"]
username = tdehaeze
[credential "https://git.tdehaeze.xyz"]
username = tdehaeze
[credential "https://gitlab.esrf.fr"]
username = dehaeze
#+END_SRC
** Diff-so-fancy
#+begin_src conf
[diff-so-fancy]
markEmptyLines = false
#+end_src
** Github
#+BEGIN_SRC conf
[github]
user = tdehaeze
oauth-token = 8cc5b41120f7e9a869c24fa3678667d3d8422e6f
#+END_SRC
* =~/.gitignore_global= - Global Git Ignore
:PROPERTIES:
:header-args:conf: :tangle ~/.gitignore_global
:header-args:conf+: :comments both :mkdirp yes
:END:
#+BEGIN_SRC conf
*~
.DS_Store
Session.vim
#+END_SRC
* =pass-git-helper= - Use =pass= for git passwords
:PROPERTIES:
:header-args: :tangle ~/.config/pass-git-helper/git-pass-mapping.ini
:header-args+: :comments both :mkdirp yes
:END:
#+BEGIN_SRC conf
[github.com*]
target=github.com/tdehaeze
[git.tdehaeze.xyz*]
target=git.tdehaeze.xyz/tdehaeze
[gitlab.esrf.fr*]
target=gitlab.esrf.fr/dehaeze
#+END_SRC