Some of the reasons I really like git, all experienced in this week:
Prepare CHANGES file
Run git log --no-merges --pretty=format:' - %s (%an)' `git tag | tail -n 1`..
to get a nicely formatted list of changes (and who checked it in) since the last tag. OK, most other VCS can also do similar, but git let's me alias this in my .gitconfig so I don't have to remember the details and just say git last_changes
.
Revert a repo to a few hours earlier
A colleague complains that the test suite for one modul is broken, and he
can't fix it. I check out his head, and can't find the problem after a few
minutes. But I experience strange behaviour during tests (if you run a single
test, it works, if you run all tests, it fails). So, we assume it has to with
the tests fu̸cking up the DB. To prove that his changes caused the problem, I do
git co a_ref_befor_his_commit
and magically travel back in time.
The tests work now. So we do git co HEAD
to travel back into the
present, and after some cross-history-diffing, we find the bug & fix it.
No need to set up a server
I was fuzzing with our post-receive hooks, which run after somebody pushed something into the public repo. Our hooks do obvious things like sending out commit mail and IRC notifications, but also nice stuff like building a tarball and uploading it to our custom cpan when the commit was a tag. Only this wasn't working after we switched to another notify-script.
But because git doesn't care where you clone from, and what exactly is a public repo, it was easy to set up a local repo on my disk, clone from it, declare another repo on my disk to be the "remote" and thus test all of the scripts without a) network, b) spamming my colleagues and (most importanly) c) any complicated setup. All that was needed were some dirs on my laptop.
And that's it for todays git propaganda!
Re:order of "git tag"
mugwumpjism on 2008-09-05T22:05:21
that's a strange requirement, but you can use something like this:
git-for-each-ref refs/tags/* --format="%(tag)" --sort="taggerdate"
Well, that only works for annotated tags... use '%(refname)' instead of '%(tag)' and add '--sort=committerdate' for a version that works with lightweight tags too. It just looks slightly uglier
:-)
You should look at git bisect
Did you notice that the bash/zsh tab-completion will also tab complete that alias command you defined?
Also, be warned that when you clone, it doesn't clone absolutely everything unless you use --mirror - by default it will just clone "heads" and "tags"