Two git Tips That Will Make You Smile
Posted 1 month, 4 weeks ago

Here, at Odeon, we use GIT to handle Source Code. We need this mature DSCM solution since we're scattered all over the globe.
We do most of our work in Django, so we deal with python. Naturally, we need to manage the .py files with GIT, but we need to ignore the .pyc (compiled python code) -- no sense keeping those under source control since they're not source code.
One way would be to create a .gitignore file in the repository root and put *.pyc in there. Another way would be to vim .git/info/exclude and put *.pyc in there. But these two are per-repository solutions. We would need to do this every time! Not nice.
Here's a simpler way:
- git config --global core.excludesfile ~/.gitignore
You don't need to use ~/.gitignore, by the way, but that just makes the most sense.
Now you have ONE file where you need to put the *.pyc line and all your problems with files you want to keep out of source control are solved!
Oh, right. Mac users: please add .DS_Store to that file, eh?
The other little trick I want to tell you about has to do with log review. I usually want a list of things I've done during the past day so I can punch them into our Issue Tracker, or just to see whether I'm to blame for a bad commit or not, or just to show off to others with the work I've done. I came up with this:
- git log --author="horia" --after=yesterday --no-merges --format=%s, --reverse
This will bring up a simple comma-separated list of commit messages. Very handy when you want to quickly answer the question "So what have you been up to?" without talking. You should obviously replace "horia" with your name.
I even set up an alias for this, so all I have to type is git me. ;-)
- git config --global alias.me log --author="horia" --after=yesterday --no-merges --format=%s, --reverse
Category: Linux
Leave a Comment


