Skip to content

Instantly share code, notes, and snippets.

@kingkool68
Created February 1, 2022 19:55
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 kingkool68/0a0a5f8832d3e0ebcab52c92be81d12a to your computer and use it in GitHub Desktop.
Save kingkool68/0a0a5f8832d3e0ebcab52c92be81d12a to your computer and use it in GitHub Desktop.
Quick little helper script to speed up your Git workflow if you ever need to merge a branch into another frequently (like your current feature branch into a `staging` branch). Useful as a custom command in the Git GUI Fork (https://fork.dev/)
#!/bin/bash
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
TARGET_BRANCH=staging
git fetch origin $TARGET_BRANCH
git checkout $TARGET_BRANCH
git merge "$CURRENT_BRANCH" -m "Merge branch '$CURRENT_BRANCH' into $TARGET_BRANCH"
git push origin $TARGET_BRANCH
git checkout "$CURRENT_BRANCH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment