Git推送后,远程仓库显示文件已删除 [英] After a Git push, remote repo shows files as deleted

查看:199
本文介绍了Git推送后,远程仓库显示文件已删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在远程存储库中找不到任何文件.

I cannot find any of the files on my remote repo.

  1. 按照其教程
  2. 所述,在共享主机(site5)上创建了一个Git存储库.
  3. 初始化它并添加了一个简单的文本文件.好
  4. 克隆到我的本地(WinXP)计算机上.好
  5. 删除了本地副本上的测试文件,并添加了一些真实文件.好
  6. 提交了本地更改.好
  7. 推送到远程服务器.好
  8. MsysGit发出了一些警告(如下),但告诉我我们成功了.
  9. 通过FTP进入远程服务器,但文件不存在.
  10. SSH(使用PUTTY)插入并运行git status.它给了我整个列表,但在每个文件之前都带有已删除"一词.参见下文.
  1. Created a Git repo on shared hosting (site5) as described by their tutorial
  2. init'd it and added a simple text file. OK
  3. Cloned on to my local (WinXP) machine. OK
  4. Deleted the test file on my local copy, added a few real files. OK
  5. Committed the local changes. OK
  6. Pushed to remote server. OK
  7. MsysGit threw a few warnings (below), but told me we had success.
  8. FTP'd into the remote server, but the files weren't there.
  9. SSH'd in (using PUTTY) and ran git status. It gave me the whole list, but with the word "deleted" preceding each file. See below.

根据我不在任何分支上的提示,我签出了特定的提交.它找到了,但是文件和git status仍然没有显示任何操作.它告诉我:

Working off of the cue that I am not on any branch, I checked out the specific commit. It found it, but the files and git status still show nothing doing. It told me:

注意:移至不是本地分支机构的"9c47b5"

Note: moving to '9c47b5' which isn't a local branch

试图结帐主HEAD.没运气,它告诉我

Tried to checkout master HEAD. No luck, it tells me

-jailshell:/usr/bin/git:没有这样的文件或目录

-jailshell: /usr/bin/git: No such file or directory


Git状态显示:


Git status shows:

[frumwebc@your tanee.com]$ git status
# Not currently on any branch.
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       deleted:    _notes/dwsync.xml
#       deleted:    contact-us/_notes/dwsync.xml
#       deleted:    contact-us/index.html
#

警告是:

warning: updating the current branch
warning: Updating the currently checked out branch may cause confusion,
warning: as the index and work tree do not reflect changes that are in HEAD.
warning: As a result, you may see the changes you just pushed into it
warning: reverted when you run 'git diff' over there, and you may want
warning: to run 'git reset --hard' before starting to work to recover.
warning: 
warning: You can set 'receive.denyCurrentBranch' configuration variable to
warning: 'refuse' in the remote repository to forbid pushing into its
warning: current branch.
warning: To allow pushing into the current branch, you can set it to 'ignore';
warning: but this is not recommended unless you arranged to update its work
warning: tree to match what you pushed in some other way.
warning: 
warning: To squelch this message, you can set it to 'warn'.
warning: 
warning: Note that the default will change in a future version of git
warning: to refuse updating the current branch unless you have the
warning: configuration variable set to either 'ignore' or 'warn'.
Pushing to fru@67......ee.com
To fru@67......ee.com/26d352f..9c47b55  master -> master

推荐答案

当您在Git中推送到远程仓库时,它不会更新该远程仓库的工作副本.这意味着工作副本将与您推送的上一个版本不同步.为了避免这种混乱,建议仅推送至裸仓库.没有工作副本的存储库.原因是,如果工作副本中的任何内容发生了更改,您将没有机会被警告并执行合并,因为您正在推送到远程存储库.

When you push to a remote repo in Git, it does not update the working copy of that remote repo. This means that the working copy will be out of sync with the last version that you pushed. To avoid this confusion, it is recommended to only push to bare repos; repos that do not have a working copy. The reason is that if anything in the working copy has changed, you will not have a chance to be warned about this and perform a merge, because you are pushing to a remote repo.

通常,修改工作副本的唯一方法是从工作副本中进行修改,例如从该工作副本中进行拉出或签出.如果您希望在推送时自动在服务器上的某个位置检出代码副本,则应设置

Generally, the only way you should be modifying a working copy is from within it, such as doing a pull or checkout from within that working copy. If you want a copy of your code to be checked out somewhere on your server automatically when you push, you should set up a post-receive hook that will then go a git pull into a repository that has a working copy.

这篇关于Git推送后,远程仓库显示文件已删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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