Sowiarz
Sowiarz

Reputation: 1081

Run batch file with git pull in gitbash

I have a following problem. I want to write batch file and run this file everyday on vm.

I have a ssh key on vm so if I manually write "git pull" in gitbash I do not have to write password after that.

Now I want to write script in batch file which will do that automatically.

c://TESTS/test/tes - I want to pull only this one folder from repo.

I do not know how to create that kind of script. Any ideas?

Upvotes: 5

Views: 27442

Answers (3)

Nikhil Dinesh
Nikhil Dinesh

Reputation: 3409

If git is not added to your environment variable, follow below code block

@echo off
set PATH=%PATH%;C:\Program Files\Git\cmd
git pull

If it is already added.

git pull

this is enough in your bat file. This file should be in your folder where you have checkout the files

Upvotes: 0

Sowiarz
Sowiarz

Reputation: 1081

I found solution in basic cmd:

cd c://TESTS/path
set HOME=%USERPROFILE%
git pull 
pause

I missed a HOME variable. Now it is working without using git.exe or bash.exe.

Upvotes: 13

Bartlomiej Lewandowski
Bartlomiej Lewandowski

Reputation: 11180

Since git is not in your PATH you need to add it in your batch script.

@echo off
set PATH=%PATH%;C:\path\to\git
cd c://TESTS/test/tes
git pull

Upvotes: 4

Related Questions