Git在命令中使用--work-tree和--Git-dir


Git use of --work-tree and --git-dir on commands

因此,我有一个php脚本,它与BitBucket的API集成,并对一些本地/共享存储库进行更改。

为此,我将--git-dir--work-tree[如果适用]与每个命令一起使用,如:

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

我在我的开发环境中使用git 1.7.0.4版本,在实时服务器上使用git 1.5.6.5版本。原因是Debian Lenny(5)没有更新版本的git,所以我只能使用旧版本。

问题是,在git v1.7上,一些正确接受--work-tree--git-dir的命令在旧版本上似乎并不太关心它。一个例子是:

/usr/bin/git--git dir=/var/www/staging.repo/.git--工作树=/var/www-staging.repo-merge"原点/主";2>amp;1.echo$?

输出:

致命:如果没有工作树,则无法使用/usr/bin/git merge。

那么,如何使用git 1.5.6.5广泛使用这些参数呢?


解决方案:

下载的git来源:

我自己:/some/folder$curl-Ohttp://git-core.googlecode.com/files/git-1.7.7.tar.gz

已安装:

我自己:/some/folder/git-1.7.7.tar.gz$./configure

我自己:/some/folder/git-1.7.7.tar.gz$make

我自己:/some/folder/git-1.7.7.tar.gz$sudo制作安装

完成!:)

参考编号:http://www.mikepilat.com/blog/2011/06/how-to-build-git-from-source-on-ubuntu/

请编译最新的git。

是的,有些命令不遵守这些参数。您可以尝试设置它们的等效环境变量。