Git for Windows "No tags file" Response from "git diff" Command

Viewed 378

Git version: 2.14.2.2

Whenever I run git diff on a repository I am greeted with the response No tags file. I have tried running the command on multiple repositories, multiple consoles (Cmd, PowerShell, MINGW64, Visual Studio Command Prompt) and all have the same response.

No tags file

Strangely, the git log command also fails. Many other commands work, however, such as git status, git pull, etc. It seems to be only log and diff.

Working commands

I have uninstalled Git entirely and reinstalled. Restarted my system. Tried referencing the git.exe directly (which yields the exact same response). Nothing is working and I have not seen this error anywhere else. I compared my user configs with those of a colleague and they are identical.

Some portion of the command executes properly, because if I supply two commit hashes, and I intentionally break one, the response I receive is:

Bad Response

It seems like another program may be hijacking the git diff command. I believe this because I'm not sure "No tags file" is even a possible Git response. Not sure what else it would be.

To make things even more confusing- my ultimate goal is to run the git diff within the context of an msbuild and it DOES EXECUTE CORRECTLY. Now, I could be satisfied with this, but I need to modify the diff command slightly, and running a full build each time is not productive, nor easy to troubleshoot. There is a task within the build script that runs an Exec command and it has no issues performing the diff. I'm also able to execute a Diff Against Current within SourceTree, which to the best of my knowledge, runs a git diff behind the scenes.

Any help would be very much appreciated.

:: Edits ::

Various commands:

git diff HEAD~1 HEAD
git diff master~1 master
git diff <commit-hash-1> <commit-hash-2>
git log HEAD~1..HEAD
git log master~1..master
git log <commit-hash-1>..<commit-hash-2>

Output:

Every one of the commands above returns the same No tags file response, in all of my repos.

Cat Head:

cd .git
cat HEAD
ls -R refs

Output:

CatHead

New Repo:

mkdir testrepo
cd testrepo
git init
echo "file1" > file1.txt
git add .
git commit -m "initial commit of file1.txt"
echo "Hi there!" > file2.txt
git add .
git commit -m "added file2.txt"
git log
git diff HEAD~1 HEAD

Output:

NewRepo

git config -e:

gitconfige

git config --global -e:

gitconfigglobale

::Edits 2::

I uninstalled all of my diffing/source control tools (SourceTree, Git, SVN, WinMerge, KDiff). Installed the portable version of Git. Opened CMD to a repo, put in full path to the git.exe portable and it still returned the No tags file response.

I also reviewed all of my path variables for: git, vim, ming, mintty and anything else that seemed suspect, but didn't find any.

I have restarted after performing all steps, and yet the problem persists.

::Edits 3::

I have a different user on my laptop, switched to that user and the git diff works properly, so clearly there is something with my main user that is conflicting. Will continue to look into my User directory for issues.

2 Answers

Here are the steps I'd take in this situation:

  1. Try the following and check the response:

    git diff HEAD~1 HEAD
    git diff master~1 master
    git diff <commit-hash-1> <commit-hash-2>
    
  2. Try the same with log:

    git log HEAD~1..HEAD
    git log master~1..master
    git log <commit-hash-1>..<commit-hash-2>
    

    I'm actually guessing that your refs are messed up, which means that the direct hashes might work, but the HEAD and/or master one may not.

  3. Look into the .git/refs folder

    From the main repo folder:

    cd .git
    cat HEAD
    ls -R refs
    

    Hopefully, HEAD is pointing to a branch, and if master is checked out, cat HEAD output should look like:

    ref: refs/heads/master
    

    Then, the ls -R refs, should show a heads folder, with files for each of your local branches (i.e. master and possibly others). You also likely have refs/remotes and refs/tags directories.

    If any of these things are radically different or missing, that could be your issue...

  4. Since you have reinstalled git, create a brand new repo and try the same commands:

    mkdir testrepo
    cd testrepo
    git init
    echo "file1" > file1.txt
    git add .
    git commit -m "initial commit of file1.txt"
    echo "Hi there!" > file2.txt
    git add .
    git commit -m "added file2.txt"
    git log
    git diff HEAD~1 HEAD
    

    If this last one works, then git is likely working okay, but some tool you have is messing things up.

  5. Post your config from git config -e and git config --global -e - maybe we can see something?

When googling for the "No tags file" message, the first results I get all talk about vi.

I do not understand why git would try to execute vi when running git diff or git log, could it be that your system is configured to use vi as a pager ?

# some possible places which could influence that :
echo $PAGER
echo $GIT_PAGER
git config --get core.pager

When digging in the documentation for less, I found that less can use a ctags file, to spot "the file that contains this tag".

So you can also look at the list of variables that influence the behavior of less :

# from bash :

# env will list all the defined environment variables
env

# the ones that impact 'less' should contain "LESS" in their names :
env | grep LESS
Related