Getting started with GitHub
This is a 10 minute intro for folks who are new to git and GitHub (like me, just a few weeks ago).
The best way to get started with social coding and GitHub is to clean up any old side-projects you have lying around and publish them to GitHub. Keep reading to find out how to publish your first project in just 10 minutes.
1. Create an account on github
Visit github.com and sign up for an account, if you haven’t already done so.
2. Create a repository
In your GitHub landing page, click on the “New repository” button.
- Name your repository. If your side project is called “MyComponent”, use that as the name
- Provide a brief description, e.g. “A component for displaying cat pictures in your app”
- Check the “Initialize with README” option
- Pick a .gitignore that matches the language that “MyComponent” was written in
- Pick a license. Visit http://choosealicense.com if you need help deciding. I personally like the MIT license
3. Pull the repository from github
The following will create a local git repository for MyComponent, associate it with the GitHub repository, then sync your local repo with GitHub.
1 2 3 4 |
cd MyComponent git init git remote add origin https://github.com/myusername/MyComponent.git git pull origin master |
Note that the above is in case you’ve already written MyComponent and just want to share it on GitHub. If you haven’t written it yet, it’s easier to setup your local repository first before doing any development, like so:
1 |
git clone https://github.com/myusername/MyComponent.git |
4. Commit your changes
Add all your files to the local repository.
1 2 |
git add . git commit -m "Initial commit" |
5. Push the changes back to github
Push the changes from your local repository to the one on GitHub.
1 |
git push origin master |
6. All done!
Congrats, you have your very first project on GitHub! Visit your project homepage at:
https://github.com/myusername/MyComponent