Github is a very popular version control system. Typically, you use a version control system in conjunction with a service that stores your software in the cloud. In this article, I’ll walk you through how to use Github as a Python programmer to put software on this platform, a website that stores your code in the cloud.
What is Version Control?
Writing software is a team sport. When working on a project as part of a team, you should all be able to make changes to the code base, folders, and files that make up your software, and you should sync those changes. You can periodically email yourself with your changes and combine several different versions yourself, but that would be tedious.
Also, what if you and your teammate both make changes to the same part of the project? How do you decide which modifications to use? These are the types of problems that a version control system solves. A version control system is a program designed to help you easily collaborate on projects with other programmers.
What are Repositories in Github?
A repository is a data structure created by a version control system, like Git, that keeps track of all changes in your programming project. A data structure is a way to organize and store information: lists and dictionaries are examples of data structures.
When you see a repository, it will look like a directory with files in it. You’ll use Git to interact with the data structure that keeps track of changes in the project.
When working on a project managed by Github, there will be multiple repositories. Typically, everyone working on the project has a repository on their computer called a local repository, which keeps track of all changes made to the project.
There is also a central repository, hosted on a website like GitHub, with which all local repositories communicate to stay in sync with each other. A programmer working on the project can update the central repository with the changes he made in his local repository, and he can update his local repository with the latest changes that other programmers have made to the central repository.
You can create a new central repository from the GitHub website. Once you’ve created a central repository, you can use Git to create a local repository that communicates with it.
Github For Python Programmers
Now let’s see how to use Github for Python. To get started, you need to create a GitHub account at https://github.com/join. To create a new repository on GitHub, log in to your GitHub account and click the + button in the upper right corner of the screen.
Click New Repository from the drop-down menu. Give the repository the name of your choice. Select the Public option and check the Initialize repository with a README checkbox. Now click on Create repository.
On GitHub, tap the button in the top right corner and select Your Profile.
You will see the name of your repository, click on it. You will see a button that says Clone or Download. When you click on it, you will see a link. Save this link.
Before you can continue, you need to install Git. You can find the installation instructions here.
Now you can easily update and commit your python repositories that are uploaded on Github from the command line only. You only need to learn some commands to managing your Python scripts on Github:
- For Renaming your branches: git push <REMOTENAME> <LOCALBRANCHNAME>:<REMOTEBRANCHNAME>
- For Pushing tags: git push <REMOTENAME> <TAGNAME> then git push <REMOTENAME> –tags
You can learn more about how to use Github for Python from the official documentation of Github. I hope you liked this article on how to use Github for Python Programmers. Feel free to ask your valuable questions in the comments section below.