Skip to main content

Git Documentation 📚

Table of Contents

  1. Getting Started
  2. Configuration
  3. Creating Repositories
  4. Basic Commands
  5. Branching
  6. Merging and Rebasing
  7. Stashing
  8. Remote Repositories
  9. Tags
  10. Undoing Changes
  11. Miscellaneous
  12. Help

Getting Started 🚀

Install Git 🛠️

  • Windows: Download here
  • macOS: Install via Homebrew
    brew install git
    
  • Linux:
    sudo apt-get install git
    

Verify Installation ✅

git --version

Configuration 🛠️

Set User Information 👤

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Check Configuration 📋

git config --list

Creating Repositories 📁

Initialize a Repository 🆕

git init

Clone a Repository 📥

git clone https://github.com/user/repo.git

Basic Commands 📝

Check Status 📊

git status

Add Changes ➕

git add <file>  # Add a specific file
git add .       # Add all changes

Commit Changes 💾

git commit -m "Commit message"

View Commit History 📜

git log

View Changes (Diff) 🔍

git diff

Branching 🌿

Create a New Branch 🆕

git branch <branch-name>

List Branches 📃

git branch

Switch Branches 🔀

git checkout <branch-name>

Create and Switch Branch 🌱

git checkout -b <branch-name>

Merging and Rebasing 🔄

Merge Branches 🔀

git merge <branch-name>

Rebase Branches ↩️

git rebase <branch-name>

Stashing 💼

Stash Changes 👜

git stash

Apply Stashed Changes 🔙

git stash apply

List Stashes 📃

git stash list

Remote Repositories 🌍

Add Remote Repository ➕

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

List Remote Repositories 🌐

git remote -v

Push to Remote Repository 📤

git push origin <branch-name>

Pull from Remote Repository 📥

git pull origin <branch-name>

Tags 🏷️

Create a Tag 🏷️

git tag <tag-name>

List Tags 📋

git tag

Push Tags to Remote 📤

git push origin <tag-name>

Undoing Changes ↩️

Unstage Changes ❌

git reset <file>

Revert Changes to a File 🔄

git checkout -- <file>

Amend Last Commit ✏️

git commit --amend

Miscellaneous 🌐

Show Commit Graph 🌲

git log --graph --oneline --all

Show Commit History of a File 📝

git log <file>

Alias Commands 📝

git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit

Help 🆘

General Help 📘

git help

Command-specific Help 📚

git help <command>

This Git documentation should serve as a quick reference guide for essential Git commands and their use cases. Feel free to add or customize it according to your needs. Happy coding! 👩‍💻👨‍💻