Using Git to improve your development workflow

My GitHub activity

Now that I’ve been using GitHub for more than a year for most of my personal (and some commisioned) projects, I think I feel comfortable enough to explain Git basics and how it makes your life easier.

Features

I wouldn’t expect you to move to Git if I only explained how it works (there are several hundred guides around), so I’m going to give you some of the improvements it made to my development life:

Creating your first repo

It doesn’t matter if you have a free or a premium account, you can create as many public repositories as you wish. You can create them by clicking the “Plus” symbol in the top and adding all the details:

GitHub repo creation page

Once you are done, you need to copy the link provided and go to your favourite IDE or console and use these commands:

# Creates a git repository in the folder you currently are
git init

# Sets the online repo to your recently created GitHub repo
git remote add origin <Your URL>

# Add all the files to git. You may want to add files you don't want to a .gitignore file
git add .

Uploading your changes

You can now start working as you would normally! Whenever you think you need to upload all your changes use:

# (OPTIONAL) Add newly created files
git add .

# Commit your changes to the local repo. NOTE: Use the -S argument if you would like to sign your commits
git commit -m 'Your commit message'

# Pushes your commits to GitHub (branch master). The -u argument saves your selection and you can later use git push only
git push -u origin master

That’s it! You now have your code backed up online available to all the developer community (if your repo is public).

Additional features you get

GitHub project navbar

GitHub isn’t only about files full of code, you also get issue management, where you can file all your nasty bugs and have a thread for each one; Pull requests, a way for others to make changes to your code; and much more! GitHub also offers an API that, for example, I have already integrated with the Lab page, where you can see all the latest commits for all my public projects.

You can see all the cool features you get at https://github.com/features.

Summary

I hope you liked the way I currently work and you start using it in your own projects. GitHub is the easiest way to backup your code online although there are other alternatives such as GitLab and BitBucket.

Today, we learnt how to create our first repository and how to push your changes online. Check out the Git Handbook for a more comprehensive guide.