Quick reference

# Check status of the working directory
git status

# Undo changes to a specific file
git checkout path/to/file.html

# Add all tracked/untracked files in the working directory to the stage
git add -A

# Add changes to a specific file to the stage
git add path/to/file.html

# Remove staged changes in a specific file
git reset path/to/file.html

# Commit staged changes
git commit -m "Update content"

# Commit all changes (staged or not)
git commit -m -a "Update content"

# Push commits on server to origin
git push origin master

Writing good commit messages

A few things help:

  • Simple and informative description
  • Written in present tense
  • References the task ID
<!-- Good -->
Update nav

<!-- Bad -->
Updates nav
Updated nav
Updating nav


For GitHub:

#{taskId} ({taskDescription}): {commitDescription}

For Bitbucket / Jira:

{projectId}-{taskId} ({taskDescription}): {commitDescription}


Pretend we’re making a website for Tony Hawk about skateboarding. There’s a Jira project with the ID HAWK, which includes task 900 for updating the history of skateboarding.

<!-- Good -->
HAWK-900 (skateboarding history): add X-Games to timeline

<!-- Bad -->
Update text