Tuesday, May 20, 2014

Come back note and How to set GIT url password with special character

Haven't written a blog for a long time since I joined Microsoft. But I still believe, blog is a good place to share my learning and do potential benefits to other people. Let more people to have shorter learning curve as what I did. : ) 

Since I moved to Seattle, a lot has been changed in my life, therefore, this blog will not only about techniques, but also some home owner saving and maintenance tips as well. 

Hope everyone could enjoy. 

As a small benefits, sharing a a small hint, if you don’t know that already. :) 

Every time we push or pull in Git Command Line, we need to type in our username and password, this would be less desirable for us. Especially in windows, there is no out-of-box supporting for SSH for GIT. Therefore, using HTTPS could be a good alternative. 

For example in OpenCV, type in the following command line in Git we could set up the automation.  

git remote set-url origin https://username:password@github.com/username/opencv.git

But our issue is that some password may have special characters, such as #, $, @, this will break the url flow. The solution is just replace these special characters with url  encoding, (http://www.w3schools.com/tags/ref_urlencode.asp)

As an example, username: blastevil and password: blastevil@2014, the Git command line should be:  (@ in url encoding is %40)


git remote set-url origin https://blastevil:blastevil%402014@github.com/blastevil/opencv.git

prettify