删除所有内容并上传新版本

pep*_*dip 12 git version-control

我们正在使用git进行版本控制,现在我们在尝试上传最新版本时收到很多警告.我是git的新手并且对这些限制没有耐心,有没有办法删除所有内容并上传当前版本?

这是我在尝试上传时获得的.

$ git push origin master
Username for 'https://code.google.com':
Password for 'https://<removed>@code.google.com':
To https://code.google.com/p/<removed>/
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://code.google.com/p/<removed>/'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)

Mic*_*ler 21

1.)删除存储库文件夹中的所有内容

2.)运行git rm *告诉git删除所有文件(检查git status是否有任何未分级的文件)

3)做了git commit -a -m "commitmessage"一个git push origin master要删除的远程服务器的Git上的所有文件

4.)检查你现在是否有一个空的远程存储库

5.)将所有新文件复制到本地存储库文件夹

6.)运行git add *告诉git添加所有新文件(检查git status是否有任何未分级的文件)

7.)提交并推送新文件

现在您应该在远程git存储库上安装该版本.


CB *_*ley 15

您无法推送,因为远程提交没有合并到您尝试推送的提交.如果要放弃当前遥控器中的所有更改,可以执行以下操作.

git fetch
git merge -s ours origin/master
git push origin master
Run Code Online (Sandbox Code Playgroud)

请注意,这会丢弃您在本地存储库中没有的远程更改.