DEV Community

Cinthia Barbosa da Silva
Cinthia Barbosa da Silva

Posted on

Essential Git Commands

In this post we will learn the basic and essential commands of Git that developers use in their daily lives!

Let's go!šŸš€

Settings:

To set the global username

git config --global user.name "username"
Enter fullscreen mode Exit fullscreen mode

To set the global email:

git config --global user.email "user@email.com"

Enter fullscreen mode Exit fullscreen mode

Basic Commands:

To initialize a git repository

git init
Enter fullscreen mode Exit fullscreen mode

To clone a repository

git clone <URL>
Enter fullscreen mode Exit fullscreen mode

To check the changes

git status
Enter fullscreen mode Exit fullscreen mode

To add a file

git add my-file
Enter fullscreen mode Exit fullscreen mode

To add all changed files

git add .
Enter fullscreen mode Exit fullscreen mode

To commit your changes

git commit -m "my first commit"
Enter fullscreen mode Exit fullscreen mode

To push changes to the current branch

git push 
Enter fullscreen mode Exit fullscreen mode

To update your branch with changes

git pull
Enter fullscreen mode Exit fullscreen mode

To switch branches

git checkout develop
Enter fullscreen mode Exit fullscreen mode

To update your local repository with remove changes

git fetch
Enter fullscreen mode Exit fullscreen mode

To create a new branch

git branch my-new-branch
Enter fullscreen mode Exit fullscreen mode

Essential Command to Merge and check log:

To merge a branch

git merge my-branch
Enter fullscreen mode Exit fullscreen mode

To check log

git log
Enter fullscreen mode Exit fullscreen mode

To revert a commit

git revert 001
Enter fullscreen mode Exit fullscreen mode

This is for today! If you have any questions, leave me a comment!

And you found this article helpful, please like the post.ā¤ļø

Top comments (0)