7

Windows has an environment variable HOME which is on a remote serve (say Y:/, set by administrator and suppose not to be changed) and I start Emacs on my local disk, say C:/. (Emacs becomes slow if I start from Y:/)

However .gitconfig file locates on Y:/ by default and magit cannot find it so I don't have the right settings for user name and emails, even if I move .gitconfig to C:/.

Is it possible to set magic and git settings independently or read .gitconfig from Y:/?

Magit version: Git 2.7.4.windows.1, Emacs 24.4.1, windows-nt

tarsius
  • 25,298
  • 4
  • 69
  • 109
NAX
  • 121
  • 1
  • 6
  • Your admin sets `HOME`? That's not a standard Windows variable. If you tell git to read from Y: it will also be slow, I suggest copying your `$HOME/.gitconfig` file to C: as well. – npostavs Jun 13 '16 at 12:03
  • @npostavs, I understand that it is not a Windows variable, but I have to remotely log into a Unix serve to work and run some software on serve. So I guess It is just easy for some common configurations on both? not sure... Tried to copy the $HOME/.gitconfig to C:/, doesn't work... but thanks anyway – NAX Jun 13 '16 at 13:15
  • Actually I think I missed something from your description, what do you mean by "start Emacs on my local disk"? Do you mean that you change `HOME` before starting Emacs? What does `(getenv "HOME")` return? – npostavs Jun 13 '16 at 15:19
  • @npostavs yes, you are right, I use batch file to start Emacs setting HOME to somewhere on my local disk (C:/ in this case per se). So it seem `(getenv "HOME")` will give C:/ but everything outside Emacs still use Y:/ as HOME, such as git. – NAX Jun 14 '16 at 06:38
  • Then copying `.gitconfig` should work. To be clear, by "copy to C:" I meant copy to the directory in C: that you set as `HOME` in the emacs bat file. – npostavs Jun 14 '16 at 12:28
  • @npostavs oddly it doesn't work if copy it to `HOME` in emacs bat file... But I set git with `git config --system` to change the user name and email system-wise such that Magit can find them. It seems will be overwritten if I use git outside Emacs, but since I am the only user on my laptop, so it is not a problem to me. Thanks! – NAX Jun 16 '16 at 08:38
  • Hmm, I'm still curious about which file git is using with `HOME` set to C:/, but setting things in `--system` sounds like a reasonable solution for your problem; you should make it an answer and accept. – npostavs Jun 16 '16 at 11:22
  • @npostavs I used `git config --list --show-origin` to see the config files. It seems the .gitconfig in C:/ (my `HOME` in Emacs) can't be found by Magit. The only file git in using is \mingw64\etc\gitconfig, which is the file that `--system` will change. Shall I really answer to my own question and accept it? – NAX Jun 17 '16 at 07:56
  • What if you run `git config --global foo.bar blah` from inside Emacs, and look for that setting in `git config --list --show-origin`? Re answering your own question: http://emacs.stackexchange.com/help/self-answer – npostavs Jun 17 '16 at 12:50

1 Answers1

5

Since Magit can't find my .gitconfig file even though it is in the HOME path of Emacs, git config --system can be used to change user name and email such that Magit can find them.

NAX
  • 121
  • 1
  • 6