Quick tip: git push origin hamster?

My typing is horrible. I make mistakes all the time. I’m an avid Vim user but I still use the arrow keys. I’m one of those people who need technology that does what they meant, not what they asked for. So if you’re a coder like me, you probably see this a lot:

$ git push origin amster
error: src refspec amster does not match any.

Fortunately there is a simple workaround: Git’s symbolic references. I can add a symbolic reference for amster:

$ git symbolic-ref refs/heads/amster refs/heads/master

And now Git does what I meant:

$ git push origin amster
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 695 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To [email protected]:user/SomeProject.git
   ec208c7..fb0cb8f  amster -> master

Because it’s a symbolic reference, anytime I mean to type master but actually type amster, Git will do the right thing. Try it!


David Farrell

David is the founder and editor of PerlTricks.com. An organizer of the New York Perl Meetup, he works as a technology consultant in New York City.

Browse their articles