Actually, I used the command git log: it showed commits made by me + commits others made to the master branch. I have to squash two commits made by me for a pull request into one. and I made commits using a non-master forked branch. Please guide me.
Asked
Active
Viewed 478 times
1
-
1I don't think you are phrasing your question correctly. Two commits on the same branch do not need to be merged, they are already merged. If you mean merging 2 commits on two different branches that's different. – E McG Oct 23 '18 at 16:33
-
You can't stash 2 commits on a single branch. You can ofc stash commits and merge them to a different branch, if thats what you're asking. – 0xInfection Oct 23 '18 at 16:43
-
Are you asking about squashing multiple commits together? This is a good guide: https://github.com/todotxt/todo.txt-android/wiki/Squash-All-Commits-Related-to-a-Single-Issue-into-a-Single-Commit – Adil B Oct 23 '18 at 16:43
-
@EMcG , you are write probably i did phrase question properly , actually i want to squash two of my commits into one. please guide. – Oct 23 '18 at 16:47
-
@TheInfectedDrake Please see the edited question. – Oct 23 '18 at 16:48
-
@AdilB , Yes i read that but when i try to squash, it also squash the other commits done recently by others. see https://github.com/coala/coala/pull/5847/commits – Oct 23 '18 at 16:50
-
@ASHOKSINGH see this answer for help: https://stackoverflow.com/questions/3921708/how-do-i-squash-two-non-consecutive-commits – Adil B Oct 23 '18 at 16:53
-
1@AdilB Thank you very much , I am looking forward it. – Oct 23 '18 at 17:03
1 Answers
1
To squash commits locally you can do it in this way.
Find hash of commit before commits that you want to squash. Use git log
for it.
Next, you can use rebase:
git rebase -i hashOfYourCommit
After that, you'll see an editor with a list of all commits after this that you specify.
You can easily specify what do you want to squash (Change p
to s
near commits that you want to squash).
The last step, change the message of your commit.
If you want to squash a few groups of commits after the first one you need to use git rebase --continue
. But everything should be visible in the console.

Patryk Rudnicki
- 755
- 1
- 8
- 21