RKh
RKh

Reputation: 14161

Adding existing source code folder to 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?

Upvotes: 38

Views: 63976

Answers (3)

Prajwal Waingankar
Prajwal Waingankar

Reputation: 2710

In case if you are using Gitkraken then it is the most simplest method.

Steps:

  1. on Gitkraken- File -> Init Repo.
  2. Fill in the details.
  3. Click on Create and Init repo. and there you go your existing source code is uploaded on your github under you mentioned or created repo.

Upvotes: 0

Bushibytes
Bushibytes

Reputation: 601

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.)

Upvotes: 48

Tamás Szelei
Tamás Szelei

Reputation: 23921

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.

Upvotes: 23

Related Questions