Git, a version control system, is the go-to tool for developers everywhere. In this quick guide, let’s cover some basic commands that every developer should know.

git init

→ Initializes a new Git repository

 

add <files>

→ Adds files to the staging area.

 

git reset

→ Undo the changes to the local files, and restore to the last commit.

 

git diff

→ Displays the difference between files in two commits or between a commit and your current repository.

 

git log

→ Used to view the entire commit history.

 

git commit -m “message”

→ Used to commit files (locally) on the repository.

 

git clone

→ Used to download existing code from a remote respository.

 

git branch

→ Used to list all the local branches on the machine.

 

git branch

→ Used to create a new branch locally.

 

git branch -d

→ Used to delete a branch.

 

git branch -m

→ Used to rename the current working branch.

 

git merge

→ Merges the provided branch with the current working branch.

 

git checkout

→ Used to switch from current branch to another one.

 

git checkout -b

→ Creates a new branch and switches to the new one.

 

git push

→ Used to save all commits to the remote repository.

 

git pull

→ Used to pull down all the updates rom the remote repository.

 

git rm

→ Used to remove a file from the working directory.

 

git stash

→ Used to temporarily remove uncommitted changes.

Fabio

Full Stack Developer / Entrepreneur

About the Author

I’m passionate about web development and design in all its forms, helping small businesses build and improve their online presence. I spend a lot of time learning new techniques and actively helping other people learn web development through a variety of help groups and writing tutorials for my blog about advancements in web design and development.

View Articles