Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location of user-level git dotfiles on Windows #183

Closed
jennybc opened this issue Dec 31, 2017 · 1 comment
Closed

Location of user-level git dotfiles on Windows #183

jennybc opened this issue Dec 31, 2017 · 1 comment

Comments

@jennybc
Copy link
Member

@jennybc jennybc commented Dec 31, 2017

From AppVeyor and my Windows VM, I gather that user's .gitconfig and .gitignore are typically not in what R regards as user's home directory. On my VM:

as.list(Sys.getenv(
  c("HOME", "R_USER", "HOMEDRIVE", "HOMEPATH", "USERPROFILE")
))
#> $HOME
#> [1] "C:/Users/JennyVM/Documents"
#> 
#> $R_USER
#> [1] "C:/Users/JennyVM/Documents"
#> 
#> $HOMEDRIVE
#> [1] "C:"
#> 
#> $HOMEPATH
#> [1] "\\Users\\JennyVM"
#> 
#> $USERPROFILE
#> [1] "C:\\Users\\JennyVM"

normalizePath("~")
#> [1] "C:\\Users\\JennyVM\\Documents"

list.files(Sys.getenv("USERPROFILE"), all.files = TRUE, pattern = "git", full.names = TRUE)
#> [1] "C:\\Users\\JennyVM/.gitconfig"

Home directory is C:/Users/USER/Documents but user's git dot files are one level up, in C:/Users/USER. I see the same on AppVeyor. I have accepted default git setup everywhere.

edit_git_config("user") and edit_git_ignore("user") should be adjusted accordingly, for Windows. Currently they seek/put these files in the home directory. This new config file then seems to mask the pre-existing one, causing, e.g., user.name and user.email to be appear to be unset.

@jennybc jennybc changed the title Location of user-level git files on Windows Location of user-level git dotfiles on Windows Dec 31, 2017
@jennybc
Copy link
Member Author

@jennybc jennybc commented Dec 31, 2017

SO thread that confirms what I see:

https://stackoverflow.com/questions/2114111/where-does-git-config-global-get-written-to

More detailed document that indicates this is total mess, i.e. there are at least 3 possible locations:

https://www.onwebsecurity.com/configuration/git-on-windows-location-of-global-configuration-file.html

This is the tricky one. When using the Windows command shell, batch scripts or Windows programs, the file will be read from %USERPROFILE%\.gitconfig

However, when you're using msys (bash) this will be read from $HOME/.gitconfig

Yet another different location can be found from within Emacs (for instance by using magit) when Emacs is started from a Windows command shell. Emacs sets the HOME variable as %APPDATA% , which means that .gitconfig will reside in %APPDATA%\.gitconfig

Handy way to check location of global gitignore, if you have access to command line git:

jenny@2015-mbp usethis $ git config --get core.excludesfile
/Users/jenny/.gitignore_global

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant