In today's digital landscape, version control is essential for developers, and Git is a powerful tool that helps manage project changes efficiently. GitHub, a popular platform built on Git, not only hosts repositories but also facilitates collaboration among developers worldwide. In this tutorial, we will explore the process of uploading your project to GitHub, ensuring your code is secure and accessible. We’ll also cover best practices for collaborating with others, making it easier to work in teams, contribute to open-source projects, and enhance your coding experience. Whether you’re a beginner or looking to refine your skills, this guide will provide the step-by-step instructions you need. Let’s get started!
Let’s say your project is located at C:/laragon/www/ims. You want to upload it to GitHub and allow others to contribute. This guide walks you through:
- Uploading your project to GitHub
- Cloning and modifying the project
- Submitting and reviewing changes via pull requests
Part 1: Upload Your Project to GitHub
Step 1: Initialise Git in Your Project Folder
cd C:/laragon/www/ims
git init
Step 2: Create a Repository on GitHub
- Go to GitHub
- Click New Repository
- Name it (e.g., ims)
- Leave it empty (no README, .gitignore, or license)
Step 3: Connect Local Project to GitHub
git remote add origin https://github.com/your-username/ims.git
Step 4: Add and Commit Files
git add .
git commit -m "Initial commit"
Step 5: Push to GitHub
git branch -M main
git push -u origin main
Part 2: Collaborator Clones and Contributes
Let’s say someone wants to contribute to your project.
Step 1: Clone the Repository
git clone https://github.com/your-username/ims.git
cd ims
Step 2: Create a New Branch
git checkout -b feature-new-ui
Step 3: Make Changes and Commit
# Edit files...
git add .
git commit -m "Added new UI layout"
Step 4: Push to Their Fork (if not a collaborator)
git push origin feature-new-ui
Step 5: Create a Pull Request
- Go to the GitHub repo
- Click Compare & pull request
- Add a description and submit
Part 3: Owner Reviews and Merges Changes
As the repository owner:
Step 1: Review the Pull Request
- Go to the Pull Requests tab
- Click the PR to review the code and comments
Step 2: Accept or Reject
- To accept, click Merge pull request
- To reject, click Close pull request and leave a comment
Other related Git Commands
| Command | Description |
| git status | Show current changes |
| git log | View commit history |
| git diff | See file differences |
| git stash | Temporarily save changes |
| git pull | Fetch and merge from remote |
| git fetch | Fetch changes without merging |
| git reset --hard | Revert to last commit (careful!) |
This guide provides a comprehensive overview of using Git and GitHub for version control and collaboration in software development. It outlines the steps to upload a project from your local machine to GitHub, create a repository, and push your code. Additionally, it explains how collaborators can clone the repository, make changes, and submit their contributions through pull requests. Happy coding and collaborating!