Getting Started with GitHub

Tutorial 1 of 5

1. Introduction

1.1 Tutorial Goals

This tutorial aims to provide you with a detailed introduction to GitHub. By the end of this tutorial, you will have a solid understanding of GitHub’s main features, how to navigate the interface, and a basic workflow for project collaboration and version control.

1.2 Learning Outcomes

  • Understand what GitHub is and its main features
  • How to create a GitHub account and repository
  • Understand basic Git commands like commit, push and pull
  • Learn how to collaborate with others on GitHub

1.3 Prerequisites

A basic understanding of Git and version control systems would be beneficial but not mandatory. Familiarity with the command line interface will also be helpful.

2. Step-by-Step Guide

2.1 Understanding GitHub

GitHub is a web-based platform used for version control. Git simplifies the process of working with other people and makes it easy to collaborate on projects.

2.2 Creating a GitHub Account

To get started with GitHub, you first need to create a GitHub account. Visit the GitHub website and sign up with your email.

2.3 Creating a New Repository

Once you've signed up and logged in to GitHub, you can create a new repository by clicking the '+' sign on the upper right corner of the dashboard and select 'New repository'.

2.4 Basic Git Commands

  • git init : Initializes a new Git repository and starts tracking an existing directory.
  • git clone : Creates a local copy of a project that already exists remotely.
  • git add : Stages a change.
  • git commit : Saves the changes to the local repository.
  • git push : Pushes changes to a remote repository.
  • git pull : Updates the local version of a repository from a remote.
  • git branch : Helps manage new branches.

3. Code Examples

# Initialize a new Git repository
git init

# Create a new file
echo "Hello World" > README.md

# Stage changes
git add README.md

# Commit changes
git commit -m "Initial commit"

# Check git status
git status

# Output should be: nothing to commit, working tree clean

4. Summary

In this tutorial, we've covered the basics of GitHub, including creating an account, creating a repository, and using some basic Git commands. You should now feel more comfortable navigating the GitHub interface and using Git for version control.

5. Practice Exercises

  1. Create a new repository on GitHub, clone it locally, make changes, commit them, and then push the changes back to GitHub.
  2. Create a new branch on your repository, make changes, commit them, and merge the changes into the main branch.

5.1 Solutions and Tips

  1. Follow the steps outlined in the tutorial to complete this exercise. Remember to replace 'your-repo-name' with the name of your repository.
git clone https://github.com/your-username/your-repo-name.git
echo "Hello again, World!" > NEWFILE.md
git add NEWFILE.md
git commit -m "Added NEWFILE.md"
git push origin master
  1. Use the git branch command to manage your branches.
git branch new-branch
echo "Hello from a new branch!" > BRANCHFILE.md
git add BRANCHFILE.md
git commit -m "Added BRANCHFILE.md in new branch"
git checkout master
git merge new-branch

Remember to practice these commands and concepts to get comfortable with using GitHub! Happy coding!