Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gittips [2021/06/03 08:59] – LiWenHsugittips [2023/03/13 14:24] (current) – Add a helper script for creating worktree for ports quarterly branch LiWenHsu
Line 14: Line 14:
         email =          email = 
 </code> </code>
 +
 +Please note, that email set in the global user config (~/.gitconfig) will get used in all repositories that do not set per repo value.
  
 ==== format ==== ==== format ====
Line 22: Line 24:
 [format] [format]
         pretty = fuller         pretty = fuller
 +</code>
 +
 +==== dealing with pgp keys ====
 +
 +When updating pgp keys in the handbook, it's helpful to be able to confirm what actually changed to your key before committing.
 +
 +Consider adding this stanza to your $HOME/.gitconfig:
 +
 +<code>
 +[diff "gpg"]
 + textconv = "f(){ gpg --list-packets < \"$1\" | grep -v \"^# off=\"; }; f"
 +</code>
 +
 +and this to /path/to/your/doc-repo-clone/.git/info/attributes:
 +
 +<code>
 +*.key diff=gpg
 +</code>
 +
 +When you now "git diff" or "git show" in the doc repo, the base64 encoded blobs will be decoded to (slightly) more readable PGP packets.
 +
 +==== rewriting history ====
 +
 +To rewrite history, including separating out components from %%FreeBSD%% src, see the examples in [[git-filter]].
 +
 +==== commit count (replacement of revision number) ====
 +
 +<code>
 +git rev-list --first-parent --count HEAD
 +</code>
 +
 +==== Show your diff while writing commit msg ====
 +
 +If you want to see your uncommitted diff while writing a commit message, either run:
 +
 +<code>
 +git commit --verbose
 +</code>
 +
 +…or configure it accordingly:
 +
 +<code>
 +[commit]
 +        verbose = true
 +</code>
 +
 +==== Show (long enough) hash ====
 +
 +<code>
 +git rev-parse --short <long hash>
 +</code>
 +
 +==== Worktree ====
 +
 +It's handy to tracking multiple branches simultaneously with [[https://git-scm.com/docs/git-worktree|git-worktree(1)]]
 +
 +<code>
 +cd freebsd-ports; git worktree add -b 2021Q3 ../freebsd-ports-2021Q3 freebsd/2021Q3
 +cd freebsd-src; git worktree add -b stable/13 ../freebsd-src-13 freebsd/stable/13
 +</code>
 +
 +=== Helper Scripts ===
 +ports
 +
 +<code>
 +#!/bin/sh
 +
 +year=$(date +"%Y")
 +month=$(date +"%m")
 +quarter=$(((month-1)/3+1))
 +
 +branch="${year}Q${quarter}"
 +
 +git worktree add -b ${branch} ../freebsd-ports-${branch} freebsd/${branch}
 </code> </code>
  
  • gittips.1622710754.txt.gz
  • Last modified: 2021/06/03 08:59
  • by LiWenHsu