codex-lv2-may-2025

๐Ÿ“„ Git Beginner Cheat Sheet


โœ… Common Git Commands

Command What it Does
git init Starts a new Git repository
git status Shows changed, staged, and untracked files
git log Shows commit history
git add <filename> Stages a specific file
git add . Stages all changes
git commit -m "Your message" Commits staged changes
git push Pushes commits to the remote repo
git pull Fetches and merges remote changes

๐Ÿš€ ACP Workflow (Add, Commit, Push)

  1. Add
git add .
  1. Commit
git commit -m "Describe your changes"
  1. Push
git push

๐Ÿ”„ Update Before Pushing

Always pull to get the latest changes:

git pull

๐Ÿงจ Merge Conflicts

When pulling, conflicts may look like this:

<<<<<<< HEAD
Your local changes here
=======
Incoming changes from remote here
>>>>>>> branch-name

What to Do:

  1. Manually edit to fix the conflict Open the file in your code editor. Look for the conflict markers:

Decide which code to keep, or combine both parts if needed. Then delete the conflict markers and any unwanted lines.

Example: Before fixing:

<<<<<<< HEAD
console.log("Hello from my changes");
=======
console.log("Hello from the team's changes");
>>>>>>> main

After fixing:

console.log("Hello from my changes");
// or merge them:
console.log("Hello from my changes and the team's changes");
  1. Stage the resolved file:
git add <filename>
  1. Commit the merge:
git commit -m "Resolved merge conflict"

๐Ÿ” Restart: Undo All Changes Since Last Commit

Remove all changes (staged & unstaged) and start fresh:

git reset --hard

โš ๏ธ Warning: This cannot be undone! Changes since the last commit are lost forever.