s A collection of linux shell scripts that simplify common git operations. Each script performs a commonly needed git function that typically requires multiple commands or complex options. Almost entirely coded by Github Copilot Agents and OpenAI's gpt-5-high, and scripts may take unsafe actions, use with great caution.
-
Clone this repository:
git clone https://github.com/waskosky/bash-git-simplified.git cd bash-git-simplified -
Run the installation script:
# Auto-detect/update (recommended). Re-run anytime to update. ./install.sh # Or explicitly choose a method: # Create symlinks in system bin (e.g., /usr/local/bin) ./install.sh symlink # Copy scripts to /usr/local/bin ./install.sh copy # Add scripts directory to PATH ./install.sh path
-
Reload your shell (for PATH method):
source ~/.bashrc
Alternatively, you can manually add the scripts to your PATH:
# Option 1: Add to your ~/.bashrc or ~/.zshrc
export PATH="$PATH:/path/to/bash-git-simplified/scripts"
# Option 2: Copy scripts to a directory already in PATH
sudo cp scripts/git-* /usr/local/bin/
# Option 3: Create symlinks
sudo ln -s /path/to/bash-git-simplified/scripts/git-* /usr/local/bin/Just re-run ./install.sh with no arguments. It auto-detects your previous method and updates accordingly. For the symlink method, it also prunes stale symlinks that pointed to this repo.
- The installer works on any modern Linux distro with Bash and Git.
- In
automode, it prefers system-wide symlinks if the system bin is writable (with or withoutsudo). - If the system bin is unavailable or not writable, it installs to
~/.local/binand adds it to yourPATH. - No distro-specific tools are required.
To remove the scripts:
./uninstall.shPull and auto-merge the latest code from origin, with automatic stashing of uncommitted changes.
Usage: git-pull-latest [branch_name]
- If no branch specified, uses current branch
- Automatically stashes uncommitted changes before pull
- Restores stashed changes after successful pull
- Handles merge conflicts gracefully
Example:
git-pull-latest # Pull latest changes for current branch
git-pull-latest main # Pull latest changes for main branchReset current branch to match another branch (useful for discarding local changes).
Usage: git-reset-to-branch [target_branch]
- If no branch specified, resets to main (or master if main doesn't exist)
- Warns before destroying uncommitted changes
- Cleans untracked files automatically
- Fetches latest changes before reset
Example:
git-reset-to-branch # Reset current branch to main
git-reset-to-branch dev # Reset current branch to match devReset to a completely clean state, removing all uncommitted changes and untracked files.
Usage: git-clean-start [branch_name]
- Removes ALL uncommitted changes and untracked files
- Clears git stash
- Resets to latest remote state
- Requires confirmation before proceeding
Example:
git-clean-start # Clean reset current branch
git-clean-start main # Clean reset to main branchHard reset the working tree to the last commit and remove untracked files.
Usage: git-reset-wipe [--yes]
- Discards all uncommitted changes (
git reset --hard HEAD) - Removes untracked files and directories (
git clean -fd) - Keeps ignored files (use
git-clean-startto remove ignored files too) - Prompts for confirmation unless
--yesis provided
Example:
git-reset-wipe # Prompt, then wipe to HEAD
git-reset-wipe --yes # Skip promptSafely commit all changes and push to origin with conflict resolution.
Usage: git-safe-push [commit_message]
- Prompts for commit message if not provided
- Shows changes before committing
- Pulls latest changes before pushing (with rebase)
- Handles push conflicts automatically
Example:
git-safe-push "Fix bug in user authentication"
git-safe-push # Will prompt for commit messageCreate and switch to a new branch from specified source branch.
Usage: git-new-branch <branch_name> [source_branch]
- Creates new branch from source (default: current branch)
- Switches to new branch automatically
- Carries uncommitted changes to new branch
- Fetches latest changes before creating branch
Example:
git-new-branch feature/user-login # Create from current branch
git-new-branch hotfix/bug-fix main # Create from main branchCreate a backup branch of current work with timestamp.
Usage: git-backup-work [backup_suffix]
- Creates timestamped backup branch
- Includes all uncommitted changes and untracked files
- Returns to original branch after backup
- Optional suffix for custom naming
Example:
git-backup-work # Creates branch-backup-20240905-143022
git-backup-work before-refactor # Creates branch-backup-20240905-143022-before-refactorSafely undo the last commit while optionally preserving changes.
Usage: git-undo-commit [--hard]
- Default: keeps changes in working directory (soft reset)
--hard: removes changes completely- Warns if commit was already pushed
- Cannot undo initial commit
Example:
git-undo-commit # Undo last commit, keep changes staged
git-undo-commit --hard # Undo last commit, remove changes completelySync with upstream repository (useful for forks).
Usage: git-sync-upstream [upstream_remote] [branch]
- Default upstream remote:
upstream - Default branch:
main - Automatically stashes uncommitted changes
- Pushes updated branch to origin
- Returns to original branch
Example:
git-sync-upstream # Sync with upstream/main
git-sync-upstream origin dev # Sync with origin/dev
git-sync-upstream upstream master # Sync with upstream/master- Error Handling: All scripts include comprehensive error checking
- Safety First: Scripts warn before destructive operations
- Colored Output: Clear status messages with color coding
- Interactive Prompts: Confirmation prompts for dangerous operations
- Automatic Stashing: Preserves work when needed
- Conflict Resolution: Handles common git conflicts automatically
- Linux (any recent distro)
- Git installed and configured
- Bash shell
Feel free to submit issues, feature requests, or pull requests to improve these scripts.
This project is open source. Feel free to use, modify, and distribute these scripts.