简体   繁体   中英

git add all gitted subdirectories

I'm creating putting all my projects on a folder and I make in this folder

git init
git add .
git commit -m"init"

After that, I create a new git repository in github and I copied like usually commands to add the repository, but When I pushed, I found that the content of all my projects haven't been pushed, but the not gitted directories are pushed correctly, I want to push all my gitted projects, how can I do ?

If you have some git repositories inside a git repository (eg : "gitted subfolders" inside your parent folder), the default behavior of git is to ignore these subrepositories when you run git add from the parent repository.

You will need to track each of your gitted directory in its own dedicated repository on github.

okay, let's be clear here. executing a git init makes the current directory that you have cd'd in, a git project. once your have executed a git init, you can start tracking that directory into a git repository! in your case, when you are trying to track all your projects in git, you will need to cd into each of those directories where your projects are using:

 cd path_to_your_project/ 

you will need to convert them to a git project by executing

 git init

then, you will have to add all the untracked files using:

 git add --all

then, you need to make you first commit:

git commit -m "my first commit"

once you have comited your changes, you can start tracking the project remotely by giving it an origin and pushing your changes to master (example assumes repo on github):

git remote add origin git@github.com:<git_user_name>/<repo_name>
git push -u origin master

Maybe you did not add the new files to your staging. See what changes are stages with git status and stage all files in your repo with git add -A . Then commit and push your changes to the remote repo.

Also you might want to check how you set up your remote repo. With git remote add origin remote repository URL you link your local repo to your remote GitHub repo. With git push -u origin master you should be able to push your changes to GitHub (which you named origin)

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