【问题标题】:Would .gitignore items in the remote repository be copied in the local project repository by git clone?远程存储库中的 .gitignore 项目会被 git clone 复制到本地项目存储库中吗?
【发布时间】:2019-05-01 06:41:27
【问题描述】:

说,如果我在存储库 ssh://user@remotehost.com:port/home/user/public_html/ 中建立了一个 git repo,

并且我想将它克隆到我的本地项目目录中,我的远程主机 .gitignore 中的附加项是否会包含在我的 public_html/.git 存储库的克隆中?

local$ git clone ssh://user@remotehost.com:port/home/user/public_html/

【问题讨论】:

    标签: git repository git-clone


    【解决方案1】:

    .gitignore 文件的唯一目的是确保 未跟踪 文件保持未跟踪状态。跟踪文件的那一刻,例如当你故意这样做时

    git add --force path/to/ignored-file
    

    那一刻,.gitignore 文件失去了对该文件的威力。因此,如果您的远程存储库包含.gitignore 文件中列出的文件,该文件仍将保留在远程存储库以及您的克隆中。

    【讨论】:

    • 这是否意味着如果忽略的文件在之前的提交中已经被 repo 跟踪,那么它可以被克隆吗?那么如果被跟踪的文件将来会发生变化,即使这些变化已经被忽略了,是否仍然会被跟踪?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-09
    • 1970-01-01
    • 1970-01-01
    • 2016-04-28
    • 2011-09-16
    • 2021-03-02
    相关资源
    最近更新 更多