doushaqing7080 2012-07-30 02:16
浏览 242
已采纳

Git在命令上使用--work-tree和--git-dir

So, I have a php script that integrates with BitBucket's API and make changes to some local/shared repositories.

To do that, I use --git-dir and --work-tree [when applicable] together with every command, as in:

/usr/bin/git --git-dir=/var/www/staging.repo/.git --work-tree=/var/www/staging.repo merge "origin/master" 2>&1; echo $?

I use git version 1.7.0.4 on my development environment, and git version 1.5.6.5 on the live server. The reason for it is that there's no newer version of git for Debian Lenny (5), so I'm stuck with the older one.

The problem is, some of the commands that correctly accept --work-tree and --git-dir on git v1.7 doesn't seem to care much about it on the older version. One example is:

/usr/bin/git --git-dir=/var/www/staging.repo/.git --work-tree=/var/www/staging.repo merge "origin/master" 2>&1; echo $?

That outputs:

fatal: /usr/bin/git-merge cannot be used without a working tree.

So, how can I make broad use of those parameters using git 1.5.6.5?


Solution:

Downloaded git source:

myself:/some/folder$ curl -O http://git-core.googlecode.com/files/git-1.7.7.tar.gz

Installed:

myself:/some/folder/git-1.7.7.tar.gz$ ./configure

myself:/some/folder/git-1.7.7.tar.gz$ make

myself:/some/folder/git-1.7.7.tar.gz$ sudo make install

Done! :)

Ref: http://www.mikepilat.com/blog/2011/06/how-to-build-git-from-source-on-ubuntu/

  • 写回答

1条回答

  • doufang8965 2012-07-30 02:54
    关注

    Please compile the latest git.

    Yes, some commands don't observe those parameters. You can try and set their equivalent environment variables instead.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM