Git Troubleshooting Guide

Common problems and fixes for GitHub Desktop. If something isn’t covered here, ask a demonstrator.


“I can’t push — it says ‘rejected’”

What happened: Someone else pushed changes to the same branch since you last pulled.

Fix: Click Fetch origin, then Pull origin in GitHub Desktop. If there’s a merge conflict, see below. Then try pushing again.


“I have a merge conflict”

What happened: Two people edited the same part of the same file. Git doesn’t know which version to keep.

What it looks like: The file will contain conflict markers:

<<<<<<< HEAD
Your version of the line
=======
Their version of the line
>>>>>>> branch-name

Fix:

  1. Open the file in RStudio
  2. Find the <<<<<<< markers
  3. Decide which version to keep (or combine them)
  4. Delete the <<<<<<<, =======, and >>>>>>> lines
  5. Save the file
  6. In GitHub Desktop, commit the resolved file

Prevention: Pull before you start working. Work on different files when possible. Use branches.


“I accidentally committed to main instead of my branch”

What happened: You forgot to create or switch to your branch before making changes.

Fix (if you haven’t pushed yet):

  1. In GitHub Desktop: Branch → New Branch — give it a name
  2. Your uncommitted changes come with you to the new branch
  3. Commit on the new branch instead

Fix (if you already pushed to main): Ask a demonstrator. We can undo it, but it’s easier with help.


“I can’t find my branch”

What happened: The branch might only exist on GitHub (remote), not on your computer yet.

Fix: In GitHub Desktop, click Fetch origin to download the latest branch list from GitHub. Then use the branch dropdown to switch to it.


“It says ‘nothing to commit’”

What happened: You haven’t saved your file in RStudio, or you’re looking at the wrong repo in GitHub Desktop.

Fix:

  1. Save your file in RStudio (Ctrl+S / Cmd+S)
  2. Check that GitHub Desktop is pointing at the correct repository (top-left dropdown)
  3. The changed files should now appear in the left panel

“My pull request has conflicts”

What happened: The main branch changed after you created your branch, and those changes overlap with yours.

Fix:

  1. In GitHub Desktop, switch to main and pull
  2. Switch back to your branch
  3. Go to Branch → Update from main (or merge main into your branch)
  4. Resolve any conflicts (see above)
  5. Commit and push — the PR will update automatically

“I deleted a file by accident”

What happened: A file was removed and the change was committed.

Fix (if not yet committed): In GitHub Desktop, right-click the deleted file in the changes list and choose Discard changes.

Fix (if already committed): Ask a demonstrator — we can recover it from the Git history.


General tips

  • Pull before you push. Always fetch and pull before starting work.
  • Commit often. Small, frequent commits are easier to undo than large ones.
  • Write real commit messages. “Updated stuff” doesn’t help anyone. “Added temperature histogram to analysis” does.
  • Use branches. Don’t work directly on main. Create a branch, do your work, then open a pull request.
  • Ask for help early. Git problems get harder to fix the longer you wait.