GitHub tutorial and basics
GitHub is a popular web based collaborative version control service. Officially launched to the public in April 2008, Github has since grown to become a significant open source community with well over 5 million users and 10 million repositories created since its inception.
|DIFFICULTY||Basic - 1 | Medium - 2 | Advanced - 3|
|TIME REQUIRED||10 min|
|RELATED PRODUCTS||Linux-based VPS or dedicated servers
Linux-based shared hosting
As the name implies, GitHub's primary purpose of distributed software control management revolves around Git, the popular distributed revision control and source code management system. In addition to offering a graphical web-based interface for Git project management, GitHub offers a variety of useful features for any project or team.
Collaborative code review allows users to quickly view changes made across various commits or branches. Team members and even outside developers within the GitHub community can comment on commits, files, or even individual lines of code to highlight a particular topic or ask a question.
GitHub Flavored Markdown is a custom text syntax (based on standard Markdown) used across all of GitHub that allows users to easily convert their plain text entries into formatted HTML output. The GitHub Flavored spinoff adds a very simple autocomplete function for easily referencing issues (#), tasks (- [ ]), people (Username), and commits (SHA).
GitHub allows developers to establish teams across individual projects or entire organizations, allowing individual members to be given read, read-write, or even admin-level access to repositories. Entire teams can even be mentioned using GitHub Flavored Markdown (@repository/team), informing the entire team of the update.
GitHub currently supports syntax highlighting for over 200 programming languages and also has mobile access through an Android app and a mobile-optimized website.
Full issue-tracking software for each repository as well as associated wiki pages for projects that need more information made available round out the core features that GitHub brings to any enterprise.
Getting Started with GitHub
Since GitHub accepts Git repositories, it is already assumed that you have Git installed locally for this tutorial. If you haven't used or installed Git yet, please check out our Git tutorial to find out how to get started with Git itself.
Register a GitHub Account
GitHub security and collaboration are tied directly to user accounts, so your first step is registering an account.
Create a GitHub Repository
Once signed in, click the + in the top-right corner and select New repository. While the repository name is the only required field, you may fill out the rest of the information as necessary then click Create repository. For this example we're creating a new repository named "my-repo."
Create a Local Git Repository
Upon creation, your front page of your repository will display quick setup commands to create a local Git repository and/or connect an existing local Git repository to your newly created "my-repo" GitHub repository.
$ touch README.md
$ git init
$ git add README.md
$ git commit -m "first commit"
$ git remote add origin https://github.com/USERNAME/my-repo.git
$ git push -u origin master
Simply follow the instructions you see in your local command line to generate your own local repository, add a remote host, and finally push your local Git repository up to GitHub.
Start by creating your local repository directory, adding a basic file for testing, and initializing Git:
$ mkdir ~/dev/my-repo
$ cd ~/dev/my-repo
$ cat > README.md
Press ctrl and C at the same time.
$ git init
Initialized empty Git repository in /root/dev/my-repo/.git/
Now add your new files to Git with the git add command and then commit that new file using the
git commit -m command:
$ git add README.md
$ git commit -m "Initial commit"
This will return:
[master (root-commit) ccfed60] Initial commit 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 README.md
Next add a remote repository with git remote add -- linked to your newly created GitHub repository -- and push your local repository up to the GitHub remote repository using the
git push command:
$ git remote add origin https://github.com/your GitHub username/my-repo.git
$ git push -u origin master<
You will be prompted to enter your GitHub credentials and after successful entry, your local Git repository will be pushed to your new GitHub repository:
Counting objects: 3, done. Writing objects: 100% (3/3), 219 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To https://github.com/USERNAME/my-repo.git * [new branch] master -> master Branch master set up to track remote branch master from origin.
That's it! Your GitHub repository is now up and running and you can continue adding to it as needed or create virtually unlimited repositories for all your future projects on GitHub.
Note: As a courtesy, we provide information about how to use certain third-party products, but we do not endorse or directly support third-party products and we are not responsible for the functions or reliability of such products. Third-party marks and logos are registered trademarks of their respective owners. All rights reserved.