Feature Branch WorkflowIn a team, you never commit directly to main. Instead, create a feature branch (git checkout -b feature/xxx), make your changes, clean up history with rebase, push, and open a pull request.
Syncing with remoteBefore starting work, always git fetch origin to get the latest changes from teammates. Then rebase or merge your branch to stay up to date and avoid merge conflicts later.
Squash before pushUse git rebase -i to squash multiple small commits into one clean commit before pushing. This keeps the main branch history readable. The interactive rebase lets you pick, squash, reword, or drop commits.
📖 Story
Your colleague pushed a lint fix to the remote.
Your task is to build a new user authentication feature. Follow the team workflow: sync with remote, create a feature branch, make your commits, squash them into one, and push.
This is the standard feature branch workflow used in most teams every day.
View the local commit history
Run git log --oneline. Your local main has 2 commits. A colleague pushed a fix to the remote — you need to sync before starting your feature.
● View the local commit history
○ Fetch the remote changes
○ Integrate the remote changes
○ Create a feature branch
○ Stage the auth module
○ Commit the auth module
○ Stage the tests
○ Commit the tests
○ Clean up with interactive rebase
○ Push your feature branch
Terminal
📘 Starting tutorial: Feature Workflow
Simulate a team workflow: fetch, branch, commit, squash, and push