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:
- Launch your chosen terminal emulator (macOS Terminal, Linux Bash/Zsh, or Git Bash on Windows).
- Execute global configuration directives matching your authentic developer credentials:
git config --global user.name "Mohamed Reda" git config --global user.email "[email protected]" - 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:
- Authenticate into your GitHub account.
- 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). - 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.





