archive
I found this handy little snippet on github yesterday when I was looking through some of the rails commits.
Git won't add a folder unless there is something in it. If you want to commit an empty folder, the common practice is to add a .gitignore file in the directory.
This snippet will add .gitignore files to all empty directories recursively from your current directory.
~ > find . \( -type d -empty \) -and \( -not -regex ./\.git.* \) -exec touch {}/.gitignore \;
Thanks to Nate for sharing. You can view the commit where he added this snippet in the comments here.
0 comments
This nice little script has been cruising the web lately. Here’s my results.
~ > history | awk {'print $2'} | sort | uniq -c | sort -k1 -rn | head
218 git
90 gst
26 rake
21 ls
20 cd
15 cap
12 mate
11 gca
11 gb
10 rm
1 comment

It may be a little hidden but Git actually comes with auto completion, you just have to set it up.
If you have the Git source on your computer then you are good to go. If not, you are going to have to download it. After downloading Git we are going to copy the git-completion bash file from the contrib/completion directory into our home directory, prepending it with a period so that it's hidden.
~ > git clone git://git.kernel.org/pub/scm/git/git.git git
~ > cp git/contrib/completion/git-completion.bash ~/.git-completion.bash
Depending on how you've setup your bash startup files the next couple of steps may differ. If you want a great guide on setting up your bash startup files, check out this article.
The first thing we are going to do is include git-completion.bash in our ~/.bash_profile. Look for the .bashrc source include and put git-completion right before it.
# ~/.bash_profile
source ~/.git-completion.bash
source ~/.bashrc
Now you just need to reload the bash_profile and auto complete is ready to go.
~ > . ~/.bash_profile
Wasn't that easy. While we're messing around in the bash startup files though, why don't we add another great little feature. Git-completion.bash includes a method (__git_ps1) to find your current branch and print out it's name. We are going to append the branch name to our command prompt so we can always tell what branch we are working in.
Open your .bashrc files and search for the 'export PS1' line and replace it with the following.
# ~/.bashrc
export PS1='\w$(__git_ps1 "(%s)") > '
After reloading your ~/.bashrc you will have your branch names showing up in the command prompt whenever you are in a Git project. No need to call git-branch to see what branch you are in anymore.
~/projects/TestGit(master) > git checkout rails20
Switched to branch "rails20"
~/projects/TestGit(rails20) >
If you run into any trouble, check out the git-completion.bash file. It has some good instructions on how to use it at the top of the file.
6 comments
Just under two years ago I was searching for a birthday present for my girlfriend. The bag that she used for school everyday was starting to fall apart so a new bag seemed in order. I started a search for the perfect bag and made up a list of criteria.
- It must be well made and durable
- It must have lots of space for textbooks
- It must have a laptop pocket
- It must look good and have some style to it
- It can't be girly. I will probably end up carrying it every once in a while and I don't want to feel silly doing it.
After a busy afternoon downtown I had narrowed the playing field down to three pretty nice bags.
The first was the Otrlieb Sling-It. I had owned this bag for the previous 3 years and it was still going strong. It had a laptop sleeve and an easy velcro closure system. The design was pretty simple and elegant, but a little too 'bicycle messenger' for what I was looking for. For $132 US, it was a great bag, but not the perfect one.
The second bag that I looked at was the Timbuk2 Messenger. It had lots of space, a sleeve for the laptop and looked really well put together. The design seemed cluttered though, with straps and pockets all over the place. The two big plastic snaps on the font looked a bit cheap, and tri-panel fabric cut, didn't really do it for me either. Prices ranged from $120 - $210 US.
The bag that I finally ended up deciding on was the Jack Spade Laptop Tech Field Bag. It blended all the elements that I was looking for into one bag. It was sleek and stylish, very functional and well made. It came with custom die cast hardware (no plastic anywhere on it) and had lots of room for papers and books. It was a bit more expensive than the other bags, running from $195 - $425 US but looked like it was worth the higher price tag.
After giving it to my girlfriend for her birthday I think I made it a couple days before I went out and bought myself the same bag but in a different color. It's been over a year and a half now and the bag is still holding up great.
While checking out the Jack Spade site recently I also found out that they've starting to sell their bags at Apple Stores.
3 comments
So you have multiple branches on your local machine and now you want to share one or more with the other developers on your project.
You can let everyone know your IP address and have them connect to your computer directly or if you're using GitHub, you can push your branches up to it, and then the other developers can pull your newly shared branches from there.
Heres the a few commands that you are going to need to know.
# Push your local branch to GitHub
git push origin <local branch name>:refs/heads/<remote branch name>
Just by pushing your branch to a remote server doesn't mean that you are tracking it. You'll need to add the branch to your git config or you can delete the branch and then create a new one that is linked to the remote one with the following command.
# Create a new local branch that tracks a remote branch.
# If you already have a branch of the same name, delete it
# first and then recreate the branch from the remote repository.
git branch -f <local branch name> origin/<remote branch name>
Now others can pull your branch from GitHub.
# Create a new local branch that tracks a remote branch
git branch <local branch name> origin/<remote branch name>
One thing to note is that you cannot delete a remote branch from your local machnine, and as far as I've seen, GitHub doesn't have a gui to delete a branch online.
# Delete a remote branch off the remote server
git push origin :<remote branch name>
You can however, remove the branch from your remote branches listing.
# Stop tracking a remote branch
git branch -d -r origin/<remote branch name>
For some other great tips on using Git, check out this wiki.
Thanks to Dustin (in the comments) for pointing out this shortcut. If your want the remote branch to be named the same as your local branch you can use the following.
# Push your local branch to GitHub
git push origin <local branch name>
5 comments