- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我错误地将我的 .git 文件夹放在了比需要更高的位置:
Folder1/
.git <-- currently here
myproject/
.git <--- should be here
我想将它移到 myproject
中,但是当我从那里查看旧提交时,它会破坏向后兼容性...
有没有办法保持一致?也许通过重写历史/假装它总是那样?我想这可以用 git filter-branch --tree-filter
来完成,但不确定怎么做?
最佳答案
由于您将 .git
文件夹移动到 myproject
文件夹,git 无法从其原始相对路径检测到该文件,但会找到新相对路径中存在的文件,所以 git status
将报告原始文件已删除并有新文件。
比如移动.git
文件夹之前,在git repo中git跟踪myproject
文件夹下的文件为root/myproject/*
。移动.git
文件夹后,myproject
文件夹下的文件现在位于git repo 的根目录下(root/*
)。所以 git 检测到它们是新文件(未跟踪)并认为 root/myproject/*
中的文件不再存在(已删除)。
并且由于 git 存储库仅供您自己使用,您可以提交更改目录。如果你想删除 .git
文件夹在 Folder1
下的原始提交历史,你可以使用 git rebase -i
来放弃一些提交。
如果你想保留 myproject
文件夹下文件的提交历史,你不应该移动 .git
文件夹,而是移动 下的文件和文件夹>Folder1
而在 myproject
文件夹 之外。
关于javascript - git : How to move git folder inside subfolder and rewrite history to pretend it always was like that?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47465187/
我是一名优秀的程序员,十分优秀!