I have a to add files in new subdirectory tothe existing repo... Say I have a repo http://myrepo.git with folder work and I have to add new files in folder subject under work. I found docs to explain how to add project to repo:
cd subject
git init
git add .
git commit
git remote add origin http://myrepo.git
git remote -v; git push origin master
But this seems to be designed to add my files to myrepo.git, how can I keep
myrepo.git/work/subject directory structure?
Thanks
You can't add an empty directory to git.
The general workaround is to add an empty file .gitkeep and to add it to git:
touch work/subject/.gitkeep
git add work/subject/.gitkeep
git commit -am "Add directory subject"
That way, the directory will exist, and you know can remove this file once you have other ones in this directory.
I have a to add files in new subdirectory tothe existing repo...
The "subject" directory is not empty, i have several new files there
I think you are doing it completely wrong, there is no need to create a fresh git repository and add files to it. Instead, you can add files to the original repo itself:
git clone myrepo.git
cd work
mkdir subject && cd subject && touch file1 file2 #touch is equivalent to new files added
git add . && git commit -m "some message"
git push origin master
The above should push your changes to the remote, and as you can clearly see, there is no new repo created in the process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With