Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 1.19 KB

2-2-2.md

File metadata and controls

28 lines (19 loc) · 1.19 KB

Git Basics

Index / Git Basics / 2-2 Recording Changes to the Repository / 2-2-2 Tracking New Files

2-2-2 Tracking New Files

In order to begin tracking a new file, you use the command git add. To begin tracking the README file, you can run this:

$ git add README

If you run your status command again, you can see that your README file is now tracked and staged to be committed:

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
 (use "git reset HEAD <file>..." to unstage)
 new file: README

You can tell that it’s staged because it’s under the “Changes to be committed” heading. If you commit at this point, the version of the file at the time you ran git add is what will be in the subsequent historical snapshot. You may recall that when you ran git init earlier, you then ran git add <files> — that was to begin tracking files in your directory. The git add command takes a path name for either a file or a directory; if it’s a directory, the command adds all the files in that directory recursively.

...Prev Page <--------------> Next Page...