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)

2

1 Answer 1

-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.

Sign up to request clarification or add additional context in comments.

3 Comments

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?
then try: git rebase -i origin/master
Ok cool, it brings up this list of commands. As I said, I'm really new to this, what do I do next?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.