Setup, Protection & Conflicts
Create the repo, lock main, and merge when you and the agent edit the same lines.
Learning objectives
- Create the GitHub repository and turn on branch protection before the first agent run
- Recognize a merge conflict
- Resolve it without letting the agent delete the other person’s work
Finish setup before the agent starts
The earlier chapters assume the repository exists. This is the checklist that makes the rest true. Do it once, in this order, on a empty project or on the booking app you already have.
- Create a new repository on GitHub named
studio. Leave it empty: no generated README, no license file, if you already have files locally. Two READMEs are the first conflict people hit. - On the laptop, in the app folder:
git init, a.gitignorethat excludes.envandnode_modules, then one commit, thengit remote add originandgit push -u origin main. Chapter 3 has those commands. - Set
user.nameanduser.emailfor the agent identity before you invite the tool to commit. Chapter 5. - On GitHub: Settings, Branches, add a rule for
main. Require a pull request. Do not allow force pushes. That is the lock on the audit trail. - Confirm the host deploys from
mainon GitHub, not from a folder the agent happens to have open.
If any box is unchecked, you do not have a system of record yet. You have a folder and a chat.
What a conflict is
A conflict happens when two commits change the same lines, and Git will not guess which lines to keep. Typical vibe-coding case: you fix a typo on main while the agent, on branch waitlist, rewrites that same paragraph. GitHub will not merge the pull request cleanly. The file contains markers like this:
<<<<<<< HEAD
The class is full. Join the waitlist.
=======
The class is full. Please call the studio.
>>>>>>> main
HEAD is your current branch, usually the agent’s branch if you are finishing the pull request there. The other side is the branch you are merging in, often main. Both versions are real work. Deleting a side because it looks older is how the typo fix or the waitlist disappears.
How to finish it
- Update the agent branch with
mainbefore you panic. From the branch:git fetch originthengit merge origin/main. - Open each conflicted file. Delete the marker lines. Keep the words you actually want, which may be a mix of both sides.
- Do not ask the agent to “resolve all conflicts” with no instruction. Tell it which sentence stays and which behavior stays. Then read the diff yourself.
git addthe files you resolved.git commit. Push the branch. The pull request updates. It does not rewritemain.
git switch waitlist
git fetch origin
git merge origin/main
# edit the conflicted files, remove the markers
git add app/reserve.php
git commit -m "Merge main and keep both the waitlist and the phone note"
git push
If a file still contains <<<<<<<, the app is not fixed. Search the repo for that string before you commit. An agent in a hurry will sometimes commit the markers and claim the conflict is resolved.
| Situation | Do this | Do not do this |
|---|---|---|
| Pull request says “conflicts” | Merge main into the feature branch and resolve there | Force-push main to match the agent |
| Both sides changed different functions in one file | Keep both functions | Pick “theirs” for the whole file |
| The agent already committed the marker lines | A new commit that removes them | A reset that drops the branch history |
Both sides are right
On main, the full-class message is “Please call the studio.” On waitlist, that same line is “Join the waitlist.” You want both: join the waitlist, and show the phone number under it. What belongs in the resolved file, and what command must not appear in the agent’s instructions?
Answer
The resolved file has the waitlist sentence and the phone number, and no conflict markers. Commit that on waitlist and push. The agent must not be told to git push --force or to check out one side with --theirs for the whole file.