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.

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

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站