Back
LearnGit & GitHub EssentialsMerge Conflicts & Pushing to GitHub

Merge Conflicts & Pushing to GitHub

1 min read

When does a conflict happen?

A merge conflict occurs when two branches change the same lines of the same file differently. Git can't decide which to keep, so it asks you.

<<<<<<< HEAD
const title = "Login";
=======
const title = "Sign In";
>>>>>>> feature-login
  • Above ======= → your current branch's version
  • Below → the incoming branch's version

To resolve: edit the file, keep the correct lines, delete the <<<<, ====, >>>> markers, then:

git add login.js
git commit        # completes the merge

Conflicts are normal — not errors. Stay calm and read both sides.

Pushing to GitHub

GitHub is a cloud host for Git repositories — for backup, sharing and collaboration.

# 1. Create an empty repo on github.com, then:
git remote add origin https://github.com/you/my-app.git

# 2. Push your main branch (first time)
git push -u origin main

# 3. After that, just:
git push

The everyday loop

git pull            # get teammates' latest changes
# ...work, then...
git add .
git commit -m "Describe your change"
git push            # share your work

That single loop — pull, commit, push — is 90% of daily Git. You now know enough to collaborate on real projects.

Tip