Skip to content

Command line tips and tricks

Nathan Chancellor edited this page Dec 29, 2021 · 29 revisions

Finding the first tag contains a commit in git

Given sha of commit, we want to know the first tag that contains the fix.

tag=$1
git describe --match 'v*' --contains "$tag" | sed 's/[~^].*//'

For finding which commit may have removed a string, try:

$ git log -S <string> <file>

(via Saravana Kannan)

Fetching a single patch or series from LKML

Link: https://www.kernel.org/lore.html

Alternatively, you can use a generic message-id redirector in the form: https://lore.kernel.org/r/message@id

Recommend installing b4.

Examples:

# Link to patch (series)
link="https://lore.kernel.org/r/[email protected]/"
or
link="https://lore.kernel.org/lkml/[email protected]/"

# Apply patch (series) in local Git
$ b4 am $link -o - | git am

# Download patch (series)
$ b4 -d am $link

Removing the currently installed kernel and modules

$ sudo rm -r /boot/config-$(uname -r) /boot/initrd.img-$(uname -r) /boot/System.map-$(uname -r) /boot/vmlinuz-$(uname -r) /lib/modules/$(uname -r)

Sending a patch to Linux upstream

Simulate the check of your patch:

$ cd /path/to/linux.git
$ git send-email --dry-run --to-cmd='scripts/checkpatch.pl' 0001-Makefile-correct-prefix-for-Clang-builds.patch

Simulate to get the list of maintainers:

$ git send-email --dry-run --to-cmd='scripts/get_maintainer.pl -i' 0001-Makefile-correct-prefix-for-Clang-builds.patch
  1. Note: Drop --dry-run for a real submission.
  2. Note: Install the package of your distribution shipping git-send-email (Debian: git-email).
Clone this wiki locally