Essential GitHub Commands Every Developer Should Know

A Beginner’s Guide to Git and GitHub Commands

Muhammad Abdullah Arif
3 min readMay 1, 2023

If you’re a developer, you’ve probably heard of GitHub. It’s a web-based hosting service for version control and collaboration using Git. Git is a distributed version control system that enables you to keep track of changes made to your code over time, as well as collaborate with other developers on a project. GitHub makes it easy to store, manage, and share your code with others.

github.com

In this article, we’ll cover some of the essential GitHub commands that every developer should know. Whether you’re new to Git and GitHub or you’re a seasoned developer, these commands will help you manage your code more effectively.

git clone

The git clone command is used to copy a repository from GitHub to your local machine. This is the first command you should use when you want to work on a project that’s hosted on GitHub. To use this command, open your terminal or command prompt and type:

git clone <repository URL>

Replace <repository URL> with the URL of the repository you want to clone. Once you run this command, Git will copy the entire repository to your local machine.

git add

The git add command is used to add files to the staging area. The staging area is where you prepare your files to be committed to the repository. To use this command, navigate to the directory where your code is located and type:

git add <file name>

Replace <file name> with the name of the file you want to add. If you want to add all the files in the directory, type:

git add .

git commit

The git commit command is used to commit changes to the repository. This command is used after you’ve added files to the staging area. To use this command, type:

git commit -m “Commit message”

Replace “Commit message” with a brief description of the changes you’ve made. This message should be short and descriptive, and it should explain what changes you’ve made to the code.

git push

The git push command is used to push changes from your local repository to the GitHub repository. To use this command, type:

git push

This will push all the changes you’ve made to the GitHub repository.

git pull

The git pull command is used to pull changes from the GitHub repository to your local repository. To use this command, type:

git pull

This will update your local repository with the changes that have been made on the GitHub repository.

git branch

The git branch command is used to create, list, or delete branches. A branch is a separate version of the code that allows you to work on new features or bug fixes without affecting the main codebase. To create a new branch, type:

git branch <branch name>

Replace <branch name> with the name of the new branch. To list all the branches in your repository, type:

git branch

To delete a branch, type:

git branch -d <branch name>

Replace <branch name> with the name of the branch you want to delete.

These are just a few of the essential GitHub commands that every developer should know. Learning these commands will help you manage your code more effectively and collaborate more efficiently with other developers. If you’re new to Git and GitHub, take some time to learn these commands and start using them in your projects. You’ll be glad you did!

If you enjoyed this article, be sure to follow me on Medium for more tricks and tips! Follow the link to my profile to stay updated on the latest insights and ideas.

Link: Muhammad Abdullah Arif — Medium

Good luck!

--

--

Muhammad Abdullah Arif

Python developer. The facts are the facts but opinions are my own.