开发者

How to replace a git repository?

I created a git repository 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 contents in the repository. When I run 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 f开发者_如何学编程rom 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 to solve this?


You just need to use a little force:

git push --force origin master

--force can also be abbreviated to -f.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜