0

How can I join two pushed commits?

For example: I have a commit fixing a typo and a commit changing a text file. I want to join both and keep only the one which says "changing a text file" on the commit log.

How can I do it?

2

1 Answer 1

1

Generally, you can use git rebase -i and fixup to rewrite the history and merge commit 2 into commit 1.

Because you already pushed the changes, beware that it is generally not recommended to rewrite the history after the changes has been pushed to a remote repository, because other clients may have already downloaded the changes and you may cause troubles with future updates.

If you are fully aware of what you are doing, use rebase to rewrite the history, and push the changes with the --force flag: git push -f.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.