An interactive web application to help beginners understand Git operations through visual representation. Built with Next.js, React Flow, and Zustand.
- Interactive Terminal UI: Simulate Git commands in a realistic terminal environment
- Real-time Visualization: See commit graphs, branches, and merge operations visualized instantly
- Virtual Git Engine: Complete state management for commits, branches, and HEAD
- Comprehensive Git Commands: Support for essential Git operations
git init- Initialize a new repositorygit commit -m "message"- Create a new commitgit branch- List all branchesgit branch <name>- Create a new branchgit branch -d <name>- Delete a branchgit checkout <name>- Switch to a branchgit merge <name>- Merge a branch into current branch
git status- Show working tree statusgit log- Show commit historygit show <commit-id>- Show commit details
- Framework: Next.js 16 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- State Management: Zustand
- Visualization: React Flow
- UI Components: Custom components with shadcn/ui patterns
# Clone the repository
git clone https://github.com/pnnnhan99/git-workflow-simulator.git
cd git-workflow-simulator
# Install dependencies
npm install
# Run development server
npm run devOpen http://localhost:3000 in your browser.
-
Create your first commit:
git commit -m "Initial commit" -
Create a new branch:
git branch feature
-
Switch to the new branch:
git checkout feature
-
Make changes on the feature branch:
git commit -m "Add new feature" -
Switch back to main:
git checkout main
-
Merge the feature branch:
git merge feature
- View all branches:
git branch - Check repository status:
git status - View commit history:
git log - View specific commit:
git show <commit-id>
git-workflow-simulator/
├── app/
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Main page
├── components/
│ ├── Terminal.tsx # Terminal UI component
│ └── GitVisualization.tsx # React Flow visualization
├── lib/
│ └── gitStore.ts # Zustand store for Git state
├── public/ # Static assets
└── package.json # Dependencies
The application uses a Zustand store to maintain a virtual Git state:
- Commits: Stored with ID, message, parent IDs, and timestamp
- Branches: Pointers to specific commits
- HEAD: Always points to the current branch's latest commit
- Merge Commits: Special commits with two parent IDs
React Flow renders the commit graph as nodes and edges:
- Nodes: Represent commits with ID, message, and branch labels
- Edges: Show parent-child relationships
- Merge Commits: Highlighted in orange with special edges
- Current Branch: Highlighted in green
- Dark Terminal Theme: Realistic terminal experience
- Command History: Use arrow keys to navigate previous commands
- Error Handling: Clear error messages for invalid operations
- Responsive Layout: Split-screen design with terminal and visualization
- Real-time Updates: Graph updates instantly with each command
# Run development server
npm run dev
# Build for production
npm run build
# Start production server
npm start
# Run linter
npm run lintISC
Contributions are welcome! Feel free to submit issues or pull requests.
This simulator is designed to help beginners understand:
- How commits form a directed acyclic graph (DAG)
- Branch pointers and how they move
- HEAD and how it tracks the current branch
- Merge operations and merge commits
- Git workflow basics
- Add support for
git rebase - Implement
git stash - Add
git cherry-pick - Support for remote operations
- Export/import repository state
- More visualization options
- Tutorial mode with guided workflows
Built with ❤️ using Next.js, React Flow, and Zustand