Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run git pull over all subdirectories windows command promt

How can I update multiple git repositories from their shared parent's directory without cd'ing into each repo's root directory on windows 7 ?

I have the following which are all separate git repositories (not submodules):

c:\projects\repos\repo1
c:\projects\repos\repo2
c:\projects\repos\repo3

On linux I can use this bash script

find ~/projects/repos/ -type d -name .git \
| xargs -n 1 dirname \
| sort \
| while read line; do echo $line && cd $line && git pull origin $1 && echo ; done
like image 436
Arkadiy Zamaraev Avatar asked Oct 23 '14 10:10

Arkadiy Zamaraev


People also ask

Can I use Git commands in cmd?

All you have to do is load Command Prompt (Load the Start menu, then click "Run", type cmd and hit enter), then you can use Git commands as normal.

How do I pull everything in git?

To get all the changes from all the branches, use git fetch --all . And if you'd like to clean up some of the branches that no longer exist in the remote repository, git fetch --all --prune will do the cleaning up!

What is pull command in git?

The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content. Merging remote upstream changes into your local repository is a common task in Git-based collaboration work flows.

What is git pull origin master?

git pull origin master will pull changes from the origin remote, master branch and merge them to the local checked-out branch. git pull origin/master will pull changes from the locally stored branch origin/master and merge that to the local checked-out branch.


1 Answers

Windows Batch solution:

if you want to use this in .bat script use this:

for /D %%G in ("*") do (echo %%G) && (cd %%G) && (git pull origin) && (cd ..)

if it's just in the console:

for /D %G in ("*") do (echo %G) && (cd %G) && (git pull origin) && (cd ..)
like image 122
Piotr W Avatar answered Oct 22 '22 17:10

Piotr W