Git and GitHub for beginners: your first repository

By SamkhyaAcademy Team · · 5 min read

GitHub for beginners

Git and GitHub for beginners: what they are, how to install Git, create your first repository, commit and push, work with branches and use GitHub as your portfolio.

Every developer uses version control, and Git is the most popular tool for it. It records the history of your code so you can go back, compare versions and work with others without overwriting each other's work. GitHub is a website where you store your Git projects online and share them. Together they are also your public portfolio, which is why employers often look at a fresher's GitHub profile. This guide takes you from nothing to your first repository.

Git and GitHub: the difference

Git is the tool that runs on your computer and tracks changes to files. GitHub is an online service that hosts your Git repositories (projects), where others can see them, comment and collaborate. There are other hosting services, such as GitLab and Bitbucket, but the Git commands are the same.

Why use version control?

  • You can undo mistakes and return to a working version.
  • You can see who changed what and when.
  • Several people can work on the same project safely.
  • You get a backup of your work online.
  • You build a visible record of your learning.

Set up

  1. Install Git from the official Git website for your operating system.
  2. Create a free GitHub account with a professional username.
  3. Tell Git who you are, once on your computer:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Your first repository

  1. Create a folder for your project and open it in a terminal.
  2. Start tracking it:
git init
  1. Create a file such as README.md, then check what Git sees:
git status
  1. Stage the file, which means choosing what goes into the next snapshot, then save the snapshot with a message. This saved snapshot is called a commit:
git add .
git commit -m "Add README"

Push it to GitHub

  1. On GitHub, click New repository, give it a name and create it empty.
  2. Connect your local folder to it and send your code:
git remote add origin https://github.com/your-name/your-repo.git
git branch -M main
git push -u origin main

Refresh the GitHub page and you will see your files online. Congratulations, that is your first repository.

The daily routine

  • git status: see what changed.
  • git add: choose the changes to include.
  • git commit -m "message": save a snapshot with a clear message.
  • git push: upload your commits to GitHub.
  • git pull: download new changes from GitHub.
  • git log: see the history of commits.

Branches

A branch is a separate line of work. The main branch holds your stable code. When you want to add a feature, create a branch, make changes and test them, then merge the branch back into main. This keeps your main code safe while you experiment.

git checkout -b add-login
# make changes, then
git add .
git commit -m "Add login form"
git checkout main
git merge add-login

Pull requests

On GitHub, a pull request is a request to merge your branch into another one, giving teammates a chance to review your changes. Even when working alone, practising pull requests prepares you for team work.

Common problems and fixes

  • Merge conflicts: two people changed the same lines. Git marks the conflict in the file; you choose the right version, save, add and commit.
  • Committed by mistake: you can undo the last commit with git reset or fix it with a new commit. Ask for help before using risky commands.
  • Authentication errors on push: use a personal access token or SSH key as GitHub's instructions explain.

Good habits

  • Commit small changes often, with meaningful messages such as "Fix login validation".
  • Write a helpful README for every project: what it does, how to run it and screenshots.
  • Use a .gitignore file to keep unwanted files out.
  • Never commit passwords, API keys or personal data. If you do by mistake, change them immediately.
  • Pin your best repositories on your GitHub profile.

Using GitHub as your portfolio

Recruiters look at your commit history, README quality and project variety. Regular small commits show consistency. A tidy profile with a short bio, links and three or four pinned projects makes a good impression. Add the GitHub link to your resume and LinkedIn.

Frequently asked questions

Do I need to use the command line? It is best to learn the basic commands, even if you also use a visual tool such as GitHub Desktop or the editor's built-in Git panel.

What should my first repository contain? A small project with a clear README, a .gitignore and a few meaningful commits.

Is GitHub free? Yes, public and private repositories are available on the free plan.

How often should I commit? Whenever you complete a small, working change, usually several times a day while building.

Can recruiters really see my activity? Yes, so keep your profile tidy and your best projects pinned.

Ready for the next step?

Practise Git on real projects in our Full-Stack Development program. If you would like guidance from people who work in the industry, join our free career guidance workshop or request a free career discovery session. We will look at your background and help you plan what to learn and build next.

Need career guidance from industry experts?

Join our free workshop or request a free career discovery session.

Keep reading