1

I want to implement featureX and I have committed it after writing it by

git commit -m "featureX"

After that I have done some changes and committed by

git commit -m "yo1"

squashed the commit by

git rebase -i HEAD~2

again some changes and committed by

git commit -m "yo1"

squashed the commit by

git rebase -i HEAD~3

Now git log shows -

featureX
yo1
yo2

I want to change commit message yo1 and yo2 to change1 and change2.

Also, I want to know that how can I see the changes that I have done in yo1 and yo2 because I have forgot what changes I have done in yo1 and yo2.

Mayank Jindal
  • 355
  • 5
  • 15

4 Answers4

4

Squashing commit means generating a new hash id for your commit and merging your commit changes in one single commit. All the information in your commit tree regarding commits with commit messages yo1 and yo2 are lost now(merged in featureX).

However you can still see them if you know their commit hash id and also given that git haven't been through garbage collection. They would still be there lying detached from your branch as an object.

Do git reflog to find out the hash id associated with your commit message (yo1 or yo2).

Then you can simply git show hashid# to see the commit change you made there.

If you just simply want to change the commit message, it is much simpler and can be accomplished by either doing

git commit --amend

or

git rebase -i HEAD~1 (-i stands for interactive mode)

2

You can use:

git commit --amend -m "New commit message"

To amend the most recent commit, since a squash commit is a all-in-one squashed commit.

Dario
  • 3,905
  • 2
  • 13
  • 27
0

You cannot know the original changes since squash combine all commits into one. It makes a new commit

You Can change commit description with an amend on last commit or an interactive rebase and edit option

Git commit --amend
Graham
  • 7,431
  • 18
  • 59
  • 84
Flows
  • 3,675
  • 3
  • 28
  • 52
0

In order to edit that HEAD (current commit) you can use the

git commit --amend

Also, I want to know that how can I see the changes that I have done in yo1 and yo2

In order to see the content of the latest commit and update it

git commit --amend --verbose

enter image description here In order to see content of a given commit you can use

git show <sha-1>

enter image description here

CodeWizard
  • 128,036
  • 21
  • 144
  • 167