Three Areas of Git
- Areas of Git

- Lets create a new folder and initialize it to be git repository
- Lets create a change
- Add the change to staging area and commit the change
- To commit a Change i.e. to maintain history, git requires
- changes
- time when commit is done
- author username and email id
- To configure username and email id
git config --global user.name "qtdevops"
git config --global user.email "qtdevops@gmail.com"
- Once git create a commit, it gives a commit id.

- When we add new changes and commit the changes the latest commit will be child of previous commit or previous commit is parent of latest commit

Now Lets focus of on the other aspects of git
Empty Folders and Folders with files
- Create a new folder and verify the status. git doesn’t identify an empty folder as a change. only the folders with files are considered as changes

- In the above image src is a folder with a file and test is an empty, so git doesn’t identify test as a change



Deleting the files which had history (Deleting tracked files)
- Deleting a tracked file is considered as change.
- Now we can add the change to staging area and then commit it


- The history would be as shown below

Making changes in Working tree and removing the changes
- Make some changes which impacts history (tracked files)

- Create some untracked files

- To clean all the changes.
-
Git has different approach to clean
- tracked files:
- we can use restore commands


- we can use restore commands
-
Execute
git restore --help -
untracked files
git clean -fd .
- tracked files:
Removing Changes from staging area to Working Tree
- Lets add changes to staging area. Now i would want to remove the changes



- Areas of Git updated

Exercises
- Create a new folder anywhere in your system and make it a git repo
- Create 3 folders and check for status
- now add a file in first folder and then execute git status
- add this change to staging area
- create one more file in second folder and add this change also to staging area
- Now commit the change
- Draw a tree like what we have done in the class
git log --oneline - Now create two files in third folder, add them to staging area and now remove one file from staging area and create 2 commit.
- Update your tree
- now add the file which you moved from staging area to working tree back to staging ared and then create a third commit
- Now create two files each in three folders add all of them to staging area
- Clean the above changes as if you have not done any changes after 3 commit.
-
Terms:
- Untracked file: Untracked files are not part of git history, they are new files which are present in working tree
Note
- Creating a VM on AWS Refer Here and Azure Refer Here
