0

I am very new to manipulating anything in git, but I have a bunch of commits that I want to combine into one commit (7 commits of me deleting one file at a time). I have made more commits since then and I would like to keep those. How would I combine all those commits into one big commit?

If you visualize it from old to new, left to right, and where the commits I want to combine are in uppercase, it looks like this:

<--b--C--D--E--F--G--H--I--j--k--l

Where I want it to look like this:

<--b--C--j--k--l

BTW, k is a merge if that matters.

The question this is marked as a duplicate of is wrong, it should be git squash older commits (not last one)

Bubinga
  • 613
  • 12
  • 29
  • 1
    https://stackoverflow.com/search?q=%5Bgit%5D+squash+multiple+commits – phd Jul 26 '20 at 10:13
  • @phd Please see the edit to the question and consider using the "edit duplicates" link to switch the duplicate target. Everyone else, [questions shouldn't be reopened just to close them again for a different reason](https://meta.stackoverflow.com/a/262212/3750257) – pppery Aug 01 '20 at 21:28

1 Answers1

-1

As I understand you want to combine several commits from your dev branch and push them into the master. Say your branch is: dev, you can use:

git rebase -i origin/master dev

This brings up an interface to list all commits you made, you combine a commit into other, change the keyword from "pick" to "squash", then save it when it's done. Then it allows you to edit your commit log before you complete the change.

Anderson
  • 19
  • 4
  • my branch is master, and when I put that into the cmd, I get an error of 'fatal: not a git repository...' I assume it's because I need to put in the name of my repository somewhere in the command, where would i put it? – Bubinga Jul 26 '20 at 01:20
  • 1
    then try: ```git rebase -i origin/master``` – Anderson Jul 26 '20 at 01:30
  • Ok cool, it brings up [this](https://imgur.com/a/nGh57Mx) list of commands. As I said, I'm really new to this, what do I do next? – Bubinga Jul 26 '20 at 01:40