DEV Community

loading...

Essential commands you should know for git

Ajo Alex
I am a front end developer love to do something
・1 min read

Git Config

This command sets the author name and email address respectively to be used wwith your commits.

git config -global user.name "[name]"
git config -global user.email "[email address]"
Enter fullscreen mode Exit fullscreen mode

Git init

This command is used to start a new repository

git init
Enter fullscreen mode Exit fullscreen mode

Git clone

This command is used to obtain a repository from an existing URL

git clone [url]
Enter fullscreen mode Exit fullscreen mode

Git push

This command push the changes to the server

git push <remote name> <branch>
Enter fullscreen mode Exit fullscreen mode

Git merge

This command merge the specified branch into the current branch

git merge [branch name]
Enter fullscreen mode Exit fullscreen mode

Git pull

This command fetches and merges changes on the remote server to your working directory

git pull
Enter fullscreen mode Exit fullscreen mode

Git add

This command adds a file to the staging area

git add

or

git add --all
Enter fullscreen mode Exit fullscreen mode

Git commit

This command records or snapshots the file permenantly in the version history

git commit -m "[commit message]"
Enter fullscreen mode Exit fullscreen mode

Git branch

This commit will create new branch only in your local system

git branch <branch-name>
Enter fullscreen mode Exit fullscreen mode

Git checkout

This will switch you to the branch name you mentioned in the command

git checkout <branch-name>
Enter fullscreen mode Exit fullscreen mode

Git status

This command lists all the files that have to be committed

git status
Enter fullscreen mode Exit fullscreen mode

Git remote

This command used to connect your local repository to the server

git remote add [variable name] [server link]
Enter fullscreen mode Exit fullscreen mode

Discussion (0)