Skip to content

Instantly share code, notes, and snippets.

@Aviksaikat
Created July 30, 2025 17:31
Show Gist options
  • Save Aviksaikat/47d8b74d37c7010476382173def28246 to your computer and use it in GitHub Desktop.
Save Aviksaikat/47d8b74d37c7010476382173def28246 to your computer and use it in GitHub Desktop.
fetch & force rabase git branches
#!/bin/bash
# $1 = path, $2 = branch
if [ "$#" -ne 2 ]; then
echo "[!] Usage: ${0} <path> <branch_name>"
exit
fi
cd $1
git fetch origin
git rebase origin/master
git push --force-with-lease origin $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment