相关疑难解决方法(0)

如何将文件从一个git仓库移动到另一个(不是克隆),保留历史记录

我们的Git存储库最初是作为单个怪物SVN存储库的一部分开始的,其中每个项目都有自己的树,如下所示:

project1/branches
        /tags
        /trunk
project2/branches
        /tags
        /trunk
Run Code Online (Sandbox Code Playgroud)

显然,将文件从一个文件移动到另一个文件非常容易svn mv.但在Git中,每个项目都在自己的存储库中,今天我被要求将子目录从中移动project2project1.我做了这样的事情:

$ git clone project2 
$ cd project2
$ git filter-branch --subdirectory-filter deeply/buried/java/source/directory/A -- --all
$ git remote rm origin  # so I don't accidentally the repo ;-)
$ mkdir -p deeply/buried/different/java/source/directory/B
$ for f in *.java; do 
>  git mv $f deeply/buried/different/java/source/directory/B
>  done
$ git commit -m "moved files to new subdirectory"
$ cd ..
$
$ git clone project1
$ cd project1
$ …
Run Code Online (Sandbox Code Playgroud)

git repository

447
推荐指数
10
解决办法
13万
查看次数

git将目录移动到另一个存储库,同时保留历史记录

首先 - 向这个问题道歉.关于它的话题已经很多了.但我对他们没有太多运气.我对git缺乏熟悉并没有多大帮助.

我正在将一个文件夹从一个git repo移动到另一个(已经存在).例如

repo-1
---- dir1
---- dir2
---- dir3
---- dir-to-move
---- dir5

repo-2
---- dir1
---- dir2
---- dir3
Run Code Online (Sandbox Code Playgroud)

最后我希望回购看起来像

repo-1
---- dir1
---- dir2
---- dir3
---- dir-to-move
---- dir5

repo-2
---- dir1
---- dir2
---- dir3
---- dir-to-move
Run Code Online (Sandbox Code Playgroud)

也就是说,在两个回购中都存在dir-to-move.但最终我会将最新的更改迁移到repo-2并从repo-1中移除dir-to-move.

我最初的研究让我相信我需要使用filter-branch.例如

如何使用`git format-patch`和`git am`将文件从一个git repo移动到另一个保存历史记录

我已经知道子树取代了这种方法.然而,它并没有达到我的预期.我以为我能够做类似的事情

repo-1工作区中

git subtree split -P dir-to-move -b split
Run Code Online (Sandbox Code Playgroud)

拆分分支过滤到仅dir-to-move及其历史记录.然后在repo-2工作区 …

git

11
推荐指数
6
解决办法
1万
查看次数

将具有完整历史记录的 Git repo A 移动到 Git repo B(非空)

我想将所有文件从 Git Repo A 移动到具有完整历史记录的 Git Repo B。Git B 已经包含另一个项目文件。我尝试了几种方法,例如

如何将文件从一个 git repo 移动到另一个(不是克隆),保留历史记录

如何使用`git format-patch`和`git am`将文件从一个git repo移动到另一个保留历史记录

我尝试通过终端执行所有提交。但是我"git filter-branch fatal:myDirectory/: 'myDirectory' is outside repository Could not get the commits"在执行git filter-branch --subdirectory-filter muDirectory -- --all.

我需要分步过程的详细指导,将所有文件从一个 repo 移动到另一个 repo。将不胜感激任何帮助,提前致谢。

git macos version-control

5
推荐指数
1
解决办法
714
查看次数

标签 统计

git ×3

macos ×1

repository ×1

version-control ×1