What is the .git folder?

前端 未结 6 1964
别跟我提以往
别跟我提以往 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 17:59

    Basiclly, it means your dir is handled by Git (Git repository). If you move it somewhere else (or delete it), you'll face something like:

    fatal: Not a git repository (or any of the parent directories): .git

    every time you use 'git *' command there.

    You can move the .git directory somewhere else using:

    git --git-dir=/myproject_path/myproject.git log --oneline

    Or:

    export GIT_DIR=/myproject_path/myproject.git

    But i don't recommend doing it. Pay attention that it is only 1 folder, unlike SVN.

    It holds all relevant info for GIT to handle your code, like the position of the HEAD, hooks to apply before/after commit/push and some other files.

    Maybe most "famous" file inside is the config file which holds all your branches info.

    Recommend to read here more info.

提交回复
热议问题