Skip to content

Instantly share code, notes, and snippets.

@got4416
Last active November 30, 2025 13:43
Show Gist options
  • Select an option

  • Save got4416/0352783f3979dcafc818107a2f23abd9 to your computer and use it in GitHub Desktop.

Select an option

Save got4416/0352783f3979dcafc818107a2f23abd9 to your computer and use it in GitHub Desktop.
The lifecycle of the status of your files
---
title: The lifecycle of the status of your files (Extended)
---
stateDiagram-v2
  workingtree_untracked : Working Tree<br>Untracked
  workingtree_deleted : Working Tree<br>Deleted
  index_new_file : Index<br>New file
  workingtree_modified : Working Tree<br>Modified  
  index_modified : Index<br>Modified
  index_deleted : Index<br>Deleted
  [*] --> workingtree_untracked : Create file
  workingtree_untracked --> index_new_file : Add the file<br>(git add)
  index_new_file --> workingtree_untracked : Unstage the file<br>(git rm --cached)
  index_new_file --> Unmodified : Commit<br>(git commit)
  Unmodified --> workingtree_deleted : Remove the file
  workingtree_deleted --> index_deleted : Stage the file<br>(git add)
  workingtree_deleted --> Unmodified : Discard changes in working tree<br>(git restore)
  index_deleted --> workingtree_deleted : Unstage the file<br>(git restore --staged)
  index_deleted --> [*] : Commit<br>(git commit)
  Unmodified --> workingtree_modified : Edit the file
  workingtree_modified --> Unmodified : Discard changes in working tree<br>(git restore)
  workingtree_modified --> index_modified : Stage the file<br>(git add)
  index_modified --> workingtree_modified : Unstage the file<br>(git restore --staged)
  index_modified --> Unmodified : Commit<br>(git commit)
Loading

https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment