I have a feeling my git cache is getting confused fairly often. I work on Mac and use both git at terminal and SourceTree.
I add or modify few files but I often notice that even files I have never modified in any way show as staged. This is very confusing already.
However, even more confusing is that often issuing git add .
to add all of the files to staging area does nothing. I have been using git for few years and have never had this before.
I read all posts here on SO and none of them resolved this issue for me. I found one suggestion to clear git cache like:
git rm --cached path/to/file
git commit -m "Repair confused cache"
git add path/to/file
git commit -m "Add file"
This did resolve the issue temporarily but soon after, the thing starts happening again.
I am also seeing that git ls-list --cache returns most of the files twice, including their hash codes which are identical like below and the files can be png images, code files etc:
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
UPDATE 1
The output of git config --list --show-origin
is:
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 [email protected]
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$
UPDATE 2
If I try to stage a file that refuses to be staged from SourceTree, I get briefly busy spinner in SourceTree (which tells me it is trying to stage it), but then it goes away and nothing happens, the file stays unstaged.
If I try to stage a file that refuses to be staged from git terminal by issuing git add path/file
or git add .
, nothing happens and file is not staged
UPDATE 3
Output of git ls-files --stage | hexdump -C
below shows two different SHA values for file IoC.cs which is currently refusing to be added to stage using git add .
command:
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|
git config --list --show-origin
? – Linlithgowgit ls-files --stage | hexdump -C
? – Linlithgow