Frequently Git Command Every Developer Should know

Nditah Samweld
2 min readOct 28, 2019

There are some frequently used git commands that would be nice to commit to memory to work more efficiently during software development. Here is a list in no particular order.

1. git config

This command is not used daily, but its the first you will encounter. It is used to set your user name and email (among other parameters) in the main configuration file.

> git config --global user.name "Username Here"
> git config --global user.email "user@example.com"

2. git init | git clone

At the beginning of a new project, you initialize a git repository in the root of your project directory with:


> git init

Or you copy a git repository from remote source, also sets the remote to original source so that you can pull again.

> git clone <git-url>

3. git status

View all the files that have been changed since your last commit.

> git status

4. git add

adds changes to stage/index in your working directory.

> git add .

5. git commit

commits your changes and sets it to new commit object for your remote.

> git commit -m "Feature|Fix informative commit message"

6. git push/git pull

Push or Pull your changes to remote. If you have added and committed your changes and you want to push them. Or if your remote has updated and you want those latest changes.

> git pull <remote> <branch> 
and
> git push <remote> <branch>

7. git branch

Lists out all the branches or all the remote branches as well when you add “- a” option.

> git branch
or
> git branch -a

8. git checkout

Switch to different branches or if you want to create and switch to a new branch.

> git checkout <branch>
or
>
**_git checkout -b <branch>

9. git stash

Utility : Save changes that you don’t want to commit immediately.

> git stash

10. git merge

Merge two branches you were working on. Switch to branch you want to merge everything in.

> git merge <branch_to_merge>

11. git reset

Utility : You know when you commit changes that are not complete, this sets your index to the latest commit that you want to work on with.

> git reset <mode> <COMMIT>

12. git remote

To check what remote/source you have or add a new remote.

> git remote add <remote_url>

--

--