- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
更准确地说,我相信“git clone”成功了,但立即删除了我生成的本地存储库中的所有文件。类似的问题可以找here ,但我想不出一种方法来表达我对这个问题的看法作为答案,所以我来了。
以下是我的场景细节的概要:
我在 github 上有一个仓库。我能够克隆这个存储库,就像任何人期望在 Ubuntu 12.04 上使用 git 一样。当我尝试克隆 wiki 时出现问题(github 使它可以通过 https://github.com/<owner>/<repository>.wiki.git 访问)。我生成的本地副本是空的。运行“git status”后,我注意到 repo 的内容在克隆后立即被某个实体删除。
在分支 master 上
要提交的更改:
(使用“git reset HEAD ...”取消暂存)
已删除:<文件名>
...对于我 wiki 中的所有其他页面,依此类推。
“git branch -a”对我和另一个人返回的是同样的东西:
*主人
remotes/origin/HEAD -> origin/master
远程/来源/主人
更新 1
的确,我没有意识到暂存区和工作目录之间的区别,但似乎这不是问题所在。另一方面,它可能揭示了更多错误。
我忘了说,当我第一次克隆存储库时,我收到消息“cannot stat
当我运行“git reset”时,所有删除都列在“重置后未暂存的更改:”下。奇怪的是
更新 2
我可以使用克隆文件夹中的 gitk 查看所有应该存在的 wiki 条目,但我很确定这些文件在我的文件系统的任何地方都没有以原始格式存在,否则“find/-name
更新 3
显然我的一个文件名太长,git 无法管理。克隆后再次检查 repo,它得到了除那个文件之外的所有文件: error: unable to create file <filename>.md (File name too long)
最佳答案
请注意,除了静默失败之外,您的空文件夹,如果在克隆之前创建(并且不是由克隆创建)也将被删除。
在您的情况下,失败是因为文件名太长。
但是,更一般地说,“git clone $there $her
e”是允许的,即使这里目录存在,只要它是一个空目录,但命令不正确在操作失败时将其删除。
该部分已通过 Git 2.16.x/2.17(2018 年第一季度)修复
参见 commit d45420c , commit f9e377a , commit 8486b84 , commit a4c4efd (2018 年 1 月 2 日)作者:Jeff King (peff
) .
(由 Junio C Hamano -- gitster
-- merge 于 commit addd37c ,2018 年 1 月 23 日)
clone
: do not clean up directories we didn't create
Once upon a time,
git-clone
would refuse to write into a directory that it did not itself create. The cleanup routines for a failed clone could therefore just remove the git and worktree dirs completely.In 55892d2 (Allow cloning to an existing empty directory,2009-01-11, Git v1.6.2-rc0), we learned to write into an existing directory.Which means that doing:
mkdir foo
git clone will-fail fooends up deleting
foo
.
This isn't a huge catastrophe, since by definitionfoo
must be empty.
But it's somewhat confusing; we should leave the filesystem as we found it.
"git clone --separate-git-dir=$elsewhere
"( man ) 用于踩踏现有目录 $elsewhere
的内容,当 $elsewhere
不是 Git 2.29(2020 年第 4 季度)的空目录。
参见 commit dfaa209 (2020 年 7 月 10 日)作者:Ben Wijen (bwijen
) .
(由 Junio C Hamano -- gitster
-- merge 于 commit f175e9b ,2020 年 7 月 30 日)
git clone
: don't clone into non-empty directorySigned-off-by: Ben Wijen
When using
git clone
(man) with--separate-git-dir realgitdir
andrealgitdir
already exists, it's content is destroyed.So, make sure we don't clone into an existing non-empty directory.
When d45420c1 ("
clone
: do not clean up directories we didn't create", 2018-01-02, Git v2.17.0-rc0 -- merge listed in batch #1) tightened the clean-up procedure after a failed cloning into an empty directory, it assumed that the existing directory given is an empty one so it is OK to keep that directory, while running the clean-up procedure that is designed to remove everything in it (since there won't be any, anyway).
Check and make sure that the$GIT_DIR
is empty even cloning into an existing repository.
关于git clone 无声地失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13094702/
什么是 vb6 或 java 中的对象克隆?我们在什么情况下使用克隆?克隆对象是什么意思?谁能用例子告诉我。 最佳答案 克隆实际上是将对象数据复制到新对象中。 此示例不克隆数据: Foo p = ne
ArrayList a=new ArrayList(); a.add(5); ArrayList b=(ArrayList)a.clone(); a.add(6); System.out.printl
这个问题在这里已经有了答案: Why does cloned() allow this function to compile (1 个回答) 关闭 3 个月前。 假设我们有一个可以克隆的某种类型的
我有这样的代码,我需要在其中将某些内容插入到两个单独的 HashMap 中。我只想要实现克隆的通用类型。 use std::collections::HashMap; use std::clone::
这段代码(also on play) use std::sync::Arc; struct Foo { x: isize, // Something complex in actual cod
我有按钮 Drag to insert h1 tag 当你拖动它时,我希望按钮留在原来的位置,助手是 Example在你放下它的地方,你会放下h1没有任何可拖动或 jQuery UI 样式的标记。 所
覆盖 clone 方法,而不实现 Cloneable 接口(interface)并且不调用 super.clone() 是一个好习惯。这样,就不会抛出 CloneNotSupportedExcepti
public abstract class Shape implements Cloneable { private String id; protected String type;
克隆远程仓库后,它不会通过 -a 选项显示任何远程分支。可能是什么问题呢?如何调试呢?在此片段中,未显示两个远程分支: $ git clone --depth 1 git://git.savannah
我看过这个答案for a git clone error ,建议不要克隆整个 repo,而是只克隆最新的提交,然后使用 unshallow 获取其余的提交。 考虑以下两个命令 1. git clone
当在网上搜索如何以多态方式深层复制对象的可能性时,我发现了 solution声称可以使用 clone() 方法解决许多问题,例如无法克隆 final 字段。该解决方案结合了在 clone() 实现中使
我正在尝试创建一个动态表单来向业务合作伙伴展示。 目标是能够在单击按钮时根据需要添加选择元素。但是,当它被点击时,它会复制模板两次,而不是一次。 这里只是我尝试过的代码的一些变体和 here is t
我知道实现 Object#clone() 的约定表明您应该调用 super.clone() 来获取复制的对象。 但我只是想知道如果我不这样做的话会有什么后果。让我们假设这个例子: class Some
我所说的示例:http://jsfiddle.net/bsnxp/1/ 如果你检查源 .show().clone() display 是 inline-block (它应该是什么)并且 .clone(
我正在编写代码来创建对象、克隆对象,然后比较两者。 所讨论的对象 Octagon 是对象 GeometricObject 的扩展 public class Octagon extends Geomet
我看到clone()在django代码中被广泛使用 queryset.query.clone() queryset.clone() 它的用途是什么?我应该模仿查询集或管理器方法中的行为吗? 最佳答案
我尝试导入 git project进入 eclipse 。手册告诉我在控制台中使用此命令: git clone http://git-wip-us.apache.org/repos/asf/mina-
我正在使用 jquery .clone(),它工作正常。但是我的问题是,当我克隆我的输入字段时,它也会克隆前一个字段的值。我不想克隆该值。我该如何克服这个问题? 这是我的代码 function add
在 this SO thread 中,结果表明,在制作项目副本方面,切片比任何方法都快。 使用: list1 = ['foo','bar'] copy1 = list1 * 1 list1.pop()
我有一个自动脚本可以解析服务器并克隆其中一个文件夹中的所有存储库。它所做的伪代码是: for each repo_name if a folder named like repo_name exi
我是一名优秀的程序员,十分优秀!