GitHub: remotes, push, pull, clone, SSH keys, tokens and a profile that gets you hired
So far your repository lives only on your computer. GitHub puts it online: a backup if your laptop is stolen, a place to collaborate, and a public portfolio employers and clients can see. In this unit you'll connect a local repo to GitHub, push and pull changes, clone projects, set up secure authentication, and polish your GitHub profile.
Step 1: Create a repository on GitHub
- Sign in at github.com → + (top right) → New repository.
- Name it (e.g.
my-website), add a short description. - Choose Public (portfolio) or Private.
- If you already have a local repo, don't tick "Add a README" (it avoids a first-push conflict).
- Click Create repository. GitHub shows the commands to connect.
Step 2: Connect your local repo (add a remote)
A remote is a named link to a copy of the repo elsewhere. The convention is to call your main one origin.
git remote add origin https://github.com/wanjiku-dev/my-website.git
git remote -v # list remotesStep 3: Push
git push -u origin mainpushsends your commits to the remote.-u(upstream) remembers that localmaintracksorigin/main, so afterwards plaingit pushandgit pullwork.
Refresh the GitHub page: your files and commit history are online.
Authentication
GitHub no longer accepts your account password for Git operations. Choose one:
Option A: HTTPS with a personal access token (PAT)
- GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens → Generate.
- Give it access to the repositories you need, with an expiry date.
- When Git asks for a password, paste the token. A credential manager (installed with Git for Windows;
gh auth loginwith GitHub CLI) stores it securely.
Option B: SSH keys (popular with developers)
ssh-keygen -t ed25519 -C "wanjiku@example.com" # press Enter for the default file; set a passphrase
cat ~/.ssh/id_ed25519.pub # copy this PUBLIC keyGitHub → Settings → SSH and GPG keys → New SSH key → paste. Test:
ssh -T git@github.comThen use SSH URLs: git@github.com:wanjiku-dev/my-website.git. Change an existing remote with git remote set-url origin git@github.com:wanjiku-dev/my-website.git.
Cloning: downloading a repository
git clone https://github.com/wanjiku-dev/my-website.git
cd my-websiteClone gives you the files, the full history, and an origin remote already set up. Clone into a different folder name: git clone URL new-folder.
Staying in sync: fetch and pull
| Command | What it does |
|---|---|
git fetch | Downloads new commits from the remote but doesn't change your files |
git pull | fetch + merge the remote branch into your current branch |
git pull --rebase | fetch + replay your local commits on top (a straight history) |
A safe daily routine:
git switch main
git pull # get the latest
git switch -c feature/faq # start new work from up-to-date main"Rejected" pushes
! [rejected] main -> main (fetch first)Someone pushed commits you don't have. Run git pull (resolve any conflicts), then git push again. Never "fix" this with git push --force on a shared branch: it deletes your teammates' commits from the remote.
Pushing branches
git switch -c feature/faq
# commit work...
git push -u origin feature/faqGitHub then offers a button to open a pull request (covered in the pull requests lesson).
README, licence and settings
A README.md is the front page of your repository. A good one has:
# Mama Mboga Online Shop
A responsive online grocery shop with M-Pesa checkout, built with HTML, CSS, JavaScript and PHP.

## Features
- Product search and categories
- Cart and M-Pesa STK push checkout (sandbox)
- Admin dashboard for orders
## Run it locally
1. Clone the repo
2. Copy `config.sample.php` to `config.php` and add your sandbox keys
3. Open with PHP's built-in server: `php -S localhost:8000`
## Live demo
https://wanjiku-dev.github.io/mama-mboga
## Author
Wanjiku Kamau – [LinkedIn](https://linkedin.com/in/...)- Add a licence (MIT is common for open projects) so others know how they may use the code.
- Add topics (tags) and a website link in the repo's About section.
A GitHub profile that gets you hired
- Profile README: create a public repo named exactly like your username; its README shows on your profile. Introduce yourself, your skills and links.
- Pin 4–6 best projects with clear READMEs, screenshots and live demos.
- Commit regularly: the contribution graph shows consistent activity (quality matters more than green squares).
- Real projects beat tutorials: a school fees tracker, a chama app, a booking site for a local business.
- Contribute to open source: documentation fixes and small issues labelled "good first issue".
- Use a professional photo, name, location (Nairobi, Kenya) and a link to your portfolio/LinkedIn.
Think about it: You cloned a team project yesterday. Today you made two commits and try git push, but it's rejected. What happened and what should you do?Show answer
A teammate pushed new commits to the remote since you cloned. Run git pull to fetch and merge their work (fix any conflicts and commit), then git push. Don't force-push, which would erase their commits from the remote.
Summary
- Create a repo on GitHub, connect it with
git remote add origin URL, and publish withgit push -u origin main. - Authenticate with a personal access token (HTTPS) or SSH keys; never commit or share secrets.
git clonedownloads a repo with history;git fetchdownloads,git pulldownloads and merges.- Rejected push → pull first; never force-push shared branches.
- A strong README and a polished profile with pinned real projects help you get hired.
Check yourself
What is the conventional name of the main remote?
Show answer
origin
Which command downloads a repository from GitHub to your computer? (two words)
Show answer
git clone
Which command downloads new commits without changing your files? (two words)
Show answer
git fetch
What does git pull do in addition to fetch?
Show answer
merge
Can you use your GitHub account password for git push over HTTPS today? (yes/no)
Show answer
no
Which file is the front page of a repository?
Show answer
README.md