简体   繁体   中英

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?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM