git clone 密码带有@等特殊字符

正常使用git clone 的方式

git clone https://remote

使用带用户名密码的方式(可以避免后续每次都要输入用户名密码)

git clone https://[username]:[password]@/remote

但有时会出现用户名或密码中含有像@这样的特殊符号,而不能被正常解析

我们需要通过下面方式进行重新编码

String c = URLEncoder.encode("@",“utf-8”);
System.out.println©;

console -> %40
所有这样就可以知道@在url中需要写成%40的形式

$ git clone https://myuser:password%[email protected]/myuser/repo.git

猜你喜欢

转载自blog.csdn.net/yy1209357299/article/details/122318112
今日推荐