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
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.
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!
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.
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.
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 ..)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With