-
-
Save noherczeg/38f4e9ab5c456c00613f69ea563d88af to your computer and use it in GitHub Desktop.
git branch reset script with optional target branch parameter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -eq 0 ] | |
then | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
else | |
branch=$1 | |
fi | |
echo "--------------------------------" | |
echo "Resetting to branch: ${branch}" | |
echo "--------------------------------" | |
git clean -fd | |
git fetch | |
git checkout $branch | |
git reset --hard origin/$branch | |
git pull | |
echo "--------------------------------" | |
git status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment