Communitygithub.com

G1Joshi/Agent-Skills

전문적인 Git 버전 관리 지원: 브랜칭, 대화형 리베이스, 체리픽, 서브모듈, 워크트리, 충돌 해결 등을 다룹니다. 소스 코드 히스토리와 협업 워크플로우 관리 시 사용하세요.

Agent-Skills란 무엇인가요?

이 스킬은 AI 에이전트가 Git 버전 관리 작업을 수행할 수 있도록 하는 종합 가이드입니다. 브랜칭, 대화형 리베이스, 체리픽, 서브모듈, 워크트리, 충돌 해결 등 Git의 핵심 개념과 고급 기능을 다룹니다. 특히 세 가지 트리 아키텍처(워킹 트리, 인덱스, HEAD), DAG 기반의 불변 객체 모델, `git switch`와 `git restore` 같은 최신 명령어 사용법을 자세히 설명합니다. 대규모 모노레포에서의 성능 최적화(Git Sparse Checkout, Scalar), `git bisect`를 활용한 자동화된 버그 탐지, `git worktree`를 이용한 멀티 브랜치 개발 패턴 등 실무에서 유용한 심화 주제도 포함되어 있습니다. 이 스킬은 Cursor, Claude Code 등 다양한 AI 에이전트 플랫폼에서 사용할 수 있습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/G1Joshi/Agent-Skills/tree/HEAD/skills/tools/git

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Git

Git은 현대 소프트웨어의 기초입니다. 2025년에는 Sparse Checkout과 Scalar(모노레포용) 같은 기능이 주류가 되고 있습니다.

사용 시점

  • 브랜칭 및 협업: 분산 팀 간의 기능 분리, 풀 리퀘스트, 트렁크 기반 개발, 코드 리뷰 관리.
  • 히스토리 재작성 및 정리: git rebase -i를 사용하여 커밋 그래프 선형화, WIP 커밋 스쿼시, 메시지 편집 후 메인라인 브랜치에 병합.
  • 자동화된 버그 사냥: git bisect를 사용한 이진 탐색으로 수천 개의 리비전 중 회귀를 유발한 커밋 격리.
  • 동시 작업 공간 컨텍스트: git worktree를 사용하여 스태시나 브랜치 전환 없이 긴급 핫픽스 작업.
  • 대규모 저장소 확장: Git Sparse Checkout, Scalar, 얕은 클론을 사용하여 거대한 모노레포의 성능 최적화.

빠른 시작

# 저장소를 클론하고 새로운 기능 브랜치 생성
git clone https://github.com/myorg/project.git
cd project

# 최신 명령어로 새 브랜치 생성 및 전환
git switch -c feature/auth-flow

# 스테이징, 커밋, 그리고 업스트림 추적을 포함한 푸시
git add .
git commit -m "feat(auth): oauth2 인증 코드 플로우 구현"
git push -u origin feature/auth-flow

핵심 개념

3-트리 아키텍처 (워킹 트리, 인덱스, HEAD)

Git은 단순히 리비전 간 변경 사항을 추적하는 대신 파일을 세 가지 뚜렷한 상태로 관리합니다:

# 1. 워킹 트리: 편집기에서 수정되었지만 커밋되지 않은 파일
echo "export const API_URL = 'https://api.v2.internal';" >> config.ts

# 2. 인덱스 (스테이징 영역): 다음 커밋을 위해 준비된 내용
git add config.ts

# 3. HEAD: 활성 브랜치의 마지막 커밋 스냅샷
git diff --staged  # 스테이징과 HEAD 간의 차이 검사
git commit -m "chore(config): 내부 API 엔드포인트 업데이트"

방향성 비순환 그래프(DAG)와 불변 객체

Git의 모든 커밋은 부모 해시와 블롭 스냅샷의 루트 트리를 가리키는 불변 노드입니다.

# 모든 커밋 해시나 HEAD 뒤의 원시 객체 검사
git cat-file -p HEAD
# 출력:
# tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
# parent 8f3d1e1c3a628a58a98b47cf7d12a9e32049e712
# author Alice <[email protected]> 1727420400 +0000
# committer Alice <[email protected]> 1727420400 +0000
#
# feat(auth): oauth2 인증 코드 플로우 구현

최신 브랜치 탐색 (git switch vs git restore)

최신 Git은 과부하된 git checkout 명령어를 전용 명령어로 분리했습니다:

# 브랜치 전환 (git checkout <branch> 대체)
git switch main
git switch -c feature/payments   # 생성 및 전환

# 파일 복원 (git checkout -- <file> 대체)
git restore src/app.ts           # 커밋되지 않은 워킹 디렉토리 변경 사항 폐기
git restore --staged src/app.ts  # 인덱스에서 파일을 언스테이지하여 워킹 트리로 되돌림

리베이스 vs 병합 전략

  • 병합 (git merge <branch>): 부모가 둘인 병합 커밋을 통해 완전한 기록 컨텍스트를 유지합니다. 장기 릴리스 브랜치 통합에 이상적입니다.
  • 리베이스 (git rebase <upstream>): 토픽 커밋을 업스트림 HEAD 위에 선형으로 재배치하여 얽힌 "철로" 그래프를 방지합니다. PR 검토 전 기능 브랜치 정리에 이상적입니다.
# 기능 브랜치를 최신 main 위에 깔끔하게 리베이스
git switch feature/auth-flow
git fetch origin main
git rebase origin/main

일반적인 패턴

Git Worktrees를 사용한 멀티 브랜치 개발

문제: 긴급 프로덕션 버그를 수정하기 위해 브랜치를 전환하려면 커밋되지 않은 작업을 스태시해야 함.

해결책: 여러 브랜치를 동시에 별도의 디렉토리에 체크아웃합니다:

# 핫픽스 브랜치용 병렬 워크트리 폴더 생성
git worktree add ../hotfix-branch main

# 현재 작업 공간을 건드리지 않고 별도 디렉토리에서 핫픽스 작업
cd ../hotfix-branch
git commit -am "fix: 중요한 인증 취약점 패치"
git push origin hotfix-branch

# 완료 후 워크트리 정리
cd ../project
git worktree remove ../hotfix-branch

깔끔한 풀 리퀘스트 히스토리를 위한 대화형 리베이스

문제: 기능 브랜치에 수많은 지저분한 "WIP", "fix typo", "checkpoint" 커밋이 있음. 해결책: 풀 리퀘스트를 열기 전에 대화형으로 스쿼시하고 히스토리를 정리합니다.

# 마지막 4개 커밋을 대화형으로 리베이스
git rebase -i HEAD~4

# 대화형 편집기에서:
# pick 8f3d1e1 feat(auth): 토큰 생성 추가
# squash 4b825dc 토큰 페이로드 오타 수정
# squash a1c94e2 누락된 임포트 추가
# reword 91f7a02 feat(auth): 리프레시 토큰 엔드포인트 추가

Git Bisect를 사용한 자동화된 회귀 탐지

문제: 500개의 커밋 사이에 버그가 도입되었지만 정확한 커밋을 알 수 없음. 해결책: 자동화된 테스트 실행 스크립트로 이진 탐색을 실행합니다.

# bisect 세션 시작
git bisect start
git bisect bad HEAD                  # 현재 HEAD가 깨짐
git bisect good v2.1.0               # v2.1.0은 정상 작동이 확인됨

# 각 bisect 단계에서 자동으로 테스트 스크립트 실행
git bisect run npm test -- --runInBand

# Git은 테스트 스위트를 깨뜨린 정확한 첫 번째 커밋에서 종료
git bisect reset

모범 사례 (2026)

권장 사항:

  • git switch와 git restore 사용: 과부하된 git checkout을 피하여 실수로 브랜치 전환이나 파일 덮어쓰기를 방지하세요.
  • --force-with-lease로 푸시: 원격 브랜치에서 동료의 커밋을 덮어쓰지 않도록 보호하세요.
  • 백그라운드 유지 관리 활성화: git maintenance start를 실행하여 팩파일, 커밋 그래프, fetch 성능을 최적화하세요.
  • SSH/GPG로 커밋 서명: 프로덕션 파이프라인에서 커밋 작성자의 진위성을 보장하세요.
  • 규칙적인 커밋 메시지 작성: 표준화된 접두사(feat:, fix:, chore:, refactor:)를 사용하여 시맨틱 버저닝과 체인지로그를 자동화하세요.

금지 사항:

  • 보호된 브랜치에 강제 푸시 금지: main, master 또는 공유 릴리스 브랜치의 히스토리를 재작성하지 마세요.
  • 시크릿이나 자격 증명 커밋 금지: .gitignore와 git-secrets/trufflehog를 사용하세요. 한 번 커밋되면 나중에 삭제하더라도 자격 증명이 팩파일 블롭에 남습니다.
  • 대용량 바이너리 파일 직접 사용 금지: 대규모 모델 가중치나 미디어는 Git LFS(Large File Storage)나 S3에 저장하세요.
  • 더티 워킹 트리 병합 금지: 풀 또는 리베이스 전에 변경 사항을 스태시하거나 커밋하여 우발적인 파일 충돌을 방지하세요.

문제 해결

오류원인해결 방법
fatal: refusing to merge unrelated histories공유 루트 커밋 없이 독립적으로 초기화된 저장소에서 풀할 때 발생.git pull origin main --allow-unrelated-histories 실행.
HEAD detached at ...브랜치 이름 대신 특정 커밋 해시를 체크아웃함.현재 위치에서 브랜치 생성: git switch -c recovery-branch.
Merge conflict in file.txt동시 커밋이 반대 브랜치에서 동일한 라인을 수정함.충돌 마커(<<<<<<<) 해결, 파일 스테이징(git add), git commit 실행.

참고 자료

Individual skills in this repo

This repo contains 11 individual skills — each has its own dedicated page.

G1Joshi/Agent-Skills

Expert Dask distributed computing assistance covering Dask DataFrames, Arrays, Futures, and cluster scaling. Use when analyzing datasets too large for pandas on a single machine or multi-node cluster.

G1Joshi/Agent-Skills

Expert dbt (data build tool) assistance covering SQL modeling, Jinja macros, tests, documentation, and semantic layer. Use when building analytics engineering pipelines on BigQuery, Snowflake, or PostgreSQL.

G1Joshi/Agent-Skills

Expert JAX assistance covering Autograd, XLA compilation (`jit`), vectorization (`vmap`), and parallelization (`pmap`). Use when building high-performance numerical computing and cutting-edge deep learning research.

G1Joshi/Agent-Skills

Expert Ray distributed computing assistance covering Ray Core (actors, tasks), Ray Train, Ray Tune, and Ray Serve. Use when scaling Python compute and ML training across multi-node clusters.

G1Joshi/Agent-Skills

Expert K9s CLI assistance covering terminal Kubernetes cluster navigation, real-time log streaming, port forwarding, and pod debugging. Use when managing and troubleshooting Kubernetes clusters with speed.

G1Joshi/Agent-Skills

Expert SWC assistance covering high-performance Rust-based JavaScript/TypeScript compilation, .swcrc configuration, Jest testing via @swc/jest, and minification. Use when replacing Babel with SWC for faster builds, accelerating test execution, or compiling modern ECMAScript features.

G1Joshi/Agent-Skills

Expert Tig assistance covering text-mode interface for Git, interactive staging, commit graph visualization, diff exploration, and blame navigation. Use when navigating Git commit history in the terminal, staging hunks interactively, browsing file changes, or reviewing revisions.

G1Joshi/Agent-Skills

Expert Vim assistance covering modal editing, .vimrc configuration, registers, macros, search/replace, and plugin management via vim-plug. Use when editing text efficiently in terminal environments, writing Vimscript, recording macros, or configuring core Vim settings.

G1Joshi/Agent-Skills

Expert Zed editor assistance covering high-performance Rust-based text editing, multi-buffer editing, language server protocols (LSP), and AI assistant integrations. Use when configuring Zed settings.json, setting up language extensions, collaborating in real-time channels, or optimizing editor startup speed.

G1Joshi/Agent-Skills

Expert Zsh assistance covering shell customization, Oh My Zsh plugins, Zinit plugin manager, prompt engineering (Starship/Powerlevel10k), and shell scripting. Use when configuring .zshrc, writing Zsh automation scripts, optimizing shell startup time, or configuring tab-completion.

G1Joshi/Agent-Skills

Expert [skill-name] assistance covering [feature 1], [feature 2], and [feature 3]. Use when [working with X], [debugging Y], or [implementing Z].

관련 스킬