Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have made a php script to export changed files on Windows. If you have a localhost development server with php set up then you can run it easily. It will remember your last repository and export always to the same folder. The export folder is always emptied before exporting. You will also see deleted files in red so you know what to delete on the server.</p> <p>These are just two files so I will post them here. Let's assume your repositories are located under c:/www in their own folders and that <a href="http://localhost" rel="nofollow">http://localhost</a> also points to c:/www and is php-enabled. Let's put these 2 files in c:/www/git-export -</p> <p>index.php :</p> <pre><code>&lt;?php /* create directory if doesn't exist */ function createDir($dirName, $perm = 0777) { $dirs = explode('/', $dirName); $dir=''; foreach ($dirs as $part) { $dir.=$part.'/'; if (!is_dir($dir) &amp;&amp; strlen($dir)&gt;0) { mkdir($dir, $perm); } } } /* deletes dir recursevely, be careful! */ function deleteDirRecursive($f) { if (strpos($f, "c:/www/export" . "/") !== 0) { exit("deleteDirRecursive() protection disabled deleting of tree: $f - please edit the path check in source php file!"); } if (is_dir($f)) { foreach(scandir($f) as $item) { if ($item == '.' || $item == '..') { continue; } deleteDirRecursive($f . "/" . $item); } rmdir($f); } elseif (is_file($f)) { unlink($f); } } $lastRepoDirFile = "last_repo_dir.txt"; $repo = isset($_POST['repo']) ? $_POST['repo'] : null; if (!$repo &amp;&amp; is_file($lastRepoDirFile)) { $repo = file_get_contents($lastRepoDirFile); } $range = isset($_POST['range']) ? $_POST['range'] : "HEAD~1 HEAD"; $ini = parse_ini_file("git-export.ini"); $exportDir = $ini['export_dir']; ?&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Git export changed files&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="." method="post"&gt; repository: &lt;?=$ini['base_repo_dir'] ?&gt;/&lt;input type="text" name="repo" value="&lt;?=htmlspecialchars($repo) ?&gt;" size="25"&gt;&lt;br/&gt;&lt;br/&gt; range: &lt;input type="text" name="range" value="&lt;?=htmlspecialchars($range) ?&gt;" size="100"&gt;&lt;br/&gt;&lt;br/&gt; target: &lt;strong&gt;&lt;?=$exportDir ?&gt;&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt; &lt;input type="submit" value="EXPORT!"&gt; &lt;/form&gt; &lt;br/&gt; &lt;?php if (!empty($_POST)) { /* ************************************************************** */ file_put_contents($lastRepoDirFile, $repo); $repoDir = $ini['base_repo_dir'] ."/$repo"; $repoDir = rtrim($repoDir, '/\\'); echo "&lt;hr/&gt;source repository: &lt;strong&gt;$repoDir&lt;/strong&gt;&lt;br/&gt;"; echo "exporting to: &lt;strong&gt;$exportDir&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;\n"; createDir($exportDir); // empty export dir foreach (scandir($exportDir) as $file) { if ($file != '..' &amp;&amp; $file != '.') { deleteDirRecursive("$exportDir/$file"); } } // execute git diff $cmd = "git --git-dir=$repoDir/.git diff $range --name-only"; exec("$cmd 2&gt;&amp;1", $output, $err); if ($err) { echo "Command error: &lt;br/&gt;"; echo implode("&lt;br/&gt;", array_map('htmlspecialchars', $output)); exit; } // $output contains a list of filenames with paths of changed files foreach ($output as $file) { $source = "$repoDir/$file"; if (is_file($source)) { if (strpos($file, '/')) { createDir("$exportDir/" .dirname($file)); } copy($source, "$exportDir/$file"); echo "$file&lt;br/&gt;\n"; } else { // deleted file echo "&lt;span style='color: red'&gt;$file&lt;/span&gt;&lt;br/&gt;\n"; } } } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>git-export.ini :</p> <pre><code>; path to all your git repositories for convenience - less typing base_repo_dir = c:/www ; if you change it you have to also change it in the php script ; in deleteDirRecursive() function - this is for security export_dir = c:/www/export </code></pre> <p>And now load localhost/git-export/ in a browser. The script is set up to export always to c:/www/export - change all paths to suit your environment or modify the script to suit your needs.</p> <p>This will work if you have Git installed so that the git command is in your PATH - this can be configured when you run the windows Git installer.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload