Git Cheat Sheet
1. Basic Git Settings
Get Git Version
git --versionInitialize a Git Repository
git initSet Author Name and Email
git config --global user.name "USER_NAME"
git config --global user.email "USER_EMAIL"
git config --global pull.rebase true
# Use rebase as the default behavior for 'git pull'
# - Prevents divergent-branch errors
# - Keeps commit history clean and linear
# - Recommended for most workflowsList Git Configurations
Add a Git Alias
2. Git Areas and File Status
Git Areas
File Status
Commands to Check Status
3. Basic Git Commands
Stage Files
Commit Changes
View Commit History
View Changes
Restore File to Last Commit
Reset Changes
Discard Local Changes
Use .gitignore to Ignore Files
.gitignore to Ignore Files4. Branch Commands
List and Create Branches
Switch Branches
備註:
Merge Branches
5. Remote Commands
Clone a Repository
Remote Repository Management
Change remote URL to 'ssh'
Push Changes
Pull Changes
Fetch Changes
6. Advanced Commands
Save Changes Temporarily
List Stashed Changes
Restore Stashed Changes
Drop Stashed Changes
Garbage Collection
Remove Untracked Files
7. Git Workflow and GitFlow
GitFlow Overview
8. Git Rebase and References
Git Rebase
Git References Table
Reference
Description
Summary
Last updated