git commit
- Git course
- Beginner
- Lesson 21/80
- 4 min
Learn to save staged changes with git commit.
What Does git commit Do?
git commit saves staged changes to the Git repository history. Each commit creates a snapshot of the files at that point in time.
git commitA Commit Is a Snapshot
A commit represents the recorded state of a project at a specific moment. This snapshot lets you refer back to previous changes and project states.
git add index.html
git commitPractice Prepare a Commit Command
Assign the git commit command to a string variable. Then print the command.
The expected output must contain only the commit command.
Starter code
// Commit komutunu tanımla
let commitCommand;
// Komutu ekrana yazdırSample solution
let commitCommand = 'git commit';
console.log(commitCommand);Expected output
git commit
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which changes does a commit save?
- All projects on the remote server
- All files on the computer
- Only changes added to the staging area Correct answer
- Only files that have not been created
Explanation: A commit saves the changes prepared in the staging area to the repository history.
2 Complete the Commit Command
git ____
git commit
Explanation: <code>git commit</code> saves staged changes to the repository history.
3 Match the Commit Concepts
| Term | Meaning |
|---|---|
git commit |
Save staged changes |
snapshot |
Recorded state at a moment |
message |
Description attached to a record |
repository |
Place containing commit history |