PYTHON INTERMEDIATE’S GUIDE | VERSION CONTROL SYSTEM AND GITHUB

Heyy, How are you all? I am back !!! Today, we will be learning about Version Control Systems and GitHub. Many of you may already know about GitHub. For those who don’t GitHub is basically a programmers’ community. It’s a lot more than just a community. Here, programmers from around the world share their projects and creations with us. You can find various dependencies, patches, modules, libraries etc. that you can use as programmers. In this lesson, we will basically learn how to become a part of this community and how we can make our own contributions to the society.

What Is A Version Control System?

It is a program designed to help you collaborate on projects with other programmers. For example, git and SVN.

Version control systems like git uses a repository. A repository is a directory on your computer that git uses to keep track of all the changes in the project.

Let me give you an example to help you understand the above lines. Let’s say, you are working on a big project and many of your programmer friends are involved in it (by the way if you have any friends who are interested in programming, do tell them about Noob Code Pro). Now all your friends live at different places in the world. You are the project manager/team leader. You come up with the brilliant idea of using git in order to complete the project. Now you login to your git account and create a project and share it with your friends and tell them what part of the project each one of them has to do. So they all accept it but before working on the project, every programmer involved has to submit a repository to git. The repository will be the directory in which they will be saving the files related to the project. This is done so that git can keep track and the other programmers are updated on each other’s progress. For example, your friend Chris is supposed to build the Graphical User Interface (GUI) of the app you are working on. So how are you supposed to know Chris’ progress? Git asks Chris to submit a repository where he will be working on the GUI. This will keep you updated on his progress. I hope you now understand how repository works.

Now, the repository that each person created on their computer is called a local repository. There is a central repository which is hosted on a website like GitHub that all local repositories communicate with to stay in sync with each other.

Note: Keep in mind that git is a VCS (Version Control System) and GitHub is a cloud-based hosting service that lets you manage git repositories.

 


We can create a new central repository from the GitHub website in the following way:

1)       1)    You will need a GitHub account to continue. Go to the GitHub website <link>and login or a sign up for an account

        2)    Once you have set up you GitHub account, create a new repository by clicking on the ‘+’ sign at the top right corner and selecting ‘New Repository’.

 


   3)    Give your repository a name and a description(optional) and click ‘Create Repository’    

 


        4)    You can see the new Central Repository you created when you go to your profile.

 


Once you create a central repository, you can use git to create local repositories but first you must have git installed on your computer, you can install git by following this article. Now, you can use git to create local repositories that communicate with the central repository by following these steps:

          1)    Go to Your Repositories



          2)    Navigate to your Central Repository

          3)    Copy this link

      4)  Open your command line and type in the command : git clone <link you just copied>

       5)  Git will install your local repository in whatever directory you ran the command from

        6)    This new directory is your local repository.

Updating the Central Repository:

When a programmer finishes making changes in his local repository, he sends the changes to the central repository, so that the other programmers working on the project can download it.

You can use the following commands to make changes to the central repository:

Note: The following commands must be executed inside the local repository. To bring the command prompt inside the repository, use the ‘cd’ command followed by the repository name. For me the name is ‘Test’, therefore I will use the command ‘cd Test’ to get inside my repository.

Pushing: Updating your central repository with changes from your local repository is called pushing.

 Command: git push origin master

If you encounter a stupid “src-refspec” error, try the solution given in this article

Pulling: Updating your local repository with changes from your central repository is called pulling.

Command: git pull origin master

Add: Adding a file means, telling git what files you want to update changes about. For example, if you add ‘Test’ file, you are basically telling git that you are  going to update the changes made to the ‘Test’ file. The next command will actually update the central repository about the changes.

Commit: It means giving the command to git to tell it the changes you made to the local repository.

Command: git commit –m ‘<a message>’`

Staging A File: This means deciding which changes you want to push. For example, if you create a file called ‘hi.py’. Then, in order to stage the file, execute the following command:

git add hi.py

If you want to unstage a file, execute:

git reset hi.py

You can use the command git remote –vto print the url, your local repository is pushing to and pulling from.

Note: Enter the command in your local repository.

 

CONGRATULATIONS !!! You now know what Version Control Systems are and how you can use GitHub to expand your horizons. Play around with GitHub and explore it. Like I always say, Have fun with it !!! Good luck !!!!   

Let me know, if you loved it, hated it, want to kill me or any other sort of feedback in the comments section below. Also, if you have any queries regarding the topics taught in this lesson or previous lessons, you can always find me in the comments section or in the telegram channel or on my pinterest profile where you can personally talk to me and ask me any question about anything we have learnt so far.

So, this was an introduction to Package Managers and PIP in Python. Stay tuned for another article next week, same time, where we will learn about a very important and a fun topic viz Web Scraping. So more cool stuff coming your way, DON’T MISS IT !!

I hope this article answered all of your questions and even helped you in becoming a better programmer. IF IT DID, leave a like AND FOLLOW THIS BLOG TO BECOME A PROFESSIONAL PYTHON PROGRAMMER FROM A TOTAL BEGINNER. IF IT DIDN'T, feel free to ask any further queries in the comment section below.


If you are a beginner, intermediate, advanced or just someone interested in programming, feel free to join our telegram channel and be among people like you:


And do you know the best part? Joining it is FREE !!!

So go ahead click on the link and I will see you there. 

You can also contact me through my email: code2learnofficial@gmail.com

or


 HOPE YOU HAVE AN AWESOME DAY AHEAD !!! 

Post a Comment

0 Comments