개발

Git 치트시트 - 빠른 명령 참조 및 메모

카테고리별로 정리된 검색 가능한 명령이 포함된 무료 온라인 Git 치트시트입니다. 분기, 병합, 리베이스, 저장, 재설정 등을 위한 Git 명령을 빠르게 찾으세요.

무료 사용 가입 불필요 브라우저에서 실행

도구 작업 영역

Setup & Config

git init

Initialize a new Git repository in the current directory

--bare
git clone <url>

Clone a remote repository to your local machine

--depth 1--branch <name>--recurse-submodules
git config user.name "<name>"

Set the author name for commits

--global--local--list
git config user.email "<email>"

Set the author email for commits

--global--local

Staging & Commits

git add <file>

Stage a file for the next commit

-A-p.
git commit -m "<message>"

Create a commit with a message

--amend--no-edit-a--allow-empty
git status

Show the working tree status

-s--short
git diff

Show unstaged changes

--staged--cached--stat--name-only
git log

Show commit history

--oneline--graph--all-n <number>--author=<name>

Branching & Merging

git branch

List, create, or delete branches

-a-d <branch>-D <branch>-m <new-name>
git checkout <branch>

Switch to a branch or restore files

-b <new-branch>--
git switch <branch>

Switch to a branch (modern alternative to checkout)

-c <new-branch>--detach
git merge <branch>

Merge a branch into the current branch

--no-ff--squash--abort
git rebase <branch>

Reapply commits on top of another branch

-i--onto--abort--continue

Remote

git remote -v

List remote repositories with URLs

add <name> <url>remove <name>rename <old> <new>
git fetch

Download objects and refs from a remote

--all--prune<remote>
git pull

Fetch and integrate changes from a remote branch

--rebase--no-rebase<remote> <branch>
git push

Upload local commits to a remote repository

-u origin <branch>--force--tags--delete <branch>

Stash

git stash

Temporarily save uncommitted changes

-u--include-untracked-m "<message>"
git stash pop

Apply the most recent stash and remove it from the list

git stash list

List all stashed changes

git stash drop

Remove a specific stash entry

stash@{n}
git stash apply

Apply a stash without removing it from the list

stash@{n}

Undo & Reset

git reset <file>

Unstage a file while preserving changes

--soft HEAD~1--mixed HEAD~1--hard HEAD~1
git revert <commit>

Create a new commit that undoes a previous commit

--no-commit-n
git restore <file>

Discard changes in the working directory

--staged--source=<commit>
git clean -fd

Remove untracked files and directories

-n (dry run)-x-i

Inspection

git log --oneline

Show compact commit history (one line per commit)

git log --graph --all

Visualize branch history as a graph

git show <commit>

Display details and diff of a specific commit

git blame <file>

Show who last modified each line of a file

git reflog

Show a log of all reference updates (useful for recovery)

git shortlog -sn

Summarize commit counts by author

Tags

git tag <name>

Create a lightweight tag at the current commit

git tag -a <name> -m "<msg>"

Create an annotated tag with a message

git tag -l

List all tags

"v1.*"
git push origin <tag>

Push a specific tag to a remote

--tags
git tag -d <name>

Delete a local tag

Git 치트시트란?

Git 치트 시트는 가장 일반적으로 사용되는 Git 명령을 범주별로 나열한 빠른 참조 가이드입니다. Git는 수백만 명의 개발자가 변경 사항을 추적하고, 코드에 대해 협업하고, 프로젝트 기록을 관리하는 데 사용하는 세계에서 가장 인기 있는 분산 버전 제어 시스템입니다. 수십 개의 명령과 수백 개의 옵션을 통해 숙련된 개발자라도 간결한 참조 자료를 쉽게 얻을 수 있습니다. 이 치트시트는 기본 설정 및 스테이징부터 대화형 리베이스, 스태시 관리, 기록 검사와 같은 고급 워크플로까지 모든 것을 다룹니다.

Git 치트시트 사용 방법

  1. 1설정, 준비, 분기, 원격, 보관, 실행 취소, 검사 및 태그 등 범주로 구성된 명령을 찾아보세요.
  2. 2검색 필드를 사용하여 키워드별로 명령을 필터링합니다. 'rebase', 'stash', 'reset' 또는 명령이나 설명의 일부를 입력하세요.
  3. 3각 명령에는 사용할 수 있는 구문, 간단한 설명, 일반 플래그 또는 옵션이 표시됩니다.
  4. 4터미널에서 즉시 사용할 수 있도록 명령 옆에 있는 복사 버튼을 클릭하여 클립보드에 복사하세요.
  5. 5각 명령 아래에 나열된 플래그를 사용하여 알지 못할 수도 있는 유용한 변형을 찾아보세요.

주요 활용 사례

일일 개발 워크플로우

브라우저를 떠나지 않고도 일상적인 개발 워크플로 중에 코드 커밋, 분기 및 푸시 명령을 빠르게 찾아보세요.

Git 학습 중

Git를 처음 사용하시나요? 정리된 범주를 탐색하여 명령을 발견하고 각 명령의 기능을 이해하고 공통 플래그와 옵션을 완성하세요.

병합 충돌 해결

충돌을 해결하거나 실수를 실행 취소해야 할 때 리베이스, 병합, 재설정 및 되돌리기에 적합한 명령을 찾으세요.

코드 검토 및 검사

git log, gitblame, git show와 같은 검사 명령을 사용하여 커밋 기록을 검토하고, 변경 사항을 이해하고, 코드 작성자를 추적하세요.

자주 묻는 질문

git merge와 git rebase의 차이점은 무엇입니까?

둘 다 한 지점의 변경 사항을 다른 지점으로 통합합니다. 'git merge'은 두 분기의 전체 기록을 보존하는 병합 커밋을 생성합니다. 'git rebase'은 대상 브랜치 위에서 커밋을 재생하여 선형 기록을 생성합니다. 공유 브랜치에서는 병합이 더 안전합니다. rebase는 병합 전 기능 분기에 대해 더 깨끗합니다.

마지막 커밋을 어떻게 취소하나요?

'git reset --soft HEAD~1'을 사용하여 커밋을 실행 취소하고 변경 사항을 스테이징 상태로 유지하세요. 커밋을 실행 취소하고 변경 사항을 스테이지 해제하려면 'git reset --mixed HEAD~1'을 사용하세요. 커밋을 실행 취소하고 모든 변경 사항을 삭제하려면 'git reset --hard HEAD~1'을 사용하세요. 커밋이 이미 푸시된 경우 대신 'git revert'을 사용하여 안전한 실행 취소 커밋을 만드세요.

git fetch와 git pull의 차이점은 무엇입니까?

'git fetch'은 원격 저장소에서 새 데이터를 다운로드하지만 작업 분기에 통합하지는 않습니다. 'git pull'은 기본적으로 'git fetch' 뒤에 'git merge'이 옵니다. 변경 사항을 가져와서 즉시 통합합니다. 병합하기 전에 변경 사항을 검토하려면 fetch를 사용하세요.