Getting Started with Git and GitHub: A Beginner's Guide
Git is the tool developers use to track changes and collaborate on code. Learn what Git and GitHub are, the essential commands, and how branching and pull requests work.
Admin
FOSS Andhra community volunteer writing about free and open source software, education and developer tools from Andhra Pradesh.
If you want to contribute to open source, Git and GitHub are the two tools you will meet first. They are not the same thing, and knowing the difference makes everything else easier.
Git is a version control system
Git runs on your own computer and records every change you make to a project, so you can look back at the history, undo mistakes and work on several ideas at once without breaking things. It was created for developing the Linux kernel and is now the standard for almost all software collaboration.
GitHub hosts Git repositories online
GitHub is a website where repositories are stored and shared. It adds collaboration features on top of Git: issues for bug reports, pull requests for proposing changes, and code review tools. GitLab, Gitea and Codeberg are popular alternatives; the Git commands are identical on all of them.
Install and set up Git
Download Git from git-scm.com, or install it with your package manager on Linux. On Windows, Git Bash gives you both Git and a Linux-style terminal. After installing, tell Git who you are:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
The commands you will actually use
git clone https://github.com/user/project.git # download a copy of a project
git status # see what has changed
git add README.md # stage a change
git commit -m "Update README" # save staged changes with a message
git log --oneline # view recent history
git pull origin main # get new work by others
git push origin main # share your commits online
Work on a branch
Good practice is to keep the main branch stable and make changes on a separate branch:
git checkout -b fix-typo-in-readme # create and switch to a new branch
When your work is ready, push the branch and open a pull request on GitHub. Others review it, suggest improvements, and then it is merged. Our step-by-step guide covers that full flow: How to Make Your First Open Source Contribution.
Tips that make learning faster
- Commit small and often, with clear messages.
git statusandgit logare your friends when something feels wrong.- Practise on a scratch folder with sample files first. Nothing you commit locally is public until you push.
- Do not be afraid of breaking a repository. A fresh copy can always be cloned again.
Learn with us
FOSS Andhra runs workshops and community events where you can get help in person. See our upcoming events and join FOSStar to become a member. New to the whole idea of open source? Start with What Is Open Source Software?.