1

I have a branch where I work since few weeks. Sometimes I go back on main to work on other features, and then come back to my branch.

While doing this, I git fetch and then git merge in my branch to stay up to date.

Problem : I have actualy 46 commits that I want to squash but I have my colleagues's commits in between.

How can I squash all my personal commits on my personal branch ?

When I git log, i see my commits but also everyone's commits.

Johan
  • 2,088
  • 2
  • 9
  • 37

1 Answers1

1

Posting the solution in case it helps :

i used git rebase -i HEAD~<number of commits> and it listed only MY commits. Just had to squash then.

Thanks for your help in comments.

Johan
  • 2,088
  • 2
  • 9
  • 37
  • It's a bit more complex because you have to know how changing `pick` to `squash` works and in what order/direction it will do the squash. But you are on the right track. – Tim Biegeleisen Jun 12 '23 at 15:32
  • I'm not convinced this should work because you said: "I want to squash but I have my colleagues's commits in between. Maybe if you changed `HEAD~X` to `main` it would work though? – TTT Jun 12 '23 at 16:17
  • This command prompt me only my commits, so it has been easy to squash them after that – Johan Jun 13 '23 at 06:17
  • Did it show all 46 commits, and none of the other people's commits? If yes, I think the premise of the question may have been wrong that they were in between your commits, unless the *only* other commits were merge commits, which fall out by default during a rebase. – TTT Jun 13 '23 at 16:35