Phro
Phro

Reputation: 374

How do I run a different version of git on a server?

I have a git repository on a server with an old version of git (1.7.1). I need a feature only available starting in git 2.3, namely I want to run the command:

git config receive.denyCurrentBranch updateInstead

After talking with the sysadmin, they installed a recent version of git (2.27.0) in a different location on the server. Using this newer version, I was able to run the above command for the repository.

However, whenever I push from my local machine to the server, I get the following error message:

fatal: bad config value for 'receive.denycurrentbranch' in ./config
fatal: Could not read from remote repository.

This seems to suggest that when I push to the server, the server defaults to running the old version of git. Is there a way to tell the server to run git from a different exec-path? When running

git --exec-path=/path/to/new/git/env

I am met with strange errors like git ignoring everything after the exec-path, or ignoring all the flags altogether. I am not sure if the --exec-path flag is even the right approach to this problem.

Upvotes: 1

Views: 160

Answers (1)

VonC
VonC

Reputation: 1325357

You need to specify the new git-upload-pack/git-receive-pack

cd /path/to/local/repo
git config remote.origin.uploadpack /path/to/new/git/usr/bin/git-upload-pack
git config remote.origin.receivepack /path/to/new/git/usr/bin2/git-receive-pack

That would be a good start for making sure git push/pull talk to the right Git.

Upvotes: 1

Related Questions