Lesson 1 — Repository Basics and the Code Tab¶
1. Learning objectives¶
By the end of this lesson, you should understand:
- What a Git repository is.
- The difference between Git and GitHub.
- How to create and clone a repository.
- How to configure Git.
- How to inspect repository status.
- How to create, modify, stage, and commit files.
- How to push changes to GitHub.
- The main sections of the GitHub Code tab.
2. Git vs GitHub¶
Git¶
Git is a distributed version control system.
It tracks changes in your project and allows you to:
- Record project history.
- Compare versions.
- Create branches.
- Restore previous versions.
- Collaborate with other developers.
GitHub¶
GitHub is a hosting and collaboration platform built around Git.
It provides:
- Remote repositories.
- Pull requests.
- Issues.
- Actions.
- Projects.
- Security tools.
- Code review.
- Releases.
Git works locally on your computer. GitHub hosts remote repositories and provides collaboration features.
3. Install and verify Git¶
Check whether Git is installed:
Example output:
If Git is not installed, download it from:
4. Configure Git¶
Configure your author information:
These values are used as the author information in your commits.
Inspect your configuration:
Get one specific value:
The --global option applies the configuration to all repositories for your operating-system user.
You can override these values inside an individual repository by running the commands without --global.
5. Create a GitHub repository¶
Create a repository on GitHub:
- Open GitHub.
- Select New repository.
- Enter the repository name.
- Choose Public or Private.
- Add a README if appropriate.
- Create the repository.
For this training, use:
6. Clone the repository¶
Cloning downloads a remote repository to your computer.
Move into the project:
Open it in VS Code:
The code . command opens the current directory in Visual Studio Code.
7. Understand the local repository¶
A Git repository contains a hidden .git directory.
It stores Git metadata, including:
- Commit history.
- Branch references.
- Repository configuration.
- Object database.
- Remote information.
Do not manually modify .git unless you know exactly what you are doing.
8. Inspect repository status¶
This command displays:
- The current branch.
- Files that are modified.
- Files that are untracked.
- Files staged for commit.
- Whether the local branch is synchronized with its upstream branch.
Use it frequently.
9. Create a project file¶
Create a directory:
Create a Markdown file inside it:
Example content:
## Project Overview
This repository is used to learn Git and GitHub.
## Topics
- Repositories
- Branches
- Commits
- Pull Requests
- GitHub Actions
10. Stage changes¶
Git has three important areas:
- Working directory: files you are editing.
- Staging area: changes selected for the next commit.
- Repository: committed project history.
Stage one file:
Stage all changes:
Check the result:
11. Create a commit¶
A commit records a snapshot of staged changes.
A commit includes:
- A unique identifier.
- Author information.
- Date.
- Commit message.
- References to the project snapshot.
12. Push changes to GitHub¶
If the branch does not yet have an upstream configured:
The -u option establishes the upstream relationship so future pushes can usually use git push.
13. Understand the GitHub Code tab¶
The Code tab is the main interface for browsing repository contents.
Important elements include:
Repository files¶
Browse directories and files.
Branch selector¶
Switch between available branches to inspect their contents.
Commits¶
View the history of changes.
README¶
GitHub displays the README on the repository homepage.
Releases¶
View published versions of the project.
Tags¶
View named references to specific commits.
Repository navigation¶
Other important repository tabs include:
- Issues
- Pull requests
- Actions
- Projects
- Wiki
- Security
- Insights
- Settings
14. Important commands reference¶
| Command | Purpose |
|---|---|
git --version |
Check Git version |
git config --global --list |
Display global configuration |
git clone URL |
Clone a repository |
cd DIRECTORY |
Change directory |
code . |
Open current directory in VS Code |
git status |
Inspect working tree |
git add FILE |
Stage a file |
git add . |
Stage all changes |
git commit -m "MESSAGE" |
Create a commit |
git push |
Push commits |
git remote -v |
Display remote URLs |
15. Practical exercise¶
Using your github-deep-dive-training repository:
- Create
docs/project-overview.md. - Add a short project description.
- Run
git status. - Stage the file.
- Inspect the staged changes.
- Commit the file.
- Push the commit to GitHub.
- Open GitHub and verify that the file is visible.
Useful commands:
git status
git add docs/project-overview.md
git diff --cached
git commit -m "docs: add project overview"
git push
16. Completion checklist¶
- [ ] Git is installed.
- [ ] Git identity is configured.
- [ ] GitHub repository is created.
- [ ] Repository is cloned locally.
- [ ] VS Code opens the repository.
- [ ] A Markdown file is created.
- [ ] Changes are staged.
- [ ] A commit is created.
- [ ] Changes are pushed.
- [ ] The file is visible on GitHub.
17. What comes next?¶
Lesson 2 covers Git branches, including creating branches, switching between branches, renaming branches, deleting branches, and understanding local versus remote branches.