Reputation: 187
I have created a new GitHub project, which is empty (I still see the setup instructions in GitHub on my repository).
I have a server that contains a developement project, this is the folder and sub-folder that I want to have on GitHub. I ran git init
on that folder.
When I push the master branch to the "origin" remote, even if I haven't added a file to the index (and when I run git status
, it says "nothing to commit, working tree clean"), Git tries to push all the files of the project.
On branch master
nothing to commit, working tree clean
Delta compression using up to 4 threads.
Compressing objects: 100% (12403/12403), done.
^Citing objects: 29% (3803/12687), 21.75 MiB | 510.00 KiB/s
I have tried to make a .gitignore file and completed him to avoid some sub folders to be sent, and tried to add and commit one unique file, that after that appears in the index by checking the status.
Could you explain why Git pushes all the files even if index is empty?
Upvotes: 0
Views: 2079
Reputation: 3018
I'm not sure I fully understood your question, but I think this might help.
When executing git push
, git
pushes your local commits to the remote. It has nothing to do with if there's something in your staging area (tracked and untracked).
If you execute git log
, you will see that you have local commits which are not in your remote. Those are the commits git
is pushing to your remote when invoking the git push
command.
The git status
command just gives you a summary of files that are in your staging area. If the output is nothing to commit, working tree clean
, that just means that all your files and changes have been commited locally. It does not tell you whether those commits have been pushed to your remote or not.
Upvotes: 1