Getting Started with Git: A Practical Guide from Local Setup to Remote Push

Verifying the Installation

Open your terminal and confirm Gits available:

git --version

Setting Up Identity

Two scopes exist for identity configuration—global (applied everywhere) or repository-local.

Global Setup

git config --global user.name "your-username"
git config --global user.email "your-email@example.com"

To inspect global values:

git config --global user.name
git config --global user.email

The global settings reside in ~/.gitconfig.

Repository-Local Setup

Run these commands within a specific repository:

git config user.name "your-username"
git config user.email "your-email@example.com"

Verify with:

git config user.name
git config user.email

These values are stored in .git/config inside the repository.

SSH Key Association

Generate an SSH key pair using the Git Bash terminal (accessible from the Git installation directory):

ssh-keygen -t rsa -b 4096 -C "your-username"

Locate the public key (typically ~/.ssh/id_rsa.pub) and add its contents to the SSH keys section of your remote Git hosting service.

Creating a Local Repository

Navigate to your desired project directory and initialize it as a Git repository:

git init

This creates a hidden .git folder, turning the directory into a local repository.

Working with Branches

Create a new branch:

git branch feature-branch

Switch to it:

git checkout feature-branch

Alternatively, create and switch in a single step:

git checkout -b feature-branch

To remove a local branch:

git branch -d feature-branch

Connecting to a Remote Repository

Link your local repository to a remote origin:

git remote add origin git@github.com:user/repo.git

If you need to reset the remote URL later:

git remote set-url origin git@github.com:user/repo.git

To detach the remote entirely:

git remote remove origin

The Core Workflow

Add a file to the staging area:

git add .

Review staged changes:

git status

Commit the staged snapshot with a descriptive message:

git commit -m "describe your changes"

Push the commit to the remote branch for the first time:

git push -u origin feature-branch

On subsequent pushes, simply use:

git push

If the remote contains changes you don't have locally, fetch and integrate them first:

git pull origin feature-branch

After a successful initial push, verify that your files appear in the remote repository. The recurring development cycle will be: stage, review, commit, and push.

Tags: Git Version Control Tutorial ssh Branching

Posted on Wed, 13 May 2026 01:53:34 +0000 by themightydude