我有一些csv
我定期修改的文件,它们实际上并不包含任何敏感信息,它们只是用作程序的导入,我会根据要求对其进行修改。
最近我发现了处理更改的更有效方法,但我在项目外部的临时 git 存储库上对其进行了测试。
由于这很成功,我现在想要对其进行更改git cherry-pick
的范围,所以首先我将临时 git repo 作为远程添加到我的项目中。
# In my project I added a remote of the test repo with
# a copy of the csv's in the HEAD of my main project.
git remote add tempchanges <path-to-test-repo>
# Created a new branch in my project to test this out in.
git checkout -b new/9_30_2019
# Cherry-picked the changes from the remote test repo, but they ended up in the root of the project.
git cherry-pick <start-commit-in-test-repo>..<head-commit-in-test-repo>
# Started a rebase
git rebase -i <start-commit-in-test-repo>~1
# (`edit`ed each commit in the rebase)
(事后看来,我认为这是一个错误,我应该在现有项目中削减另一个分支,但我离题了)
临时存储库只有一个主分支,并且所有内容都在项目的根目录中完成了一系列提交。
当我cherry-pick
对我的项目和本地分支进行更改时,这些csv
文件最终都在我的项目的根目录中,但它们属于src/csv
我的项目的文件,所以我决定rebase
从一开始就进行交互提交的范围(减去 1 次提交)并编辑每个,以便更改显示在我的项目存储库中的src/csv
目录而不是根目录中。
但是我的问题是,如果我想这样做,我应该使用git mv
移动文件还是仅使用标准 bashmv
命令,然后使用 rebase 重新应用每个更改,并将相应的提交消息添加到临时项目中。
到目前为止,我已经尝试git mv -f
在第一次提交时移动文件,并且在运行之前提交它们时甚至没有提到更改git rebase --continue
。
我还应该做些什么来使这个过程更顺利,我假设我应该使用mv
而不是git mv -f
因为在提交之前更改似乎以这种方式显示。
我还想保留提交消息,而不必从旧仓库的日志中复制它们。