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

标签 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.

最佳答案

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

2.) 运行 git rm * 告诉 git 删除所有文件(检查 git status 是否还有未暂存的文件)

3.) 执行 git commit -a -m "commitmessage" a git push origin master 删除远程 git 服务器上的所有文件

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

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

6.) 运行 git add * 告诉 git 添加所有新文件(检查 git status 是否还有未暂存的文件)

7.) 提交并推送新文件

现在您的远程 git 存储库中应该有该版本。

关于git - 删除所有内容并上传新版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11071420/

相关文章:

Windows 上的 Git : Where are my files?

git - git 服务器如何扩展?

git - 如何使用 git 将文件从一个分支复制到另一个分支?

version-control - 确保分支之间的 merge 发生在一个方向

Xcode 5 - 如何在工作区中使用源代码管理

git - 禁用 git 添加。命令

GIT 取消回滚提交

git - 我怎样才能更好地处理提交污染 git 中的 "closed"分支?

windows - Mercurial 与颠覆。谁的表现更好?

git - 在单独的 Git 存储库中跨多个项目进行一致标记