-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-export.bat
50 lines (37 loc) · 1.34 KB
/
git-export.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
::---------------------------------------------------------------------
:: A windows executable batch file that exports (checkout-index) the
:: current HEAD of a git repository to a specified directory.
:: - Uses relative directory access in case full path is not supplied.
:: - Exports contents to an "/export" directory inside the repository if no
:: argument is supplied
:: - Creates the entered directory if it does not yet exist
:: Dependencies: GitBash
:: madbarua;20180920
::---------------------------------------------------------------------
@echo off
:: Clear the input variable
set "export_path="
:: Get the user-input directory path or name
set /p export_path="Enter the full directory path or internal folder on which to export:"
if "%export_path%" == "" set export_path="./export/
GOTO GitExport
:GitExport
if exist %export_path% (
:: Check if full path (path contains ":")
If NOT "%export_path%"=="%export_path::=%" (
git checkout-index -f -a --prefix=%export_path%/
) else (
:: Export the current HEAD to specified internal relative path
git checkout-index -f -a --prefix=./%export_path%/
)
echo Exporting HEAD contents to: %export_path%
GOTO End
) else (
:: Create directory
echo Creating directory %export_path%...
mkdir %export_path%
GOTO GitExport
)
:End
set "export_path="
pause;