'How do I escape "@g" in sed (with the -global setting)? [duplicate]

I have many repositories with the remote origin set to HTTPS. Now I want to change all origin remotes to SSH.

I am using a command for this in which I want to replace all preceeding url = https://gitlab.mypath/ with [email protected]:.

Is there a way to express this with one sed call. Something like:

's@https://gitlab.mypath/@[email protected]:@g'

I have to be able to escape the first "@g"



Solution 1:[1]

The correct anwers

  1. Switch from s@@@ to s|||
  2. Apart from choosing any character for the delimiter, you can also escape that character: @

The explanation

The character after the s specifies the separator, which must occur three times in your s command.

Thanks

@Cyrus @dan

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sunshine