Codex

Code management: Git and GitHub

Git and GitHub concepts, reviewable development and isolated worktree experiments.

Git records local changes, GitHub hosts collaboration, and Codex performs coding tasks. Together they support review, rollback, isolated experiments and pull requests.

#Git versus GitHub

DimensionGitGitHub
PurposeLocal version controlHosted repositories and collaboration
LocationYour computerBrowser/cloud service
Operationscommit, branch, diff, mergerepositories, issues, PRs, Actions
NetworkNot needed for local operationsRequired for remote service operations
With CodexInspect and save generated changesCollaborate and use connected cloud workflows

#Essential Git concepts

ConceptMeaning
RepositoryProject and version history
CommitA saved change with a message
BranchAn independent line of development
DiffComparison of changed lines
StageSelect changes for the next commit
MergeCombine changes from branches
ConflictOverlapping changes that require resolution
PushSend commits to a remote
PullFetch and integrate remote changes
CloneCreate a local checkout of a remote repository

#Essential GitHub concepts

ConceptMeaning
RepositoryHosted Git project
IssueA recorded problem or request
Pull requestA proposed merge for review
Main branchThe shared stable development line
Feature branchA branch for a specific change
ReviewInspection before merging
ActionsAutomated tests, builds and other workflows
READMEProject documentation
.gitignoreFiles excluded from ordinary tracking

#Why Codex work benefits from Git

A task can change many files. Git provides:

  • Review: see exactly what changed with git diff.
  • Recovery: return to a known-good version.
  • Milestones: save coherent steps as commits.
  • Isolation: experiment on branches or worktrees.
  • Collaboration: use push, PR, review and merge.

A saved baseline makes larger changes easier to inspect and recover. Version control is not a substitute for reviewing destructive commands, but it gives you a concrete history.

#A standard Git workflow with Codex

1

Initialize the repository

Run git init at the project root if the project is not already version-controlled.

2

Create .gitignore

Ask Codex to exclude node_modules, .env and other untracked build or secret files according to the stack.

3

Save an initial commit

Before editing, inspect what will be staged and save a baseline: git add -A && git commit -m "init".

Initialize Git in Codex
4

Create a task branch

For example, git checkout -b feat/add-login keeps a task separate from the main branch.

5

Implement the task

Describe the outcome and let Codex inspect code, edit and run relevant commands.

6

Review the diff

Use git diff or the IDE to verify that the change matches your intent.

7

Validate

Run tests or start the application and reproduce the required behavior. Resolve failures before proceeding.

8

Commit

Review staged files, then save the change: git add -A && git commit -m "feat: describe the change".

9

Push

Use git push origin feat/add-login to publish the task branch.

10

Open a PR

Open a pull request and merge after the required review and checks.

#Before pushing to GitHub

RequirementDescription
AccountRegister and authenticate
Local GitInstall Git and initialize the project
RepositoryCreate or select the remote repository
AuthenticationConfigure SSH or an appropriate access token
.gitignoreExclude sensitive/unnecessary files

Give Codex the intended repository URL and explicitly request the push; it can configure the remote and initial push within that scope.

#Roll back code

1

Find the target version

Use git log --oneline or the IDE history to identify the target commit, for example a3f8c12.

2

Describe the recovery you want

For example: “Return to commit a3f8c12 while retaining subsequent work as uncommitted changes.” The command depends on whether you want to preserve local changes or shared history.

A hard reset can discard uncommitted changes. Save or stash valuable work before destructive recovery operations.

#Git worktrees: an independent working copy

Switching branches changes a normal checkout's files. A worktree lets the same repository have several independent working directories at once.

#Why use a worktree

ScenarioBenefit
Experiment with CodexKeep the main directory untouched
Parallel tasksSeparate checkout per task
Compare approachesIndependent A/B/C directories
Discard an experimentRemove the unneeded checkout after reviewing its state
Large refactorMerge only after validating the isolated change

#Basic commands

# Create a new branch and checkout next to the main project.
git worktree add -b feat/experiment ../my-project-experiment

# List checkouts.
git worktree list

# After review and merge, remove the worktree and merged branch.
git worktree remove ../my-project-experiment
git branch -d feat/experiment

Typical flow: continue normal work in the main directory, create a worktree for Codex, review its diff, then merge or remove it after checking for valuable uncommitted changes.

Git worktree

Point Codex at the worktree directory, for example cd ../my-project-experiment && codex "...", or explicitly identify the working directory in the task.

Support

Need help?

For setup, billing, or model issues, email us. Check the status page for uptime.

WeChat / QQ support is available at the bottom right.