DEV Community

Serhii Kucherenko
Serhii Kucherenko

Posted on

How to update multiple git repositories for 1 project?

Alt Text

The problem

Image a situation where you started a project locally, developed some codebase and pushed that code to your github | gitlab | bitbucket. Then you ask your friend or a colleague to help with a feature. You added hime to the repo and we both work on 1 project. Then the client comes and says that he created an account on github and setup the auto-deploy to the server so you just need to push your code in their repo.

First solution

Simply copy the project, reinitiate the git config and change remote-url to the client's one. But then you change code in your repo & clone it to another manually. That's a stupid, time-consuming operation.

Right solution

So as a lazy developer, you don't want to do such things and you don't need to do it. You can configure your git to fetch data from your own repo and push new changes to both repos simultaneously.

git remote set-url --add --push origin path/to/YOUR/repo
git remote set-url --add --push origin path/to/CLIENT/repo
Enter fullscreen mode Exit fullscreen mode

After this, when you'll next time run git push the changes will be pushed to the both gits. Check it by yourself. Isn't that awesome?

Top comments (0)