tonix
tonix

Reputation: 6939

Git Could not expand include path '~/.gitcinclude', fatal: bad config file line 49 in /usr/local/git/etc/gitconfig

I used to have an older version of Git installed on my OS X machine, but then I upgraded the system to OS X 10.11 and installed a newer version of Git (2.6.4) and Git HTTP through Apache stopped working.

I had the following error in the apache_error.log file:

[Thu Apr 28 08:41:37 2016] [error] [client ::1] error: Could not expand include path '~/.gitcinclude'
[Thu Apr 28 08:41:37 2016] [error] [client ::1] fatal: bad config file line 49 in /usr/local/git/etc/gitconfig

The contents of the gitconfig file were:

[core]
    excludesfile = ~/.gitignore
    legacyheaders = false # >git 1.5
    quotepath = false

    # http://stackoverflow.com/questions/136178/git-diff-handling-long-lines
    pager = less -r
    # if ↑ doesn’t work, try: pager = less -+$LESS -FRX

[user]
#   name = your name
#   email = your@name

[mergetool]
    keepBackup = true

[push]
    default = simple # [ matching | simple ]

[color]
    ui = auto
    interactive = auto

[repack]
    usedeltabaseoffset = true # >git 1.5

[alias]
    s = status
    a = !git add . && git status
    au = !git add -u . && git status
    aa = !git add . && git add -u . && git status
    c = commit
    cm = commit -m
    ca = commit --amend # careful
    ac = !git add . && git commit
    acm = !git add . && git commit -m
    l = log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'
    ll = log --stat --abbrev-commit
    lg = log --color --graph --pretty=format:'%C(bold white)%h%Creset -%C(bold green)%d%Creset %s %C(bold green)(%cr)%Creset %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
    llg = log --color --graph --pretty=format:'%C(bold white)%H %d%Creset%n%s%n%+b%C(bold blue)%an <%ae>%Creset %C(bold green)%cr (%ci)' --abbrev-commit
    d = diff
    master = checkout master
    spull = svn rebase
    spush = svn dcommit
    alias = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\\t => \\2/' | sort

[include]   # as of 1.7.10 https://github.com/git/git/commit/9b25a0b52e09400719366f0a33d0d0da98bbf7b0
    path = ~/.gitcinclude
    path = .githubconfig
    path = .gitcredential

#[github]
#   user =
#   token =

[diff]
    # git does copy/rename *detection*. if you want it to track copies/renames:
    # http://stackoverflow.com/questions/1043388/record-file-copy-operation-with-git
    # renames = copies

[diff "exif"]
    textconv = exif
[credential]
    helper = osxkeychain

I googled a lot, and what I found was the following post https://software.intel.com/en-us/forums/intel-xdk/topic/600175/#node-600175 (actually the one marked as BEST REPLY) where a user says that the following must be done inside that gitconfig file:

There's two things in the config file to edit....

 Under the [core] heading :

   excludesfile = ~/.gitignore     
change to....
   excludesfile = /Users/kevin/.gitignore

and under [include] change :

   path = ~/.gitcinclude
change to...
  path = /Users/kevin/.gitcinclude

(change "kevin" to your user profile name ;)

I changed those lines inside my gitconfig and replaced those ~/ with /Users/myuser/:

[core]
    excludesfile = /Users/myuser/.gitignore
    legacyheaders = false # >git 1.5
    quotepath = false

    # http://stackoverflow.com/questions/136178/git-diff-handling-long-lines
    pager = less -r
    # if ↑ doesn’t work, try: pager = less -+$LESS -FRX

[user]
#   name = your name
#   email = your@name

[mergetool]
    keepBackup = true

[push]
    default = simple # [ matching | simple ]

[color]
    ui = auto
    interactive = auto

[repack]
    usedeltabaseoffset = true # >git 1.5

[alias]
    s = status
    a = !git add . && git status
    au = !git add -u . && git status
    aa = !git add . && git add -u . && git status
    c = commit
    cm = commit -m
    ca = commit --amend # careful
    ac = !git add . && git commit
    acm = !git add . && git commit -m
    l = log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'
    ll = log --stat --abbrev-commit
    lg = log --color --graph --pretty=format:'%C(bold white)%h%Creset -%C(bold green)%d%Creset %s %C(bold green)(%cr)%Creset %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
    llg = log --color --graph --pretty=format:'%C(bold white)%H %d%Creset%n%s%n%+b%C(bold blue)%an <%ae>%Creset %C(bold green)%cr (%ci)' --abbrev-commit
    d = diff
    master = checkout master
    spull = svn rebase
    spush = svn dcommit
    alias = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\\t => \\2/' | sort

[include]   # as of 1.7.10 https://github.com/git/git/commit/9b25a0b52e09400719366f0a33d0d0da98bbf7b0
    path = /Users/myuser/.gitcinclude
    path = .githubconfig
    path = .gitcredential

#[github]
#   user =
#   token =

[diff]
    # git does copy/rename *detection*. if you want it to track copies/renames:
    # http://stackoverflow.com/questions/1043388/record-file-copy-operation-with-git
    # renames = copies

[diff "exif"]
    textconv = exif
[credential]
    helper = osxkeychain

Then Git over HTTP started to work. Can someone tell me what's went wrong with my Git installation or maybe is it a bug of the Git release I have installed?

I've installed Git from the official site https://git-scm.com/download/mac, as I said, version 2.6.4.

Apache/Git HTTP configuration:

#
# Git over HTTP configuration
#
SetEnv GIT_PROJECT_ROOT /Users/git/GitRepositories

#
# Uncomment if you want Git to serve all repos, even those without git-daemon-export-ok inside of them.
#
SetEnv GIT_HTTP_EXPORT_ALL

#
# Tell Apache that anything coming into the /git path will be handled by git http-backend
#
ScriptAlias /git/ /usr/local/git/libexec/git-core/git-http-backend/

#
# Tell Apache to allow requests to that path
#
<Directory "/usr/local/git/libexec/git-core*">
   Options ExecCGI Indexes
   Order allow,deny
   Allow from all
</Directory>

#
# Authenticated git push
#
<LocationMatch "^/git/.*/git-receive-pack$">
    AuthType Basic
   AuthName "Git Access"
   AuthUserFile /Users/git/.htpasswd
   Require valid-user
</LocationMatch>

All repos are inside the directory /Users/git/GitRepositories of the git user of my system, which is not myuser user, but I don't think that is the problem because it used to work before I updated Git.

If someone can clarify this behaviour, I will be grateful.

Thanks for the attention.

Upvotes: 6

Views: 7095

Answers (3)

bottlecap
bottlecap

Reputation: 575

Following on from Mayur/Arun's and gwk's responses, I used '$HOME' in place of the absolute path and it fixed the issue for me. I haven't tested this in a variety of scenarios, but it did address the issue I faced. YMMV.

Using Mayur/Arun's formatting my file changes were:

Under the [core] heading :

excludesfile = ~/.gitignore     

change to....

excludesfile = $HOME/.gitignore

and under [include] change :

path = ~/.gitcinclude

change to...

path = $HOME/.gitcinclude

Upvotes: 12

Mayur Dhikle
Mayur Dhikle

Reputation: 191

I made the following changes in the gitconfig file located at /usr/local/git/etc/gitconfig

Under the [core] heading :

excludesfile = ~/.gitignore     

change to....

excludesfile = /Users/username/.gitignore

and under [include] change :

path = ~/.gitcinclude

change to...

path = /Users/username/.gitcinclude

This worked for me. I no longer get the error.

Upvotes: 19

gwk
gwk

Reputation: 706

I encountered this error message when running git as a subprocess in a restricted environment. The root cause was that the 'HOME' environment variable was not set for the subprocess; once I passed it along git was happy.

Upvotes: 9

Related Questions