A GitHub repository is a project space where you can store source code, documentation, configuration files, and Git history. Creating a repository is one of the first steps when starting a project on GitHub.
A GitHub repository is a project space hosted on GitHub. It can contain source code, documentation, images, configuration files, and Git history.
my-project/
├── index.html
├── style.css
├── script.js
└── README.md
A repository provides a central location for managing and sharing project files.
The general process for creating a repository is:
The repository name identifies the project on GitHub.
Examples:
student-management
my-portfolio
online-library
weather-app
Choose a clear name that describes the project.
A repository description briefly explains what the project does.
Example:
Student management system built with PHP and MySQL.
A clear description helps visitors understand the purpose of the repository.
A public repository is intended to be visible to people according to the repository's access settings.
Public repositories are commonly used for open-source projects, learning projects, portfolios, and examples.
A private repository restricts access to authorized users.
Private repositories can be useful for projects that should not be publicly accessible.
A README file provides information about the project.
README.md
It can contain:
README.md is a Markdown file commonly used to document
a project.
GitHub automatically displays the README on the repository's main page when it is present.
A .gitignore file tells Git which files and directories
should normally not be tracked.
Examples of files that may be ignored include:
.env
node_modules/
*.log
A license can describe how others may use, modify, and distribute project code.
When creating a repository, GitHub may provide options for adding a license file.
You can create a repository without automatically adding files. This can be useful when you already have a local Git project and want to connect it to GitHub.
Local Project
↓
Git Repository
↓
GitHub Empty Repository
If you already have a project on your computer, you can create a GitHub repository and then connect your local Git repository to it.
git remote add origin https://github.com/username/project.git
If your local project is not already a Git repository, initialize it with:
git init
Then check its status:
git status
After initializing a local repository, add the project files and create a commit.
git add .
git commit -m "Initial project"
The commit records the current project state in Git history.
Connect the local repository to the GitHub repository using:
git remote add origin https://github.com/username/project.git
The name origin is commonly used for the remote.
After adding the remote, verify it using:
git remote -v
Example:
origin https://github.com/username/project.git (fetch)
origin https://github.com/username/project.git (push)
After creating a local commit and connecting the remote, push the branch to GitHub:
git push -u origin main
The -u option establishes upstream tracking for the
branch.
A GitHub repository normally has a URL based on the account name and repository name.
https://github.com/username/project
The Git remote URL may use the Git URL form:
https://github.com/username/project.git
Repository settings provide options for managing repository configuration, access, features, and other project settings.
The available options depend on the repository and account configuration.
A repository can contain many types of project files.
my-project/
├── index.php
├── style.css
├── app.js
├── images/
├── README.md
└── .gitignore
The exact structure depends on the project.
A repository can contain multiple branches for different lines of development.
main
develop
feature-login
bugfix-payment
Branches help developers work on changes independently before integrating them.
GitHub Issues can be used to track bugs, tasks, feature requests, and other project work.
Example:
Issue #12
Add student login validation
Pull requests allow developers to propose changes and discuss them before integrating those changes into another branch.
feature-login
↓
Pull Request
↓
main
Repository access can be provided to other users so that teams can work together.
The actions available to a collaborator depend on the permissions assigned to them.
.gitignore.Sign in to GitHub
↓
Create Repository
↓
Choose Name
↓
Choose Visibility
↓
Add README / .gitignore if needed
↓
Create Repository
↓
Connect Local Git
↓
Push Code
mkdir my-project
cd my-project
git init
git add .
git commit -m "Initial project"
git remote add origin https://github.com/username/my-project.git
git branch -M main
git push -u origin main
This is a common pattern for publishing an existing local Git project to a newly created GitHub repository.
.gitignore.Creating a GitHub repository provides a remote project space for storing and collaborating on Git-based projects.
Create Repository
↓
Configure Project
↓
Connect Git Remote
↓
Commit Changes
↓
Push to GitHub
For an existing local project, the important commands are:
git init
git add .
git commit -m "Initial project"
git remote add origin URL
git push -u origin main
README.md is commonly used for project documentation..gitignore specifies files Git should normally ignore.git remote add origin URL adds a remote.git remote -v verifies the remote URL.git push -u origin main can push the first main branch and set upstream tracking.Question: Which command connects a local Git repository to a GitHub repository using the remote name origin?