简体   繁体   English

合并到master后,为什么本地分支中的commit消息会显示在master提交历史中?

[英]why commit messages in local branch show up in master commit history after merged to master?

created a local branch, made several commits, merged the branch to master, then pushed to the remote master. 创建一个本地分支,进行几次提交,将该分支合并到master,然后推送到远程master。 why do the commit history in my local branch is also shown up in the remote master? 为什么本地分支中的提交历史记录也显示在远程主机中? is there any way to delete these commit messages? 有什么办法可以删除这些提交消息?

You got two options: 您有两种选择:

  1. Squash all of your history into a single commit before pushing. 在推送之前,将所有历史记录压缩为单个提交。

git merge --squash branchName

  1. Amend your commit every single time you commit. 每次提交时都要修改提交。

git commit --amend -m "New commit message"

When you merge you are merging all history. 合并时,您正在合并所有历史记录。 If you want to have a single commit use 如果您想一次提交使用

 git merge --squash branchName

This will squash all of your history into one commit which is added to master 这会将您的所有历史记录压缩为一次提交,该提交已添加到master中

这是预期的行为,因为保留了提交历史记录以防万一,然后可以使用git rebase -i将所有提交折叠为一个提交并重新编写提交消息,然后将其发送到上游分支,然后合并分支掌握

git rebase -i master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 功能分支合并推送后,从主分支中删除功能分支的提交消息 - Remove commit messages of feature branch from master branch after feature branch is merged and pushed 压榨master分支的历史记录,但将所有先前的提交消息归咎于此? - Squash master branch history but keep all prior commit messages in blame? 不正确地合并提交给主人? - Improperly merged commit to master? Git将master分支回滚到master的历史记录中的特定提交 - Git rewind master branch to specific commit in master's history 发布分支合并后,为什么母版1提前开发? - After merge of release branch, why is master 1 commit ahead of develop? Eclipse Git(EGit)-在与本地分支进行错误合并和提交之后,如何将本地主服务器恢复为远程主服务器 - Eclipse Git (EGit) - How to revert local master back to remote master after a foul merge & commit with a local branch 推送仅掌握合并提交,没有开发历史记录 - Push to master only the merged commit, without development history Git:用功能分支的历史替换Master的提交历史 - Git: replace commit history of Master with the history of feature branch 我们可以在已经与 master 合并的分支上提交吗? - Can we commit on branch that's already been merged with master? Git:合并主分支时触发“机器人”提交 - Git: trigger a "robot" commit when a master branch is merged
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM