Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I loop through all of my Git repositories and update them?

Tags:

git

bash

I have a folder where I keep all of my Git repos. I usually just do git pull to get my changes, but now that I have over 50 repos it becomes a burden to have to do this for every folder.

How can I run a command that will loop through every repo and update it for me?

like image 420
dimiguel Avatar asked Aug 13 '15 17:08

dimiguel


1 Answers

In Bash you can run this command which will loop through every repo in your working directory, stash your changes, fetch the origin and pull the latest commit.

for d in */; do cd $d; git stash; (git pull &); cd ..; done

Some things to note:

  • This will use your working branch in your repo
  • (git pull &) opens a subshell and executes in the background
like image 85
dimiguel Avatar answered Oct 08 '22 06:10

dimiguel