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.