This is a follow up to the question Is it possible to fork a public GitHub repo into an enterprise repository?
I want to fork the public project github.com/foo.git
and work on it on my enterprise server, under the name github.enterprise.com/bar.git
. However, I want to keep them linked so I can pull any changes on the master. In other words, I am going to create some new codes and edits in my enterprise bar.git
, but whenever the authors of foo.git
update their master repo, I want to pull those changes. So I followed the following steps.
- Create an empty repository on
github.enterprise.com/bar.git
- Fork
github.com/foo.git
on my public GitHub accountgithub.com/MyPublic/foo.git
- Rename my public repo as to
bar.git
so it'sgithub.com/MyPublic/bar.git
Create a bare clone of my new fork on my computer
git clone --bare https://github.com/MyPlublic/bar.git
Change directories into the bare clones folder:
cd bar.git/
Push the repository with the --mirror flag to my enterprise GitHub
git push --mirror https://github.enterprise.com/bar.git git remote set-url --push origin https://github.enterprise.com/bar.git
Now I have the bar.git/
directory on my computer, which is BARE:master
and not an editable version of the repo. I have bar.git
repos on my personal public GitHub.com account and on my Enterprise server. The next things I need to do are (1) clone the enterprise repo onto my computer and edit it; (2) commit and push those changes to the enterprise repo; and (3) I also want to pull changes from the master foo.git
repo when they happen.
I'm assuming I just do a standard clone, commit, and push for (1) and (2), i.e.
git clone GitHub.enterprise.com/bar.git
git commit
git push
Is it actually possible to do #3? I'm thinking that in my computer's bar.git/
directory, I execute
git fetch -p origin
git push --mirror
and then in the bar/
directory, I execute a standard git pull
?