Common used Git Commands Checklist for Developers

In our day to day software development version control helps us to protect from accidental data loss. Git is a free open source version control system. Compare to other repository Git is rich with Frictionless Context Switching, Role-Based Code lines, Feature Based Workflow & Disposable Experimentation. To read more about these features please visit http://git-scm.com. While working in Git version control there are many Frequently used Git Commands to operate Git. In this session let me share Git Commands checklist for Developers.

Commands to Create & Clone

To create a new repository – git init
To clone local repository – git clone /path/to/repository
To clone remote repository – git clone username@host:/path/to/repository

Git Commands to Add & Remove

Add changes to Index – git add <filename>
Add all changes to Index – git add *
Remove/Delete – git rm <filename>

Git Commands to Commit & Synchronize

To commit changes – git commit -m “Commit message.”
Push changes to remote repository – git push origin master
Connect local repository to remote repository – git remote add origin <server>
Update local repository with remote changes – git pull

Git Commands for Branches

Create a new branch – git checkout -b <branch>
Switch to master branch – git checkout master
To delete a branch – git branch -d <branch>
Push branch to remote repository – git push origin <branch>

Commands for Merge

Merge changes from another branch – git merge <branch>
View changes between two branches – git diff <source_branch> <target_branch>

Commands for Tagging

Create tag – git tag <tag> <commit ID>
Get Commit Ids – git log

Commands to Restore

Replace working copy with latest from Head – git checkout — <filename>