loading...
Cover image for Python script for cloning repositories

Python script for cloning repositories

nisevi profile image Nicolas Sebastian Vidal ・2 min read

A couple times it happened to me this year that I had to pull again the repositories from a given organization.

Mostly it happened to me because my computer broke, so a friend of mine lend me his computer so I could work. After mine was fixed I had to pull everything again.

So for not having to clone the repositories manually I wrote a Python 3 script for doing it for me:

The name of the organization is the GitHub username. So for example Facebook GitHub URL is https://github.com/facebook, if you would like to clone all their repositories you will have to replace organization-name-goes-here with facebook.

If you don't know how to create a personal access token, click the link for going to the GitHub documentation. It is well explained with screenshots of where to go and everything. Once you get it, you will have to place it where it says token-goes-here.

If you don't know how to install different versions of python on your machine, you could take a look to:

You will need to install PyGithub the library that I'm importing in the script:

pip install PyGithub

If you don't have pip installed, take a look here for setting it up properly.

Finally for running the script you just need to write in the terminal of your choice:

python cloner.py

Where cloner.py is the name of the file where we wrote our script. Be aware that all repositories will be cloned in the path where you are executing the script.

Have a great week everyone!!

Posted on by:

nisevi profile

Nicolas Sebastian Vidal

@nisevi

I'm a passionate person that enjoys not only working as a Software Engineer but technology itself.

Discussion

markdown guide