Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Calling Git from .pro - 'git' is not recognized as an internal or external command

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

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
6 Posts 3 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MrShawn
    wrote on 11 Jul 2018, 20:43 last edited by
    #1

    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)
    
    DEFINES += GIT_VERSION=\\"$$GIT_VERSION\\"
    
    VERSION = $${GIT_VERSION}
    

    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.

    Thanks,
    Shawn

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 11 Jul 2018, 20:45 last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • M Offline
        M Offline
        MrShawn
        wrote on 12 Jul 2018, 12:47 last edited by
        #3

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

        K 1 Reply Last reply 12 Jul 2018, 12:50
        0
        • M MrShawn
          12 Jul 2018, 12:47

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

          K Offline
          K Offline
          koahnig
          wrote on 12 Jul 2018, 12:50 last edited by
          #4

          @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))
          !isEmpty(GIT_VERSION):{
          

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          1
          • M Offline
            M Offline
            MrShawn
            wrote on 12 Jul 2018, 13:22 last edited by
            #5

            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.

            VERSION = $${GIT_VERSION}
            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 :)

            -Shawn

            K 1 Reply Last reply 12 Jul 2018, 14:03
            0
            • M MrShawn
              12 Jul 2018, 13:22

              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.

              VERSION = $${GIT_VERSION}
              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 :)

              -Shawn

              K Offline
              K Offline
              koahnig
              wrote on 12 Jul 2018, 14:03 last edited by
              #6

              @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.

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply
              0

              1/6

              11 Jul 2018, 20:43

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved