
Git and GitHub are often mentioned together, but they are different things. Git is a version control system: a program on your computer that records snapshots of your project so you can see what changed, when and why, and return to any earlier state. GitHub is a website that hosts Git repositories online, so you can back them up, share them and collaborate with others. GitLab and Bitbucket offer similar services. You can use Git without GitHub, but GitHub without Git makes little sense.
Git was created in 2005 by Linus Torvalds, the creator of Linux, after the Linux kernel project lost free access to the proprietary tool it had been using. He needed something fast, reliable and able to handle thousands of contributors, and he wrote the first version in a matter of weeks. Git is distributed: every copy of a repository contains the full history, so you can work offline and no single server is a point of failure. GitHub launched in 2008, grew into the largest home for open-source code and was acquired by Microsoft in 2018. Today Git is the standard version control system in software development.
Download Git from git-scm.com or install it with your system's package manager; on macOS it may already be present. Then tell Git who you are, because every commit records an author:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Use the same email address as your GitHub account so your commits are linked to your profile. You can also set main as the default branch name with git config --global init.defaultBranch main.
In your project folder, run git init. Git creates the hidden history folder and starts watching. The daily cycle then has three steps:
Use git log to see the history and git diff to see exactly which lines changed before you stage them.
A commit message is a note to your future self and your teammates. Write a short summary in the imperative mood, as if giving an instruction: "Fix login button on mobile" rather than "fixed stuff". Commit small, logical units of work. If you need the word "and" in the message, it is often two commits.
Create a file called .gitignore listing files Git should never track: installed dependencies such as node_modules, build output, system files such as .DS_Store and, above all, files containing passwords or API keys. GitHub offers ready-made templates for most languages.
Create a free account on GitHub and click New repository. Give it a name, choose public or private, and leave it empty if you already have a local project. GitHub then shows the commands to connect them:
git remote add origin git@github.com:your-name/your-repo.git
git push -u origin main
Since 2021, GitHub no longer accepts your account password for Git operations. Use an SSH key or a personal access token instead, or install the GitHub CLI (gh) or GitHub Desktop, which handle authentication for you. After the first push, git push uploads new commits and git pull downloads commits others have made.
To copy an existing project from GitHub to your computer, use git clone followed by the repository address.
Branches let you try ideas safely. Create and switch to a new one with git switch -c new-header (older tutorials use git checkout -b, which does the same). Commit on the branch as usual. The main branch stays untouched, so if the experiment fails, you simply switch back with git switch main and delete the branch. When the work is ready, you merge it into main.
On GitHub, the usual way to merge a branch is a pull request (PR). Push the branch with git push -u origin new-header, and GitHub offers a button to open a PR. A pull request shows every changed line, lets others comment on specific lines, and runs automated checks such as tests. When everyone is satisfied, you click Merge. Even when working alone, PRs are a good habit: reviewing your own diff before merging catches surprising mistakes.
To contribute to someone else's project, you first fork it, which creates your own copy on GitHub, then work on a branch of your fork and open a pull request to the original repository.
If two branches change the same lines of the same file, Git cannot decide which version to keep and reports a merge conflict. It is not an error, just a question. Git marks the file with both versions between the lines <<<<<<<, ======= and >>>>>>>. Edit the file to the version you want, delete the markers, then git add the file and commit. Editors such as VS Code show conflicts with buttons to accept one side or both.
Be careful with commands that rewrite history, such as git reset --hard and force pushes. They are useful but can delete work, especially on branches other people use.
For your first projects, this routine covers almost everything: pull the latest main, create a branch, make small commits with clear messages, push the branch, open a pull request, review it, merge it and delete the branch. Learn it until it feels automatic, and you will already work the way most professional teams do. A GitHub profile with real projects is also one of the best things a beginner developer can show to an employer.
Grade 10 Math: Functions and Reasoning - Quiz
1170 questions