Git pull all

(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 non-Linux user (Redmond), either use Git Bash with above script, or the following batch script counterpart:

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).

That’s it.

.

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

)

Also, enable Annotation Processing will be good when you are using libraries such as Lombok or Mapstruct.

(IntelliJ wrap line at 120 spaces:
+ format: Settings / … / Code Style / JAVA / Wrapping and Braces / Ensure right margin is not exceeded = Yes

+ typing:

)

 

./.

Advertisements

About DucQuoc.wordpress.com

A coder, husband and brother...
This entry was posted in Coding, Skill. Bookmark the permalink.

2 Responses to Git pull all

  1. Pingback: IDEA Tomcat HotSwap | DucQuoc's Blog

  2. When you install HotSwap plug-in with IDEA, it’s recommended to use the “always Build” feature, instead of Ctrl+F9 manually.

    However, some IDEA plugins may rely on third-party lib to run and may crash the compile-server. Especially the “SNAPSHOT” version of springloaded and HotSwapAgent. If you meet such problem, for example “SLF4J no binding”, download slf4j-simple JAR :
    https://mvnrepository.com/artifact/org.slf4j/slf4j-simple/1.7.25#maven

    and put it into classpath of the compile-server, or simply the lib folder of the plugin:
    Windoze:
    %UserProfile%\IntelliJIdea2017.1\config\plugins\hotswap-agent-intellij-plugin\lib

    Ubuntu/Mac:
    $HOME/IntelliJIdea2017.1/config/plugins/hotswap-agent-intellij-plugin/lib

    ./.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s