Git – Difference between amend and squash commands

Am wondering what exactly is the difference between amend and squash commands, as I tried both and found that both are doing the same for proper management.

  • How do I push amended commit to the remote Git repository?
  • How to undo “git commit --amend” done instead of “git commit”
  • Git prevents pushing after amending a commit
  • Edit the root commit in Git?
  • How to git commit --amend a commit that's the base of a branch
  • How to modify existing, unpushed commits?
  • Is there a method to update all of my textmate bundles at once from the git repository?
  • Creating a custom SMS/MMS app in Android - using Eclipse and GitHub - why so many unresolveds?
  • What's the best practice to “git clone” into an existing folder?
  • With git, how do I save a topic branch after the parent remote branch was rebased?
  • Elevator pitch for Git a/o DVCS
  • Git: Prevent commits in master branch
  • 2 Solutions collect form web for “Git – Difference between amend and squash commands”

    In Git, commits are rarely actual destroyed, they just become orphans, or detached, meaning that they are not pointed to or reachable by a reference like a branch or tag.

    “amending” and “squashing” are similar concepts though.

    Typically, amending is a single commit operation in which you want to combine work that you have staged with your HEAD commit. This can be very convenient if you have just created a commit and realize that you need to add some content to it. Simply recall your commit command and use the --amend option.

    Squashing is the more abstract term. I would say that an amend is a type of squash. Whenever you combine commits you could say that you are squashing them. If you have been working on a branch for a little while and have made 5 commits that taken together should be 1 commit, you can interactively rebase to squash them together.

    There are several ways in Git to amend/squash, but they all center around the concept of organizing your commit history (which means re-writing the history of a branch) in this spirit of making it easier to grok.

    amend only changes the last commit.

    squash is like merging multiple commits into one single commit.

    For only one commit, their effects may look alike.

    Git Baby is a git and github fan, let's start git clone.