gpt4 book ai didi

git - 如何替换git存储库?

转载 作者:IT王子 更新时间:2023-10-29 01:21:28 26 4
gpt4 key购买 nike

我创建了一个 git 存储库并用一些东西更新了它。后来我为这个项目新建了一个目录,并为它初始化了新的git。现在我想推送更改并替换存储库中的旧内容。当我运行 git push origin master 我得到

! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:Username/repo2.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'Note about
fast-forwards' section of 'git push --help' for details.

我该怎么做才能解决这个问题?

最佳答案

你只需要用一点力:

git push --force origin master

--force也可以简写为-f

关于git - 如何替换git存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3789298/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com