如何从远程git存储库一次提取一个提交?

Nor*_*sey 9 git mirroring darcs

我正在尝试建立一个git存储库的darcs镜像.我有一些工作正常,但有一个重大问题:如果我将一大堆提交推送到git repo,那些提交将合并到一个darcs补丁集中.我真的想确保每个git commit都设置为单个darcs补丁集.我敢打赌这可能是通过某种方式git fetch跟踪审查远程分支的本地副本,但我的git fu不能胜任这项工作.

这是我现在使用的(ksh)代码,或多或少:

git pull -v # pulls all the commits from remote --- bad!

# gets information about only the last commit pulled -- bad!
author="$(git log HEAD^..HEAD --pretty=format:"%an <%ae>")"
logfile=$(mktemp)
git log HEAD^..HEAD --pretty=format:"%s%n%b%n" > $logfile

# add all new files to darcs and record a patchset. this part is OK
darcs add -q --umask=0002 -r .
darcs record -a -A "$author" --logfile="$logfile"
darcs push -a
rm -f $logfile
Run Code Online (Sandbox Code Playgroud)

我的想法是

  1. 尝试git fetch获取远程分支的本地副本(不确定需要什么参数)
  2. 以某种方式询问本地副本以获取自上次镜像操作以来每次提交的哈希值(我不知道如何执行此操作)
  3. 循环遍历所有哈希,拉动该提交并记录相关的补丁集(我很确定如果我抓住哈希,我知道如何做到这一点)

我欢迎任何帮助充实上面的场景或建议我应该尝试的其他事情.

想法?

xen*_*ide 0

git remote update # fetch all remotes I like it better than just fetch

git log origin/master # can be any remote/branch

git cherry-pick origin/master # example remote/branch you can also specify a sha1

默认情况下,cherry-pick 将选择顶部补丁。

对于第三部分,我认为您必须编写一个脚本来为您完成它。还有其他方法来获取哈希值和许多日志选项。实际上,可能有一个用于cherry-pick的钩子,或者可能只是提交后...来运行darcs代码。查看 git hooks。

事实上,在这一点上,rebase 中应用的每个补丁都可能调用 git commit hook,因此您可以编写它,然后执行 git pull --rebase 并将该代码钉在每个应用上......