Reputation: 9956
Below is the directory structure of my directory named "Code".
Directory of C:\Name\Code
06/23/2016 12:15 PM <DIR> .
06/23/2016 12:15 PM <DIR> ..
06/23/2016 12:16 PM <DIR> Cpp
06/15/2016 06:49 PM <DIR> Java
06/22/2016 04:19 PM <DIR> Python
06/23/2016 12:17 PM <DIR> OtherStuffs
My Git account has Cpp and Java repository. I used to go individually to Cpp and Java directories and commit it to Git. So everything inside Cpp and Java gets committed to my Git repository Cpp and Java. Now I have added few more directories. I can sync those directories to Git by individually doing a "git init" on each of those directories.
Is there is an easier way to push all directories inside my parent directory "Code" into git without creating a repository named Code?
I do not want to create a parent directory "Code" in my Git repository. I just want to push all the sub directories to corresponding Sub directories in Git. Something like,
cd Code
git init
git add --all
git commit -m "Pushing everything inside Code"
git remote add origin https://... // Where should I make this point to ? I do not have "Code" repository in my Git
git push origin master
Upvotes: 1
Views: 1766
Reputation: 780
The problem is your Code
repository is not initialized to git, nor is it linked with a repository. As a result it's not actually possible to just type git push
from within your Code repository and expect it to push it's child directories.
The best thing I can suggest to you is setting up a bash (or zsh, depends on what you're using) alias that cd
s into each directory and pushes separately.
alias gpa='cd ~/path/to/Code/Java && git add . && git commit -m "autocommit" && git push -u origin master && cd ~/path/to/Code/Cpp && git add .
... and end it with && cd ~/path/to/code
However, the point of git
is to be able to make atomic commits and know exactly what is being changed - so there really isn't a good reason to do what you're trying to do. I would continue to just use your process as normal - except you really don't need to have separate repositories for each of your different folders. Wouldn't it make more sense to simply have a Code
repo?
Upvotes: 1