如何在初始(根)提交中编辑和推送更改?

时间:2020-01-04 14:05:35

标签: git github rebase

因此,只需解释一下我目前的情况:

  • 我一直将更改推送到原始主机(尚未建立分支)
  • 我决定更改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.

我在做什么错了?

1 个答案:

答案 0 :(得分:0)

如果您只想修改最后一次提交,请使用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

enter image description here

相关问题