DevOps Classroom Series – 17/Sept/2020

Three Stages of Git (Local)

  • When we are working with git, we need to understand local & Remote stages

  • The Local stages include

    1. Working Directory/Tree
    2. Staging Area (Cache)
    3. Local Repository (Git Database) Preview
  • 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 Preview

  • Lets do this practically

    1. create a directory with a file (src/main.py)
    2. Execute git status
    3. Now add the changes to the staging area using command add
    4. Execute git status Preview Preview
    5. Now commit the changes. For committing changes git will use username, email and current date time and commit message
    6. After committing the changes execute git status and git log commands Preview
    7. Lets add some lines of code in main.py
    8. Lets create a new file app.py
    9. 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.
    10. Lets move the changes of untracked and modified to the staging area Preview
    11. The changes are in staged state, now lets move them to the committed stated by executing git commit Preview
    12. Lets create a new empty directory. Git can track files not folders/directories so empty directories are not considered as changes in git. Preview
    13. Lets add a file in the empty directory to have the untracked Preview
    14. Lets move the file from staged state to committed state. Preview
  • State Transitions of a file in Git Preview

  • Status command will tell the state of a file in git.

  • Next Steps:

    1. How to move the changes from staging to Working tree
    2. How to tell git to ignore some files and not add them to staging area
    3. Git branches.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin