Three Stages of Git (Local)
-
When we are working with git, we need to understand local & Remote stages
-
The Local stages include
- Working Directory/Tree
- Staging Area (Cache)
- Local Repository (Git Database)

-
We make changes in the working tree (folder). We stage these changes to _Staging_Area. From Staging Area We commit the changes to Local Repo

-
Lets do this practically
- create a directory with a file (src/main.py)
- Execute git status
- Now add the changes to the staging area using command add
- Execute git status

- Now commit the changes. For committing changes git will use username, email and current date time and commit message
- After committing the changes execute git status and git log commands

- Lets add some lines of code in main.py
- Lets create a new file app.py
- The files changed in the working directory which are already existing in the local repo have a state of modified. If we add new files in the working directory we will have state of untracked.
- Lets move the changes of untracked and modified to the staging area

- The changes are in staged state, now lets move them to the committed stated by executing git commit

- Lets create a new empty directory. Git can track files not folders/directories so empty directories are not considered as changes in git.

- Lets add a file in the empty directory to have the untracked

- Lets move the file from staged state to committed state.

-
State Transitions of a file in Git

-
Status command will tell the state of a file in git.
-
Next Steps:
- How to move the changes from staging to Working tree
- How to tell git to ignore some files and not add them to staging area
- Git branches.
