Mohamed Reda Tech Logo
HomeArticlesApplicationsPhonesTutorialsTools
AR
Mohamed Reda Tech Logo
Mohamed Reda Tech

Tech articles, applications, and digital tools & services.

Follow Us
TelegramYouTube

Quick Links

ArticlesApplicationsTutorialsToolsPhones

Help

About UsAbout the authorEditorial policyContact Us

Stay Connected

Get notified when new articles, tools, and app updates are released.

© 2026 MR. All rights reserved.

Privacy Policy•Terms of Service•
Hands-on Git & GitHub: Initialize, Branch, Commit, and Push Your First Repository · Mohamed Reda Tech
  1. Home
  2. Tutorials
  3. Hands-on Git & GitHub: Initialize, Branch, Commit, and Push Your First Repository
Tutorials

Hands-on Git & GitHub: Initialize, Branch, Commit, and Push Your First Repository

A step-by-step practical terminal tutorial for developers: configuring global Git identity, local repository initialization, staged index commits, remote origin binding, and pushing code securely to GitHub.

By Mohamed RedaPublished: October 15, 2026Updated: November 11, 20264 min read
Local Working Tree Staging Area and Remote Repository Pipeline

Theoretical abstraction cannot substitute for tactile terminal execution when mastering distributed version control systems. Software engineers internalize Git mechanics not through slide decks, but through iterative shell interactions: staging atomic tree diffs, crafting semantic commit logs, configuring cryptographically verified upstream remotes, and managing collaborative pull requests. If you have engineered your initial web layout, microservice, or automation script and require an authoritative walkthrough to stage and push this artifact securely to GitHub, this end-to-end practical manual delivers the exact terminal commands required.

1. Phase 1: Environment Provisioning and Global Identity Mapping

Prior to initializing a repository database, Git mandates registering an authoritative committer identity to cryptographically bind your authorship metadata to all historical commits:

  1. Launch your chosen terminal emulator (macOS Terminal, Linux Bash/Zsh, or Git Bash on Windows).
  2. Execute global configuration directives matching your authentic developer credentials:
    git config --global user.name "Mohamed Reda"
    git config --global user.email "developer@example.com"
    
  3. Verify configuration bindings across global dotfiles:
    git config --list --show-origin
    

2. Phase 2: Local Repository Initialization (git init)

Navigate shell context into your project's root filesystem directory:

# Navigate to target directory
cd ~/projects/my-first-service

# Initialize local Git object repository
git init

Executing git init instantiates the authoritative, hidden .git database directory, allocating core object subdirectories (objects/, refs/, HEAD) that will encapsulate your project's immutable Directed Acyclic Graph (DAG) state.

3. Phase 3: The Staging Index and Atomic Commits (git add & commit)

Inspect the local working tree status using the primary diagnostic command:

git status

Uncommitted source files appear highlighted in red under "Untracked files". To transition these filesystem assets into the intermediate staging index cache, stage files selectively or comprehensively:

# Stage all project files recursively
git add .

# Alternatively, stage an isolated component atomically
git add server.js package.json

Verify staging index transitions via git status. Files display in green under "Changes to be committed". Commit this staged state permanently to the object repository:

git commit -m "feat(core): initialize project scaffold with baseline configuration"

Professional Commit Semantics: Follow the Conventional Commits specification (e.g., feat:, fix:, chore:, docs:) to maintain machine-readable changelogs.

4. Phase 4: Remote Upstream Binding on GitHub

With local state safely committed, bind your local tree to a remote cloud repository on GitHub:

  1. Authenticate into your GitHub account.
  2. Click New Repository. Define a URL-safe repository identifier (e.g., my-first-service), configure visibility (Public or Private), and leave initialization options unchecked (avoiding auto-generated README/License conflicts).
  3. Click Create repository. Copy the provided HTTPS or SSH remote target URL.

5. Phase 5: Branch Normalization and Remote Egress (git push)

Execute terminal commands to normalize the primary trunk pointer and push your local commits upstream:

# Explicitly rename the initial branch pointer to standardized 'main'
git branch -M main

# Register remote upstream origin alias
git remote add origin https://github.com/your-username/my-first-service.git

# Push local commits and bind upstream tracking (-u flag)
git push -u origin main

When prompted for credentials, authenticate via GitHub CLI (gh auth login) or supply a fine-grained Personal Access Token (PAT) configured with repository scopes.

6. Essential Daily Git Commands Reference

Command Operational Capability
git log --oneline --graph Renders visual commit DAG topology directly within terminal pager
git checkout -b feature/telemetry Instantiates and mounts an isolated feature branch pointer atomically
git pull origin main Fetches remote commits and executes non-conflicting fast-forward merges
git diff --staged Inspects precise unified diff hunks committed to the staging index

Operational Summary

You have successfully completed a full distributed version control lifecycle: initializing an isolated local DAG repository, staging semantic source code deltas, committing immutable cryptographic trees, and binding upstream tracking to cloud infrastructure on GitHub. Embed this terminal cadence into every software engineering initiative.

Related articles

Tutorials

Google Find My Device guide: locate, lock, or erase your lost Android phone remotely

Lost or stolen phone? A practical guide to Google's Find My Device: what to set up before you lose it, how to locate, ring, lock, or erase it remotely, and the real limits of each option.

November 28, 20263 min read
Tutorials

Comments(0)

Leave a comment

Share your thoughts or questions. Your email will not be published.

No comments yet. Be the first to share your thoughts!

Frequently asked questions

How do I securely connect my local machine to GitHub without typing passwords?+

Generate an asymmetric SSH keypair via 'ssh-keygen -t ed25519', copy your public key, and register it in GitHub under Settings -> SSH and GPG keys.

What is the difference between 'git pull' and 'git fetch'?+

'git fetch' downloads commits and refs from the remote repository without merging them into your local branches. 'git pull' executes 'git fetch' followed immediately by 'git merge'.

Why is a '.gitignore' file essential for every repository?+

A '.gitignore' prevents unneeded, heavy, or sensitive files (such as node_modules, build outputs, and .env credentials) from being accidentally committed to public version history.

Translate Chrome Pages on Android: Choose a Language and Manage Automatic Translation

Request page translation, choose its destination language and manage automatic or excluded languages. Learn how these differ from Chrome’s interface language.

November 28, 20264 min read
Tutorials

Chrome Reading Mode on Android: Adjust Text, Fonts and Background Colors

Open Reading mode for supported pages, adjust font style and size, and choose light, sepia or dark backgrounds. Understand unavailable pages and the difference from audio playback.

November 24, 20264 min read
Tutorials

Android Privacy Dashboard: Review Camera and Microphone Use and Change Permissions

Find permission activity, identify the app and access time, then change one permission and test the feature. Understand Android 12 and 13 history windows and the limits of the log.

November 24, 20264 min read