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 "[email protected]" 
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.❤️


Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
Another standout feature of cloudystorage is its commitment to delivering best value cloud storage provider services.