【发布时间】:2015-10-30 06:40:50
【问题描述】:
我需要一些帮助,因为我还想在 Windows 中运行它,所以我如何才能将这段代码从 shell 脚本编辑为批处理脚本。
#!/bin/bash
commit_limit='4'
log=`git show HEAD~$commit_limit --pretty=format:"%H" --no-patch`
echo $log > .git/info/grafts
git filter-branch -f -- --all
rm .git/info/grafts
git update-ref -d refs/original/refs/heads/master
git reflog expire --expire=now --all
git gc --force --prune=now --aggressive
git push --force origin $branch
我试过这个,但它给了我一个输出 "H" 而不是 "9b027aaccb996ae4895e4dfb428c5e6e24870e68"
SET commit_limit=4
git show HEAD~%commit_limit% --pretty=format:"%H" --no-patch
pause
【问题讨论】:
-
我试过这个但它给了我一个输出 "H" @echo off SET commit_limit=4 git show HEAD~%commit_limit% --pretty=format:"%H" --no-patch pause
-
我试过这个,但它给了我一个输出“H”而不是“9b027aaccb996ae4895e4dfb428c5e6e24870e68” >>> SET commit_limit=4 git show HEAD~%commit_limit% --pretty=format:"%H" - -无补丁暂停
-
批处理文件不起作用,但可以在 cmd 中使用以下命令: git show HEAD~4 --pretty=format:"%H" --no-patch
-
在批处理文件中尝试
"%%H"。
标签: windows shell batch-file ubuntu