我曾经在我的OS X机器上安装了旧版本的Git,但后来我将系统升级到OS X 10.11并安装了更新版本的Git(2.6.4),而Git HTTP则通过Apache停止工作。 / p>
我在apache_error.log
文件中出现以下错误:
[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
gitconfig
文件的内容是:
[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
我搜索了很多内容,我发现的是以下帖子https://software.intel.com/en-us/forums/intel-xdk/topic/600175/#node-600175(实际上是标记为BEST REPLY
的帖子)用户说必须在gitconfig
内完成以下内容文件:
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 ;)
我在gitconfig中更改了这些行,并将~/
替换为/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
然后Git over HTTP开始工作。有人可以告诉我Git安装出了什么问题,或者是否是我安装的Git版本的错误?
我已经从官方网站https://git-scm.com/download/mac安装了Git,正如我所说的2.6.4版。
Apache / Git HTTP配置:
#
# 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>
所有商家信息都位于我系统的/Users/git/GitRepositories
用户的git
目录中,该用户不是myuser
用户,但我认为这不是问题,因为它在我更新Git之前曾经工作过。
如果有人能澄清这种行为,我将不胜感激。
感谢您的关注。
答案 0 :(得分:5)
我在位于/usr/local/git/etc/gitconfig
在[核心]标题下:
excludesfile = ~/.gitignore
改为......
excludesfile = /Users/username/.gitignore
和[include]更改:
path = ~/.gitcinclude
改为......
path = /Users/username/.gitcinclude
这对我有用。我不再收到错误。
答案 1 :(得分:3)
在受限制的环境中将git作为子进程运行时遇到此错误消息。根本原因是&#39; HOME&#39;没有为子进程设置环境变量;一旦我把它通过git很高兴。
答案 2 :(得分:2)
根据Mayur / Arun和gwk的回答,我使用'$ HOME'代替了绝对路径,它为我解决了这个问题。我没有在各种情况下对此进行测试,但是它确实解决了我面临的问题。 YMMV。
使用Mayur / Arun格式化我的文件更改是:
在[core]
标题下:
excludesfile = ~/.gitignore
更改为...。
excludesfile = $HOME/.gitignore
并在[include]
下进行更改:
path = ~/.gitcinclude
更改为...
path = $HOME/.gitcinclude