35

I cloned a repository to my desktop machine using git clone sshurl. As expected, this created a folder in my desktop.

Now, instead of a single file, I want to push a whole folder into git. For example, the folder that I cloned is named project_iphone. Now I add another folder called my_project into project_iphone. The my_project folder contains lots of files and folders as well.

My question is, how should I push my_project folder to the server?

Step-by-step instructions would be helpful.

Thank You.

4 Answers 4

52

You need to git add my_project to stage your new folder. Then git add my_project/* to stage its contents. Then commit what you've staged using git commit and finally push your changes back to the source using git push origin master (I'm assuming you wish to push to the master branch).

Sign up to request clarification or add additional context in comments.

3 Comments

it works nicely.....now I've push a folder to git...how do i remove the folder? tried git rm <foldername> but failed...
never mind already..just needed to add -r..if not can't delete folder...thx for help anyway...
@da32 folders are not versioned in git, just files. It's by making a folder empty that you virtually delete it.
3

You can't push a new empty folder. First you must create at-least one new file in the new folder and then you can add, commit and push it.

Comments

1

In order to push any folder from git bash, you have to make a single file it could be anything text or etc. If you try to push an empty folder your git bash will not give you an error but when you refresh your GitHub you will not see that folder, so in order to push any folder just make a single file and push, after that you can add your stuff and delete the previous file(if you want to).

to push follow the below commands

  1. -git add (folder name) -git add . (in order to push everything) -git commit -m "anything" (to keep track of your changes)

if not added remote origin then do this

  1. -git remote add origin (your repo link) then to push files -git push -u origin main

to push on the master branch

  • -git push -u origin master

look if you have already created a repo then do

  • -git push -u origin master

Comments

0

You can directly go to Web IDE and upload your folder there.

Steps:

  1. Go to Web IDE(Mostly located below the clone option).
  2. Create new directory at your path
  3. Upload your files and folders

In some cases you may not be able to directly upload entire folder containing folders, In such cases, you will have to create directory structure yourself.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.