Undo your Git mistakes

Git and GitHub Basics. A beginner's handbook: commits, branches, merging, conflicts, undoing mistakes and pull requests.

20 lessons · 51 min of video · 17 quiz questions

How Git Works: Explained in 4 Minutes, by ByteByteGo

Try a question from this course

You ran git reset HEAD~1 with no flag. What state are your changes in?

What you'll be able to do

  • Explain where your code lives and use add, commit, push and pull
  • Create, switch to, merge and delete branches
  • Resolve a merge conflict
  • Choose the right way to undo a mistake and recover lost work
  • Open a pull request, including from a fork

What's in it

  1. Starting out

    Where your code lives, and how to get a copy of a project.

    1. The four places your code lives (add, commit, push, pull)
    2. Getting a copy of a public repo (git clone)
    3. Recap
  2. Branches

    Work on a copy so the working version is never at risk.

    1. Why use a branch instead of working on main
    2. Create, switch to and delete a branch
    3. Recap
  3. Merging and conflicts

    Bring branches together, and fix it when Git cannot decide.

    1. Merging a branch into main (fast-forward or not)
    2. Fixing a merge conflict
    3. Avoiding conflicts: pull often, keep branches small
    4. Recap
  4. Undoing mistakes

    Which undo to reach for, and how to get back work you thought was lost.

    1. Which undo should I use? (the panic flowchart)
    2. Undoing the last commit: soft, mixed, hard, or amend
    3. Reset vs revert, and undoing a pushed commit
    4. Recovering lost commits and deleted branches (git reflog)
    5. Recap
  5. GitHub: pushing, pull requests and forks

    Share branches, ask for changes to be merged, and contribute to projects you don't own.

    1. Pushing a feature branch and merging it into main
    2. What a pull request is and how to read one
    3. Contributing to a repo you don't own (fork, clone, pull request)
    4. Keeping your fork up to date (upstream)
    5. Recap

Made from these videos

More courses