0

I am trying to setup a GIT repository on a remote web server and connect it to a project on my Eclipse but have run into trouble while doing so. I have done my homework and tried everything I could and am at a dead end currently.

Created repository on remote server. Created repository on local computer. Created project connected to local computer repository. Tried all methods to get both repositories connected. Impossible.

Yes that was one of the methods I tried.
I created a git repo on my remote server.
Then I imported a project and gave my server information to connect to the repo.
I was able to connect and it gave the project all the files from my server.
I made a change to the file and then went to 'team > stage > commit > push'.
I got this error 'remote: error: refusing to update checked out branch: refs/heads/master

remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To ssh://sofiane@50.63.180.135/var/www/html/lms
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'ssh://sofiane@50.63.180.135/var/www/html/lms'

Well after about 8 hours I went into total nerd rage and smashed my keyboard against the wall. What a great way to be introduced into a popular version control tool.

This illustrates my frustration perfectly. To hell with Git. Hello subversion, I missed you.

  • 1
    It would be great if you could post some screenshots and more details about what you are trying to do. Do you have a git repository setup? If so, are you trying to connect to it through eclipse ? – Ashutosh Jindal Aug 16 '12 at 13:01
  • Yes I am trying to connect to a directory on my server with eclipse and have that directory under GIT version control using the EGIT plugin for Eclipse. I made an edit to my post to answer your latter question. –  Aug 16 '12 at 13:03
  • Reading [this](http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected-master-master-branch-is-currently-checked), it seems the problem your having is that your remote repository is not bare. Did you read this already? Read this for more details about bare repositories : http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-Server – greg0ire Aug 16 '12 at 14:50
  • Okay great thanks for the info but, now I'm going to have to go back to school and learn what authorized_keys, public keys, ssh users, .ssh directories, git servers and about a weeks worth of studying. It sounds fun but honestly I have to move forward with this project. Thanks anyway but I'm just going to go back to tortoise, its intuitive and it requires a small learning curve to perform simple tasks. I do not like git and its need to be extremely difficult with the small stuff. –  Aug 16 '12 at 15:42
  • Maybe you should start using git-svn if git is too complicated for you. It could soften the learning curve – greg0ire Aug 17 '12 at 08:09

2 Answers2

1

I think you created the repositories on the server as non-bare, which is why you can not push to the same branch that is checked out.

Check your repository on the server:

$ ls
repository

Now either:

$ ls -a repository
.git
file1
file2
..

or:

$ ls -a repository
HEAD
config
description
hooks
info
objects
packed-refs
refs

If you get the first result you have a non-bare repository. Clone it on the server as bare:

$ ls
repository
$ git clone --bare repository repository.git
$ mv repository oldrepository

Then try to push to it. The .git extension is a convention that indicates a bare repository, it is not needed for repository urls. This means your local git repositories should work with their old remote configuration.

Ozan
  • 4,345
  • 2
  • 23
  • 35
  • If I create a bare repository on the server and a working respiratory on eclipse then... I cant push from the working repository on eclipse to the bare repository on the server. –  Aug 16 '12 at 19:20
  • @sofiane: Does your ssh user 'sofiane' have write permission for the repository? We once ran 'git init' as root, which made the repository read-only for the ssh-user. If so, use chown to change ownership to 'sofiane', or chmod to make the repository writable for all. – Ozan Aug 17 '12 at 11:01
0

What do you see in your GIT Repositories view ? If you can can see your GIT Repository there then you should be able to do an File -> Import... -> Projects from Git like so :

enter image description here

Ashutosh Jindal
  • 18,501
  • 4
  • 62
  • 91
  • I never spent a whole day trying to figure out workflow before. Maybe Git was a stupid idea from the start. I'm going back to SVN tortoise this is insane. Wasted my time. –  Aug 16 '12 at 14:29
  • @SofianeMerah Before using egit, you should probably use git in CLI, just to know what you're doing. It is much superior to SVN, even with tortoise. When you're confortable, you may use egit if you really want a GUI. – greg0ire Aug 16 '12 at 14:37
  • I've spent all day learning git. I am familiar with git. I can't get Egit, the eclipse plugin to work. This should be its main function but after visiting the documentation it mentions nothing about working a local copy of a repo'ed project that is stored on a remote web server. Nothing on google either. Its 10:40AM here now and I havent slept since yesterday so I am understandably3 a little frustrated and upset right now. –  Aug 16 '12 at 14:41
  • @SofianeMerah, try this, remove the local repository completely and start by cloning that repo from within eGIT ? – Ashutosh Jindal Aug 16 '12 at 15:54
  • Thats what I tried. But everytime I push git gives me the error I posted. Its the same thing with the gui tool smartgit. So something about git prevents it from allowing two copies of a repo to 'push' changes to each other. I'm sure if I use command line I can just create a bare repo or something and that might work. But the whole point of Egit was so I can avoid command line. –  Aug 16 '12 at 16:03
  • http://hans.fugal.net/blog/2008/11/10/git-push-is-worse-than-worthless/... someone else going through my insanity. Maybe I'll gleam something here –  Aug 16 '12 at 16:07