Command Shift

Tracking Changes

Tracking changes is the whole point of git, but in order to understand how they're processed, you must understand what the Working Tree and the Staging Area are.

Learning Objectives

  • Understand what the Working Tree is
  • Understand what the Staging Area is

The Working Tree is the repo where git is initialised, with all of its files and subdirectories. Think about it as a box, where you store everything related to your project. You can check your working tree with:

git status

Which shows all of your untracked files. Even though git is initialised, and it's tracking your changes, you still need an extra step to fully use its capabilities.

You can add specific files to what we call the staging area, by running the command:

git add fileName

Or you can add them all at once:

git add .

If you add a file to the staging area by mistake, you can always remove it with:

git reset fileName

Once you have some files in the staging area, you'll have to commit them. Your commit should also have a commit message which states the changes you made to the file, so anyone reviewing the code or using it after you understands what this commit is about. You can do so by running:

git commit -m "Your commit message goes in here."

Finally, you want to push those committed files to your remote repo. The first thing to do is to check if the remote one is connected to your local one:

git remote -v

If it is connected then your output should look something like:

Example git remote output

If not, you can connect them with:

git remote add origin urlPath

adding a remote

All you need to do is:

git push -u origin main

On this page