There's no inverse (child of tip) of HEAD~1 (parent of tip) because there can be many children. But if you give git a descendant to move toward, it can do it.
git config --global alias.child '!f() { if test "$#" -gt 0; then target="$1"; else target="@{-1}"; fi; next="$(git rev-list --reverse --first-parent HEAD.."$target" | sed -n "1p")"; test -n "$next" && git switch --detach "$next" || { echo "no next commit toward $target"; return 1; }; }; f'
There's no inverse (child of tip) of
HEAD~1(parent of tip) because there can be many children. But if you give git a descendant to move toward, it can do it.git config --global alias.child '!f() { if test "$#" -gt 0; then target="$1"; else target="@{-1}"; fi; next="$(git rev-list --reverse --first-parent HEAD.."$target" | sed -n "1p")"; test -n "$next" && git switch --detach "$next" || { echo "no next commit toward $target"; return 1; }; }; f'