git commit and push via batch file on Windows

前端 未结 3 1774
眼角桃花
眼角桃花 2021-02-07 05:31

I do same task often of committing and pushing changes to remote branch. Being lazy sometimes, I needed to put set of git commands to automatically perform these steps:

相关标签:
3条回答
  • 2021-02-07 06:03

    For me, by default, Windows executes .sh files correctly using Git Bash. So I would write your script as a regular bash shell script:

    #!/bin/sh
    cd /d/wamp/www/projectName
    git checkout dev
    git add .
    git commit -am "made changes"
    git push
    echo Press Enter...
    read
    
    0 讨论(0)
  • 2021-02-07 06:04

    I had a similar need, to be able to move code from BBCloud to our development test servers, for stage 1 testing.

    To do this, I created a Windows scheduled task:

    Under "Actions", I added "C:\Program Files\Git\bin\bash.exe" in Program/script field (the quotes were required).

    In the "Add arguments" field, I entered c:\path\to\bash script\pull.sh.

    I then completed the Task Scheduler wizard (run frequency, time, etc.).

    I then created a bash script, using Nano in Git Bash for Windows containing:

    #!/bin/bash
    cd /c/path/to/bash script
    git pull
    

    I would prefer a push to the repository automatically pushing down to the test server, but Pipes, Webhooks, and DeployHQ don't seem to be a solution for our environment.

    0 讨论(0)
  • 2021-02-07 06:05

    Try this one !!

    cd c://TESTS/path
    set HOME=%USERPROFILE%
    GIT COMMAND GOES HERE
    pause
    
    0 讨论(0)
提交回复
热议问题