Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 849
Sowiarz Avatar asked Sep 24 '14 11:09

Sowiarz


People also ask

How do I use the pull command in Git bash?

The git pull command is actually a combination of two other commands, git fetch followed by git merge . In the first stage of operation git pull will execute a git fetch scoped to the local branch that HEAD is pointed at. Once the content is downloaded, git pull will enter a merge workflow.


2 Answers

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.

like image 130
Sowiarz Avatar answered Sep 30 '22 20:09

Sowiarz


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
like image 28
Bartlomiej Lewandowski Avatar answered Sep 30 '22 19:09

Bartlomiej Lewandowski