无法忽略Git中与空格相关的更改

时间:2017-01-16 08:15:31

标签: git github

为了只提交与空白相关的更改,我尝试这样做:

git diff -w --no-color | git apply --cached --ignore-whitespace

但是我收到了这个错误:

<stdin>:12: indent with spaces.
        if ( ! $data['first_name'] && ! $data['last_name']) {
<stdin>:13: indent with spaces.
            $data['first_name']   = NULL;
<stdin>:14: indent with spaces.
            $data['last_name'] = NULL;
<stdin>:15: indent with spaces.
        }
error: patch failed: application/libraries/api_data.php:89
error: application/libraries/api_data.php: patch does not apply

我还将autocrlf设置为false,如下所示:

git config --global core.autocrlf false

然而,使用git diff,我看到整个文件已更改,而不是我添加的行。

我的git config -l输出:

core.excludesfile=~/.gitignore
core.legacyheaders=false
core.quotepath=false
core.pager=less
mergetool.keepbackup=true
push.default=simple
color.ui=auto
color.interactive=auto
repack.usedeltabaseoffset=true
alias.s=status
alias.a=!git add . && git status
alias.au=!git add -u . && git status
alias.aa=!git add . && git add -u . && git status
alias.c=commit
alias.cm=commit -m
alias.ca=commit --amend
alias.ac=!git add . && git commit
alias.acm=!git add . && git commit -m
alias.l=log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'
alias.ll=log --stat --abbrev-commit
alias.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
alias.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
alias.d=diff
alias.master=checkout master
alias.spull=svn rebase
alias.spush=svn dcommit
alias.alias=!git config --list | grep 'alias\.' | sed 's/alias\.\([^=]*\)=\(.*\)/\1\     => \2/' | sort
include.path=~/.gitcinclude
include.path=.githubconfig
include.path=.gitcredential
diff.exif.textconv=exif
credential.helper=osxkeychain
core.excludesfile=/Users/ankurk/.gitignore_global
core.autocrlf=false
core.whitespace=trailing-space,space-before-tab,indent-with-non-tab
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
user.name=
user.email=
commit.template=/Users/ankurk/.stCommitMsg
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
core.autocrlf=false
remote.origin.url=
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.feature_add-eds-brand-name-marketers.remote=origin
branch.feature_add-eds-brand-name-marketers.merge=refs/heads/feature_repo

我能做些什么来解决这个问题?

1 个答案:

答案 0 :(得分:0)

在阅读My diff contains trailing whitespace - how to get rid of it?并查看输出后,我不确定这些是由空格引起的错误。我认为这些都是警告。

我认为真正的错误是第89行:

  

错误:补丁失败:application / libraries / api_data.php:89   错误:application / libraries / api_data.php:补丁不适用

第89行是什么?