【问题标题】:Understanding git commit with amend option使用修改选项了解 git commit
【发布时间】:2019-02-23 09:51:45
【问题描述】:

假设我有一个文件“A” 我已修改文件并通过以下命令将其推送到存储库

git add A
git commit -m "changed A"
git push 

后来我意识到我需要更改文件“B”,所以我修改了它并运行了以下命令

    git add B
    git commit --amend -m "changed AandB"
    git push

但我得到错误..

error: failed to push some refs to 'https://xxx@github.com/xx/xx'
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.

我应该怎么做才能克服这个错误

【问题讨论】:

标签: git commit git-commit git-extensions git-amend


【解决方案1】:

Amend 实际上改变了 git 历史。您需要强制 (-f) 推送来更新遥控器。

注意:强制推送会将远程的历史记录替换为本地的历史记录,因此,这是危险。

$ git push -f

【讨论】:

  • 什么是所有可用的标志..?一个是 -f ,我们是否还有其他可以在此刻使用的标志
  • $ git push --force。 -f 是--force 的快捷方式
猜你喜欢
  • 2015-03-11
  • 2012-12-14
  • 1970-01-01
  • 1970-01-01
  • 2017-11-05
  • 2012-02-24
  • 1970-01-01
  • 2019-03-01
  • 1970-01-01
相关资源
最近更新 更多