我有我的公司使用的git设置一些麻烦。git commit覆盖新的远程推送更改与原始代码(分离HEAD?)
我在git 1.5.4.3的Ubuntu哈代机器上用主代码库建立了一个git“server”。 我是git的新手,并通过教程一步步设置这个存储库。
git init
git add .
git commit -m "initial commit"
然后,我成立了一个客户端(Win XP的)的git的版本1.7.3.1.msysgit.0(适用于Windows官方GIT)安装并克隆该资源库通过SSH。
git clone <IP>:/var/git/<repo> <target>
<made some file changes>
git status ob my client then says:
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: searchfunc_admin.php
#
no changes added to commit (use "git add" and/or "git commit -a")
话,我提交-a这给:
[master 9404d01] + searchfunc_admin.php DB Verb. Prüfung modifiziert
1 files changed, 3 insertions(+), 3 deletions(-)
的话,我推到库的服务器上:
$ git push origin master
<user>@<IP>'s password:
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 385 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To 192.168.1.26:/var/git/farocmsafs
5267756..9404d01 master -> master
在Ubuntu机器,我cd到主回购和检查发生了什么:
git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: searchfunc_admin.php
#
如果我检查DIFF,它显示了变化,但如果我执行git的承诺,他问我要他们为旧代码应与原代码被更新(这是真正的旧代码)
git diff HEAD
diff --git a/searchfunc_admin.php b/searchfunc_admin.php
index 4e15696..17ca17a 100755
--- a/searchfunc_admin.php
+++ b/searchfunc_admin.php
@@ -9,11 +9,11 @@ require_once("additional/functions.php");
// INITS
//**********
// Connect to database
-if(!$mylocal || !$myafs)
+if($DB_CONNECTION != TRUE)
{
- if(!sqldb_connect())
+ if(($sql_return = sqldb_connect()) != TRUE)
{
- echo "Cant connect to database";
+ echo "Cant connect to database: ".$sql_return;
die(1);
}
}
处理该消息提交,但未应用新推送代码的更改。
我发现我唯一的机会应用新的更改是一个git重置 - 与远程提交ID的硬件。但这样我必须手动将所有更改应用于代码。
我不使用其他分支,只有“主”,并且不要使用git commit以外的参数,而不是“-a”,所以我没有任何线索来说明错误的来源。
从我迄今为止阅读的内容来看,这可能是一个独立的HEAD问题,但我不知道为什么头被分离。 如果我在ubuntu机器上进行了本地更改,一切顺利。在提取或拉取后,我可以提交并查看远程计算机上的更改。但我无法应用远程更改与其他重置 - 哈德。
希望有人可以帮助我。
谢谢,塞巴斯蒂安
它看起来像你推到一个非裸仓库,这应该非常明确地产生警告,并根据git的版本,一个致命的错误。我误解了吗? (当推到一个非裸回购,提交被推动,但工作树是未触及的。如果你想把它提升到最新,你必须做一个'reset --hard'。理想情况下,你只需要推动裸回购)。 – Cascabel 2010-10-20 13:53:43