git添加不会舞台文件-git cache混淆了吗?

时间:2019-01-02 06:11:30

标签: git atlassian-sourcetree git-add git-ls-files

我感觉我的git缓存经常变得混乱。我在Mac上工作,并且在终端和SourceTree上同时使用git。

我添加或修改的文件很少,但我经常注意到,即使是我从未进行过任何修改的文件也显示为已登台。这已经很令人困惑了。

但是,更令人困惑的是,经常发出git add .将所有文件添加到暂存区并没有任何作用。我已经使用git几年了,以前从未有过。

我在这里阅读了所有关于SO的文章,但没有一个为我解决此问题。我发现了一个清除git缓存的建议,例如:

git rm --cached path/to/file
git commit -m "Repair confused cache"
git add path/to/file
git commit -m "Add file"

这确实可以暂时解决问题,但不久之后,事情又开始发生。

我还看到git ls-list --cache返回了大多数文件两次,包括它们的哈希码,如下所示,并且它们可以是png图像,代码文件等:

mymbp:source username$ cd MySolution/
mymbp:MySolution username$ git ls-files --stage
100644 a658bb41271a4285977d1074a69f3302ab5cc15e 0    .gitignore
100644 a658bb41271a4285977d1074a69f3302ab5cc15e 0    .gitignore
100644 197079698252f7f85d6b1e3f68582b9cd1a9288b 0    Publishing/GooglePlay/Icons/res/mipmap-hdpi/icon.png
100644 197079698252f7f85d6b1e3f68582b9cd1a9288b 0    Publishing/GooglePlay/Icons/res/mipmap-hdpi/icon.png
100644 f03e22933ff168571cc5efac90fd4a9bbb4e5968 0    Publishing/GooglePlay/Icons/res/mipmap-mdpi/icon.png
100644 f03e22933ff168571cc5efac90fd4a9bbb4e5968 0    Publishing/GooglePlay/Icons/res/mipmap-mdpi/icon.png
100644 9f8a69a800369b1fd37061b46e808c62747115ac 0    Publishing/GooglePlay/Icons/res/mipmap-xhdpi/icon.png
100644 9f8a69a800369b1fd37061b46e808c62747115ac 0    Publishing/GooglePlay/Icons/res/mipmap-xhdpi/icon.png
100644 64c4174f8086fb7788c5ca922fd4411d8f5050ac 0    Publishing/GooglePlay/Icons/res/mipmap-xxhdpi/icon.png
100644 64c4174f8086fb7788c5ca922fd4411d8f5050ac 0    Publishing/GooglePlay/Icons/res/mipmap-xxhdpi/icon.png
100644 97a01523dd3909b8361d96c1ebd69373db33983f 0    Publishing/GooglePlay/Icons/res/mipmap-xxxhdpi/icon.png
100644 97a01523dd3909b8361d96c1ebd69373db33983f 0    Publishing/GooglePlay/Icons/res/mipmap-xxxhdpi/icon.png
100644 ab64f8448c2d2c74564c00f1cd1aca8bf1dbf200 0    Publishing/GooglePlay/Icons/web_hi_res_512.png
100644 ab64f8448c2d2c74564c00f1cd1aca8bf1dbf200 0    Publishing/GooglePlay/Icons/web_hi_res_512.png

更新1

git config --list --show-origin的输出是:

dinosmbp:MySolution dinob$ git config --list --show-origin
file:/usr/local/etc/gitconfig   credential.helper=osxkeychain
file:/Users/dinob/.gitconfig    core.excludesfile=/Users/dinob/.gitignore_global
file:/Users/dinob/.gitconfig    user.name=DinoB
file:/Users/dinob/.gitconfig    user.email=db@dbsystems.com
file:/Users/dinob/.gitconfig    color.ui=true
file:/Users/dinob/.gitconfig    color.status.changed=blue normal
file:/Users/dinob/.gitconfig    color.status.untracked=red normal
file:/Users/dinob/.gitconfig    color.status.added=magenta normal
file:/Users/dinob/.gitconfig    color.status.updated=green normal
file:/Users/dinob/.gitconfig    color.status.branch=yellow normal bold
file:/Users/dinob/.gitconfig    color.status.header=white normal bold
file:/Users/dinob/.gitconfig    commit.template=/Users/dinob/.dinosStandardCommitMsg
file:/Users/dinob/.gitconfig    diff.tool=meld
file:/Users/dinob/.gitconfig    difftool.prompt=false
file:/Users/dinob/.gitconfig    difftool.meld.trustexitcode=true
file:/Users/dinob/.gitconfig    difftool.meld.cmd=open -W -a Meld --args "$LOCAL" "$REMOTE"
file:/Users/dinob/.gitconfig    merge.tool=meld
file:/Users/dinob/.gitconfig    mergetool.prompt=false
file:/Users/dinob/.gitconfig    mergetool.meld.trustexitcode=true
file:/Users/dinob/.gitconfig    mergetool.meld.cmd=open -W -a Meld --args --auto-merge "$LOCAL" "$BASE" "$REMOTE" --output="$MERGED"
file:/Users/dinob/.gitconfig    difftool.sourcetree.cmd=/Applications/Meld.app/Contents/MacOS/Meld "$LOCAL" "$REMOTE"
file:/Users/dinob/.gitconfig    difftool.sourcetree.path=
file:/Users/dinob/.gitconfig    mergetool.sourcetree.cmd=/Applications/Meld.app/Contents/MacOS/Meld "$LOCAL" "$BASE" "$REMOTE" --auto-merge --output="$MERGED"
file:/Users/dinob/.gitconfig    mergetool.sourcetree.trustexitcode=true
file:.git/config        core.repositoryformatversion=0
file:.git/config        core.filemode=true
file:.git/config        core.bare=false
file:.git/config        core.logallrefupdates=true
file:.git/config        core.ignorecase=true
file:.git/config        core.precomposeunicode=true
file:.git/config        remote.origin.url=https://github.com/DBSystems/MySolution.git
file:.git/config        remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
file:.git/config        branch.develop.remote=origin
file:.git/config        branch.develop.merge=refs/heads/develop
dinosmbp:MySolution dinob$ 

更新2

如果我尝试暂存一个拒绝从SourceTree暂存的文件,我会在SourceTree中短暂地忙于微调器(告诉我它正在尝试暂存),但是随后它消失了,没有任何反应,该文件仍处于暂存状态

如果我尝试通过发出git add path/filegit add .来暂存从git终端暂存的文件,则什么也不会发生,并且文件也不会暂存

更新3

以下git ls-files --stage | hexdump -C的输出显示了文件IoC.cs的两个不同的SHA值,当前它们拒绝使用git add .命令添加到舞台:

0002ae90  63 73 0a 31 30 30 36 34  34 20 65 37 32 64 31 30  |cs.100644 e72d10|
0002aea0  63 34 31 65 66 31 37 36  64 31 63 35 62 63 66 30  |c41ef176d1c5bcf0|
0002aeb0  62 36 34 63 30 32 36 34  62 32 66 63 65 65 36 65  |b64c0264b2fcee6e|
0002aec0  31 62 20 30 09 53 71 75  69 72 72 65 6c 46 6f 48  |1b 0.SquirrelFoH|
0002aed0  2f 53 71 75 69 72 72 65  6c 2e 46 6f 48 2e 56 69  |/Squirrel.FoH.Vi|
0002aee0  65 77 4d 6f 64 65 6c 73  2f 49 6f 43 2f 49 6f 43  |ewModels/IoC/IoC|
0002aef0  2e 63 73 0a 31 30 30 36  34 34 20 32 62 31 39 61  |.cs.100644 2b19a|
0002af00  36 39 33 35 39 32 66 36  64 32 31 30 38 36 38 33  |693592f6d2108683|
0002af10  63 39 31 62 61 61 30 30  62 64 62 61 62 30 63 34  |c91baa00bdbab0c4|
0002af20  31 31 61 20 30 09 53 71  75 69 72 72 65 6c 46 6f  |11a 0.SquirrelFo|
0002af30  48 2f 53 71 75 69 72 72  65 6c 2e 46 6f 48 2e 56  |H/Squirrel.FoH.V|
0002af40  69 65 77 4d 6f 64 65 6c  73 2f 49 6f 43 2f 49 6f  |iewModels/IoC/Io|
0002af50  43 2e 63 73 0a 31 30 30  36 34 34 20 37 38 39 64  |C.cs.100644 789d|

0 个答案:

没有答案