The basic commands of GitHub

Steven Kyle
3 min readOct 17, 2021
Photo by Kaleidico on Unsplash

GitHub

What is GitHub? GitHub is a popular-open source version control system that is widely used by developers. Currently GitHub is boasting a total of 56 million developers and is expected to reach 100 million by the year 2025.

Needless to say, GitHub is a big deal in the tech world and the chances of working on a project that uses GitHub for its version control system is extremely high. Since the chances of using GitHub is extremely high, as a Data Scientist or developer, it is important to know and understand the basics of git.

In this blog we will cover some need to know basic commands that programmers use daily when working with GitHub.

GitHub commands

The list of commands we will cover in this blogpost are:
— git clone
— git branch
— git status
— git add
— git commit
— git push
— git pull

git clone

git clone is the basic command for “cloning” or making a copy of the remote repository. To clone a repository the following code can be run in the command line. When this command is ran it will create a copy of the specified repository locally in the working directory.

git clone <url for the github repo>

git branch

Once you have a cloned project we can go ahead and create a new branch. A branch is similar to parallel universes. These branches exist off of the main master branch and changes created to these branches will not affect the main branch until it is merged. Since changes to the branches do not affect the master branch, multiple teams can work on the same repository at the same time without affecting each other. To create a new branch the following command can be ran in the command line. ( replace <new_name> with the wanted name)

git branch <new_name> 

git status

To access the status of the current branch, git status can be ran in the command line.

git status

This will return useful information about the branch such as:
— branch is up to date
— individual file status

git add/commit/push

When changes are made locally to a repository they need to be added, commited and pushed to the remote repository. Once the changes have been pushed, the changes will be applied to the remote repository. To add changes to the repository the following command can be used in the command line.

git add -A

The -A makes sure that every change in the repo will be added. This adds the changes so that we can now commit the changes. To commit the changes the following command can be used in the command line.

git commit -m "(insert commit message here)"

Commit’s often have a message attached to it that explain the new changes to the repo. The “-m” must be in the command to input the message. Once the commit has been done locally we can push it remotely. To push all the changes to the remote repository we can use the command:

git push

This will push all changes to the remote repository so that it is now the same as the local repository.

git pull

This command is used when there has been changes to the remote repository and we need to update the local repository. To do this we can run the following in the command line.

git pull (remote)

Conclusion

Hopefully this blog post gave you a very simple intro into basic commands of GitHub. This is just a surface scratch of GitHub commands and there is many more things that need to be learn. If you find yourself working on a project that uses GitHub make sure you understand how GitHub fully works. The last thing we want to do is mess up the master branch of a repo. There’s all sorts of material on git out there so watch some videos, read how-to tutorials and most of all read the documentation.

--

--

Steven Kyle

25 year old Texan in the midst of a career change into DataScience.