1

When git rebasing a branch, you can squash commits by changing pick to squash on each line you want to squash. You can also change it to s instead as a shorthand way.

pick 4306fab7 add stuff
pick d1e9645a test ci
s 5d0458e6 test ci
s 9cdb9984 test ci

there has to be a way to shortcut the line changes. For example, if you had a branch with 50 commits you wanted to squash and rebase, you would have to go by-hand and change pick to s for each line, which takes forever.

Is there a cmd+option+s shortcut that changes it for you so you just have to do that command on each line?

user10741122
  • 781
  • 1
  • 12
  • 26

2 Answers2

3

No law requires that you use interactive rebase. It does nothing that you could not do with direct git commands. If the direct git commands are simpler, use them instead.

For example, if your entire goal was to squash all the commits after d1e9645a, you would simply reset --soft to d1e9645a and commit. Much simpler than the interactive rebase.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • If the question is really "Is there a cmd+option+s shortcut that changes it for you so you just have to do that command on each line?", then you are now asking how to use some text editor (you have not told us which one it is) and this is no longer appropriate for Stack Overflow. – matt Dec 09 '20 at 15:07
0

The editor you are seeing is most likely vim.

So your options are:

  • Learn how to do a search and replace in vim. See here.
  • Change your git editor to your editor of choice, and do the replace using that. For example see here for VS Code instructions, you can easily find instructions for any other editor.
anpel
  • 931
  • 6
  • 16
  • Theres also a good chance its `nano` given the reference to `cmd+option` – user1937198 Dec 09 '20 at 15:25
  • @user1937198 True, however `vim` is default in mac os. I guess If OP had changed the default editor they would mention in the question or the comments, we will have to wait and see. – anpel Dec 09 '20 at 15:34
  • @user1937198 i refered to cmd+option randomly as example, no reference to my editor – user10741122 Dec 09 '20 at 15:47
  • @user10741122 Oh ok. What is your editor of choice so that I update with correct instructions? – anpel Dec 09 '20 at 15:51