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/

doudandui1592
doudandui1592 可能会遗漏一些东西,但任何特殊原因你不能只编译更新版本的git?1.5.6在互联网时代有50万年的历史,编制它并不困难。
大约 8 年之前 回复

1个回答



请编译最新的git。</ p>

是的,有些命令不会观察这些参数。 您可以尝试设置等效的环境变量。 </ p>
</ div>

展开原文

原文

Please compile the latest git.

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐