All posts tagged Bash

The other day at work I needed to push only one commit out of several I had made locally to the remote server, for a release build.  Normally when one does a push, they push everything at once.  However, git does provide a way to push only one commit at a time.  The caveat is that the single commit you want to push must be directly above the tip of the remote branch (the oldest of your local commits).  If it is not, don’t worry as you can simply reorder your local commits to suit the situation.

SourceTree does not seem to provide any way to do what we want, but the command line interface of git does, and its actually pretty easy.  First you need to get the hash of the commit you want to push by using the command “git log” (Press “q” to exit the log).  A hash is a 40 character alpha-numeric string that looks something like  2dc2b7e393e6b712ef103eaac81050b9693395a4 .  Once you have the correct hash, use the push command as you normally would, except provide the hash as part of the command:

Important Note: This will push all commits up to and including the specified commit!  This means if you specify the commit that is at the top of your branch it will push everything, exactly the same as a regular push.  You need to reorder your commits first to make sure the commit you want to push is at the bottom (directly above the remote branch).  How to reorder commits with Git.

In place of the hash, you can also use standard Git revision names such as HEAD~1 or HEAD^, as well as abbreviated hash names.

There are lots of good reasons to change the order of your commits: sometimes they make more sense in a different order, or maybe you want to only push one commit out of several (more on how to do that soon).  Luckily, Git provides a way to do this, as long as the commits have not yet been pushed upstream to the remote server.  This is known as rewriting history.  I will explain how to do this with both sourcetree and git in a console.

Continue Reading

A somewhat specific problem that occurs often when developing for iOS and using SVN, is the need to escape the @ character.  The @ character is used with iOS and XCode to specify assets used for retina displays, by appending “@2x” to the end of the filename.  If you have ever tried to use a filename that contains an @ character with SVN, you likely would have encountered some trouble.  As soon as SVN sees the “@” in the filename, it seemingly ignores it and everything after it, cutting your filename short and causing an error.

Notice in the example above that everything past the “@” is missing in the warning message.  The problem is the @ character has special meaning to SVN; it expects everything after the @ to specify a revision number, so when it sees it in your path, it parses it out.  It gets trickier though, because escaping your path in the normal ways wont work, including surrounding it with quotes or using a backslash.

The workaround for this problem is simple and clever.  When parsing the filename, SVN only looks for the last occurrence of the @ character.  So if you add another @ character to the end of your filepath, the first one will stay intact.

Credit for the solution goes to gg1 at