Repository management on Github

Alok Dubey
5 min readApr 1, 2024

--

Most of us use Github for storing our projects. For the those, who have not heard of this website, Github is a Version Control System that can help us to keep the verious versions of the projects.

Why do we need a Version Control Systems ?

As a developers, we have a requirement to keep the source code of the projects in a safe way. While doing the enhancements, there will be some situations, where in we have to revert back all the changes that had been done recently. In such scenarios, the Version Control Systems. These can come handy, whenever we need to know who had changed which part of the code as well. Version control codes take a snapshot of the files and they will make them available, whenever you need them.

How to use this ?

Prerequisites : To have a Github account and to have a Git Bash software on the personal computer.

Cloning of a repository from GitHub into a local machine and do the changes using Git Bash and upload the updated repository into GitHub
GitHub -> Git Bash-> GitHub

step 1 : Visit Github website to create a new repository. However, you should sign up, if you have never used this website earlier. You need to click on New Button as highlighted below.

Homepage of Github

and one will be directed to another webpage to enter the details of the new repository and then one had to select the Create Repository option. One had to enter the details such as name of the repository, Description, license type etc.

Entering repository details prior to creating a new repository

Once the repository is created, it will be shown as below.

Step 2 : One had to open the Git bash software on the user desktop and run the following commands. One had to navigate into the directory in which one would like to clone a repository (for example C:\users\maham\documents\GitHub)

pwd : To know the present working Directory

cd : To navigate to another directory or change directory

Navigating into a required Directory

One had to copy the url of the repository from Github website and use the command.

git clone “Name of url”

You can navigate into the below Github directory to check whether the files have downloaded.

Cloning of repository on a local machine

Step 3 : Add new directories in the newly cloned repository on the local machine. For simplicity, I have added two new directories i.e.., sourcecode and data folders and I have copied some of the files into these folders as well. You can either opt to change the existing files into the repository as well.

Addition of new files into the repository

Step 4 : One had to run the following command to know the folders in the present working directory. to display the hiddent files, one had to use “-a” option in the command.

git ls

git ls -a

Display of contents of the Directory

Step 5 : To check the status of the existing repository, one had to use the following command. If the local file had been modified, the status will be shown as modified. If a new file had been added, then the status will be shown as untracked files.

git status

Display of status of local repository of gits

As we had two new directories and copied some files into this directory, git is displaying the status as untracked files in my case.

Step 6 : As the changes to the local repository have been done, we need to upload them on the Github as well. Uploading the files to the github repository is a three step process. One had to add the files, commit files and then push it to the Github repository. One can use the following command to upload the repository. One can use the command “git add “name of the file/folder” for uploading individual files or else use “git add .” to upload all the files at one go.

git add sourcecode

git add data

or

git add .

Adding the local files into github

Step 7: One had to commit the changes using the following command

git commit -m “Remarks”

Committing the files

let us check the status of the git again.

Git shows that we have done an extra commit whencompared with that of the repo in github

Step 8 : Last step is to push the changes into Github using the command. Here “main” is the name of the branch. If you would like to push it into another branch, you need to change it accordingly.

git push origin main

One had to authenticate the application to use github for the fist time in order to push the files.

As a last step, one had to visit the github repository and verify all the files have been uploaded successfully.

These are basic steps to clone the repository into your local machine and to do the changes and upload it into the repository of the github as well.

Wish you a happy coding.

--

--

Alok Dubey

A fitness freak, an avid reader, loves to play data science, badminton, volleyball, cycling, walking and movies.