GIT提交的文件丢失

时间:2014-11-10 20:30:07

标签: git version-control

当我在提交和推送时看到所有正确的消息时,我的本地提交和推送似乎正在进入远程系统:

C:\xampp\htdocs\helloworld\test\testlocalgit\test [master +2 ~0 -0 !]> git status
On branch master
Your branch is ahead of 'origin/master' by 12 commits.
( use "git push" to publish your local commits)

Untracked files:
(use "git add <file>..." to include in what will be committed)

    gittesting_where.php
    test/test/

 nothing added to commit but untracked files present (use "git add" to track)
 C:\xampp\htdocs\helloworld\test\testlocalgit\test [master +2 ~0 -0 !]> git add gittesting_where.php
 C:\xampp\htdocs\helloworld\test\testlocalgit\test [master +1 ~0 -0 | +1 ~0 -0 !]> git commit -m "new file to test git on development system 11-10-2014"
 [master 43ae93c] new file to test git on development system 11-10-2014
 1 file changed, 6 insertions(+)
 create mode 100644 gittesting_where.php
 C:\xampp\htdocs\helloworld\test\testlocalgit\test [master +1 ~0 -0 !]> git push develop master
 Warning: Permanently added 'develop.livm.net,192.168.19.70' (RSA) to the list of known hosts.
 root@develop.livm.net's password:
 Counting objects: 4, done.
 Delta compression using up to 4 threads.
 Compressing objects: 100% (3/3), done.
 Writing objects: 100% (3/3), 422 bytes | 0 bytes/s, done.
 Total 3 (delta 0), reused 0 (delta 0)
 To ssh://root@develop.livm.net:/var/www/html/demo/iMedicWare/nsg/helloworld/test/.git/
 7481ddf..43ae93c  master -> master
 C:\xampp\htdocs\helloworld\test\testlocalgit\test [master +1 ~0 -0 !]>

当我在git日志中访问远程系统时,我看到代码已被推送到远程系统上。但我没有在那里看到推文件:

 [root@develop test]# pwd
 /var/www/html/demo/iMedicWare/nsg/helloworld/test

 [root@develop test]# git branch
 * master

 [root@develop test]# git log
 commit 43ae93c981ab25d13033e974accb2f1f242f2621
 Author: meauthor<meauthor@email.com>
 Date:   Mon Nov 10 14:46:55 2014 -0500

 new file to test git on development system 11-10-2014

 [root@develop test]# git show 43ae93c981ab25d13033e974accb2f1f242f2621
 commit 43ae93c981ab25d13033e974accb2f1f242f2621
 Author: meauthor <meauthor@email.com>
 Date:   Mon Nov 10 14:46:55 2014 -0500

 new file to test git on development system 11-10-2014

 diff --git a/gittesting_where.php b/gittesting_where.php
 new file mode 100644
 index 0000000..e4d1e76
 --- /dev/null
 +++ b/gittesting_where.php
 @@ -0,0 +1,6 @@
 +<?php
 +
 +       echo("New file to test git 11-10-2014");
 +
 +
 +?>

 [root@develop test]# find . -name "gittesting_where.php" -print   
 [root@develop test]# 
 [root@develop test]# pwd
 /var/www/html/demo/iMedicWare/nsg/helloworld/test

 [root@develop test]# ls -la
 total 44
 drwxr-xr-x 8 root   root   4096 Nov  7 12:37 .
 drwxr-xr-x 4 apache apache 4096 Nov  7 10:19 ..
 drwxr-xr-x 2 root   root   4096 Nov  7 12:37 branches
 -rw-r--r-- 1 root   root     66 Nov  7 12:37 config
 -rw-r--r-- 1 root   root     73 Nov  7 12:37 description
 drwxr-xr-x 8 root   root   4096 Nov  7 15:11 .git
 -rw-r--r-- 1 root   root     23 Nov  7 12:37 HEAD
 drwxr-xr-x 2 root   root   4096 Nov  7 12:37 hooks
 drwxr-xr-x 2 root   root   4096 Nov  7 12:37 info
 drwxr-xr-x 4 root   root   4096 Nov  7 12:37 objects
 drwxr-xr-x 4 root   root   4096 Nov  7 12:37 refs
 [root@develop test]#

 [root@develop test]# cd .git/
 [root@develop .git]# pwd
 /var/www/html/demo/iMedicWare/nsg/helloworld/test/.git
 [root@develop .git]# ls -la
 total 48
 drwxr-xr-x  8 root root 4096 Nov  7 15:11 .
 drwxr-xr-x  8 root root 4096 Nov  7 12:37 ..
 -rw-r--r--  1 root root   92 Nov  4 14:44 11-04-2014_config_copy
 drwxr-xr-x  2 root root 4096 Nov  3 09:26 branches
 -rw-r--r--  1 root root  153 Nov  5 11:53 config
 -rw-r--r--  1 root root   32 Nov  7 15:11 description
 -rw-r--r--  1 root root   23 Nov  3 09:26 HEAD
 drwxr-xr-x  2 root root 4096 Nov  3 09:26 hooks
 drwxr-xr-x  2 root root 4096 Nov  3 09:26 info
 drwxr-xr-x  3 root root 4096 Nov  4 15:53 logs
 drwxr-xr-x 82 root root 4096 Nov 10 14:47 objects
 drwxr-xr-x  4 root root 4096 Nov  3 09:26 refs
 [root@develop .git]#

这是我的本地.gitconfig

 [user]
     name = meauthor
     email = meauthor@email.com
 [remote "develop"]
     url = ssh://root@develop.livm.net:/var/www/html/demo/iMedicWare/nsg/helloworld/test/.git/
     fetch = +refs/heads/*:refs/remotes/develop/*

我在远程系统上没有看到推文件,我做错了什么?

1 个答案:

答案 0 :(得分:0)

事实证明我需要在我的git目录中添加一个钩子。现在我的本地和远程GIT工作得很好!我使用了更新后的钩子:

 [root@develop hooks]# more post-update
 #!/bin/sh
 #
 # An example hook script to prepare a packed repository for use over
 # dumb transports.
 #
 # To enable this hook, rename this file to "post-update".
 # exec git update-server-info

 GIT_WORK_TREE=/var/www/html/demo/iMedicWare/nsg/websiteactualwebdir git checkout -f

我发现并遵循这两个教程来指导我:    http://toroid.org/ams/git-website-howto    http://danielmiessler.com/study/git/

我需要更多地了解裸机与常规存储库和挂钩,这是我最初错过的。