Git Move - Move and Rename Files

VerifiedSafe

Move or rename files using `git mv` to preserve Git history and automatically stage changes. Avoids breaking history into delete+add operations. Use when reorganizing code structure or refactoring file locations.

Sby Skills Guide Bot
DevelopmentBeginner
6/2/2026
Claude CodeCursorWindsurfCopilotCodex
#git#file-management#refactoring#rename#move

Recommended for

Automated summary

Uses git mv to move or rename files while preserving Git history and automatically staging changes.

Strengths

  • Preserves file history by tracking renames
  • Automatically stages changes for commit
  • Prevents accidental overwrites
  • Shows as rename in git status

Limitations

  • Requires manual update of import statements to new paths
  • Does not automatically handle complex bulk moves
  • Only works within a Git repository
When to use it

When moving or renaming files in a Git repository to keep history intact and ensure safe, staged operations.

When not to use it

When you intentionally want to delete and recreate a file, or when working outside a Git repository.

Security analysis

Safe
Quality score85/100

The skill only instructs to use `git mv` for moving/renaming files within a git repository. No external tools, destructive commands, or network operations are involved. The `-f` flag is mentioned with a caution note, but it is a standard git feature. No significant security risk.

No concerns found

How this analysis is made

Examples

Rename a component
Rename the file components/OldButton.tsx to components/Button.tsx using git mv to preserve history.
Reorganize directory structure
Move the file src/old-component.tsx to src/components/new-component.tsx using git mv, preserving history and ensuring imports are updated.

name: git-move description: Move or rename files using git mv to preserve history. Use this when moving files, renaming files, or reorganizing code structure. Always prefer git mv over regular mv or filesystem operations.

Git Move Skill

Move or rename files using git mv to preserve git history and ensure proper staging.

When to Use

  • Moving files between directories
  • Renaming files
  • Reorganizing code structure
  • Refactoring file locations

Instructions

ALWAYS use git mv instead of regular file move operations when working in a git repository.

Basic Usage

# Move a file
git mv <source> <destination>

# Examples
git mv src/old-component.tsx src/components/new-component.tsx
git mv app/page.tsx app/(home)/page.tsx
git mv utils.ts lib/utils.ts

Moving Multiple Files

# Move all files matching a pattern
git mv src/utils/*.ts lib/utils/

# Move entire directory
git mv old-directory/ new-directory/

Benefits Over Regular mv

  1. Preserves history: Git tracks the file rename
  2. Auto-stages: Change is automatically staged for commit
  3. Safe operation: Fails if destination exists (prevents overwrites)
  4. Works with git status: Shows as renamed, not deleted+added

Examples

Rename a Component

git mv components/OldButton.tsx components/Button.tsx

Reorganize Directory Structure

# Create target directory first if needed
mkdir -p components/ui

# Move files
git mv components/button.tsx components/ui/button.tsx
git mv components/input.tsx components/ui/input.tsx

Move with Force (Overwrite)

# Use -f to overwrite existing destination (use carefully)
git mv -f source.ts destination.ts

Important Notes

  • After moving, update all import statements that reference the old path
  • Run type checking (pnpm tsc --noEmit) to find broken imports
  • Consider using an IDE refactoring tool for imports if available

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/git-move-move-and-rename-files-mm8o52e0/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/git-move-move-and-rename-files-mm8o52e0' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/git-move-move-and-rename-files-mm8o52e0/download' --output '.skill-downloads/git-move-move-and-rename-files-mm8o52e0/SKILL.md.part' && mv '.skill-downloads/git-move-move-and-rename-files-mm8o52e0/SKILL.md.part' '.skill-downloads/git-move-move-and-rename-files-mm8o52e0/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/git-move-move-and-rename-files-mm8o52e0/SKILL.md' && test -s '.skill-downloads/git-move-move-and-rename-files-mm8o52e0/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/git-move' && cp -R '.skill-downloads/git-move-move-and-rename-files-mm8o52e0' '.claude/skills/git-move'

Cursor
test -f '.skill-downloads/git-move-move-and-rename-files-mm8o52e0/SKILL.md' && test -s '.skill-downloads/git-move-move-and-rename-files-mm8o52e0/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/git-move' && cp -R '.skill-downloads/git-move-move-and-rename-files-mm8o52e0' '.cursor/skills/git-move'

Codex
test -f '.skill-downloads/git-move-move-and-rename-files-mm8o52e0/SKILL.md' && test -s '.skill-downloads/git-move-move-and-rename-files-mm8o52e0/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/git-move' && cp -R '.skill-downloads/git-move-move-and-rename-files-mm8o52e0' '.agents/skills/git-move'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/git-move-move-and-rename-files-mm8o52e0'

openskills read 'git-move-move-and-rename-files-mm8o52e0'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/git-move-move-and-rename-files-mm8o52e0/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills