How Git Works: Git Architecture Flowchart

Trace code through the five major Git areas: stash, working directory, staging area, local repository, and remote repository. See how commands such as git add, git commit, git fetch, git pull, git push, and git stash move information between them.

The flowchart connects everyday Git commands to the repository areas they read and update.

Git Architecture Stages

  1. Stash: Saved Uncommitted
  2. Workspace: Working Directory
  3. Staging: Index / Next Commit
  4. Local Repo: Local History (HEAD)
  5. Remote Repo: GitHub / GitLab

Git Data-Flow Commands

git status
Show the working tree status.
git diff
Show changes between commits, commit and working tree, etc.
git diff --staged
Show changes between the index and your last commit.
git log
Show commit logs.
git add <file>
Add file contents to the index (Staging).
git add -u
Update tracked files in the index.
git rm
Remove files from the working tree and from the index.
git mv
Move or rename a file, a directory, or a symlink.
git commit
Record changes to the repository.
git commit -a
Automatically stage modified/deleted files and commit.
git restore
Restore working tree files from the index.
git reset
Reset current HEAD to the specified state, un-staging files.
git reset --hard
Reset index and working tree to match HEAD.
git revert
Create a new commit that undoes changes from a previous commit.
git switch
Switch branches, updating the working tree.
git merge
Join two or more development histories together.
git rebase
Reapply commits on top of another base tip.
git fetch
Download objects and refs from another repository.
git pull
Fetch from and integrate with another repository or a local branch.
git push
Update remote refs along with associated objects.
git clone
Clone a repository into a new directory.
git stash
Stash the changes in a dirty working directory away.
git stash pop
Remove a single stashed state from the stash list and apply it.
git stash apply
Apply a single stashed state without removing it from the list.

Explore Git Visualizer

Git Visualizer is created by .