Git Tutorial for beginners (Git Bash Commands)
Git Tutorial for beginners, Git bash commands, svn, GitHub, Atlassian, TFS, Team Foundation Server, Team Foundation Services, TFS Online, Git server, Install Git on Windows, What is Git, Git commands for linux bash, Git cheatsheet- by Kunal Chowdhury on

Version Control Systems are softwares tools that help a software team to manage changes to their source code. It keeps track of every modification to the code. If a mistake is made, developers can compare earlier versions of the code and/or revert back the changes to help fix the mistakes without disrupting the other team members.
As of now, the most widely used modern version control systems in the world are Git and TFS. Git is a mature, actively maintained open source project originally developed by Linus Torvalds, the famous creator of the Linux operating system kernel, in the year 2005.
Having a distributed architecture, Git is an example of "Distributed Version Control System" (DVCS). Rather than having only one single place for the full version history, every developer's working copy of the code can be treated as a repository in Git. In addition to being distributed, Git has been designed with performance, security and flexibility in mind.
Here is a list of some common terms used in Git, which you must know:
Blobs
Blob stands for Binary Large Object. Each version of a file is represented by blob, which holds the file data but doesn’t contain any metadata. It is a binary file and in Git database, it is named as SHA1 hash of that file.
Trees
Tree is an object as binary file, which represents a directory. It also holds blobs as well as other sub-directories. It stores references to blobs and trees which are also named as SHA1 hash of the tree object.
HEAD
HEAD is a pointer, which always points to the latest commit in the branch. Whenever you make a commit, HEAD is updated with the latest commit. The heads of the branches are stored in ".git/refs/heads/" directory.
Clone
Clone operation creates the local instance of the repository. It acts as mirroring of the complete remote repository. Users can perform any operations with this local repository. The only time networking gets involved is when the repository instances are being synchronized.
Branches
Branches are used to create another line of development from the repository's master branch to work on a new feature. Once the feature is completed, it is merged back with the master branch and we delete the branch. Every branch is referenced by HEAD, which points to the latest commit in the branch. Whenever you make a commit, HEAD is updated with the latest commit.
Pull
Pull operation copies the changes from a remote repository instance to the local repository. The pull operation is used for synchronization between two repository instances.
Push
Push operation copies changes from a local repository instance to the remote repository. This is used to store the changes permanently into the Git repository.
Commits
Commit operation holds the current state of the repository. A commit is also named by SHA1 hash code. Every commit object has a pointer to the parent commit object.
Tags
Tag assigns a meaningful name with a specific version in the repository. Tags are very similar to branches, but the difference is that tags are immutable. Once a tag is created for a particular commit, even if you create a new commit, it will not be updated. Usually, developers create tags for product releases.
Let's discuss about most used Git Bash commands:
$ git remote
- How to List all local branches?
- How to List all remote branches?
- How to List all existing branches with the latest commit comment?
- How to Create a new local branch based on current HEAD?
- How to Create a new tracking branch based on remote?
- How to Switch your HEAD to a branch?
- How to Move or rename a local branch?
- How to Move or rename a local branch (forcefully)?
- How to Delete a local branch?
- How to Delete a local branch (forcefully)?
- How to Delete a remote branch?
$ git branch
$ git fetch
- How to Add specific file(s) or directory to the index?
- How to Update all files in the entire working tree?
- How to Update specific files in the entire working tree?
- How to Interactively choose hunks of patch between the index and the work tree?
- How to Pick and choose lines of the patch to apply?
- How to Update the index just where it already has an entry matching filepath?
- How to Update the index by adding new files that are unknown to the index?
- How to Record only the fact that the path will be added later?
- How to Refresh the information in the index whithout adding the files?
- How to Continue adding files without aborting on errors?
- How to Add modified contents in the working tree interactively?
$ git add
$ git mv
- How to Remove a file from working tree and index?
- How to Remove all files from the Git directory?
- How to Forcefully remove the file and the index?
- How to Recursively remove files in folder and subfolders from Git repository?
- How to Force to recursively remove files in folder and subfolders from Git repository?
$ git rm
- How to Record changes to the repository?
- How to Record changes to the repository with a commit message?
- How to Automatically stage files that have been modified and deleted?
- How to Use the interactive patch selector to chose changes to commit?
- How to Commit by using an existing commit message (opens editor)?
- How to Commit by using an existing commit message and authorship?
- How to Take the commit message from the given file?
- How to Add Signed-off-by line at the end of commit message?
- How to Amend a commit giving user a choice to update the commit message?
- How to Amend a commit replacing the previous commit message?
- How to Amend a commit with author details?
$ git commit
- How to List all the tags?
- How to Search tags for a particular pattern?
- How to Show a tag data?
- How to Create a Lightweight Tag?
- How to Create an Annotated Tag?
- How to Create a tag for a specific commit?
- How to Push a specific tag to remote?
- How to Push all the tags to remote?
- How to Checkout a specific tag to local?
$ git tag
- How to Show the working tree status output in short-format?
- How to Show the branch and tracking info in short-format?
- How to Show the working tree status output in long-format?
- How to Show no untracked files from the working tree status?
- How to Show untracked files and directories from the working tree status?
- How to Show all, including individual files in untracked directories from the working tree status?
$ git status
- How to Push changes of current branch to remote?
- How to Push changes to a specific branch?
- How to Push the current branch to the same name on remote?
- How to Push matching branches to origin?
- How to Push the current branch to the remote ref matching master in the origin?
- How to Push the current branch forcefully to remote?
- How to Push all branches to remote?
- How to Push a single tag to remote?
- How to Push all the tags to remote?
- How to Push the tags to a remote branch?
- How to Rename a remote branch by pushing local branch?
- How to Remove remote branches that don’t have a local counterpart?
- How to Delete a remote branch?
- How to Add tracking refs for every branch that is up to date or pushed?
$ git push
- How to Record the current state of working directory, index it and clean?
- How to Stash your local modifications with a message?
- How to Stash local modifications including all untracked files?
- How to Stash local modifications including all ignored files?
- How to List the stashes that you currently have?
- How to Show the changes recorded in the latest stash?
- How to Show the changes recorded in the stash no. provided?
- How to Remove the last stashed state from the stash list and apply?
- How to Remove a single stashed state from the stash list and apply?
- How to Apply the latest stash without removing from stash list?
- How to Apply the stash without removing from stash list?
- How to Create and check out a new branch from the stash?
- How to Remove all the stashed states?
- How to Remove the last stashed state from the stash list?
- How to Remove a single stashed state from the stash list?
$ git stash
- How to Remove untracked files from the current working tree?
- How to Remove untracked directories in addition to untracked files?
- How to Forcefully clean the current working tree?
- How to Clean working tree in interactive mode?
- How to Clean working tree without using the standard ignore rules?
- How to Remove only files ignored by Git?
- How to Clean working tree to default state?
$ git clean
- How to Reset the current HEAD to last commit state?
- How to Reset the current HEAD of the specified path to last commit state?
- How to Reset the current branch to a specific commit?
- How to Reset the HEAD without touching the index file or the working tree?
- How to Reset the HEAD to a commit without touching the index file or the working tree?
- How to Reset the index but not the working tree (preserving the changes)?
- How to Reset the index to a commit but not the working tree (preserving the changes)?
- How to Reset the index and working tree?
- How to Reset the index and working tree to a specified commit?
- How to Reset the index and update the files in the working tree that are different?
- How to Reset the index to a commit and update the files in the working tree that are different?
- How to Reset the index and keep the files in the working tree that are different?
- How to Reset the index to a commit and keep the files in the working tree that are different?
$ git reset