我有一个历史悠久的GitHub存储库funfun。我还有另一个GitHub存储库TBD

现在,我想将文件夹funfun移到文件夹TBD下,然后从现在开始,我将仅在存储库TBD上工作。我希望保留funfun的提交历史记录。

我遵循了this solution。结果如下:

MBP:TBD$ ls
OCaml       README.md
MBP:TBD$ git remote add funfun ../funfun
MBP:TBD$ git fetch funfun --tags
warning: no common commits
remote: Counting objects: 11874, done.
remote: Compressing objects: 100% (4286/4286), done.
remote: Total 11874 (delta 9020), reused 9813 (delta 7494)
Receiving objects: 100% (11874/11874), 21.98 MiB | 20.68 MiB/s, done.
Resolving deltas: 100% (9020/9020), done.
From ../funfun
 * [new branch]      master     -> funfun/master
MBP:TBD$ git merge --allow-unrelated-histories funfun/master
warning: Cannot merge binary files: .DS_Store (HEAD vs. funfun/master)
Auto-merging README.md
CONFLICT (add/add): Merge conflict in README.md
Auto-merging .DS_Store
CONFLICT (add/add): Merge conflict in .DS_Store
Automatic merge failed; fix conflicts and then commit the result.
MBP:TBD$ git remote remove funfun
MBP:TBD$ ls
Addins          bin         package-lock.json   units
OCaml           config          package.json        views
README.md       git.sh          public          webpack.config.js
addin           models          routes
app.js          output.csv      ssl


当我在GitHub网站上查看TBD时,未添加funfun

是因为Automatic merge failed; fix conflicts and then commit the result.吗?有谁知道如何修理它?

PS:拥有子文件夹TBD\funfun\或将funfun的所有子文件夹放在TBD下(如上所述)都很好,我以后总是可以安排文件夹。

最佳答案

您已经完成了大部分工作。现在,仅解决合并冲突。让我们一一解决。

CONFLICT (add/add): Merge conflict in README.md


这很简单。 README.md文件存在一些冲突,您可以通过编辑文件并保存其中的任何内容来手动解决。确保删除其中包含<<<<<<<=======>>>>>>>的行,这些行被Git用于显示冲突。进入下一个。

CONFLICT (add/add): Merge conflict in .DS_Store


.DS_Store是在Mac上创建的,您可以通过运行ls -a进行查看,通常应通过将其添加到repo目录根目录的.gitignore文件中而从源代码管理中忽略它。由于尚未完成,因此该文件也发生了冲突。因此,现在您应该首先在repo目录的根目录中运行以下命令,从您的repo目录中删除所有出现的.DS_Store

find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch


接下来,如果您已经有一个.gitignore文件,请在其中添加带有.DS_Store的行。否则,通过命令在repo目录的根目录下创建并添加条目

echo .DS_Store >> .gitignore


接下来,只需像平常一样提交更改即可

git commit -am "Commit message"


然后使用

git push origin master


完成工作!

08-27 13:18