Add and tracked files
Git is a content tracker. So let’s add some content.
Create a few text files to keep notes on the commands we’re learning.
Run git status
to see what’s changed.
Note the addition of the Untracked files
section.
We now have files that can be added to git index.
Use git add <file>
to do so.
Run git status
again to
Now we see an additional section Changes to be comitted
.
Adding all changes
I’d be pretty irritated to add files one-by-one. Fortunately, Git gives us a number of options.
Most common is is the shortgut add.
Using .
adds all of the files in your working directory.
You can also use globs to select groupings of similar files.
Say, I wanted to only files with a .txt
suffix.
Assignment #1
Use the different approaches to add
files to the staging area.
Assignment #2
You may need to remove changes as well. Run git status
to discover the command git recommends for this.
Assignment #3
Check out the documentation for git-add
by running git help add
.
There’s an interactive mode that I use quite frequently but won’t cover in this guide.