Adilasif
Voice of Code
Published in
3 min readApr 28, 2020

--

Version Control with Git and Microsoft GitHub

Introduction

During my journey towards learning Git and Microsoft GitHub I had faced many issues. This article will help you get started with Git, create your own repository and upload your code on GitHub.

What is Version Control ?

Version control system is a system which helps you to keep track of the changes that were made in the file since the file was uploaded on the system. The details of the changes include the name of the person who made the changes the time the changes were made, it also keeps track of different versions of the file, and many more features.

What is Git and Microsoft GitHub ?

Git is a distributed version control system i.e. a system where every user has a local repository in there own computer where they have a backup of the code and where changes are made before uploading the code on the remote repository. GitHub is a graphical user interface to help you manage git and it’s remote repositories.

Getting Started with your first Repository ?

Here you will learn how to create a local repository and uploading the code on remote repositories using basic commands

Step 1: Creating a local repository

For a local repository you will first need to create a folder in any directory. In this folder you will place all your code that you want to push on git. After you have created a folder you will now have to open that folder location in your terminal. Then you have to run the “git init” command. The git init command creates a hidden folder named as .git folder. The .git file contains all the information and log regarding your repository example: what and when the changes were made, who made the changes, logs of different commits, etc.

Step 2: Adding your file to Staging Area

Once you have created a .git folder you have to place your file(s) in the staging area so that git can keep a track of your file. “git add .” command moves all the file(s) in your folder to the staging are if you want to add a specific file you can write “git add <your filename>”. “git status” shows the current status of the file(s). Once you place the file(s) in the staging area they will be moved to tracked file(s) section.

Step 3: Creating a remote repository

Once you sign up to your git hub account navigate the plus sign and then click on new repository
After that you will land on this page. Fill the details correctly. A private repository is one which can be accessed by you and certain people you give access to. Were as a public repository is one which can be accessed by anyone this feature is used for Opensource contribution so choose accordingly. It is a better practice to upload the README file from the computer in order to avoid problems at initial stage.

Step 4: Giving the path of remote repository

Now you have to copy the URL of your repository that you have created and run the following command git remote add <alias for your remote repository> <URL>.git

Step 5: Commit the file

“git commit -m “Enter description for commit” the file(s) it means you are saving the file. When you commit a unique key is assigned which helps you keep track of the version of the file.

Step 6: Push the files to remote repository

With the push command you upload the file(s) that were previously that had been commit to the remote repository you have created on GitHub

Pull the files to the local repository

When you will upload your file(s) next time on GitHub before you push the files you have to pull them from the remote repository. This is done so as to make sure that your local repository is already up-to-date before uploading the file(s) that you have made changes to.

Important

This was a basic walk through of setting up you repository on Git and GitHub. After you are done with all of this i would recommend you all to learn different commands and concepts like branching, fork, etc. I have attached a link to my lecture for hands-on Git and GitHub and the importance of Opensource in collaboration with Anush Krishna and Irfan Dahir.

Resource Section

Click the links to continue

--

--