Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

squash commits git

We have those commits:
	Made something... I dont know what with this thing
	Fix up some bug of that thing
	Start to make that thing

We need to squash it!

# Reset the current branch to the commit just before the last 3:
git reset --hard HEAD~3

# 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.
git commit -m "Made that thing"

# If you've pushed it, then we need to change remote branch with force
git push --force
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #squash #commits #git
ADD COMMENT
Topic
Name
4+2 =