Skip to content

Szmelc-INC/GitUP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

GitUP

Back your shit with Git <3

Single-file short version

#!/bin/bash

# --- CONFIG ---
GIT_USER="user"
GIT_EMAIL="user@gmail.com"
GITHUB_USER="user"
GITHUB_TOKEN="ghp_2u..."
REPO_URL="github.com/user/repo.git"
DIR="/full/path/to/backup"
BRANCH="main"
# --------------

cd "$DIR"

# Initialize git repo if needed
if [ ! -d ".git" ]; then
    git init
fi

# Set git config locally
git config user.name "$GIT_USER"
git config user.email "$GIT_EMAIL"

# Configure remote with authentication
if git remote | grep -q origin; then
    git remote set-url origin "https://$GITHUB_USER:$GITHUB_TOKEN@$REPO_URL"
else
    git remote add origin "https://$GITHUB_USER:$GITHUB_TOKEN@$REPO_URL"
fi

# Ensure branch exists and checkout
if git rev-parse --verify "$BRANCH" >/dev/null 2>&1; then
    git checkout "$BRANCH"
else
    git checkout -b "$BRANCH"
fi

# Perform backup
git add .
git commit -m "Backup $(date '+%Y-%m-%d %H:%M:%S')"
git push -u origin "$BRANCH"

About

Back your shit with Git <3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages