The remote repository is initialized to the bare repository git init-bare.

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.