copying a branch from one git repo to another git repo with history.

There are times where one might want to copy a branch from a public open source git repository to a private git repository. In certain situation a git fork is not an option as you might already have the destination git and you many have your internal repo in an air gaped environment.

Giridharan Kesavan
1 min readFeb 14, 2021

I found these steps easy enough to setup

I’m going to use Apache Tez as an example

clone the In-house private repo, assuming you already have a repository.

git clone git@something.somewhere.com:/project1/tez.git

get inside tez folder

git remote add apache git@github.com:apache/tez.git

git remote -v ( Now this would show both the remotes, origin and apache )

git fetch apache

checkout the branch/tag of interest from Apache.

git checkout <remote branch name> -b <local branch name>

Now you have the branch locally available.

To push it to your in-house private repo

git push origin <local branch name>

--

--