Setup private fork - AST-Course/AST5110 GitHub Wiki

Setting Up a Private Fork of a Public GitHub Repository Using SSH

Objective: Create a private fork of the public GitHub repository AST5110 and maintain synchronization with the original repository using SSH.

Prerequisites: Set up SSH keys for GitHub.

  1. Generate a New SSH Key (if you don't already have one):

    Note: The SSH key is usually in ~/.ssh/ directory on Unix-based systems.

    • Open Terminal and run:
      ssh-keygen -t ed25519 -C "[email protected]"
    • Press Enter to accept the default file location and name.
    • Enter a secure passphrase when prompted.
  2. Add Your SSH Key to the SSH Agent:

    • Start the ssh-agent in the background:
      eval "$(ssh-agent -s)"
    • Add your Ed25519 SSH private key to the ssh-agent:
      ssh-add -K ~/.ssh/id_ed25519

    Note: an alternative, e.g., RSA, is possible to replace the Ed25519 key. For more details, see Generating a new SSH key and adding it to the ssh-agent.

  3. Add Your SSH Key to Your GitHub Account:

    • Copy your Ed25519 SSH key to the clipboard:
      pbcopy < ~/.ssh/id_ed25519.pub
    • Go to GitHub, navigate to "Settings" > "SSH and GPG keys".
    • Click "New SSH Key", paste your key into the field, and save.

For more information, see Adding a new SSH key to your GitHub account

Setting Up a Private Fork of the public GitHub repositories Using SSH

There are two repositories under AST-Course, i.e., AST5110 and nm_lib. AST5110 includes the course materials and exercises, and nm_lib is the lib that would be used during exercises. Note that for PhD students, all the optional exercises are to be done. Below an example is given for setting up private forks of these two repositories.

  1. Clone the Public Repository via SSH:

    git clone https://github.com/AST-Course/AST5110.git
  2. Navigate to the Repository Directory:

    cd AST5110
  3. Remove the Existing Origin Remote:

    git remote remove origin
  4. Create a New Private Repository on GitHub (using GitHub CLI):

    gh repo create <yourusername>/<yourrepositoryname> --private

Note: Without GitHub CLI you can still create a private repository, but may need a few more steps. However, you may not have GitHub CLI. To install it, you can use the command

brew install gh

See more instructions from here.

Yet again, you may not have Homebrew to use the command, and thus you can use the command below to install Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Note that you may need to add the path of Homebrew to your $PATH. Then you can run

gh auth login

and follow the prompt, installing GitHub CLI.

  1. Manually Add Your New Private Repository as the Origin Remote (via SSH):

    git remote add origin [email protected]:<yourusername>/<yourrepositoryname>.git
  2. Push the Local Repository to Your New Private Repository:

    git push -u origin main

    Note: the branch name is master for nm_lib .

  3. Set Up the Upstream Remote (Optional):

    git remote add upstream [email protected]:AST-Course/AST5110.git
  4. Update Your Private Fork (Optional):

    • Fetch updates:
      git fetch upstream
    • Merge updates:
      git merge upstream/main main
    • Push updates:
      git push origin main

Note: Replace <your username> and <your repository name> with your actual GitHub username and the chosen name for your private repository. The SSH protocol provides a more secure connection than HTTPS and is preferred for frequent interactions with GitHub.

After having set AST5110 up, nm_lib can be set up similarly. However, to use nm_lib, further instruction is needed and given in here.

Setting up the Wiki Submodule via SSH

The wiki submodule is not downloaded by default when cloning the repository. To download the files for the wiki, run the following commands:

git submodule init
git submodule update --remote

For more information on submodules, see Git Tools - Submodules.

⚠️ **GitHub.com Fallback** ⚠️