簡體   English   中英

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

[英]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

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM