Reputation: 67
I have a bare git repository that I've been using for backups. Every time I commit on the local copy, I push it to the bare repository. Git goes through and pushes the objects without any errors. Today I tried to double check that the backups have been working by cloning the bare repository into a normal repo. When I did the clone, the files were exactly as when I did the initial bare clone, without any of the new pushed objects.
I've taken a look at the objects directory in the bare repo and new files have been added or updated over the time period. I've tried pulling from the bare repo to the new clone, but it says everything is up to date. I've also done a git log on the bare repo, and that only shows the commits up to the date I did the original clone.
What am I doing wrong? Is there another flag I should be using in the pushes? Thanks.
UPDATE: I think I may have figured it out - it looks like I was on a branch aside from master when I did the original bare clone. I just did another bare clone while master was checked out and it seems to be working.
Upvotes: 3
Views: 243
Reputation: 70135
(As you've learned) It is a branch issue. By default git clone
checks out the master branch. Thus, if you've been committing locally on another branch and pushing to the same branch on the remote then you'll have nothing on the remote's master. Options are:
git clone -b <your branch> <repository>
and then you'll confirm that <your branch>
has all your work. Or, in your local repository,
git checkout master
git merge <your branch>
git push <remote> master
which will be an easy merge (because master is empty) and will push everything up to the remote's master, where you expected it.
Upvotes: 1