Skip to main content

How to Sync One Git Repository into Another

Easy Guide: Keep Two Git Projects in Sync

Imagine you have one project you follow (the “source”) and another project where you want to save a copy (the “mirror”). Just run these simple commands—no technical background needed.

1. Open Your Project Folder

On your computer, go to the folder where your source project lives. If you haven’t downloaded it yet, do this once:


git clone <SOURCE_ADDRESS> my-project
cd my-project
  

If you already have it, skip cloning and just enter your folder:


cd path/to/my-project
  

2. Tell Git About Both Projects

By default, Git knows about the source project only. Rename that connection to “source” and add your mirror project as “mirror”:


git remote rename origin source
git remote add mirror <MIRROR_ADDRESS>
  

3. Get the Latest Changes from Source

Always grab new updates first:


git pull source main
  

(“main” is the common name for the main branch. If yours is “master,” use that instead.)

4. Send Those Updates to Your Mirror

Now push everything you’ve just pulled into your mirror project:


git push mirror main
  

5. One‑Click Sync (Optional)

Make a tiny script so you don’t have to type both commands every time. Create a file named sync.sh with these lines:


#!/bin/bash
git pull source main
git push mirror main
echo "All done!"
  

Then run:


chmod +x sync.sh
./sync.sh
  

What’s Happening?

  • git pull source: Downloads the newest version of the source project.
  • git push mirror: Uploads that version into your mirror project.

Comments

Popular posts from this blog

How to Convert a Next.js Website into a PWA and TWA

🚀 Complete Guide: Converting Next.js to PWA & TWA Transform your Next.js website into a Progressive Web App and wrap it as an Android application using Trusted Web Activity. Every step explained in detail! 📋 Table of Contents What is a PWA? What is a TWA? Prerequisites & Setup Step 1: Convert Next.js to PWA Install Dependencies Configure next.config.js Create Web App Manifest Prepare App Icons Update Document Head Build and Test PWA Step 2: Wrap PWA as TWA Create Asset Links File Install Bubblewrap CLI ...

DevOps Best Practices

 # DevOps Best Practices: Your Ultimate Guide to Modern Software Development In today's fast-paced tech world, DevOps isn't just a buzzword – it's a game-changer. Let's dive into the essential practices that can transform your software development process. ![DevOps Lifecycle](https://blogger.googleusercontent.com/img/placeholder.png) ## 🔄 1. Continuous Integration (CI) - The Foundation Think of CI as your code's quality guardian. Every time developers push code, automated tests run to catch issues early. Here's what makes great CI: - Automated builds triggered with every commit - Comprehensive test suites running automatically - Code quality checks integrated into the pipeline - Quick feedback loops to developers **Pro Tip:** Start with simple automated tests and gradually build up your test suite. Remember, it's better to have a few reliable tests than many unreliable ones. ## 🚀 2. Continuous Delivery (CD) - From Code to Customer CD ensures your software ...

How to Keep ADB Connected Over Phone Hotspot (Automatic Reconnect)

How to Keep ADB Connected Over Phone Hotspot (Automatic Reconnect) How to Keep ADB Connected Over Your Phone Hotspot This is a simple, step-by-step guide to keep your ADB connection over a phone hotspot using Windows. No CSS or JavaScript is used. Step 1: Prerequisites Windows PC with ADB installed (part of Android Platform Tools). Phone with USB debugging enabled in Developer Options. Phone and PC connected to the same hotspot network. Step 2: Enable ADB over Wi-Fi (Temporary) Connect your phone to PC via USB and open Command Prompt or PowerShell, then run: adb devices adb tcpip 5555 adb shell ip route # optional, shows phone IP After this, you can unplug the USB cable. Step 3: Connect over Wi-Fi Run the following command with your phone's IP: adb connect <phone-ip>:5555 adb devices # to check connection You should see your device listed as connected over Wi-Fi. Step 4: Automatic Reconnect Scri...