Cursor Practice Project-07: Git Tutorial Development

Project Description

cursor practice project-07: git tutorial development

Time spent: Approximately 2-3 hours

Cursor usage count: Around 10 times

In this project, I document how to use Cursor as an AI programming assistant to create a complete, high-quality, project-driven bilingual Git tutorial from scratch based on detailed requirements for learning Git commands.

My goal is to demonstrate and validate how to guide AI in generating programming-related tutorials for self-learning, transforming the traditionally tedious process of searching, organizing, and writing materials.

You can extend this methodology to learning any programming knowledge - minimal essential knowledge, project-driven approach.

Results Showcase

  • Successfully created a well-structured, comprehensive multi-chapter Git tutorial using Cursor, containing courses, exercises, and standalone practical projects, all following my predefined bilingual format.

    Result GIF - Adheres to minimal essential knowledge, project-driven approach, bilingual format, rich content, complete structure - Final project includes over 40 Markdown files organized in a clear directory structure - Content ranges from Git basics, version management, branching, remote collaboration to advanced operations, forming a complete learning path

Prerequisites

  • Cursor

  • Overall workflow

    • Set cursor rules → Set project rules (10xUse) → Communicate requirements with LLM → Cursor coding → Debug output

Issue Log

  1. Issue 1: During tutorial development, cursor tends to lose context, resulting in inconsistent content across different chapters

    • Provide context: tutorial root directory has README explaining the entire tutorial, each chapter has its own README explaining the chapter
    • When submitting to cursor, instruct it to read both READMEs and project documentation before writing
  2. Issue 2: When writing large documents exceeding 2000 lines, cursor often interrupts, especially when code is involved in the tutorial

    • Require minimal essential content, separate example code, project-driven approach
    • For lengthy documents, proceed step by step

Usage Insights

  1. Effectively using 10xUse can reduce Cursor usage count
  2. Instructions must include context, otherwise cursor tends to lose context, resulting in inconsistent content across chapters. Require reading READMEs.
  3. Programming tutorials mainly involve code - always separate code into independent exercises

Detailed Project Steps

  1. Initial Instruction: I first provided Cursor with the core requirements file pj-requirement.md and asked it to summarize the requirements to verify its initial understanding of the task.

    step-1
  2. Generate Project Documentation and Tutorial Index: cursor generates project documentation and tutorial index. Begins generating Chapter 1 content.

    step-2
  3. Continue Generation Without Interruption: When cursor attempts to end the first request, invoke rule commands to make it continue generation.

    step-3
  4. Continue Generation: Ultimately, one request generates content and exercises for two chapters.

    step-4
  5. Complete Remaining Chapters: cursor continues completing other chapters

  6. Summarize Common Git Commands and Scenario Guidance: cursor compiles a Git command cheat sheet

    Git Command Cheat Sheet

  7. Generate Project Documentation and Tutorial Index: cursor generates project documentation and tutorial index. Begins generating Chapter 1 content.



Git Command Cheat Sheet

This cheat sheet compiles the most commonly used Git commands for quick reference.

Table of Contents


Basic Operations

CommandDescription
git initInitialize a new Git repository in the current directory.
git clone [url]Clone a remote repository to local.
git statusView the status of working directory and staging area.

Version Management

CommandDescription
git add [file]Add file changes to staging area. Use . instead of [file] to add all changes.
git commit -m "[message]"Commit staged content to local repository with commit message.
git logView commit history.
git diffView differences between working directory and staging area.
git diff --stagedView differences between staging area and latest commit.
git reset [file]Unstage file while keeping working directory changes.
git checkout -- [file]Discard working directory changes, reverting to last commit state.

Branch Operations

CommandDescription
git branchList all local branches.
git branch [branch-name]Create a new branch.
git checkout [branch-name]Switch to specified branch.
git checkout -b [branch-name]Create and immediately switch to a new branch.
git merge [branch-name]Merge specified branch history into current branch.
git branch -d [branch-name]Delete a merged branch.

Remote Collaboration

CommandDescription
git remote -vView detailed information about all remote repositories.
git remote add [name] [url]Add a new remote repository.
git fetch [remote-name]Download latest history from remote repository without merging.
git pull [remote-name] [branch-name]Fetch from and integrate with remote branch.
git push [remote-name] [branch-name]Push local branch commits to remote repository.

Advanced Commands

CommandDescription
git rebase [branch-name]Rebase current branch commits onto specified branch.
git tag [tag-name]Create lightweight tag at current commit.
git tag -a [tag-name] -m "[message]"Create annotated tag.
git submodule add [repository-url] [path]Add a submodule.
git stashTemporarily save working directory changes.
git stash popRestore most recently stashed changes.

Common Scenarios & Solutions

Below are some frequently encountered problems in daily development and their recommended solutions.

ScenarioSolution
1. Need to modify incorrect commit messagegit commit --amend -m "new commit message"
(Note: Use caution if commit has been pushed remotely)
2. Want to undo most recent commitgit reset --soft HEAD~1
(Undo commit while keeping code changes)
3. Modified files but want to discard all local changesgit checkout -- .
(Discard all unstaged changes)
4. Need to apply specific commit to current branchgit cherry-pick [commit-hash]
(Apply changes from specific commit)
5. Accidentally merged wrong branch, need to undo mergegit reset --hard ORIG_HEAD
(Revert to pre-merge state)
6. Need to clean untracked filesgit clean -fd
(Force delete untracked files/directories)
7. Want to view modification history of specific filegit log -p [file-path]
(Show detailed commit history for file)
8. Local branch behind remote branch, need to syncgit fetch origin
git reset --hard origin/[branch-name]
(Force update local branch to match remote)
9. Need to temporarily switch tasks without committing current workgit stash
(Save current work progress)
git stash pop
(Restore work progress)
10. Find who modified specific line of codegit blame [file-path]
(Show author and last modifying commit per line)