Effective Version Control with Git and GitHub
A blog about version control and git/github.
2016-01-28 Some Observations About Git Submodules
2015-08-13 Using Git Rebase to Keep Your Branches In Sync
2015-06-26 Using Git Bisect To Track Down Bugs
2015-05-14 Learning Git Branching
2014-12-19 Solving the Git Merge Conflict in the Develop Branch
2014-11-28 Solving the Git Merge Conflict in the Master Branch
2014-11-21 Simple Python Scripts for Finding Common Ancestors Between Two Git Branches
2014-10-31 Solving the Merge Conflict During a Pull Request on GitHub (for Dummies)
2014-09-26 Installing PyGit2 on Windows with MS Visual Studio Express 2013 for Desktop, Step by Step and Slightly More Slowly than Needed (The Hard Way)
This is a blog about version control and git/github.
The goal of this blog is to provide an introduction to these concepts. It will assume little knowledge, but will cover a lot of ground in git and github.
Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. For the examples in this book you will use software source code as the files being version controlled, though in reality you can do this with nearly any type of file on a computer.
If you are a designer, think of how useful it would be to track different versions of an Adobe Illustrator or Photoshop file. If you are a writer, you could use version control on Microsoft Word documents to see different iterations of a paper or novel. If you are working on anything collaborative, version control is absolutely indispensable because it allows people to work on things together without stepping all over each other.
Git is a powerful tool for version control. It is not always obvious how to use it, particularly if you’re coming from an SVN or CVS background (or, like me, were never properly introduced to version control at all). This guide aims to answer many of the common questions that arise when considering using git for your own projects.
What is Git?
Git is a distributed version control system (DVCS). This means that you don’t need to be online with a central server to commit changes. Instead, each user has their own repository which contains the entire history of their project. Users can then share changes between one another by pulling from and pushing to other repositories. When users do this, they have complete freedom to choose what changes they include and what changes they leave out. The only rule is that you must merge any conflicts before you push your changes back onto the network.
GitHub provides web hosting for Git repositories. In addition it provides a social networking aspect through the form of followers and watchers. This can be extremely useful in helping people find out about your project and plotting future development.
If you’re reading this, you have probably heard of Git and GitHub. If not, they are a version control system and a service that hosts all the repositories (the place that holds all the files) for repositories using Git. But what is version control, and why do I need it?
The main benefit of using version control is that it allows you to experiment and change things without risking breaking everything. It also makes it easy to work on a project with others. When you want to make a change, you can create a branch (versus editing the master branch, which is the main code), fix your problem, then merge your changes back into master once your changes are finished. If something goes wrong during development, you can easily revert back to an earlier version.
In this article I will show how to set up Git on your computer, how to create repositories for your projects online on GitHub or Bitbucket (other options include GitLab and SourceForge), and how to collaborate with others on these projects.
One of the most effective ways to write code is to write it and then rewrite it. You start by quickly writing a first draft of what you want, then you go back, look at the draft, figure out what is wrong with it, and fix it. Then you do it again. And again. And again.
Rewriting is how you get from a rough sketch to a work of art:
Writing doesn’t get done in one go, but in many iterations (even if you’re writing something as short as a blog post).
GitHub is a great place to store your code. It can be used as a backup system, as a code review tool, or as a way to browse code. There are so many ways to use GitHub that it is difficult to recommend the “right” way to use it.
Another thing I really like about GitHub is that since everyone uses it, you can quickly learn from other people’s projects and keep up-to-date with the latest and coolest projects.