Mark Harrison
Mark Harrison

Reputation: 304434

git: clone from public github to private github

(dupe note) Not related to pull/push from multiple remote locations; I don't need multiple locations, just to interact between an internal and public github. (end note)

I'm looking for a workflow:

What git incantations will perform these three interactions?

Upvotes: 1

Views: 210

Answers (1)

Jonathan.Brink
Jonathan.Brink

Reputation: 25373

Most of your management between the the two Git servers will be managing separate remotes between them.

If you are explicit with your push's and pull's you can define a workflow that should be pretty sane.

clone from public to internal github

# this will be a one-time setup

# first clone the public repo
cd /dir/where/you/want/your/repo
git clone <public github url> myRepo
cd myRepo

# create a remote to your internal Git server
git remote add internal <internal repo url>

# push to your internal repo
# (assuming you are working on the master branch)
git push internal master

# now you have effectively "cloned" the public repo
# to your internal server

pull changes from public to internal github

# assuming you are on master branch
# and _not_ taking tracking branches
# into account (since IMO they complicate matters)
git checkout master

# pull from github
git pull origin master

# push to internal
git push internal master

push changes from internal to public github

git checkout master
git pull internal master
git push origin master

Upvotes: 3

Related Questions