简体   繁体   English

在Windows下的Git bash

[英]Git bash under windows

I am getting crazy, while trying to write a companion script to help developers in my team to look up for changes in master branch. 我正在疯狂,同时尝试编写一个配套脚本来帮助我的团队中的开发人员查找master分支中的更改。

My goal is to create a bahs/sh script to seek for ALL git repos on the developer machine, check if they were related to a certain client and them, aply some automatic updating to master branch and alerting the dev , that he should be aware of those changes when packaging their work for deployment. 我的目标是创建一个bahs / sh脚本,在开发者机器上寻找所有 git repos,检查它们是否与某个客户端及其相关,有些自动更新到master分支并提醒dev ,他应该知道打包部署时的更改。

Here's what I got so far: 这是我到目前为止所得到的:

find /c -type d -name .git -exec cygpath -U {} \; 2>/dev/null | sed 's@ @\\\\ @g' | while read eachGit
do
    cd \""$eachGit"/..\";  ##This line is failing
    pwd;
    for eachBranch in $(git branch --no-merged master)
    do
        #do some stuff for each Branch (which already works if I cd manually)
    done;
done;

When I tryed to do that cd command, it says: 当我尝试执行该cd命令时,它说:

bash: cd: "/c/Users/MyUser/.SomeSw/subDir/.git/..": No such file or directory
~
bash: cd: "/c/Users/MyUser/my\ repo\ folder/some\ project/.git/..": No such file or directory
~

If I copy the directory from the error message and try to cd to it, it works perfectly 如果我从错误消息中复制目录并尝试cd到它,它完美地工作

And I am running it from a normal git bash although my plan is to run it from windows task scheduler as soon as it became ready to go 我正在从正常的git bash运行它,虽然我的计划是在它准备好后立即从Windows任务调度程序运行它

As suggested by @torek, I was misunderstanding how to quote variables. 正如@torek所说,我误解了如何引用变量。

The following cod works 以下鳕鱼有效

find /c -type d -name .git -exec cygpath -U {} \; 2>/dev/null | while read eachGit
do
    cd "${eachGit}/..";  ##This line is failing
    pwd;
    for eachBranch in $(git branch --no-merged master)
    do
        #do some stuff for each Branch (which already works if I cd manually)
    done;
done;

I am pretty sure that I used something closely related to this before, but somewhat I got a wrong direction. 我很确定我之前使用过与之密切相关的东西,但有些方面我的方向错了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM