From 10:00 CET Friday 22nd November we will adjust how the server works to deal with some recently reported problems. Therefore there may be a load problem, if you experience more problems than usual trying to access the forum then please PM AndyS or any of the moderators so they can inform me.

Calling Git from .pro - 'git' is not recognized as an internal or external command

  • Hey guys, so I am trying to pull my version from Git's tags.

    I am working on Windows 7 pro.

    Here is what I have in my .pro file.

    GIT_VERSION = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags)

    The error i get is: 'git' is not recognized as an internal or external command, operable program or batch file.

    I run this same section of .pro file for another project on another machine, it does not have this issue.
    I am also able to call git from cmd window on the problem machine and it recognizes the command just fine.

    Any ideas on how to solve? I have tried adding git.exe to PATH for windows environment variable, also set the prepend to path under tools for the git version control.


  • Lifetime Qt Champion


    Shouldn't you be calling git.exe rather than just git ?

  • I tried git.exe but it doesn't seem to change anything.

  • @MrShawn

    I guess the quotes are missing.

    The command below I am using in my .pro files on windows and linux.

    GIT_VERSION = $$system($$quote(git describe --tags))

  • I came in this morning and went to try it again. It seems to be working. I had to add these lines in after because it was saying that there was a syntax error in the .rc file.

    win32 {
        VERSION ~= s/-\d+-g[a-f0-9]{6,}//

    I am pretty sure the solution was that I reinstalled the git for windows, and made sure I selected command line interface for windows in the installation. I think I had to restart Qt Creator which I did not do last night, this morning I came in and started Qt Creator up and it worked(I did not restart the machine). It also seems I can use git.exe or just git. I am going to mark as solved, than you all for the help :)


  • @MrShawn

    Glad to see that you have a solution.

    The quotes I had to add a while ago. This was a solution found probably in this forum. Before it did not work. However, I will not start fuzzing around there. Never change running code.

Log in to reply