Certainly! Here's a revised and formatted version of your Git Cheat Sheet in Markdown:
Git Cheat Sheet
Git is the free and open-source distributed version control system responsible for everything GitHub-related that happens locally on your computer. This cheat sheet features the most important and commonly used Git commands for easy reference.
Installation & GUIs🔽
GitHub provides platform-specific installers for Git, offering both a command line tool and a graphical user interface (GUI) for day-to-day interaction, review, and repository synchronization.
- GitHub for Windows
- GitHub for Mac
- For Linux and Solaris platforms, the latest release is available on the official Git website.
- Git for All Platforms
Setup🔽
Configuring user information used across all local repositories:
git config --global user.name "[firstname lastname]"
git config --global user.email "[valid-email]"
git config --global color.ui auto
Setup & Init🔽
Configuring user information, initializing, and cloning repositories:
git init
git clone [url]
Stage & Snapshot🔽
Working with snapshots and the Git staging area:
git status
git add [file]
git reset [file]
git diff
git diff --staged
git commit -m "[descriptive message]"
Branch & Merge🔽
Isolating work in branches, changing context, and integrating changes:
git branch
git branch [branch-name]
git checkout [branch]
git merge [branch]
git log
Inspect & Compare🔽
Examining logs, diffs, and object information:
git log
git log branchB..branchA
git log --follow [file]
git diff branchB...branchA
git show [SHA]
Tracking Path Changes🔽
Versioning file removes and path changes:
git rm [file]
git mv [existing-path] [new-path]
git log --stat -M
Ignoring Patterns🔽
Preventing unintentional staging or committing of files:
Create a .gitignore
file with patterns:
logs/
*.notes
pattern*/
Set a system-wide ignore pattern for all local repositories:
git config --global core.excludesfile [file]
Share & Update🔽
Retrieving updates from another repository and updating local repos:
git remote add [alias] [url]
git fetch [alias]
git merge [alias]/[branch]
git push [alias] [branch]
git pull
Rewrite History🔽
Rewriting branches, updating commits, and clearing history:
git rebase [branch]
git reset --hard [commit]
Temporary Commits🔽
Temporarily store modified, tracked files to change branches:
git stash
git stash list
git stash pop
git stash drop
This cheat sheet covers the essential Git commands for various tasks. Keep it handy for quick reference!
Top comments (0)