Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Business Intelligence
  3. Question
Business Intelligence

How to squash commits in git after they have been pushed?

Asked by Carole Thom Jul 12, 2021 2.2K views 1 answer
Share

About this question

This gives a good explanation of squashing multiple commits:

http://git-scm.com/book/en/Git-Branching-Rebasing 

but it does not work for commits that have already been pushed. How do I squash the most recent few commits both in my local and remote repos?

EDIT: When I do git rebase -i origin/master~4 master, keep the first one as pick, set the other three as squash, and then exit (via c-x c-c in emacs), I get:

$ git rebase -i origin/master~4 master
# Not currently on any branch.
nothing to commit (working directory clean)
Could not apply 2f40e2c... Revert "issue 4427: bpf device permission change option added"
$ git rebase -i origin/master~4 master
Interactive rebase already started

where 2f40 is the pick commit. And now none of the 4 commits appear in git log. I expected my editor to be restarted so that I could enter a commit message. What am I doing wrong? How git squash commits after push?

 


Your answer

1 Answer

More Business Intelligence discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Business Intelligence Blogs

Guides, tips and career advice on Business Intelligence from JanBask experts.