SkillAgentSearch skills...

Git

A complete Git & GitHub version control practice repository with commands, workflows, and examples.

Install / Use

/learn @mdzaheerjk/Git
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Git — Complete Reference Notes

Every Git concept and command you need: setup, branching, merging, rebasing, undoing, collaboration, advanced workflows, and more.


Setup & Configuration

Identity (required before first commit)

git config --global user.name  "Alice Smith"
git config --global user.email "alice@example.com"

Configuration levels

# Three levels — each overrides the one above
git config --system   # /etc/gitconfig        — all users on machine
git config --global   # ~/.gitconfig           — current user
git config --local    # .git/config            — current repo (default)

Common global settings

git config --global core.editor       "code --wait"     # VS Code
git config --global core.editor       "vim"
git config --global core.autocrlf     input             # Linux/Mac
git config --global core.autocrlf     true              # Windows
git config --global core.ignorecase   false
git config --global init.defaultBranch main
git config --global push.default      current           # push to same-name remote branch
git config --global pull.rebase       false             # pull = merge (default)
git config --global pull.rebase       true              # pull = rebase
git config --global merge.tool        vimdiff
git config --global diff.tool         vscode
git config --global color.ui          auto
git config --global core.pager        less
git config --global credential.helper cache             # cache password
git config --global credential.helper store             # store password on disk
git config --global alias.st          status
git config --global alias.co          checkout
git config --global alias.lg         "log --oneline --graph --decorate --all"

View & edit config

git config --list                          # all settings
git config --list --show-origin            # with file locations
git config user.name                       # read one value
git config --global --edit                 # open global config in editor
git config --global --unset user.email     # remove a setting
cat ~/.gitconfig                           # view raw file

Initialise & Clone

# New repository
git init                            # init in current directory
git init my-project                 # init in new directory
git init --bare repo.git            # bare repo (no working tree — for servers)

# Clone
git clone https://github.com/user/repo.git
git clone https://github.com/user/repo.git my-folder   # into custom folder
git clone git@github.com:user/repo.git                 # SSH
git clone --depth 1 https://github.com/user/repo.git   # shallow clone (latest only)
git clone --depth 1 --branch main https://...          # shallow specific branch
git clone --single-branch --branch dev https://...     # clone one branch only
git clone --bare https://github.com/user/repo.git      # bare clone
git clone --mirror https://github.com/user/repo.git    # full mirror (for backup)
git clone --recurse-submodules https://...             # include submodules

The Three Areas

Working Directory  →  Staging Area (Index)  →  Repository (.git)
     edit                  git add                git commit
     ←──── git restore ────┤                     │
     ←──────────────── git restore HEAD ─────────┘

Status & Inspection

git status                          # full status
git status -s                       # short format
git status -sb                      # short + branch info

# Short format symbols:
# ?? = untracked   M = modified   A = added   D = deleted
# R = renamed      C = copied     U = updated but unmerged
# First column = staging area, second = working directory

Staging (git add)

git add file.txt                    # stage one file
git add src/                        # stage entire directory
git add .                           # stage everything in current dir
git add -A                          # stage all: new + modified + deleted
git add -u                          # stage modified + deleted (not new files)
git add *.py                        # glob pattern
git add -p                          # interactive patch — choose hunks to stage
git add -p file.txt                 # patch mode on one file
git add -i                          # interactive mode (menu)
git add -N file.txt                 # mark as "intent to add" (shows in diff)

Unstage

git restore --staged file.txt       # unstage (keep working dir changes)
git restore --staged .              # unstage everything
git reset HEAD file.txt             # older equivalent
git reset HEAD                      # unstage all

Committing

git commit                          # open editor for message
git commit -m "feat: add login page"
git commit -am "fix: typo"          # stage tracked files + commit (skips git add)
git commit --allow-empty -m "chore: trigger CI"
git commit -v                       # show diff in editor when writing message
git commit --no-verify              # skip pre-commit hooks

# Amend the most recent commit (only before pushing)
git commit --amend                  # edit message + include staged changes
git commit --amend -m "new message" # just change message
git commit --amend --no-edit        # add staged changes, keep message
git commit --amend --reset-author   # update author info

Conventional Commits format

<type>(<scope>): <short description>

[optional body]

[optional footer]

Types: feat, fix, docs, style, refactor, test, chore, perf, ci, build, revert

git commit -m "feat(auth): add JWT token refresh"
git commit -m "fix(api): handle null response from payment gateway"
git commit -m "docs: update README with setup instructions"

Viewing History

git log                             # full log
git log --oneline                   # one line per commit
git log --oneline --graph           # ASCII branch graph
git log --oneline --graph --all     # all branches in graph
git log --oneline --graph --decorate --all   # with branch/tag labels
git log -n 5                        # last 5 commits
git log -5                          # same
git log --since="2024-01-01"
git log --until="2024-12-31"
git log --since="2 weeks ago"
git log --after="yesterday"
git log --author="Alice"
git log --author="Alice\|Bob"       # multiple authors
git log --grep="login"              # search commit messages
git log --grep="fix" --all-match    # multiple greps (AND)
git log -S "function login"         # pickaxe — commits that added/removed string
git log -G "regex pattern"          # pickaxe with regex
git log --diff-filter=A             # only commits that Added files
git log --diff-filter=D             # only commits that Deleted files
git log -- path/to/file             # commits touching this file
git log --follow -- path/to/file    # follow renames
git log --stat                      # show file change stats
git log --patch                     # show full diffs
git log --patch -p file.txt         # diffs for one file
git log --pretty=format:"%h %an %ar %s"   # custom format
git log --pretty=oneline
git log --simplify-by-decoration    # only commits with tags/branches
git log main..feature               # commits in feature not in main
git log main...feature              # commits in either, not both (symmetric diff)
git log HEAD~5..HEAD                # last 5 commits
git shortlog                        # grouped by author
git shortlog -sn                    # commit count per author, sorted

Single commit inspection

git show abc1234                    # show commit
git show HEAD                       # show latest commit
git show HEAD~2                     # 2 commits back
git show HEAD:file.txt              # file contents at HEAD
git show v1.0:src/app.py            # file at a tag
git show --stat abc1234             # just the stats
git show --name-only abc1234        # just the filenames changed

Diffing

git diff                            # working dir vs staging area (unstaged changes)
git diff --staged                   # staging area vs last commit (what will commit)
git diff HEAD                       # working dir vs last commit (all changes)
git diff abc1234                    # working dir vs that commit
git diff abc1234 def5678            # between two commits
git diff main..feature              # between two branches (tips)
git diff main...feature             # since they diverged (common ancestor)
git diff HEAD~3 HEAD                # last 3 commits
git diff HEAD~3 HEAD -- file.txt    # for one file
git diff --stat                     # summary only
git diff --name-only                # just filenames
git diff --name-status              # filenames + A/M/D status
git diff --word-diff                # word-level diff
git diff --color-words              # coloured word diff
git diff -w                         # ignore whitespace
git diff -b                         # ignore whitespace changes
git diff --ignore-blank-lines
git difftool                        # open in configured diff tool

.gitignore

# File patterns
*.log              # all .log files anywhere
*.py[cod]          # .pyc, .pyo, .pyd
!important.log     # negate: do NOT ignore this file
build/             # ignore directory
/build             # only ignore at root level
doc/*.txt          # ignore txt only in doc/ (not doc/sub/)
doc/**/*.txt       # ignore txt in doc/ and all subdirs
**/logs            # logs/ in any subdirectory
logs/**            # everything inside logs/

# Check what's being ignored
git check-ignore -v file.txt        # why is this file ignored?
git status --ignored                # show ignored files
git ls-files --others --ignored --exclude-standard

# Force add ignored file
git add -f ignored-file.txt

# Stop tracking a file that's now in .gitignore
View on GitHub
GitHub Stars8
CategoryDevelopment
Updated4d ago
Forks0

Security Score

90/100

Audited on Apr 5, 2026

No findings