views:

218

answers:

5

hello, I have a project with git, and I just want to clone or pull a specific directory, like myproject/javascript just like subversion does.
make some changes, commit and push back again.
It's possible?

+6  A: 

It's not possible. You need pull all repository or nothing.

shingara
Even though you need to *fetch* everything, would a pull on a sparse checkout working tree be of interest in this case? See http://stackoverflow.com/questions/2416815/how-to-git-pull-all-but-one-folder/2416991#2416991
VonC
Just to add on this, the reason why you cannot pull just a directory is because git uses data semantic tracking, not file semantic tracking, so you can seamlessly move code (or other data) in and out of files without having to tell the source tracking system (until you update of course.) Because of this, code can move in and out of directories seamlessly too, so grabbing just one directory doesn't make as much sense. Hope this helps.
OmnipotentEntity
A: 

Shingara is right. An explanation of this behaviour is given in this mailing list thread. If you really want to do this, you can make the javascript dir a submodule.

Michel Jansen
A: 

Sometimes, you just want to have a look at previous copies of files without the rigmarole of going through the diffs.

In such a case, it's just as easy to make a clone of a repository and checkout the specific commit that you are interested in and have a look at the subdirectory in that cloned repository. Because everything is local you can just delete this clone when you are done.

Abizern
A: 

I see. I'll try creating submodules and see if works for me. I'll report results.

A: 
  1. cd into the top of your repo copy
  2. git fetch
  3. git checkout HEAD path/to/your/dir/or/file

    • Where "path/..." in (3) starts at the directory just below the repo root containing your ".../file"
vergueishon