Open In App
Related Articles

How to Add Code on GitHub Repository?

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
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.


Last Updated : 10 Nov, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads