5

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?

3
  • is git in your PATH on the VM? If so, CD to your repository and run git pull Commented Sep 24, 2014 at 12:02
  • but if I call "git pull" by cmd it does not work. I want to do that from gitbash. Commented Sep 24, 2014 at 12:04
  • Why do you want to do it in gitbash? Commented Sep 24, 2014 at 12:06

3 Answers 3

13

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.

Sign up to request clarification or add additional context in comments.

Comments

4

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

6 Comments

"path to git" is the path to bash.exe?
It's the place where you have git installed. Should be in the same directory as the git bash executable
@Sowiarz put pause at the end of the script
permission denied...fatal:Could not read from remote repository.
Please make sure you have the corect acess rights and the repository exist.....but manually from git bash in folder it works
|
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.