title: Jenkins FreeStyle Project From GitHub give "fatal: not in a git directory" error
body: <p>I've been trying for three days now to find a solution, but without success. Pipeline type is working succesfully, freestyle don't working.
  I noticed that after every attempt, in the HEAD file .git  written &quot;ref: refs/heads/master&quot;, even I indicated */main.</p>
  <p><a href="https://i.stack.imgur.com/xVQ8C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xVQ8C.png" alt="enter image description here" /></a></p>
  <pre><code>Running as SYSTEM
      Building in workspace C:\Users\aziz\.jenkins\workspace\workflow
      The recommended git tool is: NONE
      using credential 605f1b8b-aff7-457a-8040-edf8d6dae69a
       &gt; C:\Program Files\Git\bin\git.exe rev-parse --resolve-git-dir C:\Users\aziz\.jenkins\workspace\workflow\.git # timeout=10
      Fetching changes from the remote Git repository
       &gt; C:\Program Files\Git\bin\git.exe config remote.origin.url https://github.com/azimkar87/Billing.git # timeout=10
      ERROR: Error fetching remote repo 'origin'
      hudson.plugins.git.GitException: Failed to fetch from https://github.com/azimkar87/Billing.git
          at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1003)
          at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1244)
          at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1308)
          at hudson.scm.SCM.checkout(SCM.java:540)
          at hudson.model.AbstractProject.checkout(AbstractProject.java:1217)
          at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:647)
          at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85)
          at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:519)
          at hudson.model.Run.execute(Run.java:1897)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
          at hudson.model.ResourceController.execute(ResourceController.java:101)
          at hudson.model.Executor.run(Executor.java:442)
      Caused by: hudson.plugins.git.GitException: Command &quot;C:\Program Files\Git\bin\git.exe config remote.origin.url https://github.com/azimkar87/Billing.git&quot; returned status code 128:
      stdout: 
      stderr: fatal: not in a git directory
      
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2671)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2601)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2597)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1968)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1980)
          at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.setRemoteUrl(CliGitAPIImpl.java:1594)
          at hudson.plugins.git.GitAPI.setRemoteUrl(GitAPI.java:161)
          at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:991)
          ... 11 more
      ERROR: Error fetching remote repo 'origin'
      [Checks API] No suitable checks publisher found.
      Finished: FAILURE
  </code></pre>