DEV Community

Cover image for Introduction to repositories
G Venkata Sandeep Reddy
G Venkata Sandeep Reddy

Posted on • Edited on

Introduction to repositories

Table of Contents

What is a Repository?
How to create a repository
Adding files to a repository
How to fork a repository
Excercise

What is a Repository?

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.

How to create a repository

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.

  1. In the upper-right corner of any page, use the drop-down menu, and select New repository. New Repository
  2. Use the Owner dropdown menu to select the account you want to own the repository. Owner dropdown menu
  3. Type a name for your repository, and an optional description. name for your repository
  4. Add Description to the repository (optional) Description to the repository
  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
  6. Enable Add a README file Add a README file
  7. Click Create repository and congratulations! You just created a repository!

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

Adding files to a repository

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
  4. In the file name field, type the name and extension for the file. To create subdirectories, type the / directory separator. File Attributes
  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
  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
  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
  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!

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
  4. Upload files either by using drag and drop or select using Choose your files feature. Upload files feature
  5. In the Commit Changes tab, Commit Changes tab
    • 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.

How to fork a repository

Demonstrated repository

  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
  3. Modify the fields only if necessary for better understandability.(Here we are not modifying any fields) Create a fork
  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!.

Excercise

Follow the instructions in the repository's 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.

Top comments (0)