How to push a new folder (containing other folders and files) to an existing git repo?



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.


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

Answered By – Gavin

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More