config.phundrak.com/docs/git.org

296 lines
8.2 KiB
Org Mode
Raw Normal View History

2023-06-30 08:51:34 +00:00
# -*- indent-tabs-mode: t; -*-
#+title: Git
2023-06-30 08:51:34 +00:00
#+setupfile: headers
#+PROPERTY: header-args :exports code :tangle no
#+PROPERTY: header-args:conf-unix :mkdirp yes :tangle ~/.config/git/config :exports code :noweb yes
* Git
** Basic configuration
2023-06-30 08:51:34 +00:00
#+begin_src conf-unix
# -*- indent-tabs-mode: t; -*-
#+end_src
#+begin_src conf-unix
[user]
2023-11-03 18:52:46 +00:00
email = lucien@phundrak.com
name = Lucien Cartier-Tilet
signingkey = BD7789E705CB8DCA
2023-06-30 08:51:34 +00:00
#+end_src
#+begin_src conf-unix
[core]
2023-11-03 18:52:46 +00:00
editor = emacsclient -c -a emacs
whitespace = fix,-indent-with-non-tab,trailing-space
excludesfile = /home/phundrak/.gitignore_global
2023-06-30 08:51:34 +00:00
#+end_src
#+begin_src conf-unix
[pull]
2023-11-03 18:52:46 +00:00
rebase = true
2023-06-30 08:51:34 +00:00
#+end_src
#+begin_src conf-unix
[init]
2023-11-03 18:52:46 +00:00
defaultBranch = main
2023-06-30 08:51:34 +00:00
#+end_src
#+begin_src conf-unix
[color]
2023-11-03 18:52:46 +00:00
ui = auto
2023-06-30 08:51:34 +00:00
#+end_src
#+begin_src conf-unix
[web]
2023-11-03 18:52:46 +00:00
browser = firefox
2023-06-30 08:51:34 +00:00
#+end_src
** Aliases
2023-06-30 08:51:34 +00:00
#+name: git-add-abbrev
| abbreviation | equivalent |
|--------------+------------------------------------------------|
| =a= | =add --all= |
| =aca= | =!git add --all && git commit --amend= |
| =acan= | =!git add --all && git commit --amend --no-edit= |
#+name: abbrev-gen
#+begin_src emacs-lisp :tangle no :exports none :var abbrevs=git-push-abbrev :wrap "src conf-unix :tangle no"
(mapconcat (lambda (abbreviation)
2023-11-03 18:52:46 +00:00
(replace-regexp-in-string
(concat (regexp-quote "\\vert") (rx (? "{}")))
"|"
(concat "\t"
(string-replace "=" "" (car abbreviation))
" = "
(string-replace "=" "" (cadr abbreviation)))))
abbrevs
"\n")
2023-06-30 08:51:34 +00:00
#+end_src
#+RESULTS: abbrev-gen
#+begin_src conf-unix :tangle no
2023-11-03 18:52:46 +00:00
ps = push
psf = push --force-with-lease
pso = push origin
psfo = push --force-with-lease origin
pushall = !git remote | xargs -L1 git push
psl = !git remote | xargs -L1 git push
pullall = !git remote | xargs -L1 git pull
pll = !git remote | xargs -L1 git pull
2023-06-30 08:51:34 +00:00
#+end_src
#+name: git-branch-abbrev
| abbreviation | equivalent |
|--------------+------------|
| =b= | =branch= |
| =bd= | =branch -d= |
| =bdd= | =branch -D= |
#+name: git-commit-abbrev
| abbreviation | equivalent |
|--------------+----------------------|
| =c= | =commit -S= |
| =ca= | =commit -Sa= |
| =can= | =commit -Sa --no-edit= |
| =cm= | =commit -Sm= |
| =cam= | =commit -Sam= |
#+name: git-checkout-abbrev
| abbreviation | equivalent |
|--------------+------------------|
| =co= | =checkout= |
| =cob= | =checkout -b= |
| =cod= | =checkout develop= |
#+name: git-clone-abbrev
| abbreviation | equivalent |
|--------------+-----------------|
| =cl= | =clone= |
2023-09-10 21:48:58 +00:00
| =cl1= | =clone --depth 1= |
2023-06-30 08:51:34 +00:00
#+name: git-fetch-abbrev
| abbreviation | equivalent |
|--------------+---------------|
| =f= | =fetch= |
| =fp= | =fetch --prune= |
#+name: git-push-abbrev
| abbreviation | equivalent |
|--------------+----------------------------------|
| =ps= | =push= |
| =psf= | =push --force-with-lease= |
| =pso= | =push origin= |
| =psfo= | =push --force-with-lease origin= |
| =pushall= | =!git remote \vert{} xargs -L1 git push= |
| =psl= | =!git remote \vert{} xargs -L1 git push= |
| =pullall= | =!git remote \vert{} xargs -L1 git pull= |
| =pll= | =!git remote \vert{} xargs -L1 git pull= |
#+name: git-pull-abbrev
| abbreviation | equivalent |
|--------------+---------------|
| =pl= | =pull= |
| =pb= | =pull --rebase= |
#+name: git-rebase-abbrev
| abbreviation | equivalent |
|--------------+-------------------|
| =r= | =rebase= |
| =ra= | =rebase --abort= |
| =rc= | =rebase --continue= |
| =rd= | =rebase develop= |
| =ri= | =rebase -i= |
#+name: git-rm-abbrev
| abbreviation | equivalent |
|--------------+------------|
| =rmf= | =rm -f= |
| =rmd= | =rm -r= |
| =rmdf= | =rm -rf= |
#+name: git-submodule-abbrev
| abbreviation | equivalent |
|--------------+-------------------------------------|
| =sm= | =submodule= |
| =sms= | =submodule status= |
| =sma= | =submodule add= |
| =smu= | =submodule update= |
| =smui= | =submodule update --init= |
| =smuir= | =submodule update --init --recursive= |
#+name: git-stash-abbrev
| abbreviation | equivalent |
|--------------+-------------|
| =st= | =stash= |
| =stc= | =stash clear= |
| =stp= | =stash pop= |
| =stw= | =stash show= |
#+name: git-unstage-abbrev
| abbreviation | equivalent |
|--------------+------------|
| =u= | =reset --= |
| =unstage= | =reset --= |
#+name: git-single-abbrev
| abbreviation | equivalent |
|--------------+----------------------------------|
| =d= | =diff -w= |
| =l= | =log --oneline --graph --decorate= |
| =s= | =status= |
| =staged= | =diff --cached= |
| =upstream= | =!git push -u origin HEAD= |
#+RESULTS:
: a = add --all
: aca = !git add --all && git commit --amend
: acan = !git add --all && git commit --amend --no-edit
#+begin_src conf-unix
[alias]
<<abbrev-gen(abbrevs=git-add-abbrev)>>
<<abbrev-gen(abbrevs=git-branch-abbrev)>>
<<abbrev-gen(abbrevs=git-commit-abbrev)>>
<<abbrev-gen(abbrevs=git-checkout-abbrev)>>
<<abbrev-gen(abbrevs=git-clone-abbrev)>>
<<abbrev-gen(abbrevs=git-fetch-abbrev)>>
<<abbrev-gen(abbrevs=git-push-abbrev)>>
<<abbrev-gen(abbrevs=git-pull-abbrev)>>
<<abbrev-gen(abbrevs=git-rebase-abbrev)>>
<<abbrev-gen(abbrevs=git-rm-abbrev)>>
<<abbrev-gen(abbrevs=git-submodule-abbrev)>>
<<abbrev-gen(abbrevs=git-stash-abbrev)>>
<<abbrev-gen(abbrevs=git-unstage-abbrev)>>
<<abbrev-gen(abbrevs=git-single-abbrev)>>
#+end_src
** Tools
*** Sendemail
2023-06-30 08:51:34 +00:00
#+begin_src conf-unix
[sendemail]
2023-11-03 18:52:46 +00:00
smtpserver = mail.phundrak.com
smtpuser = lucien@phundrak.com
smtpencryption = tls
smtpserverport = 587
2023-06-30 08:51:34 +00:00
#+end_src
#+begin_src conf-unix
[credentials "smtp://lucien@phundrak.com@mail.phundrak.com:587"]
2023-11-03 18:52:46 +00:00
helper = "secret-tool lookup password email_lucien-phundrak-com"
2023-06-30 08:51:34 +00:00
#+end_src
*** Magit
2023-06-30 08:51:34 +00:00
#+begin_src conf-unix
[magithub]
2023-11-03 18:52:46 +00:00
online = true
2023-06-30 08:51:34 +00:00
[magithub "status"]
2023-11-03 18:52:46 +00:00
includeStatusHeader = true
includePullRequestsSection = true
includeIssuesSection = true
2023-06-30 08:51:34 +00:00
#+end_src
*** GPG
2023-06-30 08:51:34 +00:00
#+begin_src conf-unix
[gpg]
2023-11-03 18:52:46 +00:00
program = gpg2
2023-06-30 08:51:34 +00:00
[commit]
2023-11-03 18:52:46 +00:00
gpgsign = true
2023-06-30 08:51:34 +00:00
#+end_src
*** Merge
2023-06-30 08:51:34 +00:00
#+begin_src conf-unix
[merge]
2023-11-03 18:52:46 +00:00
tool = ediff
2023-06-30 08:51:34 +00:00
#+end_src
#+begin_src conf-unix
[mergetool.ediff]
2023-11-03 18:52:46 +00:00
cmd = emacs --eval \" (progn (defun ediff-write-merge-buffer () (let ((file ediff-merge-store-file)) (set-buffer ediff-buffer-C) (write-region (point-min) (point-max) file) (message \\\"Merge buffer saved in: %s\\\" file) (set-buffer-modified-p nil) (sit-for 1))) (setq ediff-quit-hook 'kill-emacs ediff-quit-merge-hook 'ediff-write-merge-buffer) (ediff-merge-files-with-ancestor \\\"$LOCAL\\\" \\\"$REMOTE\\\" \\\"$BASE\\\" nil \\\"$MERGED\\\"))\"
2023-06-30 08:51:34 +00:00
#+end_src
*** Pager
2023-06-30 08:51:34 +00:00
#+begin_src conf-unix
[pager]
2023-11-03 18:52:46 +00:00
diff = delta
log = delta
reflog = delta
show = delta
2023-06-30 08:51:34 +00:00
#+end_src
*** Delta
2023-06-30 08:51:34 +00:00
#+begin_src conf-unix
[delta]
2023-11-03 18:52:46 +00:00
features = side-by-side line-numbers decorations
whitespace-error-style = 22 reverse
2023-06-30 08:51:34 +00:00
[delta "decorations"]
2023-11-03 18:52:46 +00:00
commit-decoration-style = bold yellow box ul
file-style = bold yellow ul
file-decoration-style = none
2023-06-30 08:51:34 +00:00
[interactive]
2023-11-03 18:52:46 +00:00
diffFilter = delta --color-only
2023-06-30 08:51:34 +00:00
#+end_src
*** Git forges
2023-06-30 08:51:34 +00:00
#+begin_src conf-unix
[github]
2023-11-03 18:52:46 +00:00
user = phundrak
2023-06-30 08:51:34 +00:00
#+end_src
#+begin_src conf-unix
[url "https://phundrak@github.com"]
2023-11-03 18:52:46 +00:00
insteadOf = https://github.com
2023-06-30 08:51:34 +00:00
[url "https://phundrak@labs.phundrak.com"]
2023-11-03 18:52:46 +00:00
insteadOf = https://labs.phundrak.com
2023-06-30 08:51:34 +00:00
#+end_src
*** LFS
2023-06-30 08:51:34 +00:00
#+begin_src conf-unix
[filter "lfs"]
2023-11-03 18:52:46 +00:00
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
2023-06-30 08:51:34 +00:00
#+end_src