Skip to content

Instantly share code, notes, and snippets.

@evenv
Created July 3, 2019 06:45
Show Gist options
  • Save evenv/d351cf256b01ef2d6e356a519f19f65c to your computer and use it in GitHub Desktop.
Save evenv/d351cf256b01ef2d6e356a519f19f65c to your computer and use it in GitHub Desktop.
@echo off
setlocal enabledelayedexpansion
REM Get the chosen branch as a variable (Default: current branch)
if [%2%]==[] (
git rev-parse --abbrev-ref HEAD > tmpFile
set /p git_branch=<tmpFile
del tmpFile
) else (
set git_branch=%2
git checkout dev
git pull origin dev
git checkout -B !git_branch!
)
REM Check if branch exists in remote repository
git ls-remote origin --head %git_branch% > tmpFile
set /p remote_branch=<tmpFile
del tmpFile
REM Sync with Git remote
if "%remote_branch%"=="" (
git push -u origin %git_branch%
) else (
git pull origin %git_branch%
)
REM Import the current local branch to DBC
if %1%==up (
databricks workspace delete -r /%git_branch%
databricks workspace import_dir src /%git_branch% -o
)
REM Export the current branch to local
if %1%==down (
rmdir /Q /S src
databricks workspace export_dir /%git_branch% src -o
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment