本文介绍了GIT:推后,远程回购显示文件被删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 在共享主机(site5)上创建GIT回购,如他们的教程 启动了它并添加了一个简单的文本文件。确定 克隆到本地(WinXP)计算机上。确定 删除本地副本上的测试文件,添加一些真实文件。确定 确认本地更改。确定 推送至远程服务器。确定 MsysGit发出了一些警告(下面​​),但告诉我我们已经成功了。 FTP到远程服务器,但文件不存在。 SSH(使用PUTTY)并运行git状态。 我给了我整个列表,但在每个文件前面加上了删除一词。见下面。 注意到我不在任何分支上的提示,我检查了具体提交。它发现它,但文件和git状态仍然没有显示任何事情。它告诉我: 注意:移动到'9c47b5'不是本地分支 blockquote> 试图结帐master HEAD。没有运气,它告诉我 -jailshell:/ usr / bin / git:没有这样的文件或目录 Git状态显示: [frumwebc @ your tanee.com] $ git status #目前没有任何分支。 #要提交的更改:#(使用git reset HEAD< file> ...停用)##deleted:_notes / dwsync.xml #deleted:contact-us / _notes / dwsync.xml #deleted:contact-us / index.html # 警告: 警告:更新当前分支警告:更新当前签出的分支可能会引起混淆,警告:索引和工作树不能反映HEAD中的更改。 警告:因此,您可能会看到您刚刚推入的更改警告:当您在此处运行'git diff'时恢复,并且您可能需要警告:要运行' git reset --hard'开始工作之前恢复。 警告:警告:您可以在远程存储库中将'receive.denyCurrentBranch'配置变量设置为 warning:'拒绝'以禁止推入其警告:当前分支。 警告:要允许推入当前分支,可以将其设置为'忽略'; 警告:但不建议这样做,除非您安排更新其工作 warning:tree以匹配您以其他方式推送的内容。 警告:警告:要压制此消息,可以将其设置为'警告'。 警告:警告:请注意,缺省值将在未来版本的git中更改警告:拒绝更新当前分支,除非您拥有警告:配置变量设置为要么'忽略'要么'警告'。 推到fru @ 67 ...... ee.com 到fru @ 67 ...... ee.com/26d352f..9c47b55 master - > master 解决方案当您在Git中推送到远程仓库时,它不更新该远程仓库的工作副本。这意味着工作副本将与您推送的最后一个版本不同步。为了避免这种混淆,建议只推行裸回购;没有工作副本的回购协议。原因是如果工作副本中的任何内容发生了变化,您将不会有机会被警告并执行合并,因为您正在推送到远程仓库。 通常,您应该修改工作副本的唯一方法是从其中进行修改,例如从该工作副本中进行拉取或结帐。如果你想在你的服务器上的某个地方自动检测你的代码副本,你应该设置一个 post-receive hook 然后将 git pull 放入一个具有工作副本的存储库中。 Cannot find any of the files on my remote repo.Created a GIT repo on shared hosting (site5) as described by their tutorialinit'd it and added a simple text file. OKCloned on to my local (WinXP) machine. OKDeleted the test file on my local copy, added a few real files. OKCommitted the local changes. OKPushed to remote server. OKMsysGit threw a few warnings (below), but told me we had success.FTP'd into the remote server, but the files weren't there.SSH'd in (using PUTTY) and ran git status.I gave me the whole list, but with the word "deleted" preceding each file. See below.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: Note: moving to '9c47b5' which isn't a local branchTried to checkout master HEAD. No luck, it tells me -jailshell: /usr/bin/git: No such file or directoryGit 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#The warnings were:warning: updating the current branchwarning: 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 itwarning: reverted when you run 'git diff' over there, and you may wantwarning: to run 'git reset --hard' before starting to work to recover.warning:warning: You can set 'receive.denyCurrentBranch' configuration variable towarning: 'refuse' in the remote repository to forbid pushing into itswarning: 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 workwarning: 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 gitwarning: to refuse updating the current branch unless you have thewarning: configuration variable set to either 'ignore' or 'warn'.Pushing to [email protected] [email protected]/26d352f..9c47b55 master -> master 解决方案 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:推后,远程回购显示文件被删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-13 08:29