0

I have the following git alias

[alias]  
remaster = !"git checkout $1 & git diff-tree -r --patch --diff-filter=DM $1..master"

When using the above command by hand I get the following stdout:

$ git diff-tree -r --patch development..master --diff-filter=DM

diff --git a/subfolder/subfile.exe b/subfolder/subfile.exe
deleted file mode 100644
index e69de29..0000000
diff --git a/virus.exe b/virus.exe
deleted file mode 100644
index e69de29..0000000

When using the alias the output is not available therefore I cannot use it to patch:

$ git remaster development
4

1 回答 1

1

Git 别名主要用于调用另一个git命令,而不是多个任意命令。也就是说,你通常会做类似的事情

[alias]
    aa = commit --amend -a --no-edit

注意上面只说commit,不是git commit。无论如何,通过使用虚拟 shell 函数,仍然有一个常见的技巧来实现你想要的:

[alias]
    remaster = "!f() { git checkout $1 && git diff-tree -r --patch --diff-filter=DM $1..master | git apply; }; f"

(我也把单曲改成了&正确的说法&&。)

于 2018-08-31T06:26:31.930 回答