在Git推送之后,远程仓库将文件显示为已删除

Sam*_*ody 3 git

我在远程仓库上找不到任何文件.

  1. 他们的教程中描述的共享主机(site5)上创建了一个Git仓库
  2. 初始化并添加了一个简单的文本文件.好
  3. 克隆到我的本地(WinXP)机器上.好
  4. 删除了我本地副本上的测试文件,添加了一些真实文件.好
  5. 致力于当地的变革.好
  6. 推送到远程服务器.好
  7. MsysGit发出了一些警告(下图),但告诉我我们取得了成功.
  8. FTP进入远程服务器,但文件不存在.
  9. SSH(使用PUTTY)并运行git status.它给了我整个列表,但每个文件前面都有"删除"字样.见下文.

使用我不在任何分支上的提示,我检查了具体的提交.它找到了它,但文件git status仍然没有显示.它告诉我:

注意:转移到'9c47b5',这不是本地分支

试图结帐大师HEAD.没有运气,它告诉我

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


Git状态显示:

[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
#
Run Code Online (Sandbox Code Playgroud)

警告是:

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
Run Code Online (Sandbox Code Playgroud)

Bri*_*ell 6

当您在Git中推送到远程仓库时,它不会更新该远程仓库的工作副本.这意味着工作副本将与您推送的最后一个版本不同步.为避免这种混淆,建议只推送裸露的回购; 没有工作副本的回购.原因是如果工作副本中的任何内容发生了变化,您将无法收到有关此事件的警告并执行合并,因为您正在推送到远程仓库.

通常,您应该修改工作副本的唯一方法是从其中进行,例如从该工作副本中执行提取或结账.如果您希望在推送时自动检查服务器某处的代码副本,则应设置一个post-receive挂钩,然后进入git pull具有工作副本的存储库.