GitHub Repositories – Create, Clone and Manage Repositories
A development team is building an employee management application. One developer creates the employee API, another works on the React interface, and a third developer handles database integration. All of them need access to the same project files without overwriting each other's work.
Sharing source-code folders through email or copying files manually is not a reliable solution. Developers need a central place to store project files, track changes, collaborate, and maintain a history of the application.
This is where a GitHub repository becomes important. A repository gives a project a home on GitHub and provides the foundation for version control and team collaboration.
- What a GitHub repository is and how it is organised.
- How to create a new repository on GitHub.
- How to clone an existing repository to your computer.
- How to initialise a local Git repository and connect it to GitHub.
- How to add, commit, push, pull, and fetch changes.
- How to manage repository visibility, README files, and .gitignore.
- Common repository mistakes and practical team practices.
1. What Is a GitHub Repository?
A repository, commonly called a repo, is a project workspace that stores files and their version history. It can contain source code, configuration files, documentation, scripts, tests, images, and other project resources.
When you create a repository on GitHub, you create a remote repository hosted on GitHub's platform. Developers can access it according to the permissions and visibility settings configured for that repository.
Git versus GitHub
Git and GitHub are related, but they are not the same thing.
| Git | GitHub |
|---|---|
| A distributed version control system. | A cloud-based platform for hosting Git repositories and collaborating. |
| Runs locally on your computer. | Provides remote repository hosting and collaboration features. |
| Tracks changes and maintains commit history. | Provides pull requests, issues, reviews, permissions, and other tools. |
| Can work without an internet connection for local operations. | Normally requires network access to interact with hosted repositories. |
| Can connect to different Git hosting providers. | Uses Git as its underlying version control system. |
2. Understanding the Repository Structure
A GitHub repository is more than a folder containing source code. It includes project files and Git metadata that help track the development history.
Consider an employee management application built using ASP.NET Core Web API and ReactJS.
employee-management/
│
├── backend/
│ ├── Employee.Api/
│ ├── Employee.Application/
│ ├── Employee.Domain/
│ └── Employee.Infrastructure/
│
├── frontend/
│ ├── src/
│ ├── public/
│ └── package.json
│
├── tests/
│ └── Employee.Api.Tests/
│
├── docs/
│ └── architecture.md
│
├── .gitignore
├── README.md
└── LICENSE
Here is what the important files and folders represent:
| Item | Purpose |
|---|---|
backend/ |
Contains server-side application code. |
frontend/ |
Contains the user interface application. |
tests/ |
Contains automated tests. |
docs/ |
Contains technical documentation and design information. |
.gitignore |
Specifies intentionally untracked files and directories that Git should ignore. |
README.md |
Explains the project, setup instructions, usage, and other important information. |
LICENSE |
Describes the permissions and conditions for using and distributing the project. |
.git/ |
Stores Git's internal repository data and history. It is normally hidden. |
The .git directory is created when you initialise a repository using Git or clone an existing repository. It contains the metadata required to manage commits, branches, references, and repository configuration.
3. Types of GitHub Repositories
When creating a GitHub repository, you generally choose between two visibility options: public and private.
Public repository
A public repository can be viewed by anyone on the internet. Other developers can discover the project, read its source code, and clone it. Their ability to contribute changes depends on the repository's collaboration settings and permissions.
Typical use cases include:
- Open-source projects.
- Public learning projects and tutorials.
- Developer portfolios and sample applications.
- Libraries intended for community use.
Private repository
A private repository is accessible only to the owner and users or teams who have been granted access.
Typical use cases include:
- Enterprise application source code.
- Internal business applications.
- Work in progress and proprietary projects.
- Projects containing confidential implementation details.
4. Create a Repository on GitHub
Let us create a repository for our employee management application using the GitHub website.
Step 1: Sign in to GitHub
- Open https://github.com/.
- Sign in to your GitHub account.
- Open the repository creation option using the New repository action or the repository creation page.
Step 2: Enter repository details
Provide the following information:
| Field | Example value | Description |
|---|---|---|
| Repository name | employee-management |
A clear name for the project. |
| Description | Employee management application using ASP.NET Core and React. | A short explanation of the project. |
| Visibility | Private | Limits access to authorised users. |
| Add README | Enabled | Creates an initial project description. |
| .gitignore | VisualStudio | Can add common Visual Studio-generated files to ignore. |
| License | None for this example | Select an appropriate license when required. |
Step 3: Create the repository
Review the repository name, visibility, and initialisation options. Select Create repository.
GitHub creates the remote repository and displays its main page. You can now add files through the website, upload existing files, or connect your local project using Git.
5. Clone an Existing GitHub Repository
Creating a repository on GitHub gives you a remote project location. To work with the project on your computer, you can clone it.
Cloning creates a local copy of a remote Git repository, including its available commit history and repository configuration. It also configures the remote repository, normally using the name origin.
Step 1: Copy the repository URL
- Open your GitHub repository.
- Select the Code button.
- Choose HTTPS or SSH.
- Copy the displayed repository URL.
For our example, the URL might look like this:
https://github.com/your-username/employee-management.git
The URL above is an example. Replace your-username with the actual GitHub account or organisation that owns the repository.
Step 2: Clone the repository
Open a terminal or command prompt, navigate to the folder where you want to keep your projects, and execute:
Example 1: Clone a GitHub repository
git clone https://github.com/your-username/employee-management.git
Expected terminal output
Cloning into 'employee-management'... remote: Enumerating objects... remote: Counting objects... Receiving objects: 100% ... Resolving deltas: 100% ...
The exact output, object counts, and progress percentages depend on the repository. The example shows the typical stages of a successful clone.
Step 3: Navigate into the cloned repository
cd employee-management
git status
Expected output for a clean working tree
On branch main Your branch is up to date with 'origin/main'. nothing to commit, working tree clean
The branch name may differ depending on the repository's default branch. The important point is that your local directory is now connected to the cloned Git repository.
HTTPS versus SSH cloning
GitHub supports different connection methods. HTTPS and SSH are common choices for developers.
| HTTPS | SSH |
|---|---|
| Uses an HTTPS repository URL. | Uses an SSH repository URL. |
| Authentication commonly uses a credential manager or personal access token where required. | Uses an SSH key pair configured with GitHub. |
| Often convenient for beginners. | Useful for developers who prefer SSH key-based authentication. |
Example: https://github.com/user/repo.git |
Example: git@github.com:user/repo.git |
6. Create a Local Repository and Connect It to GitHub
In the previous section, we cloned a repository that already existed on GitHub. Now let us look at another common situation.
You have already developed an application on your computer, and you want to publish it to GitHub for the first time.
In this case, you can initialise a local Git repository and connect it to a new empty remote repository.
Step 1: Create a project folder
mkdir employee-management
cd employee-management
Step 2: Add a sample project file
Create a file named README.md in the project directory.
# Employee Management
An employee management application.
## Technology Stack
- ASP.NET Core Web API
- ReactJS
- SQL Server
Step 3: Initialise Git
Execute the following command:
git init
Expected output
Initialized empty Git repository in .../employee-management/.git/
This creates the hidden .git directory and turns the current folder into a local Git repository.
Step 4: Configure your Git identity
Git records author information in commits. If you have not configured your identity on this computer, set it before creating your first commit.
git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"
Use an email address associated with your GitHub account if you want GitHub to associate your commits with your profile.
Step 5: Add files to the staging area
git add README.md
To stage all eligible changes under the current directory, use:
git add .
Git's staging area allows you to select which changes should become part of the next commit.
Step 6: Create the first commit
git commit -m "Initial commit"
Illustrative output
[main (root-commit) abc1234] Initial commit 1 file changed, 7 insertions(+) create mode 100644 README.md
The commit identifier and exact statistics will differ based on the files and content in your project.
Step 7: Create an empty repository on GitHub
Create a repository named employee-management on GitHub. For this workflow, leave the README, .gitignore, and license initialisation options unchecked so the remote repository starts without an independent initial commit.
Step 8: Connect the local repository to GitHub
Copy the HTTPS URL of the newly created repository and configure it as the remote named origin.
git remote add origin https://github.com/your-username/employee-management.git
Verify the remote configuration:
git remote -v
Expected output
origin https://github.com/your-username/employee-management.git (fetch) origin https://github.com/your-username/employee-management.git (push)
Step 9: Push the local commit to GitHub
For this example, we use main as the local branch name.
git branch -M main
git push -u origin main
Expected result
Enumerating objects... Counting objects... Writing objects... To https://github.com/your-username/employee-management.git * [new branch] main -> main branch 'main' set up to track 'origin/main'.
After a successful push, refresh the GitHub repository page. Your README and committed files should now be visible.
7. Understand the Local and Remote Repository Workflow
When working with GitHub, it is important to understand the relationship between your local repository and the remote repository.
- Working directory: The files you currently edit on your computer.
- Staging area: The selected changes prepared for the next commit.
- Local repository: The commits and history stored on your computer.
- Remote repository: The repository hosted on GitHub.
The local Git workflow prepares and records changes before synchronising commits with the remote GitHub repository.
Important Git commands for repository management
| Command | Purpose |
|---|---|
git init |
Initialises a local repository. |
git clone URL |
Copies a remote repository locally. |
git status |
Shows the current working-tree and staging status. |
git add . |
Stages eligible changes under the current directory. |
git commit -m "message" |
Creates a commit from staged changes. |
git remote -v |
Lists configured remote URLs. |
git push |
Sends local commits to a remote repository. |
git fetch |
Downloads remote updates without integrating them into the current branch. |
git pull |
Fetches remote updates and integrates them into the current branch. |
8. Push, Fetch, and Pull: Managing Repository Changes
Once your local repository is connected to GitHub, you need to synchronise changes between your computer and the remote repository.
Push local changes to GitHub
Suppose you update the README file and want to publish that change.
git status
git add README.md
git commit -m "Update project documentation"
git push
The push operation sends commits from your local repository to the configured remote branch, provided the remote accepts the update and you have the required permissions.
Fetch remote changes
Use git fetch when you want to download information about remote updates without automatically integrating them into your current branch.
git fetch origin
After fetching, you can inspect the remote-tracking information and decide how to integrate the changes.
Pull remote changes
Use git pull to fetch remote changes and integrate them into your current branch.
git pull
Git may integrate changes using a fast-forward update or a merge, depending on the repository history and configuration. If local and remote changes conflict, you may need to resolve the conflict before completing the integration.
9. Manage Repository Files and Documentation
A well-managed repository should be understandable to another developer who opens it for the first time. Two important files that help achieve this are README.md and .gitignore.
README.md
A README file introduces your project. GitHub displays the README content on the repository's main page when it is available in the expected location.
A useful README can include:
- Project name and purpose.
- Features and technology stack.
- Prerequisites and installation instructions.
- Configuration and environment setup.
- Commands to build, run, and test the application.
- API documentation or example requests.
- Contribution guidelines and license information.
Example: README.md
# Employee Management
A sample employee management application.
## Technology Stack
- ASP.NET Core Web API
- ReactJS
- SQL Server
## Prerequisites
- .NET SDK
- Node.js
- SQL Server
## Getting Started
1. Clone the repository.
2. Configure the application settings.
3. Restore backend dependencies.
4. Install frontend dependencies.
5. Run the backend and frontend applications.
## Features
- Employee creation and updates
- Employee search
- Employee details management
Keep setup instructions accurate. If the project requires environment variables, explain how to configure them using safe example values instead of publishing real credentials.
.gitignore
During development, tools generate temporary files, build output, local configuration, and IDE-specific metadata. These files usually do not belong in source control.
The .gitignore file tells Git which untracked files and paths to ignore.
Example: .gitignore for a .NET and React project
# .NET build output
bin/
obj/
# Visual Studio files
.vs/
*.user
*.suo
# Node dependencies
node_modules/
# Frontend build output
dist/
build/
# Environment files
.env
.env.local
# Operating system files
.DS_Store
Thumbs.db
10. Rename, Change, and Remove Repository Remotes
As projects evolve, you may need to rename a remote, change its URL, or remove an old remote configuration.
View configured remotes
git remote -v
Rename a remote
For example, rename the remote called origin to upstream:
git remote rename origin upstream
Change a remote URL
If the repository URL changes, update the existing remote:
git remote set-url origin https://github.com/your-username/new-repository.git
Remove a remote
To remove a remote configuration from your local repository:
git remote remove origin
This removes the local remote reference. It does not delete the repository hosted on GitHub.
11. Repository Settings and Access Management
GitHub provides repository settings that help owners manage access, collaboration, and repository behaviour.
Depending on your repository permissions and account or organisation plan, you may be able to manage settings such as:
- Repository visibility: Public or private.
- Collaborators: Invite users to access a repository.
- Teams: Manage access through organisation teams.
- Default branch: Select the branch used as the repository's default.
- Branch protection and rulesets: Apply rules that control how changes are made to important branches.
- Webhooks and integrations: Connect external systems to repository events.
- Security settings: Configure supported security and dependency features.
For an enterprise project, access should follow the principle of least privilege. Give developers the permissions they need to perform their responsibilities, rather than granting broad access by default.
Deleting a repository
GitHub also provides an option to delete a repository from its settings. Repository deletion is a destructive administrative action and should be performed only when authorised.
- Confirm that the repository is no longer required.
- Check whether applications or automation depend on it.
- Confirm that required data and history have been backed up.
- Check organisation retention and approval policies.
- Understand GitHub's repository deletion and recovery rules before proceeding.
12. Common Repository Problems and Solutions
Problem 1: Repository not found
You execute a clone command and receive a repository-not-found error.
Possible reasons:
- The repository URL is incorrect.
- The repository was renamed, moved, or deleted.
- The repository is private and your account does not have access.
- Your authentication method is not configured correctly.
Check the repository URL and verify that the authenticated GitHub account has access.
Problem 2: Authentication failed
You cannot push or clone using HTTPS.
Check your credential manager and authentication configuration. For HTTPS operations, use a supported authentication method such as Git Credential Manager or an appropriately scoped personal access token when required.
Problem 3: Remote origin already exists
You execute git remote add origin ... but Git reports that the remote already exists.
First inspect the existing remote:
git remote -v
If the URL is incorrect, update it instead of adding another remote with the same name:
git remote set-url origin https://github.com/your-username/employee-management.git
Problem 4: Push rejected because remote contains changes
A push may be rejected when the remote branch contains commits that your local branch does not have.
Inspect the current state and integrate the remote changes using the team's chosen workflow. For a straightforward case where the histories can be integrated safely, you can fetch and then pull before pushing again.
git fetch origin
git pull origin main
git push origin main
If Git reports unrelated histories or conflicts, stop and inspect the repository history before choosing a recovery approach. Do not use force-push as a shortcut to bypass a rejected push.
Problem 5: Accidentally committed generated files
Check whether the files are tracked and update your .gitignore rules. If you need Git to stop tracking a file while keeping it in your working directory, you can use:
git rm --cached path/to/file
Then commit the change. For a directory, use the appropriate recursive option after checking the path carefully.
13. Real-World Repository Management in a Development Team
Consider a team building an employee management platform. The project contains a backend API, frontend application, database scripts, automated tests, and technical documentation.
A practical repository workflow could look like this:
The project owner creates a private GitHub repository named employee-management and configures the initial access permissions.
Developers clone the repository to their own computers and verify the remote configuration.
The team adds backend, frontend, tests, documentation, README, and .gitignore files to the repository.
Developers stage and commit their work with meaningful commit messages.
Developers fetch and pull relevant remote updates and push their own commits according to the team's workflow.
The team uses branches and pull requests to review and integrate changes. These collaboration concepts will be covered in the upcoming GitHub articles.
This approach provides a central source-code location, traceable project history, and a consistent starting point for every developer.
14. Repository Management Best Practices
- Use meaningful repository names: Choose names that clearly communicate the project purpose.
- Write a useful README: Document prerequisites, configuration, setup, and execution instructions.
- Maintain a suitable .gitignore: Exclude build output, temporary files, local IDE data, and generated dependencies.
- Choose visibility carefully: Confirm whether the repository should be public or private before adding project content.
- Protect sensitive information: Never commit passwords, tokens, private keys, or production credentials.
- Use meaningful commits: Commit messages should explain the purpose of the change.
- Review permissions: Grant only the access required for each collaborator.
- Keep documentation updated: Update setup and usage instructions when the project changes.
- Synchronise carefully: Fetch and inspect remote changes before integrating when the situation requires it.
- Follow team conventions: Agree on repository structure, naming, and collaboration practices.
15. GitHub Repository Interview Questions
A GitHub repository is a hosted Git project that stores files and version history. It supports collaboration through features such as issues, pull requests, reviews, and access controls.
git init creates a new local Git repository in the current directory. git clone creates a local copy of an existing remote repository, including its available history and remote configuration.
origin is the conventional default name given to the remote from which a repository was cloned. It is a remote name, not a special GitHub server or a mandatory keyword. You can rename it or use other remote names.
A local repository exists on your computer and stores local Git history. A remote repository is hosted on a server or Git hosting platform such as GitHub and can be shared with other developers.
README.md provides an introduction to the project. It commonly explains the purpose, features, prerequisites, installation steps, configuration, and usage instructions.
.gitignore specifies untracked files and directories that Git should ignore. It is commonly used for build output, temporary files, IDE-generated content, and local environment files. It does not automatically untrack files already committed.
git fetch downloads remote updates without integrating them into the current branch. git pull fetches updates and then integrates them into the current branch.
Yes. A user can clone a private repository if they have the required access and have configured an accepted authentication method.
No. git remote remove origin removes the remote configuration from the local repository. It does not delete the remote repository hosted on GitHub.
Git creates a local working copy, downloads the available repository history, configures a remote (normally named origin), and checks out the repository's default branch.
Yes. Git is a distributed version control system that can maintain a repository and its history locally. GitHub is one of several platforms that can host Git repositories.
Committed secrets may be exposed to users who can access the repository and may remain recoverable from Git history even after deletion from the latest version. Revoke or rotate exposed credentials and use a secure secrets-management approach.
16. Hands-On Practice
Now create and manage your own GitHub repository by completing the following exercise.
Exercise: Create a project repository
Objective: Create a repository named upgradix-github-practice and connect it to a local project.
- Create a new repository on GitHub.
- Choose public or private visibility based on your preference.
- Create a local project folder with the same name.
- Initialise Git using
git init. - Create a README.md file describing your project.
- Create a .gitignore file appropriate for your technology stack.
- Stage your files using
git add .. - Create an initial commit.
- Connect your local repository to GitHub using
git remote add origin. - Push your main branch to GitHub.
- Clone the repository into another directory and verify that the files are available.
Challenge questions
- What happens if you execute
git initinside a folder that is already a Git repository? - Why might cloning a repository be better than downloading its ZIP file?
- What is the difference between deleting a file locally and removing it from Git tracking?
- Why should a local project and remote repository have compatible histories before pushing?
- How would you change the remote URL after a repository is transferred to another organisation?
Expected result: You should have a local Git repository connected to GitHub, with your project files and initial commit visible on the remote repository page.
17. Conclusion
A GitHub repository is the foundation of source-code management and collaboration on GitHub. It provides a central location for project files, commit history, documentation, and team access.
In this article, you learned how to create a repository, clone an existing project, initialise a local repository, connect it to GitHub, and manage changes using essential Git commands.
Understanding these operations is important before moving into more advanced Git and GitHub workflows. Once you are comfortable with repository management, you can start working with commits, branches, merges, and pull requests.
- A repository stores project files and version history.
- Use GitHub to host and collaborate on Git repositories.
- Use
git cloneto get an existing repository locally. - Use
git initto initialise a new local repository. - Use
git remoteto configure the remote repository. - Use
git add,git commit, andgit pushto publish local changes. - Use README and .gitignore files to keep the repository understandable and organised.
Official Documentation and Further Learning
- GitHub Docs – Creating and managing repositories
- GitHub Docs – Quickstart for repositories
- GitHub Docs – Cloning a repository
- Git Documentation – git init
- Git Documentation – git clone
- Git Documentation – git remote
- Git Documentation – git push
Upgradix by Shrash Studio – Learn Technology. Build Your Future.
Quality Technology Education. Completely Free.