Learn GitHub Basics: Host Code and Collaborate
GitHub is where developers store code, collaborate, and share projects. It's like Google Drive for code, but with powerful version control features.
This course teaches you GitHub basics. By the end, you'll know how to create repositories, upload code, collaborate with others, and use GitHub to host websites for free.
What Is GitHub?
GitHub is a website that hosts Git repositories. Think of it as:
- Cloud storage for your code
- A collaboration platform
- A portfolio showcase
- Free website hosting (GitHub Pages)
Git vs GitHub: Git is the version control tool on your computer. GitHub is the website where you store Git repositories online.
Creating a GitHub Account
Step 1: Go to github.com
Step 2: Click "Sign up"
Step 3: Enter username, email, and password
Step 4: Verify your email
That's it. Free accounts have everything you need to get started.
Creating Your First Repository
A repository (repo) is a folder for your project:
- Click the "+" icon in top right
- Select "New repository"
- Enter repository name (e.g., "my-first-project")
- Add description (optional)
- Choose Public (visible to everyone) or Private (only you)
- Don't check "Initialize with README" yet (we'll do that manually)
- Click "Create repository"
You now have an empty repository. Next, we'll add code to it.
Uploading Code to GitHub
Method 1: Using GitHub Website (Easiest)
- In your new repository, click "uploading an existing file"
- Drag and drop your files or click "choose your files"
- Scroll down, enter commit message (e.g., "Initial commit")
- Click "Commit changes"
Method 2: Using Git (Recommended for developers)
If you have Git installed (learn how to set up Git):
# In your project folder
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/yourusername/repo-name.git
git push -u origin main
Replace "yourusername" and "repo-name" with your actual GitHub username and repository name.
Understanding Repository Pages
When you open a repository, you'll see:
- Code tab: Your files and folders
- Issues tab: Bug reports and feature requests
- Pull Requests tab: Proposed changes
- Actions tab: Automated workflows
- Settings tab: Repository configuration
For now, focus on the Code tab - that's where your files are.
README Files
A README file explains what your project is and how to use it:
- Click "Add file" → "Create new file"
- Name it
README.md(must be exact) - Write a description of your project
- Click "Commit new file"
Example README:
# My First Project
This is my first GitHub repository. It's a simple website.
## Features
- Responsive design
- Contact form
- Modern styling
## How to Use
1. Clone this repository
2. Open index.html in your browser
3. Customize the content
README files are displayed on your repository's main page, so they're the first thing people see.
Making Changes
On GitHub website:
- Click a file to view it
- Click the pencil icon to edit
- Make your changes
- Scroll down, enter commit message
- Click "Commit changes"
Using Git (from your computer):
# Make changes to files
git add .
git commit -m "Description of changes"
git push
Every change is saved as a commit with a message explaining what changed.
Viewing File History
See how files changed over time:
- Click any file
- Click "History" button (clock icon)
- See all previous versions
- Click any version to see what it looked like
This is version control in action - you can see every change and go back to any version.
Forking Repositories
Forking creates a copy of someone else's repository in your account:
- Go to any public repository
- Click "Fork" button (top right)
- Choose your account
- You now have your own copy
Why fork?
- Use someone's project as a starting point
- Make changes without affecting the original
- Contribute back via pull requests
Cloning Repositories
Clone means download a repository to your computer:
- Go to repository page
- Click green "Code" button
- Copy the URL
- In terminal/command prompt:
git clone [URL]
Example:
git clone https://github.com/username/repo-name.git
This downloads the repository to your computer so you can work on it locally.
GitHub Pages (Free Website Hosting)
GitHub Pages lets you host websites for free:
- Create a repository
- Upload your website files (HTML, CSS, JS)
- Go to Settings → Pages
- Under "Source", select "main" branch
- Click "Save"
- Your site will be at:
yourusername.github.io/repo-name
Custom domain: You can also use your own domain name (like yourname.com) in Settings → Pages.
It takes a few minutes for the site to go live. GitHub will show you the URL when it's ready.
Collaborating with Others
Adding collaborators:
- Go to Settings → Collaborators
- Click "Add people"
- Enter their GitHub username
- They'll get an email invitation
Pull Requests (PRs):
Pull requests let others propose changes:
- Someone forks your repo or creates a branch
- They make changes
- They create a pull request
- You review the changes
- You merge if you approve
This is how open-source projects work - people contribute via pull requests.
Issues
Issues are like to-do lists and bug reports:
- Go to Issues tab
- Click "New issue"
- Enter title and description
- Click "Submit new issue"
Use issues for:
- Reporting bugs
- Requesting features
- Asking questions
- Tracking tasks
You can close issues when they're fixed or completed.
Best Practices
- Write good commit messages: Explain what changed and why
- Use README files: Help others understand your project
- Keep repositories organized: Use folders, name files clearly
- Make repos public: Showcase your work (unless it's private for a reason)
- Use .gitignore: Don't commit sensitive files or build artifacts
- Add licenses: Tell people how they can use your code
Common Mistakes
- Committing sensitive data: Never commit passwords, API keys, or secrets
- Bad commit messages: Write clear messages, not "fix" or "update"
- Not using README: Always include a README explaining your project
- Too many small commits: Group related changes together
- Not backing up locally: Keep local copies of important repos
Pro Tip: Use GitHub as your portfolio. Make your repositories public, write good READMEs, and keep them updated. Employers and clients look at GitHub profiles. Also, contribute to open-source projects - it's great practice and looks great on your profile.
Next Steps
Once you're comfortable with basics:
- Learn more about Git (check out our Git course)
- Explore open-source projects
- Contribute to projects via pull requests
- Set up GitHub Pages for your website
- Learn about GitHub Actions (automation)
Common Questions
Is GitHub free?
Yes, GitHub is free for public repositories and personal use. Private repositories are also free for individuals. Paid plans are for teams and organizations that need advanced features.
Do I need to know Git to use GitHub?
Not necessarily. You can use GitHub's website to upload files and make changes. But learning Git makes you more efficient and unlocks GitHub's full power. Start with the website, then learn Git when you're ready.
Can I delete a repository?
Yes. Go to Settings → scroll to bottom → Danger Zone → Delete this repository. Be careful - this is permanent and can't be undone.
Start Using GitHub
Create an account, make your first repository, and upload some code. Start simple - maybe a small website or a simple script. The more you use GitHub, the more natural it becomes. It's an essential tool for any developer.