I am using git for a rails project and I have in an old committed file the following line: user_name: 'ENV[GMAIL_SMTP_USER]',
I'm trying to replace this line of all the old commits so I can take off the quotes(') and replace them inside the brackets: user_name: ENV['GMAIL_SMTP_USER'],
. I am using sed
and --tree-filter
to accomplish it. Like the following:
git filter-branch --tree-filter "sed -i .bkp s/'ENV[GMAIL_SMTP_USER]'/ENV['GMAIL_SMTP_USER']/g config/environments/development.rb" -f
This command runs fine without errors, but it does not take out the quotes. Also, I can say that the command really works for replacing, since before that, I've successfully used to update user_name: 'myGmailUserName'
to user_name: 'ENV[GMAIL_SMTP_USER]'
The problem is only with removing the quotes. What is missing?
Thanks in advance.
As Cyrus suggested, I had a problem with escaping, but it was with the quote itself. And also, I don't know why, even with the escaping, it did not work with the repository I was working with, which was a cloned repository (backup).
So, I created a new clone repository and run the following escaping the quotes:
git filter-branch --tree-filter "sed -i.bkp s/\'ENV[GMAIL_SMTP_USER]\'/ENV[\'GMAIL_SMTP_USER\']/g config/environments/development.rb" -f
Does anybody has a better answer? Maybe explaining why it didn't work in the first clone repository...
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加