Skip to content

Instantly share code, notes, and snippets.

@jkubicek
Last active February 8, 2021 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkubicek/8391f35bb0e6545e317335054c97701a to your computer and use it in GitHub Desktop.
Save jkubicek/8391f35bb0e6545e317335054c97701a to your computer and use it in GitHub Desktop.
Git Tools
git checkout (git-main)
git pull
#!/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
#! /bin/bash
git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'
#!/usr/bin/env bash
set -e
set -o pipefail
git fetch
git merge origin/$(git-main)
#!/usr/bin/env bash
git checkout $(git-main)
git pull
git checkout -b $1
#!/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