真是No zuo no die。
前段时间刚上手git,就用来部署线上代码。
其实这段时间还都挺好的,不用每次修改都scp。
但今天不知道怎么会删掉了一些文件。
开了ss,Gist还是打开很慢,各位将就看下我的操作记录吧
我的思路很简单,服务器运行这么些天,增加了不少图片,是没有放进远端仓库的。
先在服务器端git commit -a了这些图片,然后本地仓库git pull,本地修改代码后git commit -a,然后本地git push。不知道我思路哪里出错了。。(没错,我按照svn的思路了。。)
操作记录如下
服务器:
1.git commit -am 'update';
确实有几百张图片加入仓库了
2.git status
# On branch master
nothing to commit (working directory clean)
说明已经没有新的改动了
本地操作
1.git pull
remote: Counting objects: 254, done.
remote: Compressing objects: 100% (206/206), done.
remote: Total 206 (delta 20), reused 0 (delta 0)
Receiving objects: 100% (206/206), 12.70 MiB | 76.00 KiB/s, done.
Resolving deltas: 100% (20/20), completed with 20 local objects.
From xxx:/www/web/xxxcom/
51c91d8..fe6c6c6 master -> origin/master
Updating 51c91d8..fe6c6c6
error: Your local changes to the following files would be overwritten by merge:
public_html/data/config.inc.php
public_html/data/tasks.inc.php
Please, commit your changes or stash them before you can merge.
Aborting
因为config.inc.php,tasks.inc.php是数据库配置,我之前用git undate-index --assume-unchanged file忽略掉,所以提示Aborting
2.修改bug,然后git commit -am 'fix images not show in detail'
[master 5aaf3a2] fix images not show in detail
4 files changed, 19 insertions(+), 4 deletions(-)
没错,是改了4个文件
3.git push
To xxx:/www/web/xxxcom/.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'xxx:/www/web/xxxcom/.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
失败了,猜想大概是因为本地git pull Abort的那2个文件
4.git push -f origin master
尝试性的这样提交。。然后就悲催了
Counting objects: 21, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 1.10 KiB | 0 bytes/s, done.
Total 10 (delta 8), reused 0 (delta 0)
remote: Push to checked out branch refs/heads/master
remote: W:unstaged changes found in working copy
remote: W:stashing dirty working copy - see git-stash(1)
remote: Saved working directory and index state On (no branch): dirty working copy before update to 5aaf3a2ea32bb30cf367dcf713a2031dee00f75e
remote: HEAD is now at fe6c6c6 update
remote: trapped 9133
remote: Updating working copy
remote: M public_html/app/goods.app.php
remote: M public_html/app/shop.app.php
remote: M public_html/app/cart.app.php
remote: M public_html/data/config.inc.php
remote: D public_html/data/files/store_44/goods_1/201404101820016058.jpg
remote: D public_html/data/files/store_44/goods_10/201403301603305815.jpg
***
remote: D 100多个文件
***
remote: HEAD is now at 5aaf3a2 fix images not show in detail
To xxx:/www/web/xxxcom/.git
+ fe6c6c6...5aaf3a2 master -> master (forced update)
然后服务器上的remote: D的文件都删除了。。。
我想不明白,本地也没有删除啊,怎么就push会有呢?
5.git status
On branch master
Your branch is up-to-date with 'origin/master'.
本地仓库,远端仓库项目目录已经备份(吃大亏了,必须这么做)。
尝试解决方法:
1.我尝试性在服务器目录git log
commit 5aaf3a2ea32bb30cf367dcf713a2031dee00f75e
Author: xxxx <
[email protected]>
Date: Mon Apr 14 17:04:37 2014 +0800
fix images not show in detail
commit 51c91d833a62709713d6ff1be6f48aa3ec14fe4a
Author: xxxx <
[email protected]>
Date: Fri Apr 4 14:36:00 2014 +0800
fix htaccess
居然没有17:04:37前的 'update',费解。。。
2.单个文件也尝试过,没用
git checkout deleted-file
#error: pathspec 'deleted-file' did not match any file(s) known to git.
3.git ls-files –deleted
没有删除文件
弄了一晚上,没找到解决方案,烦啊。
请问下该如何恢复,或者可以尝试哪些方法恢复。麻烦写清楚点步骤。。
回复均送金币。
只能以此为报,
不能捡肥皂。
谢谢大家看完这么长操作记录。