Creating a private fork so your repositories are not public

When creating your own Magento project you won't want them public, so you should clone our starter repo to your own private repo.

You can then start a Magento project that will be private to your Github repository.

Creating a private fork of the "Magento + Gitpod" repository located at https://github.com/develodesign/magento-gitpod, follow these steps.

This process is necessary because GitHub does not permit direct private forking of public repositories. 

1. Create a Bare Clone of the Repository : This creates a temporary bare clone of the repository. Perform this step in any directory on your computer, as this cloned folder will be removed later.

bash

$ git clone --bare https://github.com/develodesign/magento-gitpod


2. Create a New Private Repository on GitHub : Name this new repository as you prefer, relating it to your Magento + Gitpod project. If you're unable to create a private repository, consider applying for GitHub's Student Developer Pack for unlimited private repositories

3. Mirror-Push the Bare Clone to Your New Repository : After creating your new private repository on GitHub, mirror-push the cloned content to this repository. Replace <user_name> with your GitHub username and <new_private_repo_name> with the name of your new repository.


Navigate to the cloned directory:

bash

$ cd magento-gitpod.git


Then execute the mirror-push command:

bash

$ git push --mirror [email protected]:<user_name>/<new_private_repo_name>.git


4. Remove the Temporary Local Repository : Once you have successfully mirror-pushed the contents, you can remove the temporary local repository.

bash

   cd ..
   rm -rf magento-gitpod.git


5. Clone Your New Repository Locally : To work on your project, clone the new private repository to your machine. Choose a directory where you wish to clone; for example, in a code folder:

  bash

   cd ~/workspace/new-magento-project
   git clone [email protected]:<user_name>/<new_private_repo_name>.git


6. Add the Original Repository as a Remote (Optional) : If you wish to stay updated with potential future changes from the original Magento + Gitpod repository, add it as a remote. Ensure you disable push to this remote to avoid accidental push attempts.

 bash

git remote add gitpod-magento-upstream https://github.com/develodesign/magento-gitpod
git remote set-url --push gitpod-magento-upstream DISABLE


Verify your remotes:

bash

$ git remote -v


You should see your repository as origin and the original Magento + Gitpod repository as `gitpod-magento-upstream`.

7. Fetch and Rebase from Upstream (Optional) : To incorporate changes from the original repository into your work, fetch from upstream and rebase.

bash

   git fetch gitpod-magento-upstream
   git rebase gitpod-magento-upstream/master

 

By following these steps, you'll have successfully created a private fork of the Magento + Gitpod project, ready for personal or team development.

Thanks to the original Github private fork here https://gist.github.com/0xjac/85097472043b697ab57ba1b1c7530274

Lesson Summary

When creating a private Magento project, you should clone the starter repo to your private repository on Github by following these steps:

  1. Create a bare clone of the Magento + Gitpod repository by running:
    git clone --bare https://github.com/develodesign/magento-gitpod
  2. Create a new private repository on GitHub and name it accordingly, or apply for GitHub's Student Developer Pack for unlimited private repositories if needed.
  3. Mirror-push the bare clone to your new private repository by executing:
    git push --mirror [email protected]:/.git
  4. Remove the temporary local repository by running:
    cd ..
    rm -rf magento-gitpod.git
  5. Clone your new private repository locally by executing:
    cd ~/workspace/new-magento-project
    git clone [email protected]:/.git
  6. Add the original repository as a remote (optional) to stay updated with potential future changes:
    git remote add gitpod-magento-upstream https://github.com/develodesign/magento-gitpod
    git remote set-url --push gitpod-magento-upstream DISABLE
  7. Fetch and rebase from upstream (optional) to incorporate changes from the original repository into your work:
  8. git fetch gitpod-magento-upstream
    git rebase gitpod-magento-upstream/master

By following these steps, you'll have successfully created a private fork of the Magento + Gitpod project, allowing for personal or team development.

Reference: Original Github private fork

Complete and Continue  
Discussion

0 comments