Git and SSH

Rebase your branch onto main

Replay your branch's work on top of the newest main, so the history reads as one straight line.

Fill these in once
  1. Get the latest from GitHub
    Terminal
    git fetch origin
  2. Switch to your branch
    Terminal
    git switch fix-login-button
  3. Replay it on top of main
    Terminal
    git rebase origin/main

    If there's a conflict, fix the file, run git add on it, then git rebase --continue.

  4. Update your branch on GitHub
    Terminal
    git push --force-with-lease

    Rebasing rewrites history, so a normal push is refused. Only do this on a branch nobody else is using.

Check it worked

  1. See the straight history
    Terminal
    git log --oneline --graph -10
Undo it
  1. Stop a rebase halfway
    Terminal
    git rebase --abort

    Puts your branch back exactly as it was before you started.

  1. Get the latest from GitHub
    Terminal · Ubuntu / Debian
    git fetch origin
  2. Switch to your branch
    Terminal · Ubuntu / Debian
    git switch fix-login-button
  3. Replay it on top of main
    Terminal · Ubuntu / Debian
    git rebase origin/main

    If there's a conflict, fix the file, run git add on it, then git rebase --continue.

  4. Update your branch on GitHub
    Terminal · Ubuntu / Debian
    git push --force-with-lease

    Rebasing rewrites history, so a normal push is refused. Only do this on a branch nobody else is using.

Check it worked

  1. See the straight history
    Terminal · Ubuntu / Debian
    git log --oneline --graph -10
Undo it
  1. Stop a rebase halfway
    Terminal · Ubuntu / Debian
    git rebase --abort

    Puts your branch back exactly as it was before you started.

  1. Get the latest from GitHub
    PowerShell
    git fetch origin
  2. Switch to your branch
    PowerShell
    git switch fix-login-button
  3. Replay it on top of main
    PowerShell
    git rebase origin/main

    If there's a conflict, fix the file, run git add on it, then git rebase --continue.

  4. Update your branch on GitHub
    PowerShell
    git push --force-with-lease

    Rebasing rewrites history, so a normal push is refused. Only do this on a branch nobody else is using.

Check it worked

  1. See the straight history
    PowerShell
    git log --oneline --graph -10
Undo it
  1. Stop a rebase halfway
    PowerShell
    git rebase --abort

    Puts your branch back exactly as it was before you started.

New to Rebase? I explain it in plain English on Layman Terms.