简体   繁体   English

如何在git svn dcommit之前创建存档?

[英]how can I create an archive before git svn dcommit?

I'm trying to create a zip archive of my project when I push to the svn server. 当我推送到svn服务器时,我正在尝试创建项目的zip存档。 My old setup would use a post-receive hook on the remote git repo to do this. 我的旧设置将使用远程git仓库上的post-receive挂钩来执行此操作。 However, I'm now using svn and I don't own the svn server so I can't put anything over there. 但是,我现在正在使用svn,我没有svn服务器,所以我不能在那里放任何东西。 I've set up the following pre-push hook but this isn't running on git svn dcommit : 我已经设置了以下预推钩但这不是在git svn dcommit上运行的:

$cat .git/hooks/pre-push
#!/bin/sh
git archive -o foo_bar.zip --prefix foo_bar/ master

Any ideas on which hook I could use? 我可以使用哪些钩子的想法?

Thanks! 谢谢!

You are using git-svn , right? 你正在使用git-svn ,对吧? You haven't cited it anywhere, so I'm not sure you are. 你没有在任何地方引用它,所以我不确定你是谁。 Those git-hooks won't work with pure svn, you must be using git! 那些git-hooks不适用于纯svn,你必须使用git! It can be obvious, but better to be sure. 这显而易见,但更好的是确定。

As to your problem, you could probably use a post-commit hook: once you finished a commit you zip things up. 至于你的问题,你可能会使用一个post-commit钩子:一旦你完成了一个提交你就拉链了。 The downside to this, is that you won't have the zip file added to your repo. 这样做的缺点是,您不会将zip文件添加到您的仓库中。

If you need the zip on the repository, use the pre-commit hook and stash your tree. 如果您需要存储库中的zip,请使用pre-commit挂钩并stash树。 You can easily archive this tree, add the zipped file to the git index, and your done! 您可以轻松归档此树,将压缩文件添加到git索引,然后完成!

This answer might help you scripting this: Git archive of repository with uncommitted changes . 这个答案可能会帮助您编写脚本: 使用未提交的更改来存储存储库的存档

由于没有这样的钩子,如何创建别名呢?

dcm = "!f(){ git archive -o foo_bar.zip --prefix foo_bar/ master; git svn dcommit; }; f"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM