Your First Repository
💻 GitInstall Git, configure your identity and create a repository.
Every Git project starts with a repository and a configured identity. Do this once and every commit will carry the right name and email.
- Configure user.name and user.email.
- Create a repository with git init.
- Understand the default branch name.
Configure Your Identity
Git stamps every commit with a name and email. Set them globally once.
git config --global user.name "Ada Obi"
git config --global user.email "ada@example.com"
git config --global init.defaultBranch main
git config --listCreate a Repository
Run git init inside the project folder. Git creates a .git directory and begins tracking.
mkdir my-project
cd my-project
git initCheck Status
git status is the command you will run most. It tells you which files are untracked, modified or staged.
git statusPractice
- Configure your name and email for Git.
- Create a folder, initialise a repository and run git status.
- Explain the difference between an untracked and a modified file.
Hands-on exercise
In a new folder:
1. Initialise Git.
2. Create a file called README.md with one line.
3. Run git status and read the output.
4. Stage the file and run git status again.
Recap
Configure your identity once, initialise a repository per project and use git status to see what Git knows.
Example
git config --global user.name "Ada Obi"
git config --global user.email "ada@example.com"
git config --global init.defaultBranch main
git config --list
Exercises
1. Initialise Git.
2. Create a file called README.md with one line.
3. Run git status and read the output.
4. Stage the file and run git status again.
Expected Output
README.md moves from untracked to staged.
Lesson Nav
Git Course
0/9 lessons completed
- 1 Why Version Control Matters Tutorial
- 2 Your First Repository Tutorial
- 3 Staging and Committing Tutorial
- 4 History, Diffs and Logs Tutorial
- 5 Branching Tutorial
- 6 Merging and Resolving Conflicts Tutorial
- 7 Remotes and Collaboration Tutorial
- 8 Undoing Mistakes Safely Tutorial
- 9 Project: A Team Workflow Project