Git init and git init--bare

Source: Internet
Author: User

For the initialization of Git repository, some people say git init, some people say git init–bare, then I would like to tell the difference between the two.
Git init and git init–bare look like there's no –bare in the back, bare is the bare meaning
1.git init Initializes a git repository, such as creating a new Demo1 folder to initialize it to Git,

CD demo1
git init
ls-a

Found one more. git file,

cd. Git
ls

You can see that there are a lot of git configuration files, and the files we push will be displayed in the Demo1 file directory, the. git file directory is a record of what we do, we can also do a variety of git operations under DEMO1, but our local push updates, generally not immediately displayed on the server , we need to check out manually, or configure hooks, to see my previous blog.
GIT init initialization repository is unable to check out update issues immediately

2.git Init–bare is the initialization of a bare repository, such as creating a new Demo2 folder,

CD Demo2
git init--bare
ls

You will find that these generated files are actually those files in the. git file directory, but there is an error when we want to do some git operations under this file directory: This operation must is run in a working tree. This must be done on the work tree, because Git init–bare generates a bare repository, there is no workspace, it only records the history of Git commit, git log is able to see the various version information, but there is no way to version fallback or switch branch operation, But one advantage is that you can add hooks hooks in the Demo2 's sibling directory to create a new folder to store the project source code, that is, the Git repository and the project source code separation, so that the push updates will immediately appear on the project file, the specific setting method can view this blog
Git repository and project source separation

The choice of the two I think the specific situation is specific analysis, each has its merits and demerits.

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.