git 修改远程commit信息
如果你已经把本地commit的信息push到远程了,此时需要修改远程中的commit信息
第一步:git log 查看提交的信息,看下提交的commit日志
如下入所示
第二步:然后确定你需要修改的那一次commit,比如:b6a75e0056746faaaxxxxxx 的这一次
第三步:使用git rebase -i 命令
git rebase -i b6a75e0056746faaaxxxxxx
命令回车后会显示下面的信息
pick f3f4f7d changed my name a bit
pick 511164e updated README formatting and added blame
pick b5c4h0d added cat-file# Rebase xxxxx onto xxxxx
#
# 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
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
此时敲击键盘上的i 键 ,进入编辑模式,然后把比如:f3f4f7d 这次的要修改掉,就把前面的pick,改成edit,然后按:wq,保存
第四步:输入命令: git rebase --amend ,进入编辑,此时会进入到你需要修改的commit信息中,然后修改完信息后,输入:wq保存
git rebase --amend
第五步: 输入命令:git rebase --continue
git rebase --continue
第六步: 输入命令: git push origin branchName(分支名称) --force
git push origin branchName --force
结束