Git 명령어
매일 사용하는 Git 명령어에 대한 실용적인 레퍼런스 - 브랜치 작업, 되돌리기, 병합과 rebase, 그리고 원격과의 동기화. 각 명령어마다 문법, 중요한 플래그, 그리고 터미널 플레이그라운드에서 라이브로 실행할 수 있는 복사·붙여넣기 예제가 있습니다.
설정과 구성
저장소를 시작하고 Git을 구성하세요 - init, config, remotes.
git initCreate a new Git repository in the current folder.git remoteList, add, rename, and change the remote repositories your repo points at.git submoduleEmbed one repository inside another and keep it pinned to a specific commit.git cloneCopy a remote repository, with all its history, to your machine.git clone branchClone only a specific branch of a repository, or a single branch only.git configSet your name, email, editor, and other Git settings - globally or per repo.
스테이징과 커밋
변경 사항을 히스토리에 기록하세요 - add, commit, amend.
브랜치 작업
브랜치를 만들고, 전환하고, 이름을 바꾸고, 삭제하여 변경 사항을 격리된 상태로 작업하세요.
git delete local branchDelete a local branch once its work is merged - and force-delete when it is not.git rename branchRename the branch you are on, or any other branch, locally and on the remote.git create branchCreate a new branch and switch to it, from the current commit or any starting point.git checkoutSwitch branches, restore files, or check out a specific commit.git checkout remote branchFetch and check out a branch that exists on the remote but not yet locally.git branchList, create, rename, and delete branches - the core branch command.git worktreeCheck out multiple branches at once in separate working directories.
변경 사항 되돌리기
실수를 복구하세요 - reset, revert로 커밋을 안전하게 되돌립니다.
git undo commitUndo any commit - an older one, several at once, or one that is already pushed.git resetMove HEAD and choose what happens to the index and working tree: --soft, --mixed, --hard.git revertUndo a commit safely by adding a new commit that reverses it - the right choice for pushed history.git undo last commitUndo just the most recent commit - keep the work, discard it, or reverse it if it was pushed.git reset --hardForce your branch and working tree back to a commit, discarding all changes since it.git stashShelve your uncommitted changes so you can switch context, then reapply them later.git reflogSee everywhere HEAD has been - and recover commits you thought were lost.
병합과 리베이스
merge, rebase, squash, cherry-pick으로 두 브랜치의 작업을 합칩니다.
git rebase vs mergeTwo ways to combine branches: a merge commit that preserves history, or a linear replay.git squash commitsCombine several commits into one with interactive rebase for a clean history.git abort mergeCancel a merge in progress and return the branch to the state before you started.git cherry-pickApply a specific commit from one branch onto another, without merging the whole branch.git mergeCombine another branch into your current one, with or without a merge commit.git rebaseReplay your commits on top of another branch for a clean, linear history.
원격 저장소
로컬 저장소를 GitHub 같은 원격과 동기화하세요 - push, pull, fetch.
git fetch vs pullThe difference between downloading remote changes and downloading-and-merging them.git force pushOverwrite the remote branch with your local history - and do it safely with --force-with-lease.git pullDownload remote changes and merge them into your current branch in one step.git pushUpload your commits to a remote and set the upstream branch.git delete remote branchDelete a branch on the remote (GitHub) once it is merged - and locally too.git set upstreamLink a local branch to a remote branch so push and pull need no arguments.git pull remote branchPull changes from a specific remote branch into your current branch.
검사와 정리
무엇이 바뀌었는지 확인하고 작업 트리를 정리하세요 - status, log, diff, clean.
git remove untracked filesClean untracked files and directories out of the working tree with git clean.git tagMark a commit with a version tag, and push tags to the remote.git statusSee which files are staged, modified, or untracked in your working tree.git diffSee exactly what changed - unstaged, staged, between commits or branches.git bisectBinary-search your history to find the commit that introduced a bug.git logBrowse commit history, with a compact one-line and graph view.