Open In App

How to Add Code on GitHub Repository?

Last Updated : 10 Nov, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

Github is an open-source version control software that allows users to access the resources available on this platform. Github repository allows users to store their projects.

You can still add projects and files if you already have an existing repository, here we are discussing adding a file of a particular language. Suppose you have created a .cpp file then you can add this file to your repository for further use.

Ways:

To add code of a particular language Github provides several ways.

  1. Directly your code file to the repository
  2. Creating the new file by adding the snippet of code to the file

Approach 1: In order to upload directly your code file to the repository.

1.1 Choose the repository where you want to add the code.

1.2 Click on Add file and then on the Upload files option and choose the file to upload.

  

Upload files

1.3 Select the file from your system to add.

1.4 Click on the upload button.

Approach 2: One can create a new file by adding a snippet of code to the file. 

2.1 Choose the repository where you want to add the code.

2.2 Click on Add File and then click on the Create new file option.

2.3 Add the code snippet to the file as shown below as follows:

filename with extension

2.4 Make sure to add the extension of the file, for example, “.cpp” for CPP code or “.py” for Python code.

2.5 Click on Commit new file option.

With the usage of these two approaches, we can change the visibility of the repository.


Similar Reads

Creating a Pull Request on any Public Repository from GitHub using VS Code
Free and open-source, Git is a distributed version control system that makes collaborative software projects more manageable. Many projects maintain their files in a Git repository, and sites like GitHub have made sharing and contributing to code simple, valuable, and effective. You have to create a free account on https://github.com/ if you have t
6 min read
How to Open a GitHub Repository in VS Code Online?
It often feels as if one could view the files or code from a GitHub repository online in a code editor to search the files, code components, or simple text(and indeed, it does enhance the readability and management of the code) without having to clone it to your device. What if I tell you it hardly takes a second or two to open any GitHub repo in V
2 min read
How to Add GIFs on README .md File in a GitHub Repository?
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects. Github is a highly used software that is used for version control. It is more helpful when more than one person is working on a project. GIF as we all know stands for Graphics Interchange Format is a bitmap image format.
2 min read
How to Add Audio Files on README .md File in a GitHub Repository From the Local System?
Git is known as the free and open-source distributed version control system that is specially made to handle everything from small to very large projects. Github is a highly used software that is used for version control. When working in a team where we have more than one developer, this software comes in handy. In order to understand why do we nee
3 min read
How to Add Videos on README .md File in a GitHub Repository?
Git is known as the free and open-source distributed version control system that is specially made to handle everything from small to very large projects. GitHub is a highly used software that is used for version control. When working in a team where we have more than one developer, this software comes in handy. Proceeding further Git and GitHub ba
3 min read
How to Add Images on README .md File in a GitHub Repository From the Local System?
Adding images to your README.md file in a GitHub repository can significantly enhance the project documentation. Whether you're showing screenshots, diagrams, or other visuals, including images can make your README more engaging and informative. This article will guide you through the process of adding images to your README.md file from your local
3 min read
How to Clone Github Repository and Push Changes in Colaboratory?
If you are working with a Machine Learning project, the greatest bottleneck could be the lack of computational resources. With Google Colaboratory (Google Colab or Colab in short), now we have the freedom to use a GPU at your disposal. Here we are going to see how we can clone your GitHub repository into the Google Colab. To do so follow the below
2 min read
How to Change the Visibility of the GitHub Repository?
Github is an open-source version control software that allows users to access the resources available on this platform. Github repository allows users to store their projects in any visibility i.e. public or private. Public visibility allows everyone to access the data but this is not the case with private visibility the information is visible to t
2 min read
Creating Repository in GitHub
In this article, we will learn how to publish or upload projects to our GitHub account. This article will give you very detailed information about what is GitHub and how to set up a GitHub account. We will cover a brief introduction to GitHub and then we will step by step about How to create and manage a repository in our GitHub account. What are G
3 min read
How to Transfer Local Repository to GitHub Organization?
Transferring a local repository to a GitHub organization can simplify collaboration and project management. This article provides a detailed step-by-step process to help you move your local repository to a GitHub organization efficiently. PrerequisitesGitHub BasicsCreated Organization on GitHub Steps to Transfer Local RepositoryStep 1: Navigate to
2 min read
Article Tags :