筑巢网站,易搜搜索引擎,上海搜索排名优化,海外建站服务平台文章目录 核心命令详细使用模式总结示例 核心命令
git merge branch2 是将分支branch2的提交点合并到本地当前分支。 而在执行这条命令的时候#xff0c;加一个选项--squash就表示在合并的时候将多个提交点合并为一个提交点。 git merge --squash branch2
先看squash单词的意… 文章目录 核心命令详细使用模式总结示例 核心命令
git merge branch2 是将分支branch2的提交点合并到本地当前分支。 而在执行这条命令的时候加一个选项--squash就表示在合并的时候将多个提交点合并为一个提交点。 git merge --squash branch2
先看squash单词的意思拥挤使……拥挤。
以下为git merge --help中查看到的--squash选项的功能
--squash, --no-squashProduce 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 gitcommit command to create a merge commit). This allows you to create a single commit on top of the currentbranch 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.详细使用
模式总结
# 1. 先检出目标分支
git checkout 目标分支名
# 2. 查看当前的本地分支(确认一下分支是否转换成功)
git branch
# 3. 将需合并分支的代码合并到本地分支
git merge -squash有多个提交点的、需要合并为一个提交点的分支名
# 4. 查看本地git文件变动(一定会有变动)
git status
# 5. 将新的本地代码变动提交(为一个新的提交点)
git commit -m 提交信息git push. 推送
# 6. 推送代码到远程服务器
git push以上6行命令核心步骤就是3和5。
示例
目标分支/本地当前分支master 有多个提交点的、想要合并过来的分支feature/bug_xxx_fix
git checkout master
git branch
git merge -squash feature/bug_xxx_fix
git status
git commit -m fix bug xxx
git push