How do I write a batch file which opens the GitBash shell and runs a command in the shell?

前端 未结 6 1144
南方客
南方客 2020-12-01 00:22

I\'m on Windows 7 trying to use a batch file to open the GitBash shell and make a git call. This is the contents of my batch file:

REM Open GitBash 
C:\\Wind         


        
6条回答
  •  一向
    一向 (楼主)
    2020-12-01 00:38

    Use Bash is more friendly, for example

    # file: backup.sh
    
    cd /c/myProyectPath/
    PWD=$(pwd);
    
    function welcome() {
       echo "current Dir   : $PWD";
    }
    
    function backup() {
       git pull
    
       #if you have install wamp , we making slqBackup
       MYSQLDUMP="/c/wamp/bin/mysql/mysql5.6.12/bin/mysqldump.exe";
       $MYSQLDUMP --user=login --password=pass --no-create-info bd > data/backup.sql
       git add data/backup.sql;
    
       #generating tar file
       git archive -o latest.tar HEAD
    }
    
    welcome;
    backup;
    
    echo "see you";
    sleep 30;
    

    You can run the script:

    "C:\Program Files (x86)\Git\bin\sh.exe" --login -i -c "/c/myProyectPath/run.sh"
    

提交回复
热议问题