美文网首页
git之rebase

git之rebase

作者: xue57233 | 来源:发表于2017-09-01 20:17 被阅读7次
rebase的两大用处:
前言: rebase 命令删除中间的无用 commit 记录,意味着至少保留首尾两个 commit
# 从 commit_id 开始到最后 commit 进行 rebase,进入编辑模式
$ git rebase -i [commit_id]

# 进入到编辑模式会看到可编辑的条目, 排列顺序由 commit 的提交先后 从上而下。
# 编辑模式中分两部分内容, 上半部分可编辑,是要执行的指令,下半部分是指令的注释。
# 指令部分由 指令名称、 commit hash 和 commit mesage 组成
# 指令名称目前只需要知道 pick 和 squash 这两个指令,具体解释见下边的指令注释
pick 2da3fdf   add commit message_2

pick 7efd141  add  this is last commit 

# Rebase 6506966..7efd141 onto 6506966 (1 command(s))
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#

# 调整好要合并或者修改的条目之后, 执行 :wq  命令,git会执行合并或改名操作,执行之后会再次进入 vi 编辑页面。
# 该编辑页面非注释部分就是几次的commit message , 我们要做的就是要将这些内容修改成新的 commit message
# 输入 wq 保存,几次 commit 就已经合并了。
# 查看 log 信息可进行验证

注意事项

在 rebase 的过程中有操作失误, 可以使用 git rebase --abort 来撤销修改,回到没有开始操作合并之前的状态。

相关文章

  • git8~rebase

    2019.06.25 git rebase git stash git pull --rebase git sta...

  • 如何正确rebase

    git rebase -i origin/分支 合并冲突 git status git rebase --cont...

  • git整体学习

    基础 1. git ... 3. git rebase 第二种合并分支的方法是 git rebase。Rebase...

  • Git错误信息解决记录

    Git error: previous rebase directory .git/rebase-apply st...

  • Git使用教程

    拉取代码的正确步骤 git fetch git rebase git rebase --continue(遇到冲突...

  • Git 批量合并Commit或commit信息

    git rebase -i HEAD~3 git rebase -i [commitId-a] [commitId...

  • git merge conflict

    git pull --rebase编辑confilct的文件,修改完毕后git addgit rebase --c...

  • git之rebase

    rebase的两大用处: 从上游分支获取最新commit信息,并有机的将当前分支和上游分支进行合并。git reb...

  • git rebase 用法

    git rebase Git rebase 与 Git merge 的区别 如果经常多人协作开发的话,可能都很熟悉...

  • 【Git】rebase 用法小结

    本文主要参考https://git-scm.com/docs/git-rebase rebase在git中是一个非...

网友评论

      本文标题:git之rebase

      本文链接:https://www.haomeiwen.com/subject/eqwkjxtx.html