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.
- git init
- git clone
- git add
- git status
- git diff
- git commit
- git push
- git pull
- git revert
- 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:-
git clone [remote_url]
Git clone is used to creating an identical copy of a Git Remote Repository to the local machine.
Practice:-
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:-
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:-
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:-
git diff
Git diff is used to track the difference between the changes made on a file.
Practice:-
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:-
git push
Git push is used to push all the changes locally to the remote repository.
Practice:-
git pull
Git pull is used to pull all the changes from remote to the local repository.
Practice:-
git checkout [file/branchname/commit id]
Git Checkout is used to switch between files, branches and commits.
Practice:-
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.
Top comments (4)
I looking for an app like Github-desktop or Sublime-Merge for Linux are you have any suggestion?
I recommend to just use the CLI version. It's pretty easy to use
Cli also helps to remember the commands also.
I use GitHub Desktop and cli. Maybe this article helps you alternativeto.net/software/github-....