我想知道这在 git 中是否可行。所以我有主分支。我会不时地为功能开发创建一个分支。完成后,我会将其 merge 回 master。现在通常侧分支上的所有提交历史都会显示在主分支中。有没有办法让所有提交在主服务器上显示为一个?
最佳答案
$ git checkout master
$ git merge --squash <branch>
来自docs (强调我的):
--squash
--no-squash
Produce the working tree and index state as if a real merge happened (except for the merge information), but do not actually make a commit, move the HEAD, or record $GIT_DIR/MERGE_HEAD (to cause the next git commit command to create a merge commit). This allows you to create a single commit on top of the current branch whose effect is the same as merging another branch (or more in case of an octopus).With --no-squash perform the merge and commit the result. This option can be used to override --squash.
关于git: stash 分支上的详细提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31717273/