Working with Git & GitHub
Introduction to Git and GitHub
- Git:
- A distributed version control system to track changes in your code.
- Allows collaboration with multiple developers and maintains a history of changes.
- GitHub:
- A cloud-based platform for hosting Git repositories.
- Provides collaboration tools like pull requests and issue tracking.
Step 2: Signing Up for GitHub Student Pack
- Why GitHub Student Pack?
- Access to premium tools for free (e.g., GitHub Pro, cloud credits, etc.).
- Helps you explore professional-grade developer tools.
- Steps to Sign Up:
- Visit the GitHub Student Pack page.
- Click Get Your Pack.
- Sign in or create a GitHub account.
- Verify your student status by uploading proof (student ID, transcript, etc.).
- Once verified, explore the available offers (e.g.,
CoPilot
)
Step 3: Setting Up Git
- Installing Git:
- Check if Git is installed:
git --version
- If not installed, download it from git-scm.com for your operating system.
- Install Git by following the installer instructions.
- Check if Git is installed:
- Set Global Git Configuration:
- Set your username and email (these will appear in your commits):
git config --global user.name "Your Name" git config --global user.email "your-email@example.com"
- Set your username and email (these will appear in your commits):
Step 4: Initialise a Local Repository
- Create a Git Repository Locally:
- Open your terminal or command prompt.
- Navigate to the folder where you want to store your project:
cd path/to/your/folder
- Initialise the Git repository:
git init
- Add a
README.md
file and commit it:echo "# My Project" >> README.md git add README.md git commit -m "Initial commit with README"
Step 5: Creating a GitHub Repository
- Steps to Create a New Repository on GitHub:
- Log in to GitHub and click the + sign in the top-right corner.
- Select New Repository.
- Name your repository, provide a description, and choose the visibility (public or private).
- Click Create Repository.
- Push Local Repo to GitHub:
- Add the GitHub repository as a remote:
git remote add origin https://github.com/yourusername/your-repo.git
- Push your local commits to GitHub:
git push -u origin main
- Add the GitHub repository as a remote:
Step 6: Cloning a GitHub Repository
- What is Cloning?
- Cloning creates a local copy of a GitHub repository on your machine.
- Steps to Clone a Repository:
- In your GitHub repository, click the Code button and copy the repository URL.
- In your terminal, run:
git clone https://github.com/yourusername/your-repo.git
- Change into the repository directory:
cd your-repo
Step 7: Basic Git Commands
- Adding and Committing Changes:
- Modify or create new files in your repository.
- Stage the changes:
git add .
- Commit the changes with a message:
git commit -m "Added new features"
- Pushing Changes to GitHub:
- Push your changes to the remote repository:
git push origin main
- Push your changes to the remote repository:
Step 8: Branching in Git
- What is Branching?
- A branch allows you to work on new features without affecting the main codebase.
- Steps to Create a Branch:
- Create a new branch:
git checkout -b feature-branch
- Work on your feature in this branch.
- Commit the changes and push the branch to GitHub:
git push -u origin feature-branch
- Create a new branch:
Step 9: Merging Branches
- Merging a Branch to Main:
- Switch back to the main branch:
git checkout main
- Merge the feature branch into main:
git merge feature-branch
- Push the updated main branch to GitHub:
git push origin main
- Switch back to the main branch:
Step 10: Collaboration with Pull Requests
- What is a Pull Request?
- A pull request lets you propose changes to someone’s repository and have them review and merge your changes.
- Creating a Pull Request:
- Fork another repository on GitHub.
- Make changes in your forked version and push the changes.
- Go to the original repository and click New Pull Request.
- The repository owner reviews and merges your changes.
Further Reading and Resources
Git - Documentation
The official and comprehensive man pages that are included in the Git package itself.
GitHub.com Help Documentation
Get started, troubleshoot, and make the most of GitHub. Documentation for new users, developers, administrators, and all of GitHub's products.


Git Tutorials and Training | Atlassian Git Tutorial
Learn the basics of Git through this comprehensive Git training. Branching, pull requests, merging and more are covered in the Atlassian Git tutorial.
