Git Overview
Git Areas
Git contains different areas with the purpose of tracking your changes and keeping information about local and remote repo.
A git project contains three states that is used to keep track of your work history. Your working directory which is where your project files live, The staging or index area which is where your next commit files live and Git directory which is where the metadata and database of your project lives.
Every commit starts with changes on your project. Once changes are made git will indicate there were changes made to your git repo. You can view this by executing a git status.
Once you finish with your current commit, you will need to stage your files into the staging area by executing a git add <files>
You can add as many files to the current commit as you want before executing a commit. If you have already committed the files you can append the newly staged files to the last commit by issuing a git commit –amend
Before you commit your changes to your repo, you’ll spend most of the time on the Working and Staging are of your project.
Git Working Tree
Working tree is the tree you are currently referring too when committing your changes.
Branches
A branch is a pointer to a commit. Branches are a way to identify a version of your project. Commits that don’t belong to any branch are referred to as orphan commits.
Git commit
As mentioned previously, any changes made in the working directory need to be added to the working tree by executing git add. Once files are staged, it needs to be committed so it can be referenced to from the git database.
Every iteration of changes in a project is referenced to as a commit. Commit contains information about the parent commit by the use of its metadata and the modifications made to the current commit. So when a file is added to a commit, only those files are are saved in the git database, the rest of the project is referenced to from the previous commits.