Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add folders to git repository?

I would like to publish some project I created with java ,about MMU. The project folder actually contains two separate folders: the first one is for the client, and the second one for the server.

Of course, to achieve that goal , the first step is to create a new repository in my own GitHub site. So I did.

Then, I was trying tried the following to add the relevant folders in this repository:

1) Directly through GitHub :

I clicked on my repository in a browser, then I clicked on Upload Files. However, uploading an entire folder so that GitHub would preserve the hierarchy of the files and folders in my folder - is failed , since it can not select folders to be uploaded.

I also was trying to drag and drop the folders, but it always got the following error : " Yowza, that’s a big file. Try again with a file smaller than 25MB." ,even though the files I wish to upload are well under 25MB.

2) By using git-bash command line:

According to this link https://github.community/t5/How-to-use-Git-and-GitHub/How-to-upload-an-entire-folder/td-p/8516, typing the following commands should fulfill the goal of adding entire folders into a repository:

git init

git add <folder1> <folder2> <etc.>

git commit -m "Your message about the commit"

git remote add origin https://github.com/yourUsername/yourRepository.git

git push -u origin master

git push origin master

but after I type the command : git add , I get the following error:

bash: syntax error near unexpected token `<'

How do you add entire folders into a repository then?

Any help would be appreciated.

like image 589
TRUMP Avatar asked Sep 19 '25 15:09

TRUMP


1 Answers

  • git init
  • git add project_folder
  • git commit -m "Adding new Project"
  • git remote add origin https://github.com/yourUsername/yourRepository.git
  • git push -u -f origin master

Go to the local repository where project_folder is present. Execute these commands which will add project_folder inside yourRepository on github.com.

like image 129
Dakshayani Avatar answered Sep 22 '25 06:09

Dakshayani