(targeted audiences: developers/coders/programmers)
Git projects are typically small and we may have multiple projects on a workspace.
Hence sometimes we have 8+ projects on the workspace it may be tedious to update git pull manually. And we don’t have “parent project” like in SVN anymore, not update all option huh? Okay we can do it with shell script.
I’ll make it one-liner, given the current working directory is the workspace:
for i in */.git; do ( echo $i; cd $i/..; git pull; ); done
And when we need to Git pull with rebase (or the global config always rebase when pulling), just use stash along with it. Replace the normal git pull with following:
git stash && git pull --rebase || git pull --rebase && git stash pop
Combined with the command above we can still have “one-liner” , but I also made a simple bash script git-pull-all.sh for arbitrary workspace dir (not just basedir).
for /d %a in (*.*) do cd "%CD%\%a" && git pull
The git rebase stash above still works with Windows.
for /d %a in (*.*) do (cd "%CD%\%a" && git stash && git pull --rebase || git pull --rebase && git stash pop)
I also made a git-pull-all.bat for that as well (using %% variables with for loop, not % as in direct command line).
Bonus: For IDE you may want to enable auto import Maven/Gradle changes (so that after updating Git repos the dependencies will be update automatically). For example IntelliJ IDEA can enable Auto Maven Imports at:
File -> Settings -> Build, Execution, Deployment > Build Tools > Maven > Importing
(old versions of IntelliJ IDEA:
File -> Settings -> Maven > Importing
File -> Settings -> Build, Execution, Deployment > Compiler > Annotation Processors
(IntelliJ wrap line at 120 spaces:
+ format: Settings / … / Code Style / JAVA / Wrapping and Braces / Ensure right margin is not exceeded = Yes
+ typing: Settings / … / Code Style / JAVA / Wrapping and Braces / Wrap on typing = Yes