---
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)
https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository