원클릭으로
git
Git 版本控制操作与最佳实践。Use when (1) 初始化或配置 Git 仓库, (2) 执行 commit/push/pull 等操作, (3) 处理分支和合并冲突, (4) 配置 .gitignore, (5) 解决 Git 相关问题
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Git 版本控制操作与最佳实践。Use when (1) 初始化或配置 Git 仓库, (2) 执行 commit/push/pull 等操作, (3) 处理分支和合并冲突, (4) 配置 .gitignore, (5) 解决 Git 相关问题
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Complete software development lifecycle from requirements to deployment. Use when (1) starting a new project from scratch, (2) need structured end-to-end development process, (3) require comprehensive documentation and quality gates at each phase.
专业的AI Agent(AI Agents)顾问助手,探索 AI Agent 框架和应用。当用户询问以下问题时使用:(1) 技术选型和对比 (2) 使用指南和最佳实践 (3) 问题诊断和解决 (4) 资源推荐 (5) 常见问题解答
Comprehensive CV learning assistant. Use when studying image processing, object detection, segmentation, or any CV tasks. Helps with algorithm understanding, implementation, and model optimization.
Comprehensive DL learning assistant. Use when studying neural networks, CNN, RNN, LSTM, Transformer, or any DL architectures. Helps with network design, training strategies, debugging, and optimization techniques.
Comprehensive LLM learning assistant. Use when studying transformer architecture, attention mechanisms, pre-training, fine-tuning, or prompt engineering. Helps with understanding LLM principles and practical applications.
Comprehensive ML learning assistant. Use when studying supervised learning, unsupervised learning, regression, classification, clustering, or any ML concepts. Helps with algorithm understanding, implementation guidance, model evaluation, and practical applications.
| name | git |
| description | Git 版本控制操作与最佳实践。Use when (1) 初始化或配置 Git 仓库, (2) 执行 commit/push/pull 等操作, (3) 处理分支和合并冲突, (4) 配置 .gitignore, (5) 解决 Git 相关问题 |
Before any Git operation, check the current state:
git status # Check working directory status
git remote -v # List remote repositories
git branch -a # List all branches
git log --oneline -10 # View recent commits
# Initialize new repository
git init
# Add remote origin
git remote add origin <repository-url>
# Verify remote
git remote -v
# Clone with HTTPS
git clone https://github.com/user/repo.git
# Clone with SSH
git clone git@github.com:user/repo.git
# Clone specific branch
git clone -b branch-name https://github.com/user/repo.git
# Global configuration
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
# Repository-specific configuration
git config user.name "Your Name"
git config user.email "your.email@example.com"
# View configuration
git config --list
# Default branch name
git config --global init.defaultBranch main
# Line ending handling
git config --global core.autocrlf true # Windows
git config --global core.autocrlf input # Mac/Linux
# Editor
git config --global core.editor "code --wait"
# Credential caching
git config --global credential.helper cache
git status
# Stage specific files
git add file1.py file2.py
# Stage all changes
git add .
# Stage by pattern
git add *.py
# Interactive staging
git add -p
# Commit with message
git commit -m "feat: add user authentication"
# Commit with detailed message
git commit -m "feat: add user authentication" -m "- Implement JWT token generation
- Add login/logout endpoints
- Create user session management"
# Amend last commit
git commit --amend -m "Updated message"
# Stage and commit in one step
git commit -am "fix: resolve login bug"
# Push to remote
git push origin main
# Push new branch
git push -u origin feature-branch
# Force push (use with caution)
git push --force-with-lease origin main
# Pull from remote
git pull origin main
# Pull with rebase
git pull --rebase origin main
# Fetch without merging
git fetch origin
# Create new branch
git branch feature-name
# Switch to branch
git checkout feature-name
# Create and switch in one command
git checkout -b feature-name
# Modern syntax (Git 2.23+)
git switch feature-name
git switch -c feature-name
# List local branches
git branch
# List all branches (including remote)
git branch -a
# Delete local branch
git branch -d feature-name
# Force delete
git branch -D feature-name
# Delete remote branch
git push origin --delete feature-name
# Merge feature into current branch
git merge feature-name
# Merge with no fast-forward
git merge --no-ff feature-name
# Abort merge
git merge --abort
# Rebase current branch onto main
git rebase main
# Interactive rebase (last 3 commits)
git rebase -i HEAD~3
# Continue after resolving conflicts
git rebase --continue
# Abort rebase
git rebase --abort
Identify conflicted files:
git status
Open conflicted files and look for conflict markers:
<<<<<<< HEAD
Your changes
=======
Incoming changes
>>>>>>> branch-name
Resolve conflicts by editing the file
Stage resolved files:
git add resolved-file.py
Complete the merge/rebase:
git commit # For merge
git rebase --continue # For rebase
# Discard changes in specific file
git checkout -- file.py
# Discard all local changes
git reset --hard HEAD
# Discard untracked files
git clean -fd
# Unstage specific file
git reset HEAD file.py
# Unstage all files
git reset HEAD
# Revert last commit (creates new commit)
git revert HEAD
# Revert specific commit
git revert <commit-hash>
# Reset to previous commit (destructive)
git reset --hard HEAD~1
# Reset but keep changes staged
git reset --soft HEAD~1
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
env/
venv/
.venv/
*.egg-info/
dist/
build/
# IDEs
.vscode/
.idea/
*.swp
*.swo
*~
# OS
.DS_Store
Thumbs.db
# Environment
.env
.env.local
*.log
# Dependencies
node_modules/
package-lock.json
# Build outputs
dist/
build/
*.min.js
*.min.css
# Remove cached files
git rm -r --cached .
# Re-add all files
git add .
# Commit
git commit -m "chore: apply .gitignore rules"
<type>(<scope>): <subject>
<body>
<footer>
git commit -m "feat(auth): add JWT authentication"
git commit -m "fix(api): resolve null pointer in user endpoint"
git commit -m "docs: update installation instructions"
git commit -m "refactor(utils): simplify date formatting logic"
# Error: fatal: not a git repository
# Solution: Initialize repository
git init
# Error: remote origin already exists
# Solution: Remove and re-add
git remote remove origin
git remote add origin <new-url>
# Error: Your branch and 'origin/main' have diverged
# Solution 1: Merge
git pull origin main
# Solution 2: Rebase
git pull --rebase origin main
# Solution: Create branch from current state
git checkout -b recovery-branch
# Or return to main branch
git checkout main
# Error: file too large
# Solution: Use Git LFS
git lfs install
git lfs track "*.psd"
git add .gitattributes
git checkout main
git pull origin main
git checkout -b feature/new-feature
# ... make changes ...
git add .
git commit -m "feat: implement new feature"
git push -u origin feature/new-feature
Branches:
# View commit history
git log
# Compact view
git log --oneline
# Graph view
git log --graph --oneline --all
# View changes in commit
git show <commit-hash>
# View file history
git log --follow file.py
# Compare working directory with staging
git diff
# Compare staging with last commit
git diff --staged
# Compare branches
git diff main..feature-branch
# Compare specific files
git diff main feature-branch -- file.py
# Search commits by message
git log --grep="bug fix"
# Search commits by author
git log --author="John"
# Search commits by content
git log -S "function_name"
# Stash current changes
git stash
# Stash with message
git stash save "work in progress"
# List stashes
git stash list
# Apply latest stash
git stash apply
# Apply and remove stash
git stash pop
# Apply specific stash
git stash apply stash@{2}
# Drop stash
git stash drop stash@{0}
# Clear all stashes
git stash clear
Before pushing:
git status for untracked or modified filesgit diffgit branchgit diff to verify changesgit tag v1.0.0 for version markers# Status and info
git status # Check status
git log --oneline -10 # Recent commits
git diff # View changes
# Basic operations
git add . # Stage all
git commit -m "message" # Commit
git push origin main # Push
git pull origin main # Pull
# Branching
git checkout -b feature # Create branch
git merge feature # Merge branch
git branch -d feature # Delete branch
# Undo
git reset HEAD file # Unstage
git checkout -- file # Discard changes
git revert HEAD # Revert commit
# Remote
git remote -v # List remotes
git fetch origin # Fetch updates
git push -u origin branch # Push new branch