Skip to content
Commitpedia
Log in Join & edit

The everyday Git workflow: status, add, commit, push, pull

Git moves your changes through three places: the working folder, the staging area, and the commit history. These five commands, plus .gitignore and stash, cover most daily work.

Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?

Edit history of The everyday Git workflow: status, add, commit, push, pull: 1 recorded edit
Edit history · 1 edit
Type
Article
Edits
1
Editors
1
First issued
15 Oct 2026
Last edit
15 Oct 2026
Reading
2 min

Git does not save every keystroke. You decide what goes into each snapshot, called a commit. To do that, Git keeps your work in three places:

  • Working tree: the files you see and edit.
  • Staging area (also called the index): the changes you have picked for the next commit.
  • Repository: the saved commits. A remote such as GitHub holds a copy you share with others.

The daily loop

git switch main
git pull                     # get what others pushed
# ...edit files...
git status                   # what changed?
git diff                     # exact lines, not yet staged
git add app.py               # stage one file (git add . stages everything)
git diff --staged            # what the commit will contain
git commit -m "Add greeting to the home page"
git push                     # share it

git status is the command to run whenever you are unsure. git status --short gives one line per file: ?? means untracked (Git has never seen it), M in the right column means modified but not staged, and a letter in the left column means staged.

Staging lets you split work into focused commits. If you fixed a bug and also renamed a variable, stage and commit them separately. git add -p goes further and asks about each changed hunk.

Write commit messages that finish the sentence “This commit will…”: Fix crash when the cart is empty tells a reviewer far more than fixes.

Keep files out with .gitignore

Some files should never be committed: dependencies you can reinstall, build output, logs, and anything holding secrets. List them in a file named .gitignore at the root of the project and commit that file.

node_modules/
dist/
*.log
.env
.DS_Store

A trailing / matches a folder, * matches anything, and a line starting with ! re-includes something an earlier line excluded. To find out which rule hides a file, ask Git:

git check-ignore -v .env

.gitignore only affects files Git is not tracking yet. If a file is already committed, stop tracking it while keeping it on disk:

git rm --cached .env
git commit -m "Stop tracking .env"

If that file held a password or API key and was ever pushed, treat the secret as leaked and replace it. Removing the file from later commits does not remove it from history.

Park unfinished work with stash

Need to switch branches but not ready to commit? git stash saves your uncommitted changes and gives you a clean working tree.

git stash push -m "half-done search box"
git stash push -u -m "including new files"   # -u also saves untracked files
git stash list
git stash pop          # re-apply the newest stash and remove it
git stash apply stash@{1}   # re-apply but keep it in the list
git stash drop stash@{1}

Stashes are easy to forget. If you will be away from the work for more than a few hours, a commit on a branch is the safer place for it.

Did this work for you?

No votes yet. Be the first.

If it did not work, the report form below tells the editors what went wrong.

See also

Repos in the wild

  • git-extras tj/git-extras A collection of extra Git subcommands for common chores, such as summarizing a repository, deleting merged branches, and undoing commits. GitHub

History

Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.

  1. Dominik +2,881 chars

Report a problem

Something wrong, unsafe or copied? Tell the editors.
What is wrong?