0

Is it possible to batch clone git repositories to my local machine? For instance:

git clone https://github.com/dalmatinerdb/dflow
https://github.com/sasa1977/exactor
https://github.com/awetzel/exos
https://github.com/antonmi/flowex
https://github.com/tattdcodemonkey/mon_handler
https://github.com/camshaft/pool_ring

etc. This obviously doesn't work, but is there a script that does work where I can hit git cloneand then copy and paste a list of git repos and it will clone them all to that directory?

0

vcstool is a tool that can used for this use case. It is used, for example, by the ROS2 developers to simultaneously clone a bunch of connected repositories.

It uses a simple YAML format to specify the repositories:

repositories:
  vcstool:
    type: git
    url: git@github.com:dirk-thomas/vcstool.git
    version: master
  old_tools/rosinstall:
    type: svn
    url: https://github.com/vcstools/rosinstall/trunk
    version: 748

It can work with different VCS (git, mercurial, svn, bzr and also plain tar and zip archives).

This may be overkill for your use case, but is useful if you need specific versions of the repositories, or have different VCS.

0

repos.list:

dalmatinerdb/dflow
sasa1977/exactor
awetzel/exos
antonmi/flowex
tattdcodemonkey/mon_handler
camshaft/pool_ring

then on anything with a shell and wget

for proj in `cat repos.list`
do
  mkdir -p $proj
  cd $proj
  echo in `pwd`
  git init 
  git pull https://github.com/$proj
  cd -
done
  • Where do I run this script? – Cody Rutscher Oct 21 '18 at 0:45
  • @CodyRutscher wherever you want all of the files to end up at on your machine. TBH, if you are asking these kinds of questions I gotta wonder why you want to clone the repos. – ivanivan Oct 21 '18 at 0:49
  • They're frameworks to build sites. So you're saying I create a directory and call is say "frameworks." Then in that directory I create a .sh file and inside that file I put that code? – Cody Rutscher Oct 21 '18 at 0:51
  • @CodyRutscher pretty much. TBH I wouldn't even bother writing a script. I'd do it straight on the bash command line, using a single space separating each URL. You may want to go read a quick shell scripting intro tutorial, and perhaps ask over on unix.se – ivanivan Oct 21 '18 at 0:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.