Now that you know the basics of creating a repository and making commits, let's talk about how to share your work with other people.
This guide will focus on GitHub, but in fact there are lots of sites that will host a Git repository on the web for you - here's a big list from the Git wiki. If you have a server sitting somewhere on the public web, you can provide your own interface with Gitweb or a range of other tools. We use GitHub at Adafruit right now because it's both popular and a very good tool.
(Like a lot of things on the internet, this isn't a perfect state of affairs: there are reasons to be concerned that a single company controls the place where so much open source code lives, and GitHub itself isn't open source, though they contribute a lot to open source projects. For now, I take the view that the perfect is the enemy of the good, and the distributed nature of Git makes this a lot less worrisome than it might be otherwise.)
This part doesn't really need much explanation. Visit GitHub and pick a username and password (use a strong, unique password).
Once you're logged in, you'll be asked to choose a plan:
The free one is fine for most purposes - later you might want to upgrade, particularly if you need to host non-public repositories.
Choose a plan, and GitHub will drop you to its dashboard interface:
There's not much to see yet. That "Hello World" guide is pretty good, incidentally, but let's jump right into publishing the repo you've already started.
Click "Create a repository", and you'll be given a simple form:
Fill out the repository name and a short description. Don't initialize the repository with a README - you've already got one of those. Click "Create repository", and you'll be given some further instructions:
Make sure the "HTTPS" button is clicked (we'll talk about SSH later), and check out the bit under "...or push an existing repository from the command line". You want two commands:
git remote add origin https://github.com/yourusernamehere/project.git git push -u origin master
The first tells Git to add a remote called "origin" at the specified address. A remote is just another repository (almost always a copy of the same one) that Git can push or pull changes to and from. You can verify this worked with git remote -v
:
The second tells Git to push local changes on the branch called "master" to the remote called "origin". The -u
option says "make master on origin an upstream", which means that from now on you can git push
and git pull
to GitHub and things will go to the right place.
You should be prompted for a username and password - use the ones you just created on GitHub:
Now reload the repository page in your web browser and you'll see something a lot like this:
Next time you make a commit, you can say git push
without specifying a remote or a branch, and Git will use the new defaults.
Page last edited July 06, 2015
Text editor powered by tinymce.