NetBeans and git support on CentOS 6

Hey there,

I have run out of ideas. Has anyone ever been able to get a git repo to work through Virtualmin on CentOS 6?

I will provide some details if they are necessary. I can’t even use the git repo. I set it up and it just tells me smart HTTP isn’t enabled so I can’t use it. I am on Windows now. I have tried using various programs as well as git bash but I would like to use NetBeans. Unfortunately I tried this several months ago in Ubuntu and had the exact same issue then.

I have tried this several times over the years and have never had success. All I ever get is an error which says:

“Git command returned with the following error: remote does not support smart HTTP push”

I have added various flavours of things like this to my Apache config for the virtual server in an effort to get it to work but have had absolutely no luck whatsoever:

# Set the root directory where git repositories reside SetEnv GIT_PROJECT_ROOT /home/USERNAME/public_html/git/REPONAME.git

By default, the git-http-backend allows push for authenticated

users and this directive tells the backend when a user is authenticated.

SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER

Export all repositories

SetEnv GIT_HTTP_EXPORT_ALL

ScriptAliasMatch “(?x)^/git/REPONAME.git/(.*/(HEAD | info/refs | objects/(info/[^/]+ | [0-9a-f]{2}/[0-9a-f]{38} | pack/pack-[0-9a-f]{40}.(pack|idx)) | git-(upload|receive)-pack))$” /home/USERNAME/cgi-bin/git-http-backend/$1

USERNAME should be replaced by the virtual server username.
REPONAME should be replaced by the git repo name.

Here is another example of the entire virtual server Apache directives where I have disabled running CGI scripts as SUEXEC and set PHP to run as mod_php and had been messing with various configurations:

ServerName git.DOMAIN.org DocumentRoot /home/git/public_html ErrorLog /var/log/virtualmin/git.DOMAIN.org_error_log CustomLog /var/log/virtualmin/git.DOMAIN.org_access_log combined #ScriptAlias /cgi-bin/ /home/git/cgi-bin/ DirectoryIndex index.html index.htm index.php index.php4 index.php5

<Directory /home/git/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch

#<Directory /home/git/cgi-bin>
#allow from all
#AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
#

<Location /git>
DAV on
AuthType Basic
AuthName git.DOMAIN.org
AuthUserFile /home/git/etc/git.basic.passwd
Require valid-user
Satisfy All
RedirectMatch ^/git$ http://git.DOMAIN.org/git/gitweb.cgi
RedirectMatch ^/git/$ http://git.DOMAIN.org/git/gitweb.cgi
RewriteEngine off
AddHandler cgi-script .cgi

#ProxyPass /git/ !
#ProxyPassReverse /git/ !
#<Proxy *>
#allow from all
#
#<Location /git/REPONAME.git>
#Require user git
#

both http_backend and gitweb should be somewhere under here

<Directory /home/git/cgi-bin>
AllowOverride None

    #Important! Lets apache execute the script!
    Options +ExecCGI -Includes -IncludesNOEXEC +Indexes +SymLinksIfOwnerMatch
    
    Order allow,deny
    Allow from all

Set the root directory where git repositories reside

SetEnv GIT_PROJECT_ROOT /home/git/public_html/git/REPONAME.git

By default, the git-http-backend allows push for authenticated

users and this directive tells the backend when a user is authenticated.

SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER

Export all repositories

SetEnv GIT_HTTP_EXPORT_ALL

ScriptAlias /dev/ /home/git/cgi-bin/git-http-backend/

#ScriptAliasMatch “(?x)^/git/REPONAME.git/(.*/(HEAD | info/refs | objects/(info/[^/]+ | [0-9a-f]{2}/[0-9a-f]{38} | pack/pack-[0-9a-f]{40}.(pack|idx)) | git-(upload|receive)-pack))$” /home/git/cgi-bin/git-http-backend/$1

#ScriptAlias /git /home/git/public_html/list/

I have followed some of the things from the following sites, and maybe others:

http://blog.echothis.com/2012/07/20/setting-up-smart-http-for-git-on-virtualmin/comment-page-1/

http://stackoverflow.com/questions/5264949/cannot-push-git-to-remote-repository-with-http-https

http://git-scm.com/2010/03/04/smart-http.html

http://superuser.com/questions/473177/git-push-fatal-failed

Some people say webdav has to be enabled which it seems to be, however others say don’t use webdav and it doesn’t have to use webdav and can just use smart http which I apparently have absolutely no luck with.

I have even gone as far as trying to compile git from source to test if it’s the version of git but that didn’t change a thing either.

I have modified various lines and removed and added various lines to the Apache directives thinking something may be wrong or conflicting or missing, etc. Nothing ever changes, just get that blasted error again.

If anyone can help I will be forever greatful. =)

Thank you for your time.

Ryan

I have the same problem, but on Debian Wheezy.

That guy seems to have solved to problem, but I still have to figure how exactly :

http://www.virtualmin.com/node/29267

Hi there,

Thanks for the response but I’m not sure if that’s the same exact issue I was having. My error was about the server not supporting smart HTTP push. It also wouldn’t go through no matter how many times I tried. I will look into it though and see if it helps and report back what I find. Thank you!

Well it seems on a different server I don’t get the smart HTTP push issue and get the issue described on the link they posted which is: http://www.mkonrad.net/Blog/Git-over-HTTPWebDAV-A-solution-for-git-http-push-failed-errors

Also I seem to already placed that info into the .netrc file because it’s in the repository commands for the git repo I created in Virtualmin. However it seems it did not have the password in it yet and once I put that there I think it started working. Unless it was just me trying 3 times. At any rate it does appear fine on this machine. Strange I had that smart HTTP push issue on a different machine though. I guess I will just use this machine instead.

You can see the repository commands in Virtualmin if you go to the virtual server which has your repo and go to Services > Git Repositories and click the Repository Commands button. It’s under the “Setting up access to this repository” section.

So you say that you have a box running Virtualmin with Git module and which is working fine with smart HTTP ?

So maybe it’s something I’ve done on the server.

Sadly, repositories commands didn’t help much :frowning:

After some more testing it seems the error I get is from NetBeans which is the IDE I use. It works fine when I do the process documented below from the command line.

Here is what I do. You must have the login info and whatnot in the .netrc file. I go to a folder, init a git, config the upload url, add files, commit, then push.

Below is the step by step process. There are commands followed by the output in some cases. This was done from within Git Bash but should work from a Linux command line as well.

  1. Make sure to create a .netrc file with the following contents at c:\Users\YourUsername.netrc

machine example.com
login username
password YourPassword

  1. Go to a folder you want to store in the git.
    $ cd MyProject

  2. Initialize a git repository there.
    $ git init
    Initialized empty Git repository in c:/MyProject/.git/

  3. Config the remote URL.
    $ git config remote.upload.url http://username@example.com/git/RepositoryName.git/

  4. Add all the files in the folder to the repo.
    $ git add .

  5. Commit the files.
    $ git commit -m ‘Initial commit’
    [master (root-commit) 0f8ba0d] Initial commit
    1 file changed, 1 insertion(+)
    create mode 100644 hello.txt

  6. Push the files to the remote.
    $ git push upload master
    Fetching remote heads…
    refs/
    refs/tags/
    refs/heads/
    updating ‘refs/heads/master’
    from 0000000000000000000000000000000000000000
    to 0f8ba0d8cccd8093a708eb683fca44059a36081d
    sending 3 objects
    done
    Updating remote server info
    To http://username@example.com/git/RepositoryName.git/

  • [new branch] master -> master

If you make changes to any files repeat steps 5-7 to upload them to the git repo again.

The error I get in Netbeans is:
remote does not support smart HTTP push

Here’s the output from NetBeans when it fails with the above error when I try to push through it:
git branch
git remote -v
setting up remote: upload
git push http://username@example.com/git/RepositoryName.git/ refs/heads/master:refs/heads/master

I found out the .netrc file may also have to be named _netrc to work properly. That is from some debug output I get in Git Bash, probably would not be the case for Linux and may not be the case at all. Just thought I should mention it.

Found another idea to try not putting the username on the git URL to force it to use the _netrc file credentials and there are other methods to work with credentials as well: http://stackoverflow.com/questions/6031214/git-how-to-use-netrc-file-on-windows-to-save-user-and-password/6031266

The remote URL can be changed with this command:
git remote set-url upload http://example.com/git/RepositoryName.git/

I think it also might be a good idea to use the word origin instead of the word upload for the remote name above as well as in steps 4 and 7 in my previous post since many of the git config variables will default to that.

Thanks for all you answers !

I can’t try it right now (leaving for holidays) but I will ASAP.

edit: I couldn’t wait and now I’m late but … it works a lot better.

I also had to use _netrc instead of .netrc but I also had to copy libcurl.dll from Git/bin and paste it into /Git/libexec/libcore/ and rename it libcurl-4.dll. I think this problem occured because I choosed NOT to set up the Windows PATH variable when installing Git bash.

Now my next step will be to understand how gitweb is supposed to work, because right now I’m only getting “403 Forbidden - No project found.” when browsing http://domain.tld/git/gitweb.cgi

I remember I had to modify the gitweb.cgi a little to make it work. I can’t remember exactly what I did but there are instructions on that one link above. I use gitlist ( http://gitlist.org/ ) instead for viewing my repos on the web if I want to.