Frequently used GIT commands (with Video)
Version Control System (VCS) is one of the important tools in developers’ toolkit. It is really handy while working on multi developer projects as it allows to track different revisions of documents, revert to previous revision or merge different versions and so on.
There are various Version control system available. Among them, Git is the most widely used version control system. Moreover, it is a distributed version control system (DVCS). Local copy of code contains the full history of all changes.
I use Git as Version Control System while working on projects. Mostly, I create new branch, commit changes and push the working branch to the live server.
Here’s my list of frequently used git commands. Don’t forget to share yours.
Checkout
Switch to the branch you want to use
$ git checkout <branch>
Create your own local branch
$ git checkout -b <branch_name>
Status
Check the current status of the repository
$git status
Add
All
$git add -A stages
New and modified, without deleted
$git add .
Modified and deleted, without new
$git add -u
Commit
Add, Delete changes and use the given <msg> as the commit message
$git commit -am ‘msg’
Push
Push the local branch to another repository
$git push origin <branch>
Remote
Get a list of any configured remote urls
$git remote -v
Adds a remote named <name> for the repository at <url>
$git remote add <name> <url>
Branch
Rename current active <branch>
$git branch -m <branch>
Rename <branch> with <new_name>
$git branch -m <branch> <new_name>
Delete the <branch>
$git branch -D <branch>
Merge
Merge <branch> with current branch
$git merge <branch>
Miscellaneous Git Commands
See non-staged (non-added) changes to existing files
$git diff
Show commit logs
$git log
Get help for a specific git command
$git help <command>
You can go through this video for visual information:
I will keep on updating this list. Till then, take care.