Skip to content

Instantly share code, notes, and snippets.

@Artistan
Last active March 27, 2018 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Artistan/c469456ea65bc6f056b2a307bddc8b77 to your computer and use it in GitHub Desktop.
Save Artistan/c469456ea65bc6f056b2a307bddc8b77 to your computer and use it in GitHub Desktop.
Git Checkout, Merge and Squish
#!/bin/bash
master="master"
# git-branch.sh dev
branch="$1"
git checkout $master
git fetch --all
git pull upstream $master
git status # check that everything is clean...
git checkout -b $branch
#!/bin/bash
# the number is the count of commits that you have after creating your dev branch -1 (8 commits -1 = 7)
# this will squish all the commits into the first one you made after branching
# git-squish.sh dev 12
branch="$1"
revisions="$2"
# squish all your commits BACK into the first one of the current branch.
./git-squish.sh $branch $revisions
# merge your one commit into
./git-merge.sh $branch
#!/bin/bash
master="master"
# merge all your commits BACK into the first one of the current branch.
# git-merge.sh dev
branch="$1"
# Reset the current branch to the commit just before the last 12:
git checkout $branch
# git rebase onto $master via phpstorm
# git push origin $branch
# create pull request
#!/bin/bash
# git-squish.sh dev 12
branch="$1"
revisions="$2"
# Reset the current branch to the commit just before the last 12:
git checkout $branch
git reset --hard HEAD~$revisions
# HEAD@{1} is where the branch was just before the previous command.
# This command sets the state of the index to be as it would just
# after a merge from that commit:
git merge --squash HEAD@{1}
# Commit those squashed changes. The commit message will be helpfully
# prepopulated with the commit messages of all the squashed commits:
git commit
@Artistan
Copy link
Author

Artistan commented Aug 4, 2017

@Artistan
Copy link
Author

Artistan commented Aug 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment