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.
- Directly your code file to the repository
- 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.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!