DEV Community

Deep
Deep

Posted on

Automate GIT PULL

Have you encountered a situation where you have a bunch of projects git repos and every morning you have to manually do git pull for all the project repos, so that you have the latest code in local development machine.

Well I used to go to each and every repo folders and open git bash and manually pull the latest changes. Think of you have ten different projects/solutions/Microservice you work on day to day basis and you have to repeat this process every time, its tedious right, so as a developer what can we do AUTOMATE boring tedious tasks.

Well you can say this level of automation won't save a lot of time for me, maybe 10 mins a day. Well you are kind of correct but think of 10*5*4 = 200, you will save 200 mins a month. Not bad huh so let's get to the actual script on how can we do that.

Prerequisite:

  • Install GIT on your machine
  • Admin privileges(though its not required but sometimes PS acts crazy if you don’t have admin permission)
  • Group all project repo under single directory in your local box (for example I have all my project repos located under C:\Code, you can modify below script if you project scattered all across your drive )

You can skip user input by hard coding 'repoLocalpath'

Using the above script you can customize based on your needs such as find a difference before pulling remote changes or push/sync all repo.

Top comments (2)

Collapse
 
nevercodealone profile image
Never Code Alone

This is hard on work i think. How do you feel with this workflow?

Collapse
 
dmehro profile image
Deep

With this workflow , I am definitely saving manual work.

In my project I have bunch of dependencies where I need to make sure I have latest code available for dependent project ( I also automated build process , where it goes in to each repo and build projects )