Commit and branch with Git
Put a project under local version control, commit your work and move between branches.
Git operations run through Py Editor Helper, so set Helper up first. Nothing on this page publishes your code.
Start a local repository
- Open the project folder in Py Editor.
- Click Commit in the left rail.
- If the panel says the folder is not a Git repository, choose Start a local repository. The Git chip in the toolbar offers the same action as Create Local Git Repository….
- Check that the toolbar now shows
mainand that your files are listed as untracked.
A project already under Git shows its branch name in the toolbar as soon as you open it.
Inspect a change before committing
- Save the change.
- Open Commit and click Refresh if the panel still reports a clean working tree.
- Click the filename, not its checkbox.
- Read the comparison: the left side is HEAD, the right side is Working Tree, and the header counts removed and added lines.
- Choose Close diff and return to the editor when you are done.
Opening the comparison also opens that file in an editor tab. It does not select the file for the commit.
Create a commit
- Open Commit.
- Select each file that belongs in this commit, or use Include all changed files after reading the list.
- Enter a short message in Commit Message describing the saved state.
- Click Commit.
- Wait for the panel to report a clean working tree.
Select Amend before committing when you want to replace the previous commit instead of adding a new one.
Read the history
- Open Git log in the Results dock, or choose Git → Show Git Log.
- Select a commit to inspect the changes it recorded.
- Click Refresh history after another Git operation if the list looks stale.
The history describes this repository on this Mac. A commit listed here does not exist on a server until you push it.
Create a branch and switch back
- Open the Git chip in the toolbar.
- Choose New Branch….
- Enter a branch name and choose Create. The toolbar switches to it.
- Open the chip again, choose Switch Branch ▸ and pick
mainto return.
Merge Branch ▸ merges another branch into the current one. Abort Merge or Abort Rebase appears in the same menu while a conflict is unresolved.
Work with a remote
Fetch, Pull, Pull with Rebase and Push… in the Git menu talk to a configured remote and can change history on both sides. Before using one, check the repository URL with Copy Repository URL, the current branch and the commits involved. Branch, fetch and pull operations need an up-to-date Helper; the toolbar offers Update Helper for Branches and Pull… when yours is too old.
Sign in to GitHub and set the name and email used for new commits in Application Settings → Source Accounts.