deltaskelta deltaskelta - 1 year ago 119
Git Question

git: cleanup or delete commit to cleanup the commit history

The docs and searching is just confusing me about what to do to cleanup a commit history.

Say I have a branch called tests that I use to push builds to travis-ci and I have a build failing. I would then have to make some small commits to try to fix the error message and re-push the


This could lead to a chain of small and nearly pointless commits that I do not really want to make, but I am forced to nonetheless. How would I compact these into one commit? I think
is what I am looking for but I am confused about a few things.

If I use
, I find that I run into a ton of merge conflicts that I have to then go and solve manually.

I think the solution may be to just delete the commits, but then I am not sure if I will be deleting some history that my final "working" commit needs.

Say my commit history looks like this:

commit1: some new feature
commit2: crap, builds failing, trying fix
commit3: more build attempts
commit4: Ahh I think I got it this time
commit5: ok finally fixed, build passing

Now I would essentially like to have only one commit to merge back into the
. What would you do here that isn't going to lead to merge conflicts?

Answer Source

How about

git reset --soft HEAD~[n]
git commit

That should squash your n last commits.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download