Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Swiping that first one - I have hundreds of commits which were just one or two character tweaks after I had hit the commit button. Often, they squash bugs. (Hah, test run completed and now I realize the error of my ways...)

More articles like this, please?



Glad you like it. Another weird thing I do is that "g" is not just an alias, it's a function in my ~/.bashrc

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
  }


> History rewrite sounds like a dirty thing

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.


> history re-writing becomes a dirty word when you re-write history that someone else may have already seen.

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.


You should try out Stacked Git, it provides a very easy way to deal with temporary commits.

http://www.procode.org/stgit/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: