Skip to content

Instantly share code, notes, and snippets.

@justinhennessy
Last active December 26, 2015 18:08
Show Gist options
  • Save justinhennessy/7191731 to your computer and use it in GitHub Desktop.
Save justinhennessy/7191731 to your computer and use it in GitHub Desktop.
Squashing commits in git

** NEVER DO THIS IN MASTER **

To squash the last 4 commits:

git rebase -i HEAD~4

This will open up vim with the following

pick e948f38 Added some notify statements to see the heira hash
pick 10e19b2 Finalised the proof of concept for using hiera and create_resources to create users
pick 3fd7908 Completed the move of users to the new YAML setup
pick 28f62bd Removed duplicate setup items for edhdev and edhadmin

# Rebase 1573120..28f62bd onto 1573120
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

Change the top of the file to match this

pick e948f38 Added some notify statements to see the heira hash
s 10e19b2 Finalised the proof of concept for using hiera and create_resources to create users
s 3fd7908 Completed the move of users to the new YAML setup
pick 28f62bd Removed duplicate setup items for edhdev and edhadmin

Then write and quit vim.

Then you will be asked to put in a commit message

Converted user management to use heira
# This is a combination of 3 commits.
# The first commit's message is:
Added some notify statements to see the heira hash

# This is the 2nd commit message:

Finalised the proof of concept for using hiera and create_resources to create users

# This is the 3rd commit message:

Completed the move of users to the new YAML setup

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Not currently on any branch.
# You are currently editing a commit while rebasing branch 'jh_try_create_resource_for_users' on '1573120'.
#
# Changes to be committed:
#   (use "git reset HEAD^1 <file>..." to unstage)
#
# modified:   hiera.yaml
# new file:   hieradata/users.yaml
# modified:   modules/users/manifests/init.pp
# deleted:    users.yaml

To get origin/branch_name up to date

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