Search code examples
gitgithubsquashgit-squash

How to squash a commit made in the GitHub website?


I did a little editing in a file on my GitHub repository through the website and then committed the changes. It's not like changing a file, committing and then pushing it to the origin, I did it directly by going to the website. Now there are two commits in that branch. Can I squash the last commit from the terminal? If not, is there any way I can squash it from the GitHub website?

I'm not a native English speaker. So, pardon my bad English.


Solution

  • I don't think you can do it from the website itself. But you can do it from the terminal.

    # Pull in the remote changes
    $ git pull
    
    # Rebase the last 2 commits interactively
    $ git rebase -i HEAD~2
    pick abcdef commit to keep
    squash 123456 commit to squash
    
    # Override the remote branch
    $ git push -f origin <branch>