ParisNakitaKejser
ParisNakitaKejser

Reputation: 14839

Sub folder in Git project?

I have been using Subversion for a long time and now I have switched to Git.

Now I need to know how to get sub folders in my Git project?

I know sombody will make 2 projects for this but I dont need 2 projects for this. I need to clone a subfolder and not my main project.

I use github.com.

Upvotes: 5

Views: 33669

Answers (5)

Keenal
Keenal

Reputation: 1

You won't be able to add an empty folder. Create a file first, add a folder inside it and then link the file inside the folder. Similarly, once you have a main folder, you can add files or create subfolders inside this folder.

Upvotes: 0

Ho1
Ho1

Reputation: 1289

Yes, you can! Github also provides SVN access for repositories. For example I want to get Android fonts here:
https://github.com/android/platform_frameworks_base/tree/master/data/fonts
Just run this command, see the pattern, replace /tree/master with /trunk:

svn checkout https://github.com/android/platform_frameworks_base/trunk/data/fonts

Upvotes: 2

Yuming Cao
Yuming Cao

Reputation: 945

  1. create a folder
  2. "git add" this folder
  3. "git commit -m 'message'"
  4. "git push"

DONE!

Upvotes: 3

ParisNakitaKejser
ParisNakitaKejser

Reputation: 14839

I found an answer: http://blog.quilitz.de/2010/03/checkout-sub-directories-in-git-sparse-checkouts/

I had git 1.5.5, and it requires 1.7+; now I have 1.7 and it's all working fine. :) But thanks a lot for the answer.

Upvotes: 0

ThiefMaster
ThiefMaster

Reputation: 318488

When cloning a git repository you always clone the whole repository.

If you want subfolders in your project simply create them though. As soon as you add files inside them (git only tracks files no folders -> if a folder is empty you cannot add it to your repo), they can be committed to your repository by committing the files inside.

Upvotes: 6

Related Questions