Home FAQ New Contact Mock Test About

Create and organise your GitHub repository

A repository is the folder on GitHub that holds your project and its full history. Set one up correctly once, and every host and automation tool can build on it.

Create your repository

You need a free GitHub account. Free accounts can have unlimited public and private repositories.

1

Sign up and start a new repo

  1. Create an account at github.com/signup and verify your email.
  2. Press the + button at the top right, then New repository.
2

Fill in the form

FieldWhat to enter
Repository nameShort, lowercase, with hyphens, for example my-portfolio
DescriptionOne line about the project
Public or PrivatePublic is visible to everyone. Private is visible only to you and people you invite.
Add a README fileTick it, so the repo starts with a front page
Add .gitignorePick a template such as Node, or none for plain HTML
Choose a licenseMIT is a common open choice. Skip it for private work.
3

Press Create repository

You land on the Code tab. The other tabs matter later: Issues for tasks, Pull requests for reviewing changes, Actions for automation and Settings for everything else.

Add your files

Use the browser for a quick start, or Git on your computer for regular work.

1

Option A: upload in the browser

  1. On the Code tab press Add file, then Upload files.
  2. Drag your files and folders into the page.
  3. Write a short message such as Add website files and press Commit changes.
Files added through the browser can be 25 MiB at most each.
2

Option B: use Git on your computer

Install Git from git-scm.com, then set your name and email once:

git config --global user.name "Your Name" git config --global user.email "you@example.com"

Copy the repo to your computer, using the address from the green Code button:

git clone https://github.com/USERNAME/my-portfolio.git cd my-portfolio

After editing files, save and upload your changes:

git add . git commit -m "Update homepage" git push
3

Sign in when Git asks

GitHub no longer accepts your account password for Git over HTTPS. Sign in through the browser window that Git Credential Manager opens, run gh auth login if you use GitHub CLI, or paste a personal access token as the password. Create a token under Settings, Developer settings, Personal access tokens.

Treat a token like a password and never put it in your code.

Organise the folders

A clean layout makes the repo easy to read and lets hosts find your files without extra settings.

1

Use a simple layout

my-portfolio/ ├── index.html ├── about.html ├── css/ │ └── style.css ├── js/ │ └── main.js ├── images/ ├── favicon.svg ├── og-image.png ├── README.md ├── .gitignore ├── LICENSE └── .github/ └── workflows/ └── deploy.yml
PathPurpose
index.htmlHomepage. Keep it in the root so hosts serve it first.
css/ js/ images/Styles, scripts and pictures, one folder each
README.mdFront page of the repo, shown on GitHub automatically
.gitignoreFiles Git must never upload
.github/workflows/GitHub Actions automation files

Name files in lowercase with hyphens and no spaces, for example contact-us.html.

2

Add a README

# My Portfolio Short description of what this project is. ## Live site https://yourdomain.com ## Run locally Open index.html in a browser, or run `npm install` and `npm run dev`. ## Built with HTML, CSS and JavaScript. ## License MIT

Save it as README.md in the root of the repo.

3

Add a .gitignore

node_modules/ dist/ .env .env.local .DS_Store *.log

Save it as .gitignore. Anything matching these lines stays on your computer, so secrets and bulky folders never reach GitHub.

Branches and everyday commands

Keep main working. Do new work on a branch, then merge it through a pull request.

1

Make a change safely

  1. Create a branch: git switch -c fix-navbar.
  2. Edit files, then git add . and git commit -m "Fix navbar".
  3. Run git push -u origin fix-navbar.
  4. On GitHub press Compare & pull request, then Merge pull request when it looks right.
  5. Press Delete branch to tidy up.

Commands you will use most

CommandWhat it does
git statusShows changed and untracked files
git diffShows exactly what you changed
git add .Stages every change for the next commit
git commit -m "message"Saves a snapshot with a message
git pushUploads commits to GitHub
git pullDownloads and merges the latest changes
git switch -c nameCreates and switches to a new branch
git log --onelineLists recent commits in short form
git restore fileThrows away uncommitted changes to a file

Repository settings worth setting

Open the Settings tab, or the gear next to About on the Code tab.

WhereWhat to do
About (Code tab)Add a description, your website link and topics so people can find the project
Settings, PagesPublish a static site from a branch or from GitHub Actions
Settings, Secrets and variablesStore API keys for Actions without putting them in code
Settings, CollaboratorsInvite people to work on the repo
Settings, BranchesOptional rule to protect main so changes go through pull requests
Releases (right sidebar)Attach zips or installers, up to 2 GiB per file
Settings, Danger ZoneChange visibility, rename, transfer, archive or delete
Renaming a repo keeps old web and Git links redirecting for a while, but update your remotes and hosting settings afterwards.

Common mistakes and fixes

Most repo problems fall into one of these.

ProblemFix
An API key or .env file was uploadedRevoke and replace the key first. Deleting the file in a new commit does not remove it from history, so clean the history too, for example with git filter-repo.
File is too largeGitHub blocks files over 100 MiB and warns above 50 MiB. Use Git LFS, or attach the file to a Release instead.
node_modules was committedAdd it to .gitignore, then run git rm -r --cached node_modules and commit.
Push rejected: updates were rejectedSomeone changed the branch. Run git pull, fix any conflict, then push again.
Wrong files in the repo rootMove the project into the root so index.html sits at the top level, then commit.
Repo is getting hugeGitHub recommends keeping repositories under 1 GB. Keep videos and big datasets outside Git.

Common questions

Should my repo be public or private?

Public suits portfolios and open projects, and it is the safe default for free static hosting. Use private for client work or anything with unpublished content, and never store secrets in either.

Can I host a site from a private repo?

Cloudflare, Vercel and Render can all deploy private repos once you grant access. GitHub Pages from a private repo needs a paid GitHub plan.

What is a commit?

A saved snapshot of your files with a message. You can return to any earlier commit if something breaks.

How do I delete a repository?

Open Settings, scroll to Danger Zone, choose Delete this repository and type its name to confirm. Download a copy first if you may need it.