Re:Correct Git commits with git-autofixup
by chrismorgan on Thursday March 18, 2021 @01:01PM
(#26504807)
My aliases for those two deals with remote-tracking branches (see git-rev-parse(1) for documentation of the @{upstream} part if you’re not familiar with it). Might as well provide a more full excerpt:
# I almost always use glog rather than log.
glog = log --graph
# “Short log”
slog = log --graph --oneline
# `git id` = `git rev-list --max-count=1` with default refspec HEAD.
id = "!f() { case \"x$1\" in x-*|x) refspec=HEAD;; *) refspec=\"$1\"; shift;; esac; git rev-list --max-count=1 \"$refspec\" \"$@\"; }; f"
# `git tip` = `git log --max-count=1` with default refspec HEAD.
tip = "!f() { case \"x$1\" in x-*|x) refspec=HEAD;; *) refspec=\"$1\"; shift;; esac; git log --max-count=1 \"$refspec\" \"$@\"; }; f"
# `git out` = glog commits that exist locally but not on the upstream branch. No way to refer to different origins, sorry.
out = "!f() { case \"x$1\" in x-*|x) branch=;; *) branch=\"$1\"; shift;; esac; git glog \"$branch@{upstream}..$branch\" \"$@\"; }; f"
sout = "!f() { case \"x$1\" in x-*|x) branch=;; *) branch=\"$1\"; shift;; esac; git slog \"$branch@{upstream}..$branch\" \"$@\"; }; f"
# `git in` = glog commits that exist on the upstream branch (remember to fetch them first) but not locally.
in = "!f() { case \"x$1\" in x-*|x) branch=;; *) branch=\"$1\"; shift;; esac; git glog \"$branch..$branch@{upstream}\" \"$@\"; }; f"
sin = "!f() { case \"x$1\" in x-*|x) branch=;; *) branch=\"$1\"; shift;; esac; git slog \"$branch..$branch@{upstream}\" \"$@\"; }; f"
Re:Correct Git commits with git-autofixup
by StavrosK on Thursday March 18, 2021 @08:52PM
(#26509194)
Is there one of these `@{}` tags that means "the point where this branch split off from master"? That'd be very useful, because that's usually the scope of my rebases.
Re:Correct Git commits with git-autofixup
by chrismorgan on Friday March 19, 2021 @06:58AM
(#26511924)
I recommend reading the git-rev-parse(1) man page in full, it’ll give you good ideas for this sort of thing.
What you’re looking for could be spelled $(git merge-base HEAD master) (that’s a subshell invocation, outputting a single commit ID). In some circumstances dotted range notation might do: master.. includes all the commits after master and HEAD diverge. That’s good for logging, for example, but not so useful for the sort of rebasing you’re describing, where you may wish to use the merge base instead.
When I am in git, I use this version from https://github.com/sympy/sympy/wiki/Git-hg-rosetta-stone#set...:
Feature-wise, the mercurial command is way more powerful: https://www.mercurial-scm.org/doc/hg.1.html#incoming