How To Launch Git Bash from DOS Command Line?

前端 未结 9 1666
北海茫月
北海茫月 2020-12-07 08:21

I\'ve got what I\'m hoping is a simple question, but I haven\'t been able to find the answer yet. I would like to launch Git Bash from a DOS batch file. Here is what I tri

相关标签:
9条回答
  • 2020-12-07 08:54

    I prefer, putting git in environment variable and just calling

    c:\Users\[myname]>sh
    or 
    c:\Users\[myname]>bash
    

    Steps to create Environment variable (Win7)

    • From the desktop, right click the Computer icon.
    • Choose Properties from the context menu.
    • Click the Advanced system settings link.
    • Click Environment Variables.
    • In the section User variables, hit button NEW, put variable name as GIT_HOME, value as (folder-where-you-installed-git).

      • for me it is was c:\tools\git, others maybe have C:\Program Files\Git
    • find the PATH environment variable and select it. Click Edit. (If the PATH environment variable does not exist, click New).

    • In the Edit window, add a new value %GIT_HOME% and %GIT_HOME%\bin. Click OK. Close all remaining windows by clicking OK.
    • [Make sure you close the CMD which you want use for git]
    • open new Command prompt, and just type sh or bash or git-bash
    0 讨论(0)
  • 2020-12-07 09:00
    start "" "%SYSTEMDRIVE%\Program Files (x86)\Git\bin\sh.exe" --login -i
    

    Git bash will get open.

    0 讨论(0)
  • 2020-12-07 09:04

    You can add git path to environment variables

    • For x86

    %SYSTEMDRIVE%\Program Files (x86)\Git\bin\

    • For x64

    %PROGRAMFILES%\Git\bin\

    Open cmd and write this command to open git bash

    sh --login
    

    OR

    bash --login
    

    You can see this GIF image for more details:

    https://media1.giphy.com/media/WSxbZkPFY490wk3abN/giphy.gif

    0 讨论(0)
提交回复
热议问题