Git Cheat Sheet for AI Prompting
Git Cheat Sheet for AI Prompting
This is your quick reference for Git commands and ā more importantly ā example prompts you can use with AI coding tools like Claude Code. Bookmark this page!
Setup & Config
| Command | What It Does |
|---|---|
git --version | Check if Git is installed |
git config --global user.name "Name" | Set your name |
git config --global user.email "email" | Set your email |
git config --global --list | See your configuration |
AI Prompts for Setup:
- "Help me install Git on my [Mac/Windows/Linux]"
- "What should I set my Git config to for a new developer setup?"
- "Generate a .gitignore file for a [React/Python/Node] project"
Creating Repositories
| Command | What It Does |
|---|---|
git init | Create a new repository |
git clone URL | Copy an existing repository |
AI Prompts for Repos:
- "I found this GitHub repo: [URL]. Clone it and explain the project structure to me."
- "Help me set up a new Git repository for a [type] project"
- "I cloned a repo but I'm not sure how to run it. Can you look at the README and help?"
Daily Workflow
| Command | What It Does |
|---|---|
git status | See what's changed |
git add filename | Stage a specific file |
git add . | Stage all changes |
git commit -m "message" | Save a snapshot |
git diff | See unstaged changes |
git diff --staged | See staged changes |
git log --oneline | View commit history |
AI Prompts for Daily Work:
- "I ran git status and see this: [paste output]. What should I do next?"
- "Look at my git diff and review the changes I made"
- "I've been working for a while. Help me organize my changes into logical commits."
- "Suggest a commit message for these changes: [describe changes]"
Branches
| Command | What It Does |
|---|---|
git branch | List branches |
git checkout -b name | Create and switch to a new branch |
git checkout name | Switch to an existing branch |
git merge name | Merge a branch into current branch |
git branch -d name | Delete a merged branch |
AI Prompts for Branches:
- "Create a new branch called 'feature/[name]' before we make any changes"
- "I have a merge conflict in [file]. Here's what it looks like: [paste]. Help me resolve it."
- "I'm done with this feature branch. Walk me through merging it into main."
- "I messed up on this branch. How do I get back to a clean state on main?"
Remote Repositories
| Command | What It Does |
|---|---|
git remote -v | Show connected remotes |
git push | Upload commits |
git pull | Download and merge changes |
git push -u origin branch | Push a new branch |
AI Prompts for Remotes:
- "I have a local project. Help me create a GitHub repo and push my code."
- "I'm getting a push rejection error: [paste error]. Help me fix it."
- "Help me create a pull request for my current branch"
- "I need to pull the latest changes but I have uncommitted work. What should I do?"
Undoing Things
| Command | What It Does |
|---|---|
git restore --staged file | Unstage a file |
git restore file | Discard changes to a file |
git checkout . | Discard ALL uncommitted changes |
AI Prompts for Undoing:
- "I need to undo my last commit but keep the changes"
- "I accidentally committed a file with secrets. Help me remove it from Git history."
- "I want to go back to how my project looked 3 commits ago. What are my options?"
- "I ran a command and now my repo is in a weird state. Here's what git status shows: [paste]"
Working with AI Coding Tools
Here are prompts specifically for getting the most out of AI tools with Git:
Before Starting Work
- "Before we start, let's create a new branch so I can easily undo changes if needed."
- "Check my git status. Do I have any uncommitted changes I should save first?"
During Development
- "Show me the git diff of what you just changed so I can review it."
- "Commit the changes you just made with an appropriate message."
- "I don't like the last changes. Help me revert them."
After Changes
- "Let's review all the changes on this branch before merging."
- "Help me push this branch and create a pull request with a good description."
- "Clean up: delete the feature branch since we merged it."
When Things Go Wrong
- "Something broke after the last change. Show me the git log so we can figure out what happened."
- "I need to undo everything from the last 20 minutes. What are my options?"
- "My git repo is in a weird state. Run git status and help me understand what's going on."
The Complete Beginner Workflow
If you remember nothing else, remember this flow:
# Check your starting point git status # Create a safe branch git checkout -b feature/my-change # Make changes... # See what changed git status git diff # Save your work git add . git commit -m "Describe what you did" # Push to GitHub git push -u origin feature/my-change # When done, merge to main git checkout main git merge feature/my-change git push
Keep Learning
You now have a solid foundation in Git. Here are ways to keep building your skills:
- Practice: Use Git in every project, even small ones
- Ask your AI: Whenever you encounter a Git situation you don't understand, just ask
- Explore: Try new commands in a test repository where nothing can go wrong
Remember: Every experienced developer once Googled "how to undo a git commit." Git has a learning curve, but with AI tools by your side, you can learn faster than ever.
Happy building!
š www.genai-mentor.ai