Last active
January 27, 2022 00:19
-
-
Save amg1127/7a7c067de95b53bb054fb56586f5b3f3 to your computer and use it in GitHub Desktop.
Sample script that downloads files from a Git repository published on Github
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
REM Sample script that downloads files from a Git repository published on Github | |
REM This script assumes that Git client is installed. | |
REM If it is not, please download the official Git client from https://www.git-scm.com/download/win and install it. | |
REM Files from public repositories can be downloaded straight away. | |
REM However, Git client will need a personal access token in order to download files from private repositories. | |
REM Please follow these articles for guidance: | |
REM - https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token | |
REM - https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git | |
REM Please specify the full path of the Git client executable | |
REM If Git installation directory is listed in %PATH%, then specifying "git.exe" here will work | |
set GIT_CLIENT="%PROGRAMFILES%\Git\bin\git.exe" | |
REM set GIT_CLIENT="git.exe" | |
REM Please specify the URL of the Github repository here | |
set GITHUB_REMOTEURL="https://github.com/amg1127/IT_BR_NZ" | |
REM Please specify a directory where a local clone of the Github repository will be stored | |
set GITHUB_LOCALDIR="local IT_BR_NZ" | |
REM REM REM REM | |
@echo on | |
REM Create a clone of the remote repository, unless an existing clone is present | |
if not exist %GITHUB_LOCALDIR%\.git %GIT_CLIENT% clone %GITHUB_REMOTEURL% %GITHUB_LOCALDIR% | |
REM Fetch latest changes from the remote repository | |
%GIT_CLIENT% -C %GITHUB_LOCALDIR% pull --ff-only | |
if %ERRORLEVEL% NEQ 0 goto failure | |
REM Further commands that handle the downloaded files go here | |
copy /y %GITHUB_LOCALDIR%\README.md %TEMP% | |
goto eof | |
:failure | |
echo "! Operation failed!!!" | |
exit /b 1 | |
:eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment