Contents

Mirroring a git repo

I like to use open source projects for my smart home projects. Since these projects may occasionally be deleted depending on their size and popularity, further development, updating, or reconfiguration would be impossible without access to the original repository. That’s why I copy the corresponding repositories into my own local Git. I keep my personal configurations and adjustments, such as default values, certificates and access data, in a separate branch. I build all projects exclusively on this (my) branch in my repository. To ensure that my cloned repository stays current, I regularly sync it with the original repository without accidentally pushing back my changes. Below I will explain how I do this using Tasmota as an example.


> git clone https://github.com/arendst/Tasmota.git

> git remote -v
origin  https://github.com/arendst/Tasmota.git (fetch)
origin  https://github.com/arendst/Tasmota.git (push)

> git remote set-url origin http://git.lokal/Tasmota.git

> git remote add upstream https://github.com/arendst/Tasmota.git

> git config remote.upstream.pushurl "not this direction"

> git remote -v
origin  http://git.lokal/Tasmota.git (fetch)
origin  http://git.lokal/Tasmota.git (push)
upstream  https://github.com/arendst/Tasmota.git (fetch)
upstream  not this direction (push)

> git pull upstream master:master --allow-unrelated-histories

> git push origin master

Now I am able merge the master into my branch, configure, … and atleast I need to push my branch

> git push origin bc6

Banner image by BÙI VĂN HỒNG PHÚC on Pixabay

Related Content