The Little Things #3 — updating your git push password to Azure

--

I’ve been deploying one of my node.js projects from my git repository to an Azure web site for some time now and fortunately the git push command does not require me to enter my credentials every time. I did it once after setting up the remote to Azure, and that was good enough.

In short my deployment process looks like this to Azure, any time I want:

git push myazureremote master

This works great until you forget your deployment credentials while using the Azure portal debug console. So, of course I reset those credentials from the Azure portal and then at a moment when I wanted to deploy to Azure again from my git push command, I got a fatal error with Authentication Failed. Of course that made perfect sense.

Now, how the heck do I change those credentials for the git push command??

You’d think a little googling would surface an easy answer, but alas there is a lot of documentation covering different ways to deal with git push credentials and really I don’t have the patience to read through all of that mess of instruction so I gave up for a bit, and came back to a fresh google that finally helped.

DISCLAIMER: There are probably ways to edit the actual credential store as well, but this approach worked quickly and effectively for me. Tweet me a better way if you know it!

The summary is that I edited the git configuration file that included the Azure remote url with username, using vim. If you look at the following screenshot the remote url is defined as:

https://[username]@[websitename].scm.azurewebsites.net:443/[repositoryname].git

Here’s where I found it in the git config file:

I modified [username] to an invalid value, saved the config file, tried to run the git push command which failed as unauthorized. Then I edited the file again and restored the correct username, saved the file, ran the git push command again and it prompted me for a new password. Yay!

Command line looked like this: Micheles-Macbook-Pro:[projectfolder] mlb$ git push myazureremote master
Password for ‘https://[username]@[websitename].scm.azurewebsites.net:443':

Now, for the tricky part…at least for me…a vim noob.

I really LOVE the simplicity of working with git for command line source interaction and deployment, but I am still new to it…so every time I turn a corner I run into something that I don’t really have time to “read up on”. Sigh.

So, even after figuring out my plan of attack, to edit the config file, I still had to figure out how to actually edit the config file contents after opening it in vim. Seriously. So, I type the following commands:

git config -l — list contents of config, see the azure remote url I want to edit in there 
git config -e — edit the config file, which opens vim

I’ve already figured out a few key things about vim at this point.
1. When you edit a file you have to type :wq <enter> to save your changes. If you just want to quit, type :q <enter>. Great.

The problem: I could not seem to insert anything into the file.
I found this link with some great vim tips and found that there are two modes for vim: command mode and edit mode. Thank you captain obvious, I know, but remember I’m a little out of my element here. So I learned that just by typing the letter a I enter “insert mode” and the cursor bounces to the top of the file.

I could then arrow down to the line I want to edit, arrow across to the exact part I want to edit, then hit Esc to return to command mode.

Once in command mode I execute my trusty :wq to save the changes and voila! One less thing to annoy me when I’m working with git and vim.

Such a silly little thing to have to learn. Superb.

Originally published on August 2, 2014.

--

--

Cofounder / CIO Solliance; Cloud / Security Architect; Microsoft Regional Director and Azure MVP; author Learning WCF, Developing Microsoft Azure Solutions