相关疑难解决方法(0)

如何以编程方式编辑旧的git提交消息?

您可以以编程方式仅编辑最后一次提交消息:

git commit --amend -m 'xxxxxxx'
Run Code Online (Sandbox Code Playgroud)

或者以交互方式随机提交:

git rebase -i HEAD~n
# Vim opens up, select the commit you want to modify, and change the word "pick" for "edit"
git commit --amend -m "Changing an old commit message!"
git rebase --continue
Run Code Online (Sandbox Code Playgroud)

我如何结合两者?我想以编程方式更改消息,但是先前提交,而不仅仅是最后一次.

我想要修改的提交已经被推送到git服务器,但让其他人重新同步git项目并不是一个问题.

git git-rebase git-amend git-commit

6
推荐指数
3
解决办法
3833
查看次数

git rebase -i 在 rebase 和强制推送后显示错误的提交历史记录

在将一个分支重新建立到另一个分支上后,我遇到了一个有趣的问题;git rebase -i HEAD~n不仅显示错误的提交历史记录(旧分支),还显示错误的提交数量。

我想做的事

我希望能够对git rebase -i HEAD~n正确的提交历史记录进行操作,以便压缩我基于分支的旧分支的剩余提交。

我做了什么导致了这个问题

# On another Feature branch
git branch -b NewFeautureBranch
# Develop my commit
git add editedfile.extension
git commit -m "Commit message"
# I squashed and merged the feature branch into the development branch, as well as some other feature branches
git fetch --all
git checkout DevelopmentBranch
git pull
git checkout NewFeatureBranch
git rebase DevelopmentBranch
git push -f
Run Code Online (Sandbox Code Playgroud)

运行git loggitk会显示应有的历史记录,这是我当前的提交和它最初基于的功能分支的较旧提交,如预期的那样。然而,如果我随后运行,git rebase -i …

git command-line git-rebase windows-10

5
推荐指数
1
解决办法
7247
查看次数