MarzleyTech Learn

Home / Learn / Git & GitHub / GitHub: remotes, push, pull, clone, SSH keys, tokens and a profile that gets you hired

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

  1. Sign in at github.com → + (top right) → New repository.
  2. Name it (e.g. my-website), add a short description.
  3. Choose Public (portfolio) or Private.
  4. If you already have a local repo, don't tick "Add a README" (it avoids a first-push conflict).
  5. 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.

Terminal
git remote add origin https://github.com/wanjiku-dev/my-website.git
git remote -v            # list remotes

Step 3: Push

Terminal
git push -u origin main
  • push sends your commits to the remote.
  • -u (upstream) remembers that local main tracks origin/main, so afterwards plain git push and git pull work.

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)

  1. GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens → Generate.
  2. Give it access to the repositories you need, with an expiry date.
  3. When Git asks for a password, paste the token. A credential manager (installed with Git for Windows; gh auth login with GitHub CLI) stores it securely.

Option B: SSH keys (popular with developers)

Terminal
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 key

GitHub → Settings → SSH and GPG keys → New SSH key → paste. Test:

Terminal
ssh -T git@github.com

Then 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

Terminal
git clone https://github.com/wanjiku-dev/my-website.git
cd my-website

Clone 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

CommandWhat it does
git fetchDownloads new commits from the remote but doesn't change your files
git pullfetch + merge the remote branch into your current branch
git pull --rebasefetch + replay your local commits on top (a straight history)

A safe daily routine:

Terminal
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

Terminal
git switch -c feature/faq
# commit work...
git push -u origin feature/faq

GitHub 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:

Markdown
# Mama Mboga Online Shop

A responsive online grocery shop with M-Pesa checkout, built with HTML, CSS, JavaScript and PHP.

![Screenshot](screenshot.png)

## 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

  1. Profile README: create a public repo named exactly like your username; its README shows on your profile. Introduce yourself, your skills and links.
  2. Pin 4–6 best projects with clear READMEs, screenshots and live demos.
  3. Commit regularly: the contribution graph shows consistent activity (quality matters more than green squares).
  4. Real projects beat tutorials: a school fees tracker, a chama app, a booking site for a local business.
  5. Contribute to open source: documentation fixes and small issues labelled "good first issue".
  6. 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 with git push -u origin main.
  • Authenticate with a personal access token (HTTPS) or SSH keys; never commit or share secrets.
  • git clone downloads a repo with history; git fetch downloads, git pull downloads 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

  1. What is the conventional name of the main remote?

    Show answer

    origin

  2. Which command downloads a repository from GitHub to your computer? (two words)

    Show answer

    git clone

  3. Which command downloads new commits without changing your files? (two words)

    Show answer

    git fetch

  4. What does git pull do in addition to fetch?

    Show answer

    merge

  5. Can you use your GitHub account password for git push over HTTPS today? (yes/no)

    Show answer

    no

  6. Which file is the front page of a repository?

    Show answer

    README.md

Lesson 7 of 12 in Git & GitHub · Printable course notes