如何编辑和推送初始(root)提交中的更改?
How to edit and push the change in initial (root) commit?
所以,简单说明一下我现在的情况:
- 我一直在将更改推送到 origin master(尚未创建分支)
- 我决定更改 Github 存储库
初始提交的提交消息
- 我做了
$ git rebase -i --root
并成功更改了提交消息
我试图通过 $ git push --force
强制推送,但出现以下错误:
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master.
我尝试按照说明操作,但得到:
! [rejected] master -> master (non-fast-forward) error: failed
to push some refs to 'git@github.com:BLAHBLAH.git' hint: Updates were
rejected because the tip of your current branch is behind hint: its
remote counterpart. Integrate the remote changes (e.g. hint: 'git pull
...') before pushing again. hint: See the 'Note about fast-forwards'
in 'git push --help' for details.
我做错了什么?
如果您只是想修改最后一次提交 - 使用 ammend
# Change the latest commit message
git commit --amend --no-edit -m"<new message>
要推送您的更改:
使用这个命令:
# It will set up the "track" and will force the push
git push --set-upstream origin master -f
所以,简单说明一下我现在的情况:
- 我一直在将更改推送到 origin master(尚未创建分支)
- 我决定更改 Github 存储库 初始提交的提交消息
- 我做了
$ git rebase -i --root
并成功更改了提交消息 我试图通过
$ git push --force
强制推送,但出现以下错误:fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin master.
我尝试按照说明操作,但得到:
! [rejected] master -> master (non-fast-forward) error: failed
to push some refs to 'git@github.com:BLAHBLAH.git' hint: Updates were
rejected because the tip of your current branch is behind hint: its
remote counterpart. Integrate the remote changes (e.g. hint: 'git pull
...') before pushing again. hint: See the 'Note about fast-forwards'
in 'git push --help' for details.
我做错了什么?
如果您只是想修改最后一次提交 - 使用 ammend
# Change the latest commit message
git commit --amend --no-edit -m"<new message>
要推送您的更改:
使用这个命令:
# It will set up the "track" and will force the push
git push --set-upstream origin master -f