Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding existing source code folder to Git

Tags:

git

I am new to Git. I want to add an existing source code folder to Git, but based on the little documentation that I read, I guess files must be a Tar ball or tar.gz archive. I am also not finding a way to add an entire existing folder.

Is it not possible to add non-compressed files to Git repository along with the folder that contains the files?

like image 877
RKh Avatar asked Aug 02 '11 11:08

RKh


People also ask

How do I import an existing repository?

Select Repos, Files. From the repo drop-down, select Import repository. If the source repo is publicly available, just enter the clone URL of the source repository and a name for your new Git repository.


2 Answers

It depends what you mean by adding a directory to a Git repository.

I get the feeling that you mean that you want to create a new project using an existing directory. In which case, you would need to go inside your directory and use git init. Here a quick guide I just found.

However, if you mean that you already have a Git project and wish to add a directory - the answer is simply to use git add path

Let us know if you need more information (such as setting up a remote, or using github.)

like image 135
Bushibytes Avatar answered Oct 05 '22 10:10

Bushibytes


No, you don't need it compressed. Git operates on the filesystem.

If you want to create a new repository from existing source, just cd into that directory and type: git init.

Add the current state of files to the index with git add . (note the trailing dot)

If you want to add existing code to an existing repository, you also need git add (and probably copy the files to where you repo is).

I suggest to take some time to actually learn and understand git before using, because doing so will save you a lot of trouble.

like image 24
Tamás Szelei Avatar answered Oct 05 '22 12:10

Tamás Szelei