Tips for a Subversion addict learning Git

Posted: 2009-05-11
Category: Git

This post is a mixture of things learnt from IRC, educated guesses and the results of many hours of trial and error.

Local & Remote repositories

In Subversion you have one repository which all of your code is submitted to directly when a commit is made. This is very different for Git and is what makes it a "distributed" version control system. A repository can be on a SSH server, GitHub, a local folder or network drive. Each repository is given a nickname, which is called a "remote".

git remote add origin
git pull origin master

The name of this new remote repository is "origin", but it can be anything you like.

The pull command fills your local repository with commits from the remote repository for the "master" branch, which is essentially the same as the Subversion "trunk".

As I mentioned earlier, when you make a commit it doesn't actually send the changes anywhere. To do that you need to use git push.

git push origin master

This just sends any commits on your local repo to the remote repo.

Summary of point: Subversion only has one repository, Git can have any number from 1 to... lots.

Local & Remote branches

In Subversion seeing as you only have the one repo, all branches exist there and all your commits update that branch straight away. Git has branches stored in two places, local and remote. This idea confused the hell out of me when I first heard about it but after learning to understand point #1, this became very useful.

Git allows you to create a local branch, check it out, work on it and commit to it all offline without contacting the remote repo. Eg:

git branch ticket5
git checkout ticket5
git commit -a -m "Commiting changes"

Then when you are done, you may send all of your commits to the remote branch in 'origin' using push again.

git push origin ticket5

This is what the guide meant when it said "You will never directly modify a remote branch." because you don't, you work on a copy of that branch then send that copy to the repo when you are done.

Summary of point: You can commit, switch and merge branches offline then send it all off online.

Empty folders

Subversion can add a folder in the same was as you can add a file. Git has a known bug that simply ignores any folder with no files in it. No matter what you do, you cannot add or commit an empty folder. Always just add a index.html or another empty file if that folder needs to be there.

The developers know about this, but to quote from the official Git FAQ:

"...nobody competent enough to make the change to allow empty directories has cared enough about this situation to remedy it.". Fair enough then.

Summary of point: Make sure each directory has at least one file.

Do not rename

Just don't even bother trying, it seems to just break at random. It is better to copy the file(s), set the new name and delete the old copy. My worse rename experience was renaming "public_html" to "application" in the PyroCMS repo. It added "application" but kept an empty directory structure of some of "public_html" and it was a nightmare to remove this ghost directory as it did not exist in local copies and could not be pulled or fetched.

Summary of point: Do not rename a thing, copy and delete.

Get a Mac or use Linux

Seriously, do not try install Git on a Windows machine unless you are a masochist: it is NOT worth it. Use anything with a Unix shell and the install will be done in minutes.

That said, installing Git on CentOS 5 was an absolute nightmare for me as well.

If you are using Windows, give SmartGit a try. It actually makes the whole process rather painless.

Summary: Git is one confusion S.O.B when you first start using it, but it soon begins to make sense if you stick with it. Read the manuals, use the command line and try to stop thinking like a Subversion user. Ignore what you know about Subversion and learn Git like it is something brand new. If you can't forget about Subversion then head my advice here and save yourself the headaches I have suffered the last 2 weeks.


Shaved Goat


I should email you about it.



Great comments Phil. I actually want to start learning to use Git and GitHub, you comments will help a lot! Thanks.



Hey, you're comments actually helped. I was beginning to think I was stupid for not getting git (no pun intended) right off the bat. There's still a bit of confusion, but I'll keep at it. I've been using subversion for too long :)



Any plans for a 1.6.x version of this module?

Scott Boyde



Nice addition to EE, trying to watch the video and it won't let me toggle full screen so can't see it properly.



I could make a 1.6.x version if there is enough demand. Is there any point with 1.6.x being on the way out?



I think I'd love to see a 1.6.9 version of this... I want to move to 2.1 when EllisLab puts its final stamp on it, but I have a feeling I'm still going to be waiting for a couple of third-party add-ons. It'll be nice to add REST and know I'll have an update path for it, unlike other add-ons that I currently have which have no ETA for 2.0 compatible versions.



I think I just salivated a little bit.

I'd go for a 1.6.x version.



Using your plugin, can REST requests be dynamically generated using channel field? E.g., I have a channel for organizations that includes a custom field for twitter username. I want to display a twitter feed for each organization, but the REST request needs to be dynamically generated from the custom field.



You can build your requests on the fly using any template tags you like. If EE supports it, the Rest module will.

Phil Fish


Can't see the video. The text is too tiny and it doesn't allow us to enlarge.

Dave Brookes


Can you think about adding some kind of fallback for when the API is down? When the Twitter API is down it just spits out raw tags.

Trevor Davis


Can you nest REST requests? So if I want to use a flickr.people.getPublicPhotos request, and then pass the {id} of each photo into a REST request, it doesn't seem to parse {id}.

Marcus Neto


Trying to follow along in the video for the flickr portion but the video is extremely tiny and you move pretty quick without talking through what you are doing. Any chance of some detailed documentation?



Maybe I'm missing something, but where are the docs on how to install this?



How do you suggest handling links in the Twitter timelines... for example, linking to user names or links people tweet out?



A 1.6.x version would be nice, I am waiting on a more mature 2.x version and addon/plugin support before moving forward.

Btw, is it possible to add REST support to EE itself? Remotely adding posts via REST? Moblog and Blogger APi have limitations etc...

Michael C.


Can this be used to parse event data from a private Google Calendar feed and display it in an EE template?

If so, I'd love to see a 1.6.x version of this!



Great module Phil..

I found a little problem though, while using the Flickr API to pull images from a photoset (flickr.photosets.getPhotos): recurring attributes, like @id, confuse EE's template tags parsing engine, which assigns the same value to all elements. For instance, the response from Flickr is a "photoset" object (with an @id representing the set id) containing "photo" objects, which in turn have individual @id values. EE substitutes all {id} occurrences with the same "photoset" @id, ignoring the "photo" @ids. I cobbled together a workaround by adding a prefix to the @id attributes (eg: @photoset_id and @photo_id) in the _force_array function.
This works for me but maybe someone else could benefit from it. Does this sounds interesting to you? Should I send you the modified

Guy Stephens



I'm having that same issue - would love to see your workaround.



Joe Stevens


I am a total noob when it comes to REST and APIs. I wanted to use this with the Netflix API, do you have any suggestions as to how to use this with a Library that requires OAuth authentication?

John Eystein


If you’ve used the SimpleXML functions in PHP, you may have noticed some strange things happening with CDATA values in your XML file/string. All I needed to do was extract the value of my CDATA fields, however these were always coming back blank in the structure that simplexml_load_file returns.
Finally, after hours of trawling google, I’ve come up with the following solution:

private function _xml

line 324
$data = ((!$recurse) && is_string($input)) ? simplexml_load_string($input,'SimpleXMLElement', LIBXML_NOCDATA): $input;

Use this line of code when you are loading the XML file into the SimpleXML Object. The key is the LIBXML_NOCDATA option as the third parameter. This returns the XML object with all the CDATA data converted into strings. You can read about this in the php manual.
This solved all the problems I was having getting CDATA values out of SimpleXML in php. Hope it helps :)



Documentation should come with a paid add-on. Don't have time to waste my time on watching a video.



I'm pulling a Wordpress RSS feed and I want to customize the date so it appears normal. Currently it appears like this:

Mon, 27 Sep 2010 20:55:50 +000

I want to cut out the date and time. If I add the "format" parameter to the rest tag, all the dates revert to some arbitrary date in 1969. If I encapsulate the rest tag in a character limiter tag, there is no effect. Anyone have any ideas? I'd be happy with the date just looking like this:

Mon, 27 Sep 2010

You can see an example of this here: (news section, dates in blue on the left). Thanks!




im not able to see the video in full screen............

Posting comments after three months has been disabled.