DEV Community

loading...
Cover image for Mostly used git commands for beginners

Mostly used git commands for beginners

Shilpa
FrontEnd Developer
・2 min read

Git is a magic bullet for developers to track your work. Git also differentiates the other teammate work by using git commands. Here are the 10 most used git commands.

  1. git init
  2. git clone
  3. git add
  4. git status
  5. git diff
  6. git commit
  7. git push
  8. git pull
  9. git revert
  10. git checkout

git init

Git init is used to initialise the git to a local repository. But when are you clone from remotely then you don't need the git init.
Practice:-

Alt Text

git clone [remote_url]

Git clone is used to creating an identical copy of a Git Remote Repository to the local machine.
Practice:-

Alt Text

git add [file name/.]

Git add is used to add the modified files in the staged area. There are following ways to use git add, by adding the entire folder and specific files. Dot means the entire folder.
Practice:-

Alt Text

git commit -m "Your message about the commit"

Git commit is used to add the changes with a unique message in an individual file or set of files. Git commits also creates a unique id. A "unique message" shortly describes what changes you have done. It also helps you track your commits.
Practice:-

Alt Text

git status

Git status is used to check the status of the modified files. It also shows which files are staged, unstaged, and untracked.
Practice:-

Alt Text

git diff

Git diff is used to track the difference between the changes made on a file.
Practice:-

Alt Text

git revert [commit id]

Git revert is used to undo the changes of the given commit which we have pushed in a "remote" repository and changes add in the current branch. Without losing your previous commit.
Practice:-

Alt Text

git push

Git push is used to push all the changes locally to the remote repository.
Practice:-

Alt Text

git pull

Git pull is used to pull all the changes from remote to the local repository.
Practice:-

Alt Text

git checkout [file/branchname/commit id]

Git Checkout is used to switch between files, branches and commits.
Practice:-

Alt Text

Conclusion

In this article, I cover mostly used git commands for beginners. I also define the syntax, purpose and usage of command at one place.
I hope this article help to learn git commands.

Discussion (4)

Collapse
yilmazbatuhanys profile image
Batuhan Yaşar Yılmaz

I looking for an app like Github-desktop or Sublime-Merge for Linux are you have any suggestion?

Collapse
shilpa3495 profile image
Shilpa Author • Edited

I use GitHub Desktop and cli. Maybe this article helps you alternativeto.net/software/github-....

Collapse
haxnet profile image
HaxNet

I recommend to just use the CLI version. It's pretty easy to use

Collapse
shilpa3495 profile image
Shilpa Author • Edited

Cli also helps to remember the commands also.