Reputation: 1916
I have a work directory's: D:\Dev\\replay
, D:\Dev\\common
and D:\Dev\\tools
Usually I start my work day like this in gitbash
:
cd d:\dev\\replay
git pull upstream develop
cd d:\dev\\common
git pull upstream develop
etc.
Instead of doing this I want to click on a script file and then get all three updated
How to write a script that do this for me (automatically)?
Upvotes: 2
Views: 236
Reputation: 7261
Using bash: in a file, e.g. "update-repositories"
prefix='d:/dev'
repositories=(replay common tools)
for repository in "${repositories[@]}"
do cd "$prefix/$repository" && git pull upstream develop
done
Execute as
bash update-repositories
Sidenote: Can't judge without knowing the specifics, but this workflow feels a little odd. If you really must work on multiple repositories at once, then they're intrinsically associated you should probably track these associations too (e.g. which version of a tree works with which version of the others). git submodules allow you to do this, and they provide the expected commands to e.g. update all submodules (which are just normal repositories) to the latest version of an arbitrary branch. All you'd need is add a fourth repository with the others as submodules.
Upvotes: 3