Skip to content

Instantly share code, notes, and snippets.

@DanEdens
Created June 16, 2023 16:51
Show Gist options
  • Save DanEdens/a2a7659bdf4ba1261e9c6688ba9c55e7 to your computer and use it in GitHub Desktop.
Save DanEdens/a2a7659bdf4ba1261e9c6688ba9c55e7 to your computer and use it in GitHub Desktop.
Git repo Toggle. Will either re-Clone or autocommit and delete. I made this to be able to remove clutter without losing easy access to it. Includes sh and cmd versions
@echo off
setlocal
set repo_url=https://github.com/DanEdens/resume.git
set repo_folder=resume
if not exist "%repo_folder%" (
echo Cloning repository...
git clone "%repo_url%" "%repo_folder%"
cd "%repo_folder%"
) else (
echo Repository folder already exists. Performing commit and push.
cd "%repo_folder%"
git add --all
git commit -m "Commit message"
git push origin master
cd ..
rd /s /q "%repo_folder%"
)
endlocal
#!/bin/bash
repo_url="https://github.com/DanEdens/resume.git"
repo_folder="resume"
if [ ! -d "$repo_folder" ]; then
echo "Cloning repository..."
git clone "$repo_url" "$repo_folder"
cd "$repo_folder"
else
echo "Repository folder already exists. Performing commit and push."
cd "$repo_folder"
git add --all
git commit -m "Commit message"
git push origin master
cd ..
rm -rf "$repo_folder"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment