How can I combine two commits into one commit?

前端 未结 3 700
情歌与酒
情歌与酒 2021-01-29 19:31

I have a branch \'firstproject\' with 2 commits. I want to get rid of these commits and make them appear as a single commit.

The command git merge --squash

3条回答
  •  遥遥无期
    2021-01-29 20:07

    1. Checkout your branch and count quantity of all your commits.
    2. Open git bash and write: git rebase -i HEAD~ (i.e. git rebase -i HEAD~5)
    3. In opened txt file change pick keyword to squash for all commits, except first commit (which is on the top). For top one change it to reword (which means you will provide a new comment for this commit in the next step) and click SAVE! If in vim, press esc then save by entering wq! and press enter.
    4. Provide Comment.
    5. Open Git and make "Fetch all" to see new changes.

    Done

提交回复
热议问题