I created a bare repository:
git init --bare
I understand that:
git log
will not work because no master branch is created at the moment. I also understand there are (at least) 3 possible fixes. I don't have any branch already created (it's a newly created repository). I don't have an existing commit. So it leaves me with:
Push a new master branch into the repository from somewhere else
I have a local repository (the above was created on a remote server). I'm using NetBeans 7.4. I'm trying to push to the remote, bare repository I created above. For local branches, I can only select 'master -> master' and the tooltip says 'master will be added'. For Remote Branches I can only select 'master -> origin/master' and the tooltip says 'origin/master will be created'. After pressing Finish the log says:
git branch
git remote -v
setting up remote: origin
git push sftp://path.to.rep.git refs/heads/master:refs/heads/master
==[IDE]== Dec 18, 2013 3:22:58 PM Pushing - ### finished.
I should mention I do have a commit in my local repository, the one I'm trying to push.
Back on the server, in the bare repository:
git log
fatal: bad default revision 'HEAD'
So, the push from NetBeans didn't do anything. Also:
git branch
returns nothing. So master wasn't created.
On the server, I tried:
git clone bare.repo.git myrepo
In myrepo:
touch myfile
git add myfile
git commit -m "added myfile"
git push bare.repo.git master
Then, back in the bare repository:
git log
now works (which is what I expected).
Back in NetBeans, now I have 2 options for Local Branches: 'master -> master' and the tooltip says 'Pull of remote master is needed' and 'master' and the tooltip says 'master will be deleted'. The first option doesn't work - NetBeans says: 'Push would result in a non fast-forward update'. The second one probably deletes the master branch in the bare repository because 'git log' doesn't work anymore. Now I'm back to the start.
Is this the normal behaviour? Am I missing something? Or maybe it's a NetBeans bug? Or a git bug?
I'm just trying to push from NetBeans to a newly created, remote repository.