Matt W
Matt W

Reputation: 12423

Squashing commits with BitBucket

I have only master on a test repo and I'm trying to squash 3 commits into one so that a file change and deletion appear as one commit.

So far, my attempts to squash have resulted in 3 commits, all with the same content.

I am not using a branch. How should I squash commits with BitBucket git?

Upvotes: 1

Views: 1580

Answers (1)

CodeWizard
CodeWizard

Reputation: 142014

The best way to do it is to use the command line.

git squash (interactive rebase)

You have to verify that your branch is not locked for rewriting history and than from the command line do this:

# edit the desire 3 commits.
# keep in mind that if the commits were merged you will have more than 3 commits
git rebase -i HEAD~3

Now use the s to squash the desired commits into the previous one.

The order of the commits are reversed meaning that the first one that you see is the oldest of the X commits.

Here you can see a sample of how to squash your commits.

enter image description here

Upvotes: 1

Related Questions