0% found this document useful (0 votes)
20 views4 pages

Git & GitHub Version Control Guide

This guide provides an expanded overview of Git, GitHub, and version control, including graphical diagrams and command explanations. It covers the process of creating and merging feature branches, the differences between merging and rebasing, and offers an undo decision guide for various Git commands. Additionally, it outlines a standard GitHub workflow for team collaboration and includes a one-page cheatsheet for quick reference.

Uploaded by

mrfrontman782
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

Git & GitHub Version Control Guide

This guide provides an expanded overview of Git, GitHub, and version control, including graphical diagrams and command explanations. It covers the process of creating and merging feature branches, the differences between merging and rebasing, and offers an undo decision guide for various Git commands. Additionally, it outlines a standard GitHub workflow for team collaboration and includes a one-page cheatsheet for quick reference.

Uploaded by

mrfrontman782
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Git, GitHub & Version Control — Expanded Guide

Senior-dev curation with graphical diagrams and inline command explanations.

Generated: 2025-09-24 [Link] UTC

Branch Graph: Feature branch and merge


Diagram shows a feature branch diverging from main and later merging back. Solid line = main; dashed
= feature branch.

How to create & merge a feature branch


git checkout -b feat/my-feature
# Work: git add, git commit ...
git push -u origin feat/my-feature
# Open a PR on GitHub and merge after review
Explanation: Create a short-lived branch for the feature. Push it and open a PR. The PR is the review
gate — merge when approved.

Merge vs Rebase

Explanation: Merging preserves the original history and creates a merge commit; rebasing rewrites
feature commits to sit on top of main creating a linear history. Rebase locally; avoid rewriting published
history.

Undo Decision Guide

Inline explanations: - git restore → Discard changes in working directory for that file. - git reset --hard
HEAD~1 → Move branch back one commit, deleting newer commits (destructive). Use only locally. - git
revert → Create a new commit that undoes the specified commit (safe for shared repos). - git stash →
Temporarily store uncommitted changes.

GitHub Workflow (Feature Branch → PR → Merge)

Explanation: This is the canonical flow for team collaboration. Keep main protected; require PR reviews
and CI checks before merging.

Inline Command Explanations (What, When, Example)

git init
Creates a new local Git repository. Use when starting a new project.
git init
git clone
Copies a remote repository locally, creating a working copy.
git clone git@[Link]:user/[Link]

git status
Shows current changes and untracked files. Use frequently before committing.
git status

git add
Stages changes to be included in the next commit.
git add [Link]

git commit -m "msg"


Saves staged changes as a commit with the provided message.
git commit -m "Add README"

git push
Upload local commits to the remote repository (e.g., origin).
git push origin main

git pull
Fetch remote changes and merge into current branch. Use to sync before working.
git pull --rebase

git branch -b name


Creates a new branch and switches to it.
git checkout -b feat/x

git merge
Merge another branch into the current branch.
git merge feat/x

git rebase
Replay commits onto another base; creates linear history. Use carefully.
git rebase main
Appendix — One-page cheatsheet
Quick visual and command references for daily use.

You might also like