Git Add
Part of the Version Control section of Coddy's Terminal journey — lesson 10 of 58.
The git add command moves changes into the staging area. You name the file (or files) you want to stage:
git add hello.txtYou can stage several files at once, or use a wildcard:
git add file1.txt file2.txt
git add *.mdOr stage every change in the current folder with a single dot:
git add .After staging, git status --short shows the file with a different prefix. Untracked files used the ?? code; staged new files use A (for added).
A hello.txtThe file is now ready to be included in the next commit.
Challenge
BeginnerThe folder contains a file called welcome.txt. Initialize the repository, stage welcome.txt, then run git status --short.
The expected output is the staged-add line.
Cheat sheet
Use git add to move changes into the staging area:
git add hello.txt # single file
git add file1.txt file2.txt # multiple files
git add *.md # wildcard
git add . # everything in current folderAfter staging, git status --short shows A (added) prefix for newly staged files:
A hello.txtTry it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Version Control
2Getting Started
Initialize A RepositoryThe .git FolderConfigure Your IdentityGit StatusRecap - First Repo8Merging
What Is A MergeFast-Forward MergeThree-Way MergeMerge ConflictsResolve A ConflictRecap - Merge Master11Feature Branch Project
Project OverviewInitialize Main3Tracking Changes
The Staging AreaGit AddGit CommitModifying A Tracked FileGit LogRecap - First Commits6Recipe Site Project
Project OverviewInitialize And Ignore