6

Good day!

I'm not familiar with Powershell at all, and I want to make a script that excecutes every night at 2AM a git pull command in a given directory location. So basically the script must "cd" to that location and then execute "git pull".

I know Windows have the scheduler in which you can call the script, I just have no idea how to make that script.

Thanks in advance.

Warm regards.

5

cd in Powershell an alias for Set-Location which is cd, and if the Git command line executable is in your path, you can call it from Powershell as well.

cd C:\path\to\myrepo.git\
git pull

or

Set-Location C:\path\to\myrepo.git\
Git pull

The second solution is more idiomatic for Powershell. And remember, if the path to your repo contains spaces, you must put it between quotes.

| improve this answer | |
  • Thanks for your quick answer. One of those 2 options must be saved as .ps1 file and be executed with Windows Task Scheduler? – Alain Jul 5 '17 at 14:49
  • Yes. You just need to be sure that Git is in your path. If you don't know, open a Powershell prompt and type git --version. – Nathan.Eilisha Shiraini Jul 5 '17 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.