0

I wish to write a python script that allows me to navigate and git pull multiple repositories. Basically the script should type the following on the command-line:

cd
cd ~/Desktop/Git_Repo
git pull Git_Repo

I am not sure if there is a python library already out there that can perform such a task.

Jack_The_Ripper
  • 673
  • 2
  • 6
  • 24

1 Answers1

1

Use subprocess, os, and shlex. This should work, although you might require some minor tweaking:

import subprocess
import shlex
import os

# relative dir seems to work for me, no /'s or ~'s in front though
dir = 'Desktop/Git_Repo' 

# I did get fetch (but not pull) to work
cmd = shlex.split('git pull Git_Repo') 

# you need to give it a path to find git, this lets you do that.
env = os.environ 

subprocess.Popen(cmd, cwd=dir, env=env)

Also, you'll need your login preconfigured.

Russia Must Remove Putin
  • 374,368
  • 89
  • 403
  • 331