I’ve a script that refreshes the index to latest commit but git also stages the files changed between the old and new commits which I don’t expect.
Steps are as following :
Fetch latest changes from remote repo
git fetch origin master
Git references looks like the following now :
❯ git show-ref | grep -E "master$"
79ba3075fcf4263273dfd222cdd7773624c80913 refs/heads/master
688e154cf3bc04198b401789e75e4d496f7344b6 refs/remotes/gerrit/master
c87fb2b5bc576a23e9af600745210d7b9cab30d2 refs/remotes/origin/master
Update the local reference with the latest remote refernce.
git update-ref refs/heads/master refs/remotes/origin/master
Now the local index is updated too which we expected
❯ git show-ref | grep -E "master$"
c87fb2b5bc576a23e9af600745210d7b9cab30d2 refs/heads/master
688e154cf3bc04198b401789e75e4d496f7344b6 refs/remotes/gerrit/master
c87fb2b5bc576a23e9af600745210d7b9cab30d2 refs/remotes/origin/master
Now I expected the git status to not report any problem. But I see that git also staged the files which were changed between the old and new commits.
git status | wc -l
3196
I don’t understand why would that happen. The same script work for other user.
I did not get any clue over the web or in the command manual. Any idea what could be the reason ?