SovranCode
Learn
Learn on SovranCodeCourses7 free learning paths→ExercisesPractice with live challenges→GuidesDirect answers for developers→E-booksFocused field guides→
Build
Build on SovranCodeTemplatesSovranCode team marketplace→Developer toolsFast browser utilities→
Connect
Connect on SovranCodeForumQuestions and discussions→JournalPractical development notes→AboutWhy SovranCode exists→PricingFree, Plus, and Student Plus→
Services
SearchCreate account
Explore SovranCodeLearn, practice, and build.
LearnCourses7 free learning paths→ExercisesPractice with live challenges→GuidesDirect answers for developers→E-booksFocused field guides→
BuildTemplatesSovranCode team marketplace→Developer toolsFast browser utilities→
ConnectForumQuestions and discussions→JournalPractical development notes→AboutWhy SovranCode exists→PricingFree, Plus, and Student Plus→
Search
Guides/Developer Setup/How to Install Git and Configure GitHub
All guides
How-to guide

How to Install Git and Configure GitHub

Install Git on Windows, macOS, or Linux, configure your identity and default branch, connect securely to GitHub, and push your first repository without guessing.

Beginner 22 min readUpdated September 17, 2026
Version Authenticate Push
A branching commit path connecting a developer workstation to a secure remote repository
LOCAL commit history REMOTE
QUICK ANSWER

Install a current Git release, then set the name and email that should appear on your commits. Choose main as the default initial branch. To connect GitHub, use HTTPS with a credential manager for the shortest setup or SSH for a durable key-based workflow. Finish by creating or cloning a repository, making one commit, and pushing it to origin.

01

Understand Git, GitHub, and the four places your work moves

Git and GitHub solve related but different problems. Git is the version-control program on your computer. It creates commits and branches without needing an internet connection. GitHub hosts remote Git repositories and adds collaboration features such as pull requests, reviews, issues, and automation.

The path from an edit to GitHub
PlaceWhat it containsCommand that moves work forward
Working treeFiles you are editing right now.git add
Staging areaThe exact changes selected for the next commit.git commit
Local repositoryCommits and branches stored in the hidden .git directory.git push
GitHub remoteA hosted copy that authorized collaborators can fetch and update.Pull request or git pull
A commit is not a backup on GitHub

git commit records work in the local repository. Nothing reaches GitHub until a remote is configured and the commit is pushed successfully.

An abstract Git workflow moving changed files through staging and commits to a secure remote repository
Working files become selected changes, local commits, and finally a pushed remote history.
02

Install Git on Windows, macOS, or Linux

  1. 01

    Download Git for Windows

    Use the official Windows download from git-scm.com. It includes Git, Git Bash, and Git Credential Manager for secure HTTPS authentication.

  2. 02

    Keep the sensible installer defaults

    Choose your preferred editor when asked. For PATH, the recommended option that exposes Git to the command line and third-party software works for most developers. Keep bundled OpenSSH unless your organization documents another client.

  3. 03

    Open a fresh terminal

    Close existing terminals and editor windows after installation. Reopen PowerShell, Command Prompt, Git Bash, or your editor terminal before verifying Git.

Official Windows download

Git for WindowsOfficial Git download page for Windows.Git for Windows projectRelease notes and Windows-specific project information.
Verify Git on Windows
git --version
where.exe git
git config --list --show-origin
Git Bash is optional

Git Bash provides a Unix-like shell and common tools on Windows. Git itself also works from PowerShell, Command Prompt, and editor terminals.

03

Configure your commit identity and defaults

Git records an author name and email inside every commit. These values do not sign you in to GitHub; GitHub uses them to associate a pushed commit with an account. Use the identity you intend to publish in repository history.

Set your global Git identity
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
Keep your email private when needed

GitHub can provide a no-reply commit email in account email settings. Copy the exact address GitHub shows, set it in Git, and enable the account option that blocks command-line pushes exposing a private email if that matches your privacy goal.

Inspect the effective configuration
git config --global --list
git config --list --show-origin
git config --get user.name
git config --get user.email
git config --get init.defaultBranch
Global settings versus repository settings
ScopeUse it forExample
--globalYour normal identity and defaults across repositories for this user account.git config --global user.name "Your Name"
--localA different identity or rule for the repository in the current folder.git config --local user.email "work@example.com"
--systemMachine-wide policy for every user; normally managed by an administrator.Avoid changing it unless you manage the computer.
Configuration is not authentication

user.name and user.email label commits. HTTPS credentials, an SSH key, or GitHub CLI authentication separately prove that GitHub should allow a fetch or push.

04

Choose HTTPS or SSH for GitHub

Both protocols are secure when configured correctly
MethodBest fitHow authentication works
HTTPSMost beginners, managed networks, and computers already using Git Credential Manager or GitHub CLI.A browser sign-in, credential manager, GitHub CLI, or personal access token supplies credentials. Your account password is not accepted for Git operations.
SSHDevelopers who want a durable key-based terminal workflow or regularly use several repositories.A private key stays on the computer; the matching public key is added to GitHub.
Start with one method

A repository remote uses either an HTTPS URL or an SSH URL. Both reach the same repository. Pick one, verify it, and only change the remote URL if your workflow later requires the other.

05

Option A: Configure GitHub over HTTPS

HTTPS is the shortest setup for many developers. Git for Windows includes Git Credential Manager; other platforms can use a compatible credential helper or GitHub CLI. GitHub CLI can authenticate through the browser and configure Git to use the resulting credentials.

  1. 01

    Install GitHub CLI only if you want its workflow

    The gh command is separate from Git. Install it from the official GitHub CLI instructions, or keep your operating system's supported credential helper.

  2. 02

    Authenticate to GitHub

    Run gh auth login, choose GitHub.com and HTTPS, then follow the browser flow. Review the requested permissions before authorizing.

  3. 03

    Verify the account

    Run gh auth status. For plain Git, the first authenticated clone, fetch, or push may open a credential-manager sign-in instead.

GitHub CLI HTTPS setup
gh auth login
gh auth status

# Inspect the repository URL later
git remote -v

HTTPS authentication references

GitHub CLI authenticationOfficial gh auth login options and behavior.GitHub remote repositoriesSupported remote URL formats and authentication overview.
Do not enter your GitHub password into Git

Password authentication for Git operations is not supported. Use a credential manager, GitHub CLI, SSH, or a deliberately scoped personal access token when a tool specifically requires one.

06

Option B: Configure GitHub with an SSH key

  1. 01

    Check for an existing key

    List the .ssh directory before generating anything. A managed or older computer may already have keys with documented owners and purposes.

  2. 02

    Generate a modern key pair

    Use Ed25519 when your environment supports it. Replace the sample email with the address associated with your GitHub account and choose a strong passphrase.

  3. 03

    Load the private key into the agent

    Start or use your operating system's SSH agent, then add the private key. Windows, macOS, and Linux agent setup differs, so follow GitHub's platform tab when the generic command is not enough.

  4. 04

    Add only the public key to GitHub

    Copy id_ed25519.pub, then open GitHub Settings > SSH and GPG keys > New SSH key. Give it a device-specific title and paste the public key.

  5. 05

    Test the connection

    Run ssh -T git@github.com, verify GitHub's host fingerprint against the official documentation on first connection, and confirm the success message names your account.

Generate and inspect an SSH key
ls -al ~/.ssh
ssh-keygen -t ed25519 -C "you@example.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub
ssh -T git@github.com
Never upload or paste the private key

id_ed25519 is private and must remain secret. GitHub needs only the file ending in .pub. If a private key is exposed, remove its public key from GitHub and replace the pair.

Official SSH setup

Generate and add an SSH keyPlatform-specific agent and key-generation instructions.Add the public key to GitHubGitHub account steps for an authentication key.Test the SSH connectionExpected messages and official host-fingerprint guidance.
07

Create a local repository and push it to GitHub

For an existing local project, create a new empty GitHub repository without initializing a README, license, or .gitignore. That avoids an unrelated remote commit before your first push. Replace the example owner and repository URL below.

Initialize and make the first commit
mkdir hello-git
cd hello-git
printf "# Hello Git\n" > README.md
git init
git add README.md
git status
git commit -m "Create project README"
git log --oneline
Add an HTTPS remote and push
git remote add origin https://github.com/OWNER/REPOSITORY.git
git remote -v
git push -u origin main

The first push is complete when

  • git status reports a clean working tree after the commit.
  • git remote -v shows the GitHub repository you intended to use.
  • git push finishes without an authentication or non-fast-forward error.
  • The main branch and README appear on the correct GitHub repository page.
  • git branch -vv shows main tracking origin/main.
The -u flag saves the upstream

After git push -u origin main, plain git push and git pull know which remote branch belongs to the current local branch.

08

Clone a repository and use the everyday workflow

If the GitHub repository already contains work, clone it instead of running git init. Cloning creates the folder, downloads the history, adds origin, and checks out the default branch.

Clone over HTTPS
git clone https://github.com/OWNER/REPOSITORY.git
cd REPOSITORY
git remote -v
git status
A small, reviewable work cycle
git switch -c docs/improve-readme
# Edit files
git status
git diff
git add README.md
git diff --staged
git commit -m "Improve setup instructions"
git push -u origin docs/improve-readme
Commands that look similar but answer different questions
CommandWhat it doesWhen to use it
git fetchDownloads remote branches and commits without changing your working branch.Inspect remote work before integrating it.
git pullFetches and then integrates the selected upstream branch.Update a clean branch when you understand the integration policy.
git pushUploads local commits to a remote branch.Publish reviewed commits; it does not upload uncommitted edits.
git switch -cCreates and checks out a new branch.Start isolated feature or documentation work.
09

Add a .gitignore and keep secrets out of history

A .gitignore file prevents matching untracked files from being added. It does not remove a file that Git already tracks, and it cannot erase a secret from earlier commits.

A small cross-project .gitignore example
.env
.env.*
!.env.example
node_modules/
dist/
build/
.DS_Store
Thumbs.db
*.log
Check why a path is ignored
git status --ignored
git check-ignore -v .env
Rotate exposed credentials first

If a token, password, or private key is committed, revoke or rotate it immediately. Deleting the file in a later commit does not remove the value from Git history or existing clones.

Ignore-file resources

GitHub gitignore templatesMaintained starting points for languages, frameworks, and editors.Removing sensitive dataGitHub's response and history-rewrite guidance after exposure.
10

Troubleshoot common Git and GitHub errors

Use the exact error to choose the fix
ProblemWhat it usually meansWhat to check
git is not recognizedThe terminal has an old PATH or Git was not installed for this shell.Restart terminals and editors, then run where.exe git or command -v git.
Author identity unknownuser.name or user.email is missing in the effective configuration.Set the intended global or repository-local identity and inspect --show-origin.
Repository not foundThe URL is wrong, the repository is private, or the authenticated account lacks access.Open the repository in GitHub, copy its Code URL again, and verify the signed-in account.
Permission denied (publickey)GitHub did not accept a key offered by the SSH client.Check ssh -vT git@github.com, the loaded agent keys, the public key in GitHub, and which ssh executable Git uses.
Authentication failed over HTTPSCached credentials are expired, for another account, or insufficiently authorized.Use the credential manager or gh auth status; do not retry with the account password.
Remote origin already existsThe repository already has a remote named origin.Inspect git remote -v, then use git remote set-url origin URL if the existing URL is wrong.
src refspec main does not match anyNo commit exists yet, or the current branch has another name.Run git status and git branch --show-current; create a commit before pushing.
Push rejected: non-fast-forwardGitHub contains commits your branch does not have.Fetch first, inspect the remote history, then merge or rebase according to the project workflow. Do not force-push blindly.
A focused diagnostic snapshot
git --version
git status
git branch -vv
git remote -v
git config --list --show-origin

# Add this only for SSH connection debugging
ssh -vT git@github.com
Inspect before deleting configuration

Most first-day problems are a stale terminal, the wrong repository URL, the wrong authenticated account, or a branch that has no commit. The diagnostic commands above separate those cases without destroying work.

11

Final Git and GitHub setup checklist

You are ready to collaborate when

  • git --version reports a recent Git 2.x release from the expected path.
  • Your commit name and email are deliberate and visible in git config.
  • New repositories default to main unless a project specifies another convention.
  • Exactly one tested GitHub authentication route—HTTPS or SSH—works.
  • You can clone an existing repository and push a new branch.
  • You understand the difference between working files, staged changes, local commits, and the GitHub remote.
  • Secrets, private keys, dependencies, and generated output are excluded appropriately.

Keep learning from primary references

Pro Git bookThe official, free Git book.Git referenceAuthoritative command documentation.GitHub Git basicsGitHub's current setup and remote-workflow documentation.

Frequently asked questions

What is the difference between Git and GitHub?

Git is the local version-control system that creates commits and branches. GitHub is a hosting and collaboration service for Git repositories. You can use Git without GitHub, and GitHub repositories are accessed through Git-compatible tools.

Do I need a GitHub account to use Git?

No. Git works locally and can synchronize with many hosting services or private servers. You need a GitHub account only for repositories and collaboration features hosted on GitHub.

Should I use HTTPS or SSH with GitHub?

HTTPS with a credential manager or GitHub CLI is usually the shortest beginner setup. SSH is excellent for a durable key-based terminal workflow. Both are secure when configured correctly; use the one your team supports.

Can I use my GitHub password with git push?

No. GitHub does not accept account passwords for Git operations. Use a supported credential manager, GitHub CLI, an SSH key, or a deliberately scoped personal access token when required.

Which email should I set in Git?

Use an email verified on your GitHub account if you want commits attributed to that account. Use GitHub's provided no-reply address when you do not want a personal email published in commit metadata.

Is an SSH public key safe to share with GitHub?

Yes. The file ending in .pub is designed to be shared. The private key without .pub must remain secret and should be protected with a passphrase.

Why does GitHub not show my commit after git commit?

git commit updates only the local repository. Check git remote -v, then push the branch. Confirm that the push succeeded and that you are viewing the same repository and branch on GitHub.

How do I change an existing repository from HTTPS to SSH?

Copy the SSH URL from the repository's Code menu, then run git remote set-url origin followed by that URL. Verify the result with git remote -v and test SSH first.

Should I commit package dependencies or build output?

Usually commit dependency manifests and lockfiles, not downloaded dependency folders. Build-output policy varies by project. Follow the repository's existing .gitignore and deployment process.

What should I do if I committed a secret?

Revoke or rotate the credential immediately, then follow GitHub's sensitive-data removal guidance. A later deletion commit does not make the earlier secret safe.

On this page
Understand Git, GitHub, and the four places your work movesInstall Git on Windows, macOS, or LinuxConfigure your commit identity and defaultsChoose HTTPS or SSH for GitHubOption A: Configure GitHub over HTTPSOption B: Configure GitHub with an SSH keyCreate a local repository and push it to GitHubClone a repository and use the everyday workflowAdd a .gitignore and keep secrets out of historyTroubleshoot common Git and GitHub errorsFinal Git and GitHub setup checklistFAQ
CONTINUE LEARNING

Put the answer to work.

COURSEJavaScript courseE-BOOKJavaScript: From Values to Applications
RELATED GUIDES

Keep moving.

Browse all guides
How-to guideBeginner

How to Install Node.js and npm: Complete Setup Guide

Install Node.js and npm correctly on Windows, macOS, or Linux, verify your setup, create a first project, and fix the most common PATH and permission problems.

20 min readUpdated Sep 2026
Open guide
How-to guideBeginner

How to Install Python: A Safe Setup Guide

Install a current Python release on Windows, macOS, or Linux; prove which interpreter and pip you are using; create an isolated project environment; and fix the common setup failures without damaging your system Python.

18 min readUpdated Sep 2026
Open guide
SOURCES

Official documentation

  • Git — Installing Git
  • Git — First-time setup
  • GitHub Docs — Set up Git
  • GitHub Docs — About authentication
  • GitHub Docs — Connect with SSH
  • GitHub Docs — About remote repositories
  • GitHub Docs — Push commits
  • GitHub Docs — Get remote changes
THE SOVRANCODE PLATFORM

Learn enough to build something real.

Start learning
SovranCode

A free-first programming platform for people who learn best by understanding, practicing, and building.

● Core learning content is free
FollowYouTubePinterestX
LearnHTML courseCSS courseJSJavaScript coursePython courseC courseSQL courseGit courseDeveloper guidesAll exercises
BuildTemplate marketBuyer libraryTemplate licensesDeveloper toolsE-books
CommunityForumJournalContact
CompanyPricing previewAboutServicesPrivacyEnglish edition. Additional languages will be published only after full editorial review.
© 2026 SovranCode · Built for curious minds.Next.js · Node.js · PostgreSQL