I have staged my files like this
git add mydir
git add mydir/myfile
and then pushed them to my repo
git remote add origin https://github.com/usename/myrepo.git
git push origin master
When I look at git status -s it says my files have been added, but I cannot see them in my actual repository. Does anyone know whats going on here?
You have not “added” your files to the repository, only to the staging index.
You need to
git committo get your changes from thestaging indexto therepository.git statusshows you the status of the working tree and staging index.git logshows you the status of the history – in other words,git logwill show you what’s been committed to the repository.As an example, see this
git statusoutput:In this case, we can see that the changes to be committed involve
Game.py. Note that these changes haven’t yet been added to the repository – they’re just staged, ready to be committed, as thegit statussays.The next step is to commit these changes we’ve prepared in the
staging indexand add them to the repository.git commitis the command to do this.This answer, as well as the linked Pro Git book, have some excellent reading which will help you understand the setup and steps in committing to a
gitrepository.What do you mean by “actual” repository? I am presuming you mean you can’t see a local commit, but there may be some confusion about the repositories you’re using.
You’re using two repositories, one
localand oneremote. Theremoterepository is, in your case, on GitHub. You do your work locally, thengit pushto remote.First, local changes and commits
So the steps to get your code changes into the
localrepository are as follows:working directory. This is most often writing some code.commitby staging changes. This is done usinggit add.git commit.These steps take place **locally*. None of these steps have any affect on your
GitHubrepository.Secondly,
git pushto theremoterepository (in this case, your GitHub one).To get your code from
localtoremoterepositories,git pushis used.remoterepositories are known by yourlocalrepository:git remote -v.GitHubrepository is not shown, you’ll need to add it:git remote add <NAME> <URL>.git clone, the two repositories (localandremote) don’t have any commits in common. That’s ok; it just meansgitdoesn’t automatically know where to push your changes, so you’ll have to specifiy:git push <NAME> master:master. That’ll push yourlocal masterbranch to the<NAME> masterbranch.