1

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.

Community
  • 1
  • 1
Anakin001
  • 1,226
  • 2
  • 14
  • 30

1 Answers1

1

It's not the normal behaviour, or at least NetBeans does not behave in a controlled way. It seems the reason the push fails is because NetBeans throws an exception:

java.lang.NullPointerException
at org.eclipse.jgit.lib.ObjectIdOwnerMap.get(ObjectIdOwnerMap.java:131)
at org.eclipse.jgit.revwalk.RevWalk.parseAny(RevWalk.java:895)
at org.eclipse.jgit.storage.pack.PackWriter.findObjectsToPack(PackWriter.java:1598)
at org.eclipse.jgit.storage.pack.PackWriter.preparePack(PackWriter.java:748)
at org.eclipse.jgit.storage.pack.PackWriter.preparePack(PackWriter.java:711)
at org.eclipse.jgit.transport.WalkPushConnection.sendpack(WalkPushConnection.java:229)
at org.eclipse.jgit.transport.WalkPushConnection.push(WalkPushConnection.java:169)
at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:141)
at org.eclipse.jgit.transport.Transport.push(Transport.java:1162)
at org.netbeans.libs.git.jgit.commands.PushCommand.runTransportCommand(PushCommand.java:111)
at org.netbeans.libs.git.jgit.commands.TransportCommand.run(TransportCommand.java:140)
at org.netbeans.libs.git.jgit.commands.GitCommand.execute(GitCommand.java:72)
at org.netbeans.libs.git.GitClient.push(GitClient.java:858)
at org.netbeans.modules.git.client.GitClient$38.call(GitClient.java:603)
at org.netbeans.modules.git.client.GitClient$38.call(GitClient.java:599)
at org.openide.util.NetworkSettings.suppressAuthenticationDialog(NetworkSettings.java:140)
at org.netbeans.modules.git.client.GitClient$CommandInvoker$1$1.call(GitClient.java:816)
at org.netbeans.modules.git.client.GitClient$CommandInvoker$1.call(GitClient.java:837)
at org.netbeans.modules.git.client.GitClient$CommandInvoker.runMethodIntern(GitClient.java:849)
at org.netbeans.modules.git.client.GitClient$CommandInvoker.runMethod(GitClient.java:778)
at org.netbeans.modules.git.client.GitClient$CommandInvoker.runMethod(GitClient.java:760)
at org.netbeans.modules.git.client.GitClient$CommandInvoker.access$400(GitClient.java:754)
at org.netbeans.modules.git.client.GitClient.push(GitClient.java:599)
at org.netbeans.modules.git.ui.push.PushAction$2.perform(PushAction.java:214)
at org.netbeans.modules.git.client.GitProgressSupport.performIntern(GitProgressSupport.java:102)
at org.netbeans.modules.git.client.GitProgressSupport.run(GitProgressSupport.java:95)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1432)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2042)

I found a workaround for this. All I had to do was to replace the sftp protocol with ssh.

Anakin001
  • 1,226
  • 2
  • 14
  • 30