Make changes reviewable and recoverable
Git records snapshots locally. A hosting service such as GitHub provides remote collaboration and review. A branch is a movable reference to commits, not an automatic backup of every uncommitted file.
A focused feature workflow
git status
git switch -c feature/course-catalogue
git diff
git add src/CourseList.jsx server/course-routes.js
git diff --staged
git commit -m "Show published courses in the catalogue"
git push -u origin feature/course-catalogueUse paths that exist in your project. Review the staged diff before committing so unrelated files or secrets do not slip in. A pull request should explain the problem, resulting behavior and validation, then receive the project's normal review.
Coordinate with teammates
Fetch remote changes and inspect them before integrating. Choose the team's merge or rebase convention deliberately. Do not rewrite a shared branch's published history merely to make a local graph look tidy. If a conflict appears, resolve the actual intended combined behavior and rerun relevant checks.
Secrets and generated files
Ignore local environment files containing credentials, dependency directories and disposable build outputs as appropriate. A .gitignore entry does not remove a secret already committed. If a real credential entered history, revoke/rotate it through the responsible process and coordinate cleanup; deleting the line in the latest commit is not enough.
Safer recovery
Use git diff and status before any discard operation. A new revert commit can undo a published change while preserving history. Commands that reset or clean working files can destroy uncommitted work; understand their scope and keep backups before using them.
Exercises
- Create a small branch, make two related commits and inspect their diff.
- Stage only one of two changed files and verify the staged snapshot.
- Resolve a harmless conflicting text edit in a disposable practice repository.
- Write a review description with a concrete before/after behavior and test result.
Reference: official Git tutorial.