
The phrase "I pushed the code to GitHub," often heard in the software world, doesn't concern only programmers. Anyone who works on a website, documents, automation scripts or data analysis can use these tools to keep versions of their files safely, track changes and work with others. In this guide you learn what Git and GitHub are, how they differ, how to create your first repository and the basic terms (commit, branch, pull request).
What is Git?
Git is a version control system that records changes to files over time. Each saved state is called a commit. You can go back to any earlier version, see the difference between two versions and work on different features at the same time. Git runs on your own computer and doesn't need an internet connection.
Think of the "final.docx, final_v2.docx, final_last.docx" mess: Git solves this systematically, keeping who made which change, when and why.
What is GitHub?
GitHub is a platform that hosts Git repositories in the cloud. A repository holds all of a project's files and history. GitHub provides:
- Cloud backup and sharing: your code or documents are stored online.
- Teamwork: reviewing and merging changes others propose (pull requests).
- Issue tracking (issues): a list of bugs and tasks.
- Automation (Actions): automating test and release processes.
- Pages (Pages): publishing a static website.
- Open-source community: millions of open projects and the chance to contribute.
There are similar platforms such as GitLab and Bitbucket. Git is common; you can move between platforms.
Git vs GitHub
| Git | GitHub | |
|---|---|---|
| What? | A version control tool (software) | An online hosting and collaboration platform |
| Where does it run? | On your computer | In the cloud (browser/app) |
| Does it need internet? | No | Yes |
| What for? | Recording changes | Sharing, reviewing, automating |
| Owner | An open-source project | A company (Microsoft) |
Basic terms
| Term | Meaning |
|---|---|
| Repository (repo) | The folder holding a project's files and history |
| Commit | A record of changes with a descriptive message |
| Branch | An independent line of work split from the main line |
| Merge | Combining one branch's changes into another |
| Clone | Copying a repository to your computer |
| Push | Sending local commits to GitHub |
| Pull | Bringing changes on GitHub to your computer |
| Fork | A copy of someone else's repository in your account |
| Pull request (PR) | A proposal and review request for merging changes |
| Issue | A record of a bug, task or idea |
| README | The file that introduces the project |
| .gitignore | A list of files Git should not track |
Step by step: create your first repository
- 1
Open a GitHub account and enable two-factor authentication
- 2
Create a new repository (New repository)
- 3
Install Git on your computer and set your username
- 4
Clone the repository and add a file
- 5
Commit and send it to GitHub (push)
1. Open an account and secure it
Open a free account on GitHub. Use a strong password and two-factor authentication (preferably a passkey or authenticator app); your code repositories can be valuable to attackers (see our two-factor and passkey guides).
2. Create a new repository
With "New repository" give a name (for example my-first-project), choose Public (open to everyone) or Private. Adding a README is a good start. Make projects with private information Private.
3. Install and configure Git
Install Git from its official site. Then in the terminal set your name and email:
git config --global user.name "Your Name"
git config --global user.email "email@example.com"4. Clone the repository
Take the address from the repository page on GitHub and run:
git clone https://github.com/username/my-first-project.git
cd my-first-project5. Add a file, commit and push
Add a file to the folder, then:
git status
git add .
git commit -m "Add first file"
git pushgit status shows the state, git add . stages the changes, git commit records, git push sends to GitHub. For authentication GitHub asks for a personal access token or a browser-based sign-in instead of a password.
If you don't like the command line: GitHub Desktop or VS Code's Git interface does the same operations with buttons.
Branches and pull requests: the basis of teamwork
The main branch (usually main) holds the working, stable version. For a new feature a separate branch is opened:
git checkout -b new-feature
git add .
git commit -m "Add new feature"
git push -u origin new-featureThen on GitHub you open a pull request for this branch. In the PR you see the changes, comment, follow automatic tests and, after approval, merge into the main branch. This flow protects the main branch and ensures changes are reviewed.
How to write a good commit message
- Keep it short and clear ("Fix validation error in the login form").
- Say what you did and why.
- One commit should hold one logical change.
- Avoid vague messages such as "fix" or "last".
README and .gitignore
README.md says what the project is, how to install and use it. It's the first file anyone visiting the repository sees. It's written in Markdown.
The .gitignore file lists files that shouldn't be tracked: dependency folders, build output, environment files, temporary files. For example:
node_modules/
.env
*.logSecurity: never put these in a repository
- Passwords, API keys, tokens, database connection details. These should be kept in files such as
.env, added to .gitignore and used as environment variables. - Personal data and customer data.
- Private key files.
If you commit a secret by mistake, deleting it from the repository isn't enough; it stays in the history. Revoke and renew the key at once. In public repositories secrets can be found by automated scanners within minutes. You can enable GitHub's secret scanning and dependency alerts (Dependabot).
Is GitHub free?
GitHub's free plan offers individuals unlimited public and private repositories; there are paid plans for extra features, teams and enterprise security. Features and limits can change over time; see the official pricing page for current information.
Is Git/GitHub only for developers?
No. These people benefit too:
- Writers and documentation teams: managing versions and comments of Markdown documents.
- Data analysts: keeping the history of scripts and notebooks.
- Website owners: versioning the site and setting up automatic deployment (GitHub Pages, Git integration at providers such as Hostinger).
- Students: organising assignments and projects, building a portfolio.
- Automation enthusiasts: backing up their scripts (see our automation tools guide).
Large binary files (video, big data) aren't suitable for Git; use cloud storage for these files (see our cloud storage guide).
Common mistakes
- Committing a secret.
- Working a long time without committing. Small, frequent commits make going back easier.
- Working directly on the main branch (in teamwork).
- Vague commit messages.
- Not using .gitignore.
- Panicking at a merge conflict. It's when two people change the same line; you fix the conflicting parts by hand and commit again.
- Putting large files in the repository.
Frequently asked questions
Is the code I upload to GitHub public? If you make the repository "Public," yes; a "Private" repository is open only to those you permit.
Is Git hard to learn? The basic flow (add, commit, push, pull) is learned in a few hours; advanced topics come with time.
I made a mistake and committed, can I undo it? Yes; you can go back with git revert and similar commands. Forcibly changing shared history is risky in teamwork.
What is GitHub Copilot? An AI assistant for writing code (see our AI for coding beginners guide).
Can I publish a site with GitHub Pages? Yes, it's an easy route for static sites.
Can I deploy automatically from GitHub to hosting? Many hosting providers support automatic deployment from Git.
Summary
Git is the tool that records changes, while GitHub is the platform that hosts these records in the cloud and enables sharing and teamwork. Opening your first repository and trying the add–commit–push flow is a sufficient start. Keep secrets out of the repository, use two-factor authentication and keep a clean repository with .gitignore.
Serkan Akyürek is the founder and author of toolrota; he writes step-by-step guides on Excel, AI, the cloud, personal finance and digital security.