# Git Back To Main

> Discard local changes, switch to main, and pull latest Use when this capability is needed.

- Skill: `tomevault-io/git-back-to-main` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/git-back-to-main`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/git-back-to-main/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/git-back-to-main

---


# Git Back to Main

Abandon the current branch and return to a clean, up-to-date `main`.

## Instructions

1. Record the current branch name with `git branch --show-current`.
2. Discard all local changes (staged, unstaged, and untracked):
   ```
   git checkout -- .
   git clean -fd
   ```
3. Switch to main: `git checkout main`
4. Pull latest: `git pull origin main`
5. If the pull fails (e.g. diverged history), hard reset to origin:
   ```
   git fetch origin main
   git reset --hard origin/main
   ```
6. Report: previous branch name, current branch, and HEAD commit.

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/adamfilli) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-11 -->

