# Squashing commits

**URL:** <https://talk.openmrs.org/t/squashing-commits/28565>\
**Category:** Uncategorized\
**Created:** [May 19, 2020, 7:29pm UTC](https://talk.openmrs.org/t/squashing-commits/28565 "2020-05-19T19:29:21Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![gracebish](https://talk.openmrs.org/user_avatar/talk.openmrs.org/gracebish/32/13547_2.png) [@gracebish](https://talk.openmrs.org/u/gracebish)\
**Post date:** [May 19, 2020, 7:29pm UTC](https://talk.openmrs.org/t/squashing-commits/28565/1 "2020-05-19T19:29:21Z")

</div>

I tried to squash all my commits by running git rebase -i HEAD~n and got blocked somehow. when i run q to exit, i get stuck. @jwnasambu, please help

---

<div class="post-metadata">

**Author:** ![jwnasambu](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jwnasambu/32/13543_2.png) [@jwnasambu](https://talk.openmrs.org/u/jwnasambu)\
**Post date:** [May 19, 2020, 7:31pm UTC](https://talk.openmrs.org/t/squashing-commits/28565/2 "2020-05-19T19:31:33Z")

</div>

Oh sorry about this. Run `git log` to confirm then number of commits you have then `q` to exit.

---

<div class="post-metadata">

**Author:** ![sharif](https://talk.openmrs.org/user_avatar/talk.openmrs.org/sharif/32/11982_2.png) [@sharif](https://talk.openmrs.org/u/sharif)\
**Post date:** [May 19, 2020, 7:35pm UTC](https://talk.openmrs.org/t/squashing-commits/28565/3 "2020-05-19T19:35:06Z")

</div>

You can follow this link [https://wiki.openmrs.org/display/docs/Git-Squashing+commits](https://wiki.openmrs.org/display/docs/Git-Squashing+commits)

---

<div class="post-metadata">

**Author:** ![jwnasambu](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jwnasambu/32/13543_2.png) [@jwnasambu](https://talk.openmrs.org/u/jwnasambu)\
**Post date:** [May 19, 2020, 7:35pm UTC](https://talk.openmrs.org/t/squashing-commits/28565/4 "2020-05-19T19:35:24Z")

</div>

Run:

`git rebase -i HEAD~4 ` to see a list of commits, each commit starting with the word “pick”. Then press `i` you will then see the word -INSERT- at the bottom left navigate the letter writer on the screen to the last “Pick” and replace it with ‘f’ then press Esc you will see a blank space at the bottom and type :x then press enter (I am using --\> as pointer don’t type it in, only the commands) then run git push --force

---

<div class="post-metadata">

**Author:** ![gracebish](https://talk.openmrs.org/user_avatar/talk.openmrs.org/gracebish/32/13547_2.png) [@gracebish](https://talk.openmrs.org/u/gracebish)\
**Post date:** [May 19, 2020, 7:39pm UTC](https://talk.openmrs.org/t/squashing-commits/28565/5 "2020-05-19T19:39:21Z")

</div>

There are 4 commits on that branch. so i run git rebase -i HEAD~4. but still somehow blocked

---

<div class="post-metadata">

**Author:** ![jwnasambu](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jwnasambu/32/13543_2.png) [@jwnasambu](https://talk.openmrs.org/u/jwnasambu)\
**Post date:** [May 19, 2020, 7:41pm UTC](https://talk.openmrs.org/t/squashing-commits/28565/6 "2020-05-19T19:41:08Z")

</div>

Just follow the above procedure and share the output. Thanks.

---

<div class="post-metadata">

**Author:** ![reagan](https://talk.openmrs.org/user_avatar/talk.openmrs.org/reagan/32/10652_2.png) [@reagan](https://talk.openmrs.org/u/reagan)\
**Post date:** [May 19, 2020, 7:43pm UTC](https://talk.openmrs.org/t/squashing-commits/28565/7 "2020-05-19T19:43:57Z")

</div>

What exactly do you mean by blocked?!.. Hope you are keeping [this](https://talk.openmrs.org/t/rfc-favour-not-squashing-commits-over-squashing-commits/28482) in mind too

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [May 19, 2020, 8:22pm UTC](https://talk.openmrs.org/t/squashing-commits/28565/8 "2020-05-19T20:22:33Z")

</div>

Did you guys read this? [RFC: Favour not squashing commits over squashing commits](https://talk.openmrs.org/t/rfc-favour-not-squashing-commits-over-squashing-commits/28482)

---

<div class="post-metadata">

**Author:** ![gracebish](https://talk.openmrs.org/user_avatar/talk.openmrs.org/gracebish/32/13547_2.png) [@gracebish](https://talk.openmrs.org/u/gracebish)\
**Post date:** [May 19, 2020, 8:30pm UTC](https://talk.openmrs.org/t/squashing-commits/28565/9 "2020-05-19T20:30:38Z")

</div>

Thanks for the help. Successful

---

<div class="post-metadata">

**Author:** ![jwnasambu](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jwnasambu/32/13543_2.png) [@jwnasambu](https://talk.openmrs.org/u/jwnasambu)\
**Post date:** [May 19, 2020, 8:39pm UTC](https://talk.openmrs.org/t/squashing-commits/28565/10 "2020-05-19T20:39:01Z")

</div>

Well, that sounds great but was dwelling on @wyclif comment

---

<div class="post-metadata">

**Author:** ![herbert24](https://talk.openmrs.org/user_avatar/talk.openmrs.org/herbert24/32/8178_2.png) [@herbert24](https://talk.openmrs.org/u/herbert24)\
**Post date:** [May 19, 2020, 9:35pm UTC](https://talk.openmrs.org/t/squashing-commits/28565/11 "2020-05-19T21:35:11Z")

</div>

@gracebish you can still describe a few steps here that led to your success here to help others

---

<div class="post-metadata">

**Author:** ![gracebish](https://talk.openmrs.org/user_avatar/talk.openmrs.org/gracebish/32/13547_2.png) [@gracebish](https://talk.openmrs.org/u/gracebish)\
**Post date:** [May 20, 2020, 9:03am UTC](https://talk.openmrs.org/t/squashing-commits/28565/12 "2020-05-20T09:03:00Z")

</div>

git log -\> to know the number of commits git rebase -i HEAD~n Press Esc -\> creates a blank line where ther’s INSERT at the bottom then :x  
git push --force
