Set up a repository
- Git course
- Beginner
- Lesson 77/80
- 6 min
Set up a repository with init, add and commit to record the first snapshot.
Create Your First Git Repository
To manage a new project folder with Git, you first initialize a repository inside it. The git init command creates the required Git structure.
mkdir my-first-project
cd my-first-project
git initYou can now track files in this folder and build a history of your changes with Git.
Practice Prepare Your File for the First Commit
Add the README.md file to the area Git will track. Then print a message indicating that the operation is complete.
Starter code
print("Depo hazır")Sample solution
git add README.md
print("Dosya kayda hazır")Expected output
Depo hazır Dosya kayda hazır
Practice Create the First Commit
Add the README.md file in the new repository and create the first commit with the message Initial project snapshot. Then print a completion message.
Starter code
git initSample solution
git add README.md
git commit -m "İlk proje kaydı"
print("İlk commit oluşturuldu")Expected output
İlk commit oluşturuldu
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which command turns a new folder into a Git repository?
- git add
- git commit
- git status
- git init Correct answer
Explanation: Correct. git init initializes a new Git repository in the current folder.
2 Initialize the First Repository
git ____
git init
Explanation: The git init command creates a new Git repository in the current folder.
3 First Repository Commands
| Term | Meaning |
|---|---|
git init |
Initializes the repository |
git add |
Stages a file |
git commit |
Saves a snapshot |
git status |
Shows working status |