1. Differences between git init and git init-bare
The version library initialized with "Git init" can also perform all git operations in this directory. However, other users are prone to conflicts when pushing updates.
For example, a user executes git operations under this directory (called a remote repository), and has two branches (master and B1), which are currently under the master branch. Another user wants to submit the update of the master branch of his local warehouse (known as the Local warehouse) to the master branch of the remote warehouse.
Git push origin master: Master
As a result
Because the remote repository user is operating on the master branch, and you have to submit the update to this master branch, of course there will be an error.
However, if you submit data to the idle branch in the remote warehouse, for example
Git push origin master: B1 can still be successful
The solution is to use the "Git init-bare" method to create a so-called bare repository. This is called a bare repository because it only saves the version information submitted by git history, users are not allowed to perform various git operations on the above. If you have to perform the operations, you will only get the following error ("this operation must be run in a work Tree ")
This is why it is best to initialize the remote warehouse as a bare warehouse.
Source:Http://blog.csdn.net/feizxiang3/article/details/8065506