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.

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

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题