Previously, you successfully created a new Git repository and added and tracked a single file under version control. Great job! With README.md safely under version control, ask Git again what's up:
git status
Untracked Files
Oh right! There were all these other mysterious lines describing a lot of other files. Maybe they even showed up in red:
Untracked files: (use "git add <file>..." to include in what will be committed)
01_python_fundamentals
02_basic_data_types
...
nothing added to commit but untracked files present (use "git add" to track)
Decipher the Message
Try to figure out what Git is telling you with this message:
- Untracked Files: There are files that Git can see inside of this folder, but they are not currently tracked under version control
01_python_fundamentals(etc.): Next, Git shows you a list of all the untracked files. I've truncated the output in the example above; yours is probably much longer- (use "git add" to track): Finally, Git tells you what you need to do in order to add your untracked files to version control: Use
git add <file>
Now that's pretty helpful; thank you, Git, for the hint!
You have already gone through this exact process with your README.md file. To gain further practice with the basic Git process, your next task is to add and commit everything else to version control. The basic Git process always stays the same, and you will use it a lot in your career as a software developer.
Git Commit Multiple Files
It's time to add and commit all contents of this folder under version control.
All Files Shortcut
To make that tedious task a little easier, Git provides you with a shortcut for adding many files at the same time:
git add .
The . in UNIX systems always stands for "this current directory". Therefore, as long as you're at the root of your Git repository, you can use this shortcut to add everything that is inside the current folder to the staging area.
Note: You always want to be aware of what you are adding to a Git commit. Therefore it is generally better to specifically name each file or folder that you are adding to a commit. In this case, since you're just setting up the repository, it is fine to add everything at once
Give it a go and brace yourself for the power of this command! Once you are done adding the files, remember to:
- Check the status
- Commit the files with a meaningful commit message
- Check the status again
If you get stuck, read over this page again, starting from the beginning, and follow along by adding the additional folders. The process is the same as the one you went over when adding the README.md file.
Check the Status
You are done with this exercise once you run git status and see a message saying that your working tree is clean:
On branch master nothing to commit, working tree clean
This means that every change to the Git repository is safely recorded in its very own history book.
Info: The output also mentions something that you haven't learned about yet: `On branch master``. You can think of branches as a way to make collaboration between different developers easier, but you don't have to worry about it at this point.
Additional Resources
- CodingNomads: Version Control with Git and GitHub course
Summary: Git Commit with Multiple Files
git add .will add all files inside the current folder- When using the
.shortcut, it is important to know which directory you're currently in and everything that's inside