Introduction to repositories
Tags: github, developer
Published: 2024-06-08 04:14:03


## Table of Contents
[What is a Repository?](#repository)
[How to create a repository](#create a repository)
[Adding files to a repository](#add a file)
[How to fork a repository](#fork a repository)
[Excercise](#excercise)

## What is a Repository? <a name="repository"></a>
A **repository** contains all of your project's files, revision history, and collaborator discussion. You can use repositories to manage your work, track changes, store revision history and work with others. Before we dive too deep, let’s first start with how to create a repository.
<br>

## How to create a repository <a name="create a repository"></a>
You can create a new repository on your personal account or any organization where you have sufficient permissions.

Let’s tackle creating a repository from [github.com](https://github.com/).
1. In the upper-right corner of any page, use the drop-down menu, and select New repository.
![New Repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6hyvpa0iyriwv9bvwbcn.png)
2. Use the Owner dropdown menu to select the account you want to own the repository.
![Owner dropdown menu](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9v6o1r2j6zbxf16jhx0.png)
3. Type a name for your repository, and an optional description.
![name for your repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aniklkqm99z9bcsmdkq4.png)
4. Add Description to the repository (optional)
![Description to the repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m9q3g3l8frywp6cdu8u0.png)
5. Choose a repository visibility.
     * Public repositories are accessible to everyone on the internet.
     * Private repositories are only accessible to you, people you explicitly share access with, and, for organization repositories, certain organization members.
![Repository Visibility](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w3pmys083hlaohoqkipw.png)
6. Enable _Add a README file_
![Add a README file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8qcionhb7di3sb0901ic.png)
7. Click Create repository and congratulations! You just created a repository!

Next up, let’s review how to add files to your repository.
<br>

## Adding files to a repository <a name="add a file"></a>

Files in **GitHub** can do a handful of things, but the main purpose of files is to store data and information about your project.

Let’s review how to add a file to your repository.

But before we begin, it is worth knowing in order to add a file to a repository you must first have minimum Write access within the repository you want to add a file.

1. On GitHub.com, navigate to the main page of the repository.
2. In your repository, browse to the folder where you want to create a file.
3. Above the list of files, select the Add file ᐁ dropdown menu, then click ᐩ Create new file.
![Create new file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2tb2dd3oynbmk0fz63f5.png)
4. In the file name field, type the name and extension for the file. To create subdirectories, type the / directory separator.
![File Attributes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7nxlmlcoxq01vo9uc3sh.png)
5. In the file contents text box, type content for the file.
6. To review the new content, above the file contents, click Preview.
![Preciew tab](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h9r8y59oy1e2ch6o2cb9.png)
7. Click Commit changes...
8. In the "Commit message" field, type a short, meaningful commit message that describes the change you made to the file. You may provide _Extended description_ to the commit.
9. You can attribute the commit to more than one author in the commit message.
10. If you have more than one email address associated with your account on GitHub.com, click the email address drop-down menu and select the email address to use as the Git author email address. Only verified email addresses appear in this drop-down menu. If you enabled email address privacy, then [username]@users.noreply.github.com is the default commit author email address.
![Author Selection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v4cpivt2elv6qemx6qst.png)
11. Below the _Extended description_ field, decide whether to add your commit to the current branch or to a new branch. If your current branch is the default branch, you should choose to create a new branch for your commit and then create a pull request.
![Extended Description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vq41eivawa7vw4l0u2gf.png)
12. Click Commit changes or Propose changes.

Congratulations you just created a new file in your repository! You have also created a new branch and made a commit!
<br>

### Uploading files
1. On GitHub.com, navigate to the main page of the repository.
2. In your repository, browse to the folder where you want to create a file.
3. Above the list of files, select the Add file ᐁ dropdown menu, then click ᐩ Upload files.
![Upload Files](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/886t62e9h5tubyjlg00u.png)
4. Upload files either by using _drag and drop_ or select using _Choose your files_ feature.
![Upload files feature](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k0g0xjgoxrzts7b9i1mm.png)
5. In the Commit Changes tab,
![Commit Changes tab](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/va88g7rvawey0hl4xuqv.png)
     * In the "Commit message" field, type a short, meaningful commit message that describes the change you made to the file. You may provide _Extended description_ to the commit.
     * Below the _Extended description_ field, decide whether to add your commit to the current branch or to a new branch. If your current branch is the default branch, you should choose to create a new branch for your commit and then create a pull request.
6. Click Commit changes or Propose changes.

Congratulations you just created a new file in your repository! You have also created a new branch and made a commit!

**_We will discuss about pull request in coming posts_**.

<br>
<br>
## How to fork a repository <a name="fork a repository"></a>
**Demonstrated [repository](https://github.com/skills/introduction-to-github)**
1. Navigate to the Repository which we need to fork
2. In the Header part of the repository select fork option
![Header part of the repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p8y4y14lk7t5146604u8.png)
3. Modify the fields only if necessary for better understandability.(Here we are not modifying any fields)
![Create a fork](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zo5eu9r92w9ehrcgfy8c.png)
4. Here we are having an option called _Copy the **main** branch only_
    * This refers to copy only the main branch and then contribute back to the original Repository.
5. Click on Create fork

Congratulations you just created a Copy of [repository](https://github.com/skills/introduction-to-github)!.
<br>

##Excercise<a name="excercise"></a>
Follow the instructions in the [repository's](https://github.com/skills/introduction-to-github) README file to understand how the exercise works, its learning objectives, and how to successfully complete the exercise.
- **Note:**
     - You don't need to modify any of the workflow files to complete this exercise. Altering the contents in this workflow can break the exercise's ability to validate your actions, provide feedback, or grade the results.
     - Refresh page after 20 seconds when a step completed.