4

I have to run a command to clone my project through git.

However my git version is quite old; my version is 1.7.1, and does not recognize the command. It show me error: unknown switchc'` error.

My command is

$ git clone -c http.sslVerify=false https://myProject:password1@data.c-village.net/git/gerrit/hlbb/gib/

I believe that the -c is not a valid command on version 1.7.1. One of the solutions is upgrade the git. However, would like to ask about the command of version 1.7.1 to doing the same thing. I searched with Google but it looks like I'm not getting a good result.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Panadol Chong
  • 1,793
  • 13
  • 54
  • 119
  • try `GIT_SSL_NO_VERIFY=true git clone https://example.com/path/to/git`. I confirmed that this environment variable is used in 1.7.1. (http://stackoverflow.com/questions/11621768/how-can-i-make-git-accept-a-self-signed-certificate#answer-19363404) – ymonad May 22 '17 at 04:38

2 Answers2

2

The -c or --config flag (to git clone—different from git -c key=value clone) was new in Git 1.7.7. See commit 84054f79de35015fc92f73ec4780102dd820e452. As VonC and ymonad said, in this particular case, you can get the same effect using GIT_SSL_NO_VERIFY, but in the more general case, if this configuration value affects the operation of Git and there is no other way to set it in time, you would have to break git clone into its equivalent constituent parts: git init, git config, git remote add, git fetch, and git checkout. (The git config step is required if and only if there are -c options.)

(In most cases, git clone -c key=value url) can be handled as git clone url followed by cd-ing into the new repository and setting the configuration. But this is not true for this particular configuration item.)

Community
  • 1
  • 1
torek
  • 448,244
  • 59
  • 642
  • 775
1

The -c allows you to set a local config just for that one git command.
In this instance, it sets it after cloning.

An alternative in your case is to use an environment variable:

 GIT_SSL_NO_VERIFY=false git clone...

That variable was introduced in commit 3dcb90f in July 2005 ofr Git 0.99.2

The point is: there is no direct alternative to the lack of -c, except than to check if the local setting you want to override has a corresponding environment variable for you to set.

Once you have clone the repo, you can go into it, and do a local git config to persists the setting.
Although... I wouldn't recommend that one: checking SSL certificate is usually a good practice.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Actually this particular `-c` persists after the clone. The normal `git -c =` one does not, of course, but here the problem is that there's no repository yet! – torek May 22 '17 at 04:46