使用gitattributes和gitconfig

时间:2015-12-03 17:25:10

标签: git

99%用于替换已签出的文件中的访问密钥。 我在结帐时丢失了单引号

git checkout AppConfig.groovy

  accessKey =  GARB//AGE

但我真的想要

  accessKey =  'GARB//AGE'

这是我的.gitattributes和〜/ .gitconfig

AppConfig.groovy filter=awsRdsBotKeys


[filter "awsRdsBotKeys"]
        clean = sed -e 's/secretKey = .*/secretKey = ''/'
        smudge = sed -e 's:secretKey = .*:secretKey = 'GARB//AGE':'

1 个答案:

答案 0 :(得分:2)

尝试:

sed -e 's:secretKey = .*:secretKey = '\''GARB//AGE'\'':'

原来你必须逃避单引号from the bash itself。我刚刚学到了!见下面的工作示例:

echo "secretKey = FSIL38908LDKA" | sed -e 's:secretKey = .*:secretKey = '\''GARB//AGE'\'':'