如何取代git回购? [英] How to replace git repo?

查看:113
本文介绍了如何取代git回购?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个git仓库,并用一些东西进行了更新。后来我为这个项目创建了一个新目录,并为它初始化了新的git。现在我想推动更改并在回购中替换旧的。当我做 git push origin master 我得到

 ! [被拒绝] master  - > master(非快速转发)
错误:未能将某些文件推送到'git@github.com:用户名/ repo2.git'
为防止您丢失历史记录,非快进更新被拒绝
在再次推送之前合并远程更改。有关详细信息,请参阅'git push --help'的'关于
快速转发的注意事项'部分。

我能做什么?

解决方案

你只需要使用一点点力量:

git push --force origin master
$ b

- force 也可以缩写为 -f


I created a git repo and updated it with some stuff. Later I created a new directory for this project and initialized new git for it. Now I want to push changes and replace the old ones in repo. When I do git push origin master I get

! [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.

What can I do?

解决方案

You just need to use a little force:

git push --force origin master

--force can also be abbreviated to -f.

这篇关于如何取代git回购?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆