我在承诺信中写错了。
我怎么能改變訊息呢?承諾尚未推動。
我在承诺信中写错了。
我怎么能改變訊息呢?承諾尚未推動。
当前回答
更改最新承诺消息
git commit --amend
git commit --amend -m "New commit message"
...任何人,这可能会使多线承诺消息或小纠正更有吸引力进入。
确保您在做此之前没有任何工作复制变更,或者它们也会被承诺(未进行的变更不会被承诺)。
git push <remote> <branch> --force
# Or
git push <remote> <branch> -f
// n is the number of commits up to the last commit you want to be able to edit
git rebase -i HEAD~n
一旦你错过了你的承诺,选择e/r来编辑消息:
如果你使用 git rebase -i HEAD~n 可以有更多的 n 命令. Git 将“收集”最后 n 命令中的所有命令,如果在这个范围之间有某个合并,你会看到所有的命令,所以结果将是 n + 。
好提示:
git-commit(1) 手动 页 git-rebase(1) 手动 页 git-push(1) 手动 页
其他回答
我意识到我已经推着一个承诺与一个类型在其中。为了放弃,我做了以下事情:
git commit --amend -m "T-1000, advanced prototype"
git push --force
警告:强迫推你的变化将重新写下远方分支与你的当地一个. 确保你不会过度写下任何你想保持的东西. 也要小心强迫推一个修改(重新写)承诺,如果其他人与你分享分支,因为他们将需要重新写下自己的历史,如果他们有旧的副本的承诺,你刚刚重新写。
正如前面提到的那样, git commit --amend 是重写最后一份重写的方式。
git commit -a --amend -m "My new commit message"
更改最新承诺消息
git commit --amend
git commit --amend -m "New commit message"
...任何人,这可能会使多线承诺消息或小纠正更有吸引力进入。
确保您在做此之前没有任何工作复制变更,或者它们也会被承诺(未进行的变更不会被承诺)。
git push <remote> <branch> --force
# Or
git push <remote> <branch> -f
// n is the number of commits up to the last commit you want to be able to edit
git rebase -i HEAD~n
一旦你错过了你的承诺,选择e/r来编辑消息:
如果你使用 git rebase -i HEAD~n 可以有更多的 n 命令. Git 将“收集”最后 n 命令中的所有命令,如果在这个范围之间有某个合并,你会看到所有的命令,所以结果将是 n + 。
好提示:
git-commit(1) 手动 页 git-rebase(1) 手动 页 git-push(1) 手动 页
我喜欢使用以下内容:
git status git add --all git commit -am “消息走到这里关于变化” git pull <origin master> git push <origin master>
如果您正在使用 Git GUI 工具,则有一个按钮称为 修改最后的承诺. 点击该按钮,然后它将显示您的最后的承诺文件和消息. 只需编辑该消息,您可以承诺它一个新的承诺消息。
或使用此命令从控制台/终端:
git commit -a --amend -m "My new commit message"