Created
May 5, 2025 14:27
-
-
Save pascalwhoop/cfad4375a76bb6a8801ed40164850c55 to your computer and use it in GitHub Desktop.
Revisions
-
pascalwhoop created this gist
May 5, 2025 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/bin/bash # ensure we're in git root cd "$(git rev-parse --show-toplevel)" # zip .git folder and store in above folder zip -r ../git_folder.zip .git # get uncommitted changes git diff > ../uncommitted_changes.txt git diff main > ../branch_diff.txt # now we reset the repo to remote git reset --hard git fetch --all git checkout main git reset --hard origin/main git clean -fd # Delete all local branches except 'main' for branch in $(git branch | sed 's/\*//g' | awk '{$1=$1;print}' | grep -v "main"); do git branch -D "$branch" echo "Deleted local branch: $branch" done # Optional: Prune old refs and optimize git remote prune origin git gc --prune=now