Skip to content

Instantly share code, notes, and snippets.

@ad-m
Created September 28, 2018 23:15
Show Gist options
  • Select an option

  • Save ad-m/e6816e06f1d2c588d35f27f08b45688c to your computer and use it in GitHub Desktop.

Select an option

Save ad-m/e6816e06f1d2c588d35f27f08b45688c to your computer and use it in GitHub Desktop.
function git_push_delayed(){
TMP_BRANCH=$(date +"tmp-%s");
CUR_BRANCH=$(git rev-parse --abbrev-ref HEAD);
git checkout -b "$TMP_BRANCH" "$CUR_BRANCH";
git branch -D "$CUR_BRANCH";
git checkout -b "$CUR_BRANCH" "origin/master";
git log "$TMP_BRANCH"...origin/master --format="oneline" --reverse | awk '{print $1}' | while read COMMIT_ID; do
git merge "$COMMIT_ID";
git push origin "$CUR_BRANCH" --force;
done;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment