Aaron
Aaron

Reputation: 1743

Adding a new directory to existing repository

I have a folder containing source code that I would like to add to an existing git repository. I first do the init, add ., and commit commands. When I push to origin master, it tells me

error: failed to push some refs to '.../project.git'  

And so I do pull origin master, and it adds a local copy of the existing project. When I then try to add my new folder with source code, it shows

modified: new_project_folder (modified content)

and

no changes added to commit

What should I do in order to add this new folder into the existing master branch?

Upvotes: 0

Views: 232

Answers (2)

ishenkoyv
ishenkoyv

Reputation: 673

Is your new folder imported from another git repository? Check for .git folder inside it and remove it if presented. And make git add again.

If your new folder is empty then simply create empty file inside it

Upvotes: 0

Rob
Rob

Reputation: 11723

Why did you do the init again?

Go back to the one you just pulled, put in your code, then do:

git add .
git commit -m "New module blah...'

and then push.

One thing that is a tad bit confusing in git is when you add directories, it echoes just the dir and so leaves you with the impression that maybe the contents were not added. They were.

Upvotes: 1

Related Questions