Errror while connecting to a repository in Jenkins

“Failed to connect to repository : Error performing command: git.exe ls-remote -h https://github.com/narendravenkata/React-Demo.git HEAD”



I was getting this error when I installed Jenkins on my windows 10 machine and trying to build my first job.

The error is caused because either git is not installed on your machine or the path of git.exe is not provided correctly.

Solution:

  1. After you install Jenkins, you will be running Jenkins as a service and we can access it at http://localhost:8080/ .
  2. Go to the url and login with the registered credentials.On the left hand side you see a side bar with items and click on Manage Jenkins and go to Global Tool Configuration.
  3. When yo see under git you will have an error like below.
  4. Now as I mentioned earlier we need to specify the correct path of the git.exe.
  5. After we specify the correct path, the error disappears and looks like below.
  6. After the above step ,we can now comfortably add the repository in our job and it looks like below.
In this manner we can resolve the error while adding a git repository in our jenkins job .