My Plants Started Growing When I Stopped Watering Them

When I first began my plant journey, I started with basic knowledge. Sun, water, and propagating. While my first dew plants were of simple care, I still struggled to keep them healthy. My pothos was…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Sync your Code to multiple Git repositories

Have you ever been into a situation where you have multiple Git repositories and you have to manually sync code to each of these repositories?

As a programmer, most of my code which I write is in Python and hence it becomes very important to keep all my code in a repository so that I can use it in future when needed and also share it with others.

I maintain my code repositories in three locations namely github, bitbucket and Gitlab. The only reason I made three repositories is that I wanted to explore all three platforms. There is no difference of content between these repositories.

I normally write my Python program in Visual Studio Code and commit it to my code repositories. Earlier, I had to manually commit my code to all the repositories individually. But with the process below, I can do it in one go.

Let’s assume that we don’t have an existing version of code cloned into our local machines. As a first step, I will launch Visual Studio Code and clone my BitBucket repository.

Clone the BitBucket repository

Next I would open my cloned folder on my local machine. Visual Studio code comes bundled with a source control provider and would automatically detect the git repository.

Let’s first try to get a list of remote repositories which are being tracked. Please type the below command to get the list. You will see only the bitbucket repository in this case:

As the last step let’s configure visual studio code to push the changes to both the repositories using the below commands

This will add entries of the repositories to remote.origin.pushurl and now the code will be pushed to both the destinations. We can check it by running the following command

You will get a similar output with two push URL’s

To make sure this works, I would make a dummy change and try to push to changes and see if it gets committed to both my github and bitbucket repositories

In my case, I committed a small dummy change as below and I can see the same committed to both bitbucket and github repositories.

Let’ see the change in bitbucket and voila, I can see the change committed.

BitBucket repository

Let’s see if I can see the change in my github repository and voila, I can see the change there too.

GitHub Repository

So now, I don’t have to worry about keeping all my repositories in sync. Once I save my code and commit the changes, it will reflect in all the repositories. Before closing this article, let’s add a third repository to the push URL, in my case its the GitLab repository.

Add a comment

Related posts:

The Two Different Mindsets to the Financial Independence and Early Retirement Strategy

I was on Twitter the other day and noticed the pool of minds all swimming toward a life of financial freedom take two different paths. I never realized that some people in one mindset don’t consider…

5 Common Concerns about Alternative Options

The acquaintance who is trying her fifth fad diet in a year. Another article making the rounds about how “insert natural, organic or other buzzword here” is going to turn your life around. The horror…

Two BIG Mistakes Women Make When Trying To Lose Weight 2023

And keeping in mind that a portion of the data is without a doubt decent, a decent larger part of it simply doesn’t pile up. Particularly with regards to female fat misfortune and sustenance. Ladies…