Last active
February 8, 2021 21:02
-
-
Save jkubicek/8391f35bb0e6545e317335054c97701a to your computer and use it in GitHub Desktop.
Git Tools
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
git checkout (git-main) | |
git pull |
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 | |
set -e | |
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
MAIN_BRANCH=$(git-main) | |
if [ $MAIN_BRANCH = $CURRENT_BRANCH ] | |
then | |
echo "Cannot run this command on the mainbranch" | |
exit 1 | |
fi | |
git branch --force backup/cleanup | |
git checkout $MAIN_BRANCH | |
git pull | |
echo "Now deleting branch" $CURRENT_BRANCH | |
echo "To restore: git branch" $CURRENT_BRANCH "backup/cleanup" | |
git branch -D $CURRENT_BRANCH |
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 | |
git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@' |
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
#!/usr/bin/env bash | |
set -e | |
set -o pipefail | |
git fetch | |
git merge origin/$(git-main) |
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
#!/usr/bin/env bash | |
git checkout $(git-main) | |
git pull | |
git checkout -b $1 |
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 | |
set -e | |
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
git branch --force backup/git-squash-to-main | |
git checkout "$(git-main)" | |
git pull | |
git checkout -b $USER/$CURRENT_BRANCH | |
git merge --squash $CURRENT_BRANCH | |
git branch -D $CURRENT_BRANCH | |
git commit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment