0

I am working on git master and sub branch. Master and subcode Branch.

Now I have done one change in subcode branch and commit(4 to 5 commits done) that changes and push over subcode branch.

Now I want to show only one commit in my subcode branch but currently its show me 5 commits.

I have used following command for rebase the commits.

git rebase -interactive HEAD~3 

And then perform some edits like this.

pick 6336d7c Commit commit#1
pick 54e8a9b Commit commit#2
pick 39f1d2h Commit commit#3 

git rebase --continue

But it still show me 5 commits. Is there any idea how can I squash and rebase all commit into one commit?

piet.t
  • 11,718
  • 21
  • 43
  • 52
Smithiam
  • 162
  • 1
  • 16
  • 1
    Possible duplicate of [Squash my last X commits together using Git](https://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git) – Marc Feb 14 '19 at 09:28

2 Answers2

3

Once the editor opens with the selected commits, change pick with squash. So it should like something like this if you want to squash all commits into the #1:

  1. pick 6336d7c Commit commit#1
  2. squash 54e8a9b Commit commit#2
  3. squash 39f1d2h Commit commit#3

Then save, exit the editor and execute:

git rebase --continue
AlexK
  • 1,380
  • 10
  • 17
1

you can use: git rebase -i <after-this-commit> and then replace "pick" on the second and subsequent commits with "squash" or "fixup". refer https://git-scm.com/docs/git-rebase#_interactive_mode

prachi
  • 305
  • 1
  • 7