by hayeah · 15y ago · 0 comments
So "g" (without any argument) is "g status", with arguments, g is effectively an alias for git. A micro-optimization, true.
Another git feature I use quite a bit is the history rewrite. "git fuss 5" allows me to fiddle with the last 5 commits. I should write another article to explain git fuss. History rewrite sounds like a dirty thing. But my git workflow involves doing a whole bunch of temporary commits, so I can track small incremental steps with git. History rewrite is pretty legit for this usage pattern.
g() {
if [[ $# == '0' ]]; then
git status
else
case $1 in
fuss)
shift
git rebase -i HEAD~"$1";;
*)
git "$@";;
esac
fi
}well you're only rewriting local history, so you're a-ok. history re-writing becomes a dirty word when you re-write history that someone else may have already seen. i know you already know this.
It seems like git (or some friendlier wrapper) could track this for you. For example, if you've pushed changes to a remote repo, then git could mark those changes as "published" in your local repo and warn you when you later try to rewrite that branch's history.