从SVN转到SourceTree,在想导出几个提交版本所牵涉到的文件时, 必定会怀念SVN的Export功能。 怎么让SourceTree也有这个功能呢?
看看在TortoiseSVN里面怎么作的: php
到了SourceTree里面, 我可怎么也找不到Export的命令。
好在最新版本的SourceTree支持Custom Action。 这样咱们就能本身编写Export命令了。
如下是windows的bat命令, 储存为export.bat。 linux下的请按图索骥 linux
@set export_php="E:\projects\sia\tools\export.php" @set export_dir="E:\projects\sia\export" @set source_files=%* @rmdir %export_dir% /s/q @mkdir %export_dir% @php %export_php% %source_files% @explorer %export_dir%
如下是E:\projects\sia\tools\export.php windows
<?php date_default_timezone_set('Asia/Shanghai'); if($argc == 0) { exit('Nothing to copy'); } define('DS', DIRECTORY_SEPARATOR); // I always use this short form in my code. $source_dir = 'E:'.DS.'projects'.DS.'sia'.DS.'sia'; $exp_dir = 'E:'.DS.'projects'.DS.'sia'.DS.'export'; function ExportOneFile($path) { global $source_dir,$exp_dir; $final_source = $source_dir.DS.$path; $final_dest = $exp_dir.DS.$path; $final_dest_dir = dirname($final_dest).DS; if(!is_dir($final_dest_dir)) { mkdir($final_dest_dir,0777,true); } return copy($final_source,$final_dest); } foreach($argv as $index=>$path) { if($index === 0) { continue; } if(ExportOneFile($path)) { echo $index.' : '.$path." exported\n"; } } echo "All Complete. Please go to $exp_dir to view files";
请修改这几个变量指向的路径: bash
export_php // export.php所在的位置 export_dir // 输出目录所在的位置
$source_dir // 项目文件所在的位置 -- SourceTree所掌控的目录 $exp_dir // 输出目录所在的位置
最后, 在SourceTree,选择 Tools=>Options=>Custom Actions=>Add this
Script to run 就是那个bat的位置。 spa
ok便可。 code
之后只须要选择相关的commit, 选择相关的文件。 而后选择Actions=》Custom Actions=》Export... 便可。 orm
导出完毕后, 会自动打开export文件夹。 挺方便的。 ip