3.1 Basic Git Concepts
Links: Source Control for Test Automation with Git MOC
3.1 Basic Git Concepts
With the third command, git status
, you are able to see all the current path differences between working directory, staging index area, local repository and remote repository if you have configured a remote one.
The fourth command is git log
.
With git log
, you can see all the commits which were created on a branch. It shows you the whole commit history including the hash, the author, and the date of the current active, which means checked-out local branch.
NOTE
At this point, I would like to mention that for each of the commands in Git, there do exist a couple of additional options you can concatenate, but we won't go through them in this course. That's something you can read up on your own in the official online Git documentation.
Now the time has come to dive into the basic concepts. The first one we are starting with, is initializing.
When we initialize a repository locally, we will get these three boxes. They represent the development environment. As we already learned, these boxes are called the three Git trees.
Let's have a closer look at these three Git trees.
- The first box is the working directory. That's the construction site or the place where we actually work on our project files.
- The second box is the staging or also called index area. That's the place where we package the files for a commit.
- The third place is the local repository. That's the place where all the created commits and other objects are stored.
By initializing a Git repository (using git init
) a hidden directory named “.git” is created.
This directory contains the index file, the local repository and all the other information that is necessary for our project. Information about commits, remote repository if available, addresses, a lock which stores the commit history, et cetera.
You can see the “.git” directory is a bit of a magic place where we put our magic show in.
If we want to destroy a local repository, we just have to re-delete this folder. That is why this folder is hidden to omit that we accidentally deleted.