Git中的空格 - GIT_AUTHOR_NAME的委托过滤器

时间:2016-05-27 00:45:13

标签: windows git github

我尝试在上传到GitHub之前在本地存储库中重命名所有提交的作者,但如果名称包含空格,则会收到错误。存储库最初未配置名称,所有提交都来自同一用户。

以下是我一直使用的脚本:

YCSB Client 0.1
Command line: -db com.yahoo.ycsb.db.AsyncMongoDbClient -s -P LisWorkloadA -p mongodb.url=mongodb://192.168.4.168:27017/ycsb?w=0 -threads 1 -t
mongo connection created with mongodb://192.168.4.168:27017/ycsb?w=0
18:09:22.758 [Thread-1] DEBUG c.a.m.c.c.b.BootstrapConnectionFactory - Simple MongoDB bootstrap to 192.168.4.168/192.168.4.168:27017.
18:24:23.109 [Thread-1] DEBUG c.a.mongodb.client.ClientImpl - MongoDB Connection closed: MongoDB(56194-->192.168.4.168/192.168.4.168:27017)
[OVERALL], RunTime(ms), 900433.0
[OVERALL], Throughput(ops/sec), 2878.1730567404793
[READ], Operations, 1296287.0

***[READ], AverageLatency(us), 687.2264621954861***

[READ], MinLatency(us), 105.0
[READ], MaxLatency(us), 5455871.0
[READ], 95thPercentileLatency(us), 1220.0
[READ], 99thPercentileLatency(us), 1749.0
[READ], Return=OK, 1296287
[CLEANUP], Operations, 1.0
[CLEANUP], AverageLatency(us), 1672.0
[CLEANUP], MinLatency(us), 1672.0
[CLEANUP], MaxLatency(us), 1672.0
[CLEANUP], 95thPercentileLatency(us), 1672.0
[CLEANUP], 99thPercentileLatency(us), 1672.0
[UPDATE], Operations, 1295315.0

***[UPDATE], AverageLatency(us), 4.323250329070535***

[UPDATE], MinLatency(us), 1.0
[UPDATE], MaxLatency(us), 42015.0
[UPDATE], 95thPercentileLatency(us), 6.0
[UPDATE], 99thPercentileLatency(us), 10.0
[UPDATE], Return=NOT_FOUND, 1295315

导致的错误:

git filter-branch --commit-filter '
GIT_AUTHOR_NAME="FirstName LastName";
GIT_AUTHOR_EMAIL="FirstNameLastName@users.noreply.github.com";
GIT_COMMITTER_NAME="FirstName LastName";
GIT_COMMITTER_EMAIL="FirstNameLastName@users.noreply.github.com";
git commit-tree "$@";' HEAD

我试图通过使用fatal: ambiguous argument 'LastName; GIT_AUTHOR_EMAIL=FirstNameLastName@users.noreply.github.com; GIT_COMMITTER_NAME=FirstName': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' 转义空间来解决此问题,但是我只能通过删除空格来成功运行脚本,例如\变为FirstName LastName

3 个答案:

答案 0 :(得分:1)

尝试

git filter-branch --commit-filter "
GIT_AUTHOR_NAME='FirstName LastName';
GIT_AUTHOR_EMAIL='FirstNameLastName@users.noreply.github.com';
GIT_COMMITTER_NAME='FirstName LastName';
GIT_COMMITTER_EMAIL='FirstNameLastName@users.noreply.github.com';
git commit-tree ""$@"";" HEAD

我改变了&#34;到&#39;反之亦然,并在$ @

附近添加双引号

答案 1 :(得分:0)

似乎是Windows上的Powershell问题。切换到Git Bash后,脚本正确地运行了空格。

答案 2 :(得分:0)

正在Powershell内核上运行的其他解决方案:

param(
    [Parameter(Mandatory = $true)]
    [string]
    $name,

    [Parameter(Mandatory = $true)]
    [string]
    $email
)
$command = @"
GIT_COMMITTER_EMAIL='$mail';
GIT_AUTHOR_EMAIL='$mail';
GIT_COMMITTER_NAME='$name';
GIT_AUTHOR_NAME='$name';
git commit-tree "$@";
"@

& git filter-branch -f --commit-filter $command head