May 15, 2013

Git: Pulling a single directory only from a remote repository

I was working with a web application that used the Laravel framework and, because big projects take time, the framework was updated mid-project. I wanted to use these updates without messing up the changes I had already made to config files. So I came up with this workaround:

git checkout laravel/master -- laravel/

So in detail, I run the 'git checkout' command with the parameter 'laravel/master'. That parameter is a reference to the remote repository 'laravel' (which I had set up earlier by running 'git remote add laravel git://github.com/laravel/laravel.git') and specifically the 'master' branch. The '--' in the command means I want to check-out a specific file or directory, which in this case means the 'laravel/' directory.

Nice, short and sweet.


No comments:

Post a Comment

Thanks for contributing!! Try to keep on topic and please avoid flame wars!!