Jump to content
  • 0
Ragno

R> How to squash commits on GitHub?

Question

8 answers to this question

Recommended Posts

  • 0

git rebase --interactive HEAD~3

here the 3 means the last 3 commits
Then you change the ones you want to sqash (most of the time you want to fixup e.g in a pull request

Afterwards you need to git push -f

Share this post


Link to post
Share on other sites
  • 0

After so many tries I still can't do it :( Please help me, this is what I'm doing.

 

I'm using SourceTree Terminal for this:

 

1. Clic on Terminal button. Opens a new console window with this:

Ragno@Samsung MINGW64 ~/Desktop/Repositorios/Fork/Hercules (barricade_woe_se_fix|REBASE-i)
$ 

 

2. Then, as Ridley said, I put this and hit Enter.

Ragno@Samsung MINGW64 ~/Desktop/Repositorios/Fork/Hercules (barricade_woe_se_fix|REBASE-i)
$ git rebase --interactive HEAD~2

 

3. Changes screen to a text editor with this:

pick 285e1fc Adds a protection to 1st Barricade line on WoE SE maps to avoid splash damage without destroying Guardian Stones previously.
pick 9450be2 Arrays improvement. Thanks Emistry!

# Rebase 9fba7e8..9450be2 onto 9fba7e8 (2 command(s))
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

 

4. I changed first line to this:

fixup 285e1fc Adds a protection to 1st Barricade line on WoE SE maps to avoid splash damage without destroying Guardian Stones previously.
pick 9450be2 Arrays improvement. Thanks Emistry!

# Rebase 9fba7e8..9450be2 onto 9fba7e8 (2 command(s))
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

 

5. Then, since I don't know how to close that screen and return to terminal, I hit Ctrl+Z and it returns to terminal. Now terminal looks like this:

Ragno@Samsung MINGW64 ~/Desktop/Repositorios/Fork/Hercules (barricade_wo                                                                                                                e_se_fix)
$ git rebase --interactive HEAD~2
Stopped

Ragno@Samsung MINGW64 ~/Desktop/Repositorios/Fork/Hercules (barricade_woe_se_fix|REBASE-i)
$

 

6. Then I add new command:

Ragno@Samsung MINGW64 ~/Desktop/Repositorios/Fork/Hercules (barricade_wo                                                                                                                e_se_fix)
$ git rebase --interactive HEAD~2
Stopped

Ragno@Samsung MINGW64 ~/Desktop/Repositorios/Fork/Hercules (barricade_woe_se_fix|REBASE-i)
$ git rebase --continue

 

7. After hiting Enter it starts to process the command and then happens this:

Ragno@Samsung MINGW64 ~/Desktop/Repositorios/Fork/Hercules (barricade_wo                                                                                                                e_se_fix)
$ git rebase --interactive HEAD~2
Stopped

Ragno@Samsung MINGW64 ~/Desktop/Repositorios/Fork/Hercules (barricade_woe_se_fix|REBASE-i)
$ git rebase --continue
error: could not apply 285e1fc... Adds a protection to 1st Barricade line on WoE SE maps to avoid splash damage without destroying Guardian Stones previously.

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
Could not apply 285e1fc... Adds a protection to 1st Barricade line on WoE SE maps to avoid splash damage without destroying Guardian Stones previously.

Ragno@Samsung MINGW64 ~/Desktop/Repositorios/Fork/Hercules (barricade_woe_se_fix|REBASE-i 1/2)
$

 

8. To finish all the process I put git rebase --abort

 

 

 

 

Sorry to keep bothering but I have tried this really hard a lot of times (I even discovered Ctrl+Z by accident while pressing a lot of key shortcuts). I need help and would be trully grateful with this.

Edited by Ragno

Share this post


Link to post
Share on other sites
  • 0
pick 285e1fc Adds a protection to 1st Barricade line on WoE SE maps to avoid splash damage without destroying Guardian Stones previously.
pick 9450be2 Arrays improvement. Thanks Emistry!

If you want to squash 9450be2 into 285e1fc, when you're given the output in your step 3, press i (which means insertion mode). navigate to the line of 9450be2 and change pick or 's' or 'squash' like so - 

s 9450be2 Arrays improvement. Thanks Emistry!

then press esc

then type :wq

and hit enter.

 

You'd have rebased your revisions unless some conflicts occur.

Edited by Smoke

Share this post


Link to post
Share on other sites
  • 0

 

pick 285e1fc Adds a protection to 1st Barricade line on WoE SE maps to avoid splash damage without destroying Guardian Stones previously.
pick 9450be2 Arrays improvement. Thanks Emistry!
If you want to squash 9450be2 into 285e1fc, when you're given the output in your step 3, press i (which means insertion mode). navigate to the line of 9450be2 and change pick or 's' or 'squash' like so - 
s 9450be2 Arrays improvement. Thanks Emistry!
then press esc

then type :wq

and hit enter.

 

You'd have rebased your revisions unless some conflicts occur.

 

Thanks a lot Smoke! I didn't know about :wq. You are my hero!

 

I follow steps and ended with this:

 

 

684b199575154b4a810404c831ec1818.png

 

 

But now, I try to push it and gives me this error:

 

 

4468cc22a189b7505224afe8d2e5551c.png

 

 

What am I doing wrong?

Share this post


Link to post
Share on other sites
  • 0

 

You have to force push

git push origin <your branch> --force

 

Thank you a lot, I finally did it. I tried it over 3 months ago and finally did it.

 

Thank you all guys for help with this.

Share this post


Link to post
Share on other sites
  • 0

another issue was here

 

fixup 285e1fc Adds a protection to 1st Barricade line on WoE SE maps to avoid splash damage without destroying Guardian Stones previously.
pick 9450be2 Arrays improvement. Thanks Emistry!

where it should be

 

pick 285e1fc Adds a protection to 1st Barricade line on WoE SE maps to avoid splash damage without destroying Guardian Stones previously.
fixup 9450be2 Arrays improvement. Thanks Emistry!

fixup = squash without message

 

and yes, thhen :wq and git push -f

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.