Gitting stuff done

# Fullstack Bash Scripting notes & code

Gitting stuff done#

At this point you should have a directory with the name of your project. Maybe you’ve created a repository to try out some of the stuff in this book:

Go into your directory and you’ll see a hidden “.git” directory:

The “.git” directory contains all the information that the git commands use to keep track of changes to your files. You’ll learn about some of these below, but in general you should not need to change any of them manually.

Start your Git career by checking the status of the repository:

That’s a lot of nonsense if you’re not yet used to version control systems. A quick glossary:

  • Commit is a super important verb and noun. Each commit in a repository is a collection of file changes (a “diff”, short for “difference”) along with some metadata, including a long hexadecimal ID.

  • The working tree refers to the tree of files inside the repository except for the “.git” directory. Being “clean” means there are no relevant file changes; basically, nothing to do.

  • A branch is a marker assigned to a commit ID. When a branch is active and you create a commit the branch is moved to the new commit. People often talk about several commits being “on a branch” – this refers to the commit the branch is assigned to and all its ancestor commits. Commits will often be on more than one branch. In this case, when people talk about commits on a branch they usually mean the commits which are only on that branch.

  • “master” is the name of the default branch.

  • “origin” is the name of the default remote, basically the place you cloned from, and “origin/master” refers to the “master” branch on the “origin” remote. Being “up to date” means that as far as the local repository is concerned the current branch on the remote refers to the same commit as the current branch on your clone of the repository.

You might have noticed how I mention “files” but not “directories” above. This is deliberate, because for technical and historical reasons Git only tracks changes to the contents of files, not directories. Which means that you can’t track a completely empty directory in Git. This has led to a convention of creating an empty “.gitkeep” file within a directory you really do want to track, and tracking that file as a substitute for the directory.


This page is a preview of The newline Guide to Bash Scripting

No discussions yet