DEV Community

Cover image for GitHub Code Setup: Choosing Your Workflow (HTTPS, SSH, Terminal, & Desktop)
Amrishkhan Sheik Abdullah
Amrishkhan Sheik Abdullah

Posted on

GitHub Code Setup: Choosing Your Workflow (HTTPS, SSH, Terminal, & Desktop)

Getting a codebase from GitHub onto your local machine is the first step in any development project. While the core action is always a "clone," the method you choose affects your daily workflow, security, and integration with the GitHub platform.

Here's a detailed guide to the four main ways you can set up your code environment, complete with steps and examples for each.


1. The Git Protocol Choice: HTTPS vs. SSH ๐Ÿ”‘

Before you even pick a tool (Terminal or Desktop), you must decide how your machine will authenticate with GitHub.

A. HTTPS (The Simple Way)

HTTPS uses your standard GitHub username and password, often combined with a Personal Access Token (PAT) for authentication, or relies on a local credential manager.

Pros Cons
Simple Setup: No key generation required. Token Reliance: Requires authentication (password or PAT) for every push/pull unless a credential manager is used.
Universal: Works everywhere without configuration. PATs can expire and require occasional regeneration.

When to use it: For quick, one-off projects, or when you are on a machine where you cannot set up SSH keys.

Crucial Missing Step: Setting up the Credential Manager (Recommended)

To avoid entering your PAT or password constantly, you should configure Git to store your credentials securely.

  1. Generate a PAT: Go to GitHub $\rightarrow$ Settings $\rightarrow$ Developer settings $\rightarrow$ Personal access tokens $\rightarrow$ Tokens (classic). Generate a new token with appropriate permissions (usually repo). Copy this token immediately; you won't see it again.
  2. Configure Credential Manager: This command tells Git to use your OS's built-in credential manager (like macOS Keychain or Windows Credential Manager).

    git config --global credential.helper store
    
  3. First Clone & Authentication: The very first time you push or pull after running the above command, Git will prompt you. Enter your GitHub username and the PAT you generated as the password. The credential manager saves it for future use.

Example Clone Command:

git clone https://github.com/username/repo-name.git
Enter fullscreen mode Exit fullscreen mode

B. SSH (The Secure Way)

SSH (Secure Shell) uses a pair of cryptographic keys: a private key stored securely on your machine and a public key uploaded to GitHub. This method is the most secure and convenient once set up.

Pros Cons
Highly Secure: Uses key pairs; your private key never leaves your machine. Initial Setup: Requires key generation and configuration.
Convenient: Once set up, it requires zero authentication for pushes/pulls (if using an agent). Requires proper passphrase management.

When to use it: For your daily driver, primary development machine, or any sensitive codebase.

Detailed SSH Setup

This process requires a few crucial steps to work seamlessly:

๐Ÿ” Step 1: Generate SSH Key

Open your terminal and run the following command. The -t ed25519 flag uses the recommended secure algorithm.

ssh-keygen -t ed25519 -C "your_email@example.com"
Enter fullscreen mode Exit fullscreen mode
  • File Prompt: Press Enter to accept the default file location (~/.ssh/id_ed25519).
  • Passphrase Prompt: Enter a strong, memorable passphrase. This encrypts your private key file.

๐Ÿ”‘ Step 2: Add SSH Key to SSH Agent

The SSH agent manages your private keys and keeps them in memory, allowing you to use the key without entering the passphrase for every Git operation.

  1. Start the ssh-agent:

    eval "$(ssh-agent -s)"
    
  2. Add your private key to the agent:

    ssh-add ~/.ssh/id_ed25519
    

    (You will be prompted to enter the passphrase you created in Step 1.)

๐Ÿ“‹ Step 3: Copy Your Public Key

Copy the contents of the public key file (.pub extension) to your clipboard using a command like cat (for macOS/Linux/Git Bash):

cat ~/.ssh/id_ed25519.pub
Enter fullscreen mode Exit fullscreen mode

๐ŸŒ Step 4: Add SSH Key to GitHub

  1. Go to GitHub Settings: Navigate to your GitHub Profile $\rightarrow$ Settings $\rightarrow$ SSH and GPG keys.
  2. Add New SSH Key: Click the "New SSH key" button.
  3. Title: Give it a descriptive name (e.g., "Home PC").
  4. Key: Paste the public key you copied into the key field.
  5. Click "Add SSH key."

๐Ÿงช Step 5: Test SSH Connection

Test the connection from your machine to GitHub to ensure authentication works:

ssh -T git@github.com
Enter fullscreen mode Exit fullscreen mode

You should receive a confirmation message that includes your username.

๐Ÿ“ฅ Step 6: Clone Repository Using SSH

Now clone the repository using the SSH URL:

git clone git@github.com:username/repo-name.git
Enter fullscreen mode Exit fullscreen mode

3. The Tool Choice: Terminal vs. GitHub Desktop ๐Ÿ› ๏ธ

Once your chosen protocol is set up, you choose your interface for the git clone command.

A. Terminal / Command Line (The Power User's Way)

Using the terminal gives you the fastest, most granular control over Git operations and is the preferred method for most experienced developers.

Prerequisites: Git must be installed, and your chosen protocol (HTTPS/SSH) must be configured.

Setup Example (Using HTTPS and Credential Manager):

  1. Navigate to your Development Folder:

    cd ~/Projects/
    
  2. Clone the Repository:
    (Copy the HTTPS link from the GitHub repo page.)

    git clone https://github.com/your-user/your-repo.git
    
  3. Start Working:

    cd your-repo
    # Make changes...
    git add .
    git commit -m "Initial setup"
    git push  # Should prompt for credentials only once, then use the credential manager
    

B. GitHub Desktop (The Visual Workflow)

GitHub Desktop provides a simplified graphical interface (GUI) that abstracts away complex commands. It's excellent for beginners, visual learners, or for managing branches and commits quickly.

Prerequisites: You must have the GitHub Desktop application installed and be logged into your GitHub account within the app.

Setup Example (Visual Clone):

  1. Open GitHub Desktop.
  2. Go to File $\rightarrow$ Clone Repository.
  3. Select the GitHub.com tab.
  4. Choose the repository you want from your list.
  5. Specify the Local Path where the code should be stored.
  6. Click "Clone".

The application automatically handles the git clone command and uses the authentication it saved when you signed into the app. All subsequent pulls and pushes are done by clicking the Fetch and Push buttons.


4. Quick Reference Table

Method Interface Authentication Complexity Best For
HTTPS Terminal PAT + Credential Manager Medium Quick tests, public repos, shared/temporary machines.
SSH Terminal SSH Key Pair + Agent High Daily driver, maximum security, high-volume pushes/pulls.
GitHub Desktop GUI Saved Token / Credentials Low Beginners, visual management, non-technical collaborators.

Top comments (0)