git - 存储库是 .git 文件夹还是带有 .git 文件夹的目录?

标签 git

根据https://www.git-tower.com/learn/git/ebook/en/command-line/basics/basic-workflow#start

In Git, the repository is just a simple hidden folder named ".git" in the root directory of your project.

但是Git for beginners: The definitive practical guide

A git repository is simply a directory containing a special .git directory

“存储库”是指 stash 的 .git 文件夹还是包含 .git 目录的目录?

我知道当您 git commit 时,您会将更改记录到本地 .git 文件夹中。这是否意味着当我们推送到 GitHub 上托管的远程存储库时,我们只是推送 .git 文件夹的内容而不是其他内容?

最佳答案

Does "repository" refer to the hidden .git folder or the directory containing a .git directory?

严格意义上,存储库只是 .git/ 子目录。包含 .git/ 和所有项目文件的目录名为 "working tree" ,严格意义上 .git/ 子目录不属于工作树。

但人就是人,我们使用宽松的术语,因此我们经常将整个工作树 + .git/ 称为“存储库”或“项目”或其他名称。

I know that when you git commit, you are logging changes into your local .git folder. Does this mean when we push to a remote repository like one hosted on GitHub, we are just pushing the contents of the .git folder and nothing else?

简短回答:是的。

更长的答案很复杂。是的,git push 仅从 Git 对象数据库推送对象,并推送引用(分支和标签)。但是 .git/ 中还有更多永远不会推送或 pull 的内容:配置文件、 Hook 以及与当前存储库相关的许多其他文件和目录。

关于git - 存储库是 .git 文件夹还是带有 .git 文件夹的目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59349277/

相关文章:

git - 如何更改git分支输出顺序

windows - 如何重写历史以删除 git 中的可执行位

git - 如何在 Git 存储库中查找和恢复已删除的文件?

git - 仅针对某些文件/提交的 pull 请求

git - 无法通过ssh连接到github

git - 在 github 中创建的文件与推送到 github 的文件之间的区别?

git - Git 中的快进推送是什么?

ruby-on-rails - Eventmachine start_tcp_server 没有接受者 - 端口正在使用或需要 root 权限(RuntimeError)

git - 如何为 git rebase 选择 merge 策略?

windows - Git - 如何在 Windows 上使用 .netrc 文件保存用户和密码