Lädt...

🔧 How to Sync two GIT repositories?


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Steps for synching one Github repository with another Github repository using your local Macbook

Before you start…

  • Lets say, on your local macbook, you have a folder called “CODE”.
  • You already have the first or source repo (ak-repo1) on your local (on a feature branch — ‘feat/sync-1’ for the below example)
  • You don’t have a second or target repo created yet

Image description

Step 0) Create a Target (blank repository)

Create a new repository (ak-repo2) on Github
In this step, this ak-repo2 can stay as a blank repo

Step 1) Clone target repository to your local

Clone ak-repo2 from github to your local CODE folder
git clone https://github.com/akaak/ak-repo2.git

Verify the ‘remote’ for this target repository

CODE/ak-repo2 - <main> $ git remote -v
origin  https://github.com/akaak/ak-repo2.git (fetch)
origin  https://github.com/akaak/ak-repo2.git (push)

Step 2) Set Repo2 (target) as “remote” for Repo1 (source) on your local

From Repo1 (ak-repo1), set remote for repo2
CODE/ak-repo1 - <main> $ git remote add ak-repo2 https://github.com/akaak/ak-repo2.git

Verify the remotes on your Source repo

CODE/gss-mvp - <feat/sync-1> $ git remote -v
ak-repo2    https://github.com/akaak/ak-repo2.git (fetch)
ak-repo2    https://github.com/akaak/ak-repo2.git (push)
origin  https://github.com/akaak/gss-mvp.git (fetch)
origin  https://github.com/akaak/gss-mvp.git (push)
CODE/ak-repo1 - <feat/sync-1> $

As you can see, there are two remotes on this source (ak-repo1). One for the newly added ‘ak-repo2’ and other other for ‘origin’

Step 3) Push from repo1 to repo2

From the Repo1 execute the command “git push ” to push to Repo 2

While on the branch ‘feat/sync-1’ of repo1, push repo1 branch contents to repo2

CODE/ak-repo1 - <feat/sync-1> $ git push ak-repo2 feat/sync-1

Here the repo2 name of ak-repo2 is recognized by this ‘git push’ command and pushes the code to github’s repo2. repo2 is set up as remote in Step 2 above.

the above command gives an output similar to the one given below…

CODE/ak-repo1 - <feat/sync-1> $ git push ak-repo2 feat/sync-1
Enumerating objects: 213, done.
Counting objects: 100% (213/213), done.
Delta compression using up to 8 threads
Compressing objects: 100% (155/155), done.
Writing objects: 100% (210/210), 365.70 KiB | 121.90 MiB/s, done.
Total 210 (delta 38), reused 210 (delta 38), pack-reused 0
remote: Resolving deltas: 100% (38/38), done.
remote:
remote: Create a pull request for 'feat/sync-1' on GitHub by visiting:
remote:      https://github.com/akaak/ak-repo2/pull/new/feat/sync-1
remote:
To https://github.com/akaak/ak-repo2.git
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

Step 4) Verify Repo 2 on Github

Go to Repo2 on Github and you should see the feature ‘branch’ feat/sync-1 show up as a new branch.

Step 5) Refresh (Fetch) Repo2 on your local

Go to your Repo2 folder on your local

CODE/ak-repo2 - <main> $ git fetch
remote: Enumerating objects: 214, done.
remote: Counting objects: 100% (214/214), done.
remote: Compressing objects: 100% (156/156), done.
remote: Total 211 (delta 38), reused 210 (delta 38), pack-reused 0 (from 0)
Receiving objects: 100% (211/211), 366.55 KiB | 4.17 MiB/s, done.
Resolving deltas: 100% (38/38), done.
From https://github.com/akaak/ak-repo2
   1f31f5b..592155f  main        -> origin/main
 * [new branch]      feat/sync-1 -> origin/feat/sync-1
CODE/ak-repo2 - <main>

Switch to the feature branch on your local
You can switch to the pushed feature branch on your local:

CODE/ak-repo2 - <main> $ git checkout feat/sync-1
branch 'feat/sync-1' set up to track 'origin/feat/sync-1'.
Switched to a new branch 'feat/sync-1'
CODE/ak-repo2 - <feat/sync-1> $ 

You may also use ‘git log’ command on to check and compare the git log on both the repositories to ensure that they both look the same.

CODE/ak-repo1 - <feat/sync-3> $ git log --oneline

That’s it. Now, both Repo1 and Repo2 are synched both at Github and on your Local!

...

🔧 How to Sync two GIT repositories?


📈 34.88 Punkte
🔧 Programmierung

🔧 Sync Git multiple repositories with shell/bash script


📈 28.75 Punkte
🔧 Programmierung

🔧 How to Create and Sync Git and GitHub Repositories


📈 28.75 Punkte
🔧 Programmierung

🐧 Ansible Git Module: Manage Git Repositories


📈 26.84 Punkte
🐧 Linux Tipps

🐧 git-cliff: Generate changelog for your Git repositories from the command line


📈 26.84 Punkte
🐧 Linux Tipps

🐧 Git Clone: Repositories kopieren in Git


📈 26.84 Punkte
🐧 Server

📰 Git-Secrets Prevents You From Committing Secrets And Credentials Into Git Repositories


📈 26.84 Punkte
📰 IT Security Nachrichten

📰 Safest Kodi Repositories: Best Add-on Repositories Ranked High for Trust


📈 23.9 Punkte
🖥️ Betriebssysteme

🔧 DAY 5 Git rebase, Git stash, Git cherry-pick.


📈 22.34 Punkte
🔧 Programmierung

🔧 Git Rebase and Git stash and Git pop -day 4


📈 22.34 Punkte
🔧 Programmierung

🔧 Ditch Git Checkout: Use Git Switch and Git Restore Instead


📈 22.34 Punkte
🔧 Programmierung

🔧 Restaurando e Alternando Branches com Git: Domine os Comandos git restore e git switch


📈 22.34 Punkte
🔧 Programmierung

🎥 Top Git Commands | Most Used Git Commands | Git Commands With Examples


📈 22.34 Punkte
🎥 Video | Youtube

🔧 git switch and git checkout – How to switch branches in git


📈 22.34 Punkte
🔧 Programmierung

🐧 sync two calendars of two different mail accounts


📈 21.62 Punkte
🐧 Linux Tipps

🔧 Automating File Sync Across Repositories with a GitHub Action


📈 21.3 Punkte
🔧 Programmierung

🔧 How to Sync Your Portfolio with GitHub Repositories 😻👌


📈 21.3 Punkte
🔧 Programmierung

🔧 Sync GitHub User or Organization Repositories with a Simple Script


📈 21.3 Punkte
🔧 Programmierung

🔧 Sync GitHub User or Organization Repositories with a Simple Script


📈 21.3 Punkte
🔧 Programmierung

🐧 Open-Source Tool ‘Gitjacker’ Detects Leaking .git Repositories On Websites


📈 19.4 Punkte
🐧 Linux Tipps

🎥 Syncing your local and remote Git repositories


📈 19.4 Punkte
🎥 Video | Youtube

📰 Hacker holding Git repositories for ransom


📈 19.4 Punkte
📰 IT Security Nachrichten

📰 TheCl0n3r - Tool To Download And Manage Your Git Repositories


📈 19.4 Punkte
📰 IT Security Nachrichten

🍏 Vergleichswerkzeug Kaleidoscope integriert Git-Repositories


📈 19.4 Punkte
🍏 iOS / Mac OS

📰 Code execution bug in malicious repositories resolved by Git Project


📈 19.4 Punkte
📰 IT Security Nachrichten

📰 Gitjacker - Leak Git Repositories From Misconfigured Websites


📈 19.4 Punkte
📰 IT Security Nachrichten

🐧 GRV - terminal interface for viewing git repositories


📈 19.4 Punkte
🐧 Linux Tipps

📰 Git 2.28 bringt neue Konfigurationsoption für das Erstellen von Repositories


📈 19.4 Punkte
📰 IT Nachrichten

matomo