Git Cheat Sheet for Writers

Eli Ridge (egret), Fedora Docs Team Last review: 2026-09-01

This cheat sheet for docs writers provides some commonly used Git tasks and their respective commands. You will have previously cloned a repository (repo) to your computer and pushed to your remote fork on Forge. Refer to the Local workflow guide to get started with Git.

This cheat sheet assumes that your Git configuration uses origin for your remote fork and upstream for the upstream repository. Run git remote -v to check these names.

Pulling updates from upstream

Update your local main branch:

Synchronizes the main branch of your local clone with the upstream repository’s main branch:

git switch main
git pull upstream main
# local main is now updated
git push origin main
# to update your fork in forge

Update a local feature branch:

Synchronizes the given feature branch with the main branch of your local clone.

  1. Change to the feature branch that you want to update:

    git switch <branch-name>
  2. Rebase the feature branch:

    git rebase main

Push your local branch to your remote fork:

git push origin <branch-name>

The --force-with-lease flag may be needed if you have rebased a branch that has already been pushed. This should be used with caution.

Pulling updates from your remote fork

Pull changes from your remote fork:

Synchronizes the respective branch of your local clone with your remote fork. Use this if you have made changes to your fork using the forge web interface.

git pull --rebase origin <branch-name>

More tasks

List untracked changes:

Identifies your current branch and the files that have changes.

git status

List the commits about to be pushed:

git log --oneline origin/<branch-name>..<branch-name>

List staged files:

git diff --name-only --staged

Push to your remote fork:

git switch <branch-name>
git push origin <branch-name>

Destructive commands

Exercise caution when using the following commands. Incorrect use can result in lost data.

Reset your feature branch:

Results in the feature branches matching your main branch state exactly - disregards all changes to your feature branch.

git switch <branch-name>
git reset --hard main

Delete local branches that you no longer need:

git branch -d <branch-name>