Friday, June 22, 2018

Developing in GitHub using Cloud Shell

If you're not familiar with Google Cloud Shell, it's a great tool for doing command line development in a Linux environment. I've been using it as an always-on development environment for web focused projects. Whichever machine I happen to be using, my dev environment is always available.

One of the ways I'm using Cloud Shell is as a development environment for my open source projects. Cloud Shell comes with loads of developer tools pre-installed, including git which is quite handy if you are hosting projects on Github. Head over to https://console.cloud.google.com/cloudshell/editor to start using Cloud Shell.

Here's how you can set up your own open source development environment with Github in Cloud Shell, in three easy steps!

Set up your git environment

First, you'll need to have the git client available. Easy, git is already installed (yay!)

Next, set up your git environment with the email address and name that your changes will be published under:

git config --global user.name "YOUR NAME"
git config --global user.email "YOUR EMAIL ADDRESS"

If you are using two factor auth for your GitHub account, you'll need to generate an access token. Once created, you'll use the hexidecimal string instead of your GitHub account password. For example, the generate password might look something like

4e6f742061207265616c206b6579203b2d29

Clone a repo from GitHub to Cloud Shell

With command line credentials in hand, you can now clone the repository from GitHub into your Cloud Shell environment to start making changes. Step three!

For example:

git clone https://github.com/jscud/jsBytes.git

Now the files are available in your local Cloud Shell environment and you can change them to your heart's content. There is a simple text editor available in Cloud Shell which you can launch from the command line with a command like

cd jsBytes
edit README

Commit and publish your changes

After editing a file or two, commit your changes to your local repository and then publish them on GitHub. Remember that when prompted for the password, use the access token you generated earlier instead of your GitHub password.

git status
git commit -a -m 'Add one usage example to README.'
git push origin master

There you have it, an easy way to work on your GitHub project using Google Cloud Shell as your development environment.

Post a Comment