Practice & Assessment
Test your understanding of Git Workflows and Developer Best Practices
Multiple Choice Questions
5What is the correct order of commands to create a new feature branch, make a commit, and merge it back to main?
A developer committed a .env file with API keys. It is in the latest commit but not yet pushed. What is the correct fix?
What does git stash pop do?
What is the golden rule of git rebase?
What type prefix should a commit use when updating a dependency version in package.json without changing any application logic?
Coding Challenges
1Git Workflow Simulation Script
Write a Bash script called git-practice.sh that sets up and demonstrates a complete Git workflow in a temporary directory. The script must: (1) create a temp directory and git init it, (2) create an initial README.md and commit on main with message chore: initial project setup, (3) create feature branch feature/add-config, add a config.json file, commit with feat(config): add default configuration, (4) switch back to main, add CHANGELOG.md, commit with docs: add changelog, (5) merge the feature branch into main, (6) print git log --oneline to show the result. Input: none. Output: a functioning git repository in /tmp/git-practice with a clean commit history. Time estimate: 20-25 minutes.
Mini Project
Team Development Workflow Simulator
Simulate a multi-developer Git workflow in WSL2. Create a script full-workflow.sh that: (1) initializes a bare remote repo in /tmp/remote-repo.git using git init --bare, (2) clones it twice into /tmp/dev-alice and /tmp/dev-bob to simulate two developers, (3) as alice creates feature/api-routes, adds routes.js, commits with a conventional commit message, pushes the branch, (4) as bob creates feature/middleware, adds middleware.js, commits, pushes, (5) as alice pulls main, merges feature/api-routes to main, pushes main, (6) as bob pulls main, rebases feature/middleware on top of updated main, merges to main, pushes, (7) generates a final git log --all --oneline --graph output. The project combines branching, merging, rebasing, push, pull, and conventional commits in one demonstration.
