4

I have windows 7 installed.
C:\ is a local drive. H:\ is a work network drive that continually re-installs every time I boot. I have learned to just disconnect it whenever I am doing any coding from home or installing coding related apps, as I tend to have issues.

I installed Git and tried to create a repository for the first time.
It gives me the following error:

error: could not lock config file H:\/.gitconfig: No such file or
directory error: could not lock config file H:\/.gitconfig: No such
file or directory
     while executing "exec {C:/Program Files/Git/libexec/git-core/git-config.exe} --global --add
 gui.recentrepo C:/Users/bmyhre/Desktop/Testing/projects/skeleton"
     ("eval" body line 1)
     invoked from within "eval exec $opt $cmdp $args"
     (procedure "git" line 23)
     invoked from within "git config --global --add gui.recentrepo $path"
     (procedure "_append_recentrepos" line 16)
     invoked from within "_append_recentrepos [pwd]"
     (procedure "_git_init" line 17)
     invoked from within "_git_init $this"
     (procedure "choose_repository::_do_new2" line 5)
     invoked from within "choose_repository::_do_new2 ::choose_repository::__o1::__d"
     invoked from within ".buttons.next invoke "
     invoked from within ".buttons.next instate !disabled { .buttons.next invoke } "
     invoked from within ".buttons.next instate pressed { .buttons.next state !pressed; .buttons.next instate !disabled { .buttons.next invoke
 } } "
     (command bound to event)

My guess is that it is trying to reach the H: drive somewhere (I installed it with H: disconnected), but I don't know where/how to change this so it actually looks where the real .gitconfig on the C: drive is.
How to avoid this error message?

VonC
  • 14,433
  • 5
  • 47
  • 61
notthehoff
  • 165
  • 1
  • 7

1 Answers1

6

Check if you have an %HOME% environment variable defined.

If that variable exists and refers to H:\ (instead of %USERPROFILE%), then it will look for the global git config file in H:\.gitconfig (meaning %HOME%\.gitconfig).

Changing that %HOME% variable to a local path like %USERPROFILE% would solve that issue.

VonC
  • 14,433
  • 5
  • 47
  • 61
  • Where would I see that? Here are the contents of my .gitconfig file that exists at C:\Program Files\Git\etc [core] symlinks = false autocrlf = true [color] diff = auto status = auto branch = auto interactive = true [pack] packSizeLimit = 2g [help] format = html [http] sslCAinfo = /bin/curl-ca-bundle.crt [sendemail] smtpserver = /bin/msmtp.exe [diff "astextplain"] textconv = astextplain [rebase] autosquash = true – notthehoff Dec 18 '13 at 01:57
  • @user1525974 Check first your environment variables ([with `set`](http://stackoverflow.com/q/5327495/6309), or [`echo %HOME%`](http://superuser.com/a/341193/141) ) – VonC Dec 18 '13 at 06:55
  • 1
    This worked. I just created a new environment variable named `HOME` and set the value to `%USERPROFILE%`, worked great. – BrainSlugs83 Jun 08 '15 at 22:32
  • @BrainSlugs83 Note that with the latest Git for Windows (2.4.x: https://github.com/git-for-windows/git/releases), this is done for you when running `git-cmd.exe`. – VonC Jun 08 '15 at 22:34
  • I did that, and also I have a .gitignore file in %USERPROFILE%\.gitconfig but am still getting this error `error: could not lock config file .git/config: No such file or directory` – Lrrr Jun 23 '15 at 10:49
  • @Lrrr `.git/config` isn't the same as `~/.gitconfig`: the former is the local config to a repo, the latter is the global config. Are you using git for windows 2.4.4? – VonC Jun 23 '15 at 10:54
  • @VonC yes after I post my comment I understand the difference, also your solution solved my global problem :) no I'm using windows 7 service pack 1 and my git version is : `git version 1.9.4.msysgit.2` – Lrrr Jun 23 '15 at 11:04
  • @Lrrr Don't hesite to use the latest one: https://github.com/git-for-windows/git/releases – VonC Jun 23 '15 at 11:11
  • @VonC ok, I'll download that and see if this fix my problem, thanks for your time – Lrrr Jun 23 '15 at 11:19
  • @VonC version 2.4.4 was the answer :) thanks again :) – Lrrr Jun 23 '15 at 13:53
  • @Lrrr Great! See here to see what the differences are between the old msysgit and the new "git for Windows": http://stackoverflow.com/a/26826359/6309 – VonC Jun 23 '15 at 14:16