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 ~/.local/bin ./install.sh symlink # Copy scripts to ~/.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
mkdir -p "$HOME/.local/bin"
cp scripts/git-* "$HOME/.local/bin/"
# Option 3: Create symlinks
mkdir -p "$HOME/.local/bin"
ln -s /path/to/bash-git-simplified/scripts/git-* "$HOME/.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 installs user-local symlinks in~/.local/binand adds that directory to yourPATHif needed. - The installer never invokes
sudo. For a system-wide install, run as a user that can write the destination and setBASH_GIT_SIMPLIFIED_DEST_DIR=/usr/local/bin. - 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
- Verifies
origin/<branch>exists before stashing local work - Automatically stashes tracked and untracked changes before pull
- Restores only the auto-stash it created, and keeps it with recovery commands if restore conflicts
- Prints next actions when the remote branch does not exist
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 or untracked changes
- Suggests
git-backup-workbefore destructive reset - 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)
- Creates missing origin branches with
git push -u - 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 - Verifies the upstream branch exists before stashing local work
- Automatically stashes tracked and untracked changes
- Restores only the auto-stash it created, and keeps it with recovery commands if restore conflicts
- 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/masterShow repository state and Git settings that commonly explain confusing tool output.
Usage: git-doctor
- Shows current branch, upstream, commit, remotes, divergence, working tree changes, and stashes
- Shows WSL/Desktop-sensitive settings including
core.filemode,core.autocrlf,core.eol, andcore.ignorecase - Warns when the repository is on a Windows-mounted WSL path
- Suggests follow-up checks for GUI/terminal status disagreements
Example:
git-doctor- 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
- Exact Stash Recovery: Auto-stash restore never blindly pops an older stash
- Diagnostics:
git-doctorexplains branch, stash, dirty tree, and cross-platform settings - 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.