Master Git Hub Programming From Scratch

Clear, interactive, and structured coding lessons designed for absolute beginners.

Initial Configuration

To configure Git and connect it to your GitHub account for the first time, you need to set up your identity globally and configure your default settings. This process ensures your local code changes are correctly attributed to your GitHub profile when you push them.

1. Set Your Identity (Required)

Open your terminal (Mac/Linux) or Git Bash (Windows) and type the following commands. Make sure the email matches the one registered to your GitHub Account.

  • Set your name:

    git config --global user.name "your_name"
  • Set your email:

    git config --global user.email "your_email@example.com"

2. Set the Default Branch Name

GitHub defaults to using main as the primary branch for all new repositories. Match this convention locally by changing your default initial branch name:

  • git config --global init.defaultBranch main

3. Verify Your Settings

You can confirm that your global configurations were saved properly by listing them:

  • git config --list

4. Connect a Local Project to GitHub

Once your identity is configured, you can initialize a local folder and push it to a new, empty repository on GitHub.

  • Step Command / Action Description
    Initialize git init Turns your current local directory into a Git repository.
    Stage Files git add . Tracks and prepares all files in the directory for your commit.
    Commit git commit -m "Initial commit" Saves a snapshot of your staged files locally.
    Link Remote git remote add origin Connects your local project to your remote GitHub repository URL.
    Push git push -u origin main Pushes your local main branch code up to GitHub.