What is the .git folder?

前端 未结 6 1966
别跟我提以往
别跟我提以往 2020-12-13 17:44

What is the folder called .git?

It\'s created in a repository. What is contained within it and why is created?

6条回答
  •  旧巷少年郎
    2020-12-13 18:19

    This explanation should help beginners to understand the .git folder.

    The .git folder is a bit like a magic hat into which you put your current magic show.

    When you create a new git repository (git init), everything you organise into a show format is put inside this magic hat and can be 'pulled out' whenever, wherever you want.

    After pulling everything out, you can throw everything away when you are finished with the show (i.e. all your files except the .git folder), and you can always pull out exactly the same show at a later date. (As each new show is simply a clone of what is inside the hat).

    If you send someone JUST the .git folder, they can always pull out your project files into the same structure (show format) as you put them in.

    git add tells the .git folder what is able to be pulled out e.g. a rabbit wearing a tuxedo and holding a cane (or a single file or whole menu bar on your website).

    git rm tells the .git folder to stop allowing something to be pulled out of the hat e.g. imagine if you no longer wanted the rabbit to be part of your magic show. (Important to note, that you can still recover a previous version of your show, which would include the rabbit (your 1999 version of your blog with Comic Sans), if you really wanted, but your current show would not include the rabbit if you used git rm).

提交回复
热议问题