Working With git and GitHub
This post will explain the basics of working with git and GitHub. For more in depth information, read a book on git or work through a proper tutorial.
Software Versions
Creating a GitHub Repository
First, create a GitHub account and install git on your computer. Next, create a new repository on GitHub by clicking “Start a project” on the main page. If you want other people, like potential employers, to be able see the project, make sure it is public. If the project contains sensitive client or company details, it should be private. Name the project and add a description. It is gnerally a good idea to add a README, .gitignore file for your language of choice, and a license. I like the BSD licenses and dislike the GNU licenses, but feel free to pick what works for you and your project needs.
If you do not add any files to your project, you will see instructions for initializing the GitHub repository. The path to the repository will be needed to initialize it. SSH is more convenient than HTTPS after your SSH keys have been added to GitHub. The SSH path a GitHub repository will look something like this:
The HTTP path will look something like this.
For the purposes of this blog post, the project path will be added to an environment variable. Feel free to use either the SSH or HTTPS version.
A new repository can be created from the command line with the following steps.
Alternatively, a new repository can be pushed from the command line.
Finally, GitHub has an option to import code from another repository.
Working with git
In practice, most of the work done with git only requires using a few commands.
Additionally, it can sometimes be useful to rebase so that multiple commits can be squashed into one before pusing to GitHub. For example, the following command will list the last 3 commits so that they could potentially be squashed.
These are the basics of working with git. Sometimes situations arise where more complicated commands need to be used. Additionally, sometimes conflicts need to be resolved when pulling changes. For more advanced usage requirements, read a proper tutorial or a book.