Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| gittips [2021/06/03 08:29] – Init LiWenHsu | gittips [2023/03/13 14:24] (current) – Add a helper script for creating worktree for ports quarterly branch LiWenHsu | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| Some Git Tips useful for contributors and developers | Some Git Tips useful for contributors and developers | ||
| + | |||
| + | Here we put some tips and cheatsheets, | ||
| + | |||
| + | ==== .gitconfig ==== | ||
| + | |||
| + | There are two common places for git config, global (~/ | ||
| + | |||
| + | You can set your preferred name and email for different projects: | ||
| + | |||
| + | < | ||
| + | [user] | ||
| + | name = | ||
| + | email = | ||
| + | </ | ||
| + | |||
| + | Please note, that email set in the global user config (~/ | ||
| + | |||
| + | ==== format ==== | ||
| + | |||
| + | To show both for author and committer information for checking the credit is given to the submitter, set fuller format for '' | ||
| + | |||
| + | < | ||
| + | [format] | ||
| + | pretty = fuller | ||
| + | </ | ||
| + | |||
| + | ==== 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/ | ||
| + | |||
| + | < | ||
| + | [diff " | ||
| + | textconv = "f(){ gpg --list-packets < \" | ||
| + | </ | ||
| + | |||
| + | and this to / | ||
| + | |||
| + | < | ||
| + | *.key diff=gpg | ||
| + | </ | ||
| + | |||
| + | 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) ==== | ||
| + | |||
| + | < | ||
| + | git rev-list --first-parent --count HEAD | ||
| + | </ | ||
| + | |||
| + | ==== Show your diff while writing commit msg ==== | ||
| + | |||
| + | If you want to see your uncommitted diff while writing a commit message, either run: | ||
| + | |||
| + | < | ||
| + | git commit --verbose | ||
| + | </ | ||
| + | |||
| + | …or configure it accordingly: | ||
| + | |||
| + | < | ||
| + | [commit] | ||
| + | verbose = true | ||
| + | </ | ||
| + | |||
| + | ==== Show (long enough) hash ==== | ||
| + | |||
| + | < | ||
| + | git rev-parse --short <long hash> | ||
| + | </ | ||
| + | |||
| + | ==== Worktree ==== | ||
| + | |||
| + | It's handy to tracking multiple branches simultaneously with [[https:// | ||
| + | |||
| + | < | ||
| + | cd freebsd-ports; | ||
| + | cd freebsd-src; | ||
| + | </ | ||
| + | |||
| + | === Helper Scripts === | ||
| + | ports | ||
| + | |||
| + | < | ||
| + | #!/bin/sh | ||
| + | |||
| + | year=$(date +" | ||
| + | month=$(date +" | ||
| + | quarter=$(((month-1)/ | ||
| + | |||
| + | branch=" | ||
| + | |||
| + | git worktree add -b ${branch} ../ | ||
| + | </ | ||