>_FoxiRef
Git

Git Cheatsheet

Frequently used Git commands

#Setup

CommandDescription
git config --global user.name "[name]"Set user name
git config --global user.email "[email]"Set email
git config --listList all settings
git initInitialize new repository
git clone [url]Clone remote repository

#Basic Commands

CommandDescription
git statusCheck status
git add [file]Stage file
git add .Stage all changes
git commit -m "[message]"Create commit
git commit -am "[message]"Stage and commit
git pushPush to remote
git pullPull from remote
git fetchFetch without merge

#Branches

CommandDescription
git branchList branches
git branch [name]Create new branch
git checkout [branch]Switch branch
git checkout -b [name]Create and switch
git switch [branch]Switch branch (new)
git switch -c [name]Create and switch (new)
git merge [branch]Merge branch
git branch -d [name]Delete branch
git branch -D [name]Force delete

#History

CommandDescription
git logCommit history
git log --onelineOne line per commit
git log --graphShow graph
git log -pShow patches
git show [commit]Show commit details
git diffShow changes
git diff --stagedStaged changes
git blame [file]Show line authors

#Undo

CommandDescription
git restore [file]Discard changes
git restore --staged [file]Unstage file
git reset HEAD~1Undo last commit (keep changes)
git reset --hard HEAD~1Undo last commit (discard)
git revert [commit]Revert commit (new commit)
git clean -fdRemove untracked files

#Stash

CommandDescription
git stashStash changes
git stash save "[message]"Stash with message
git stash listList stashes
git stash popApply and remove stash
git stash applyApply stash (keep)
git stash dropDrop stash
git stash clearClear all stashes

#Remote

CommandDescription
git remote -vList remotes
git remote add [name] [url]Add remote
git remote remove [name]Remove remote
git push -u origin [branch]Set upstream and push
git push origin --delete [branch]Delete remote branch

#Tags

CommandDescription
git tagList tags
git tag [name]Create tag
git tag -a [name] -m "[msg]"Create annotated tag
git push origin [tag]Push tag
git push origin --tagsPush all tags

#Advanced

CommandDescription
git rebase [branch]Rebase
git rebase -i HEAD~[n]Interactive rebase
git cherry-pick [commit]Cherry-pick commit
git bisect startStart bisect
git reflogReference log
git submodule add [url]Add submodule

#Frequently Asked Questions

이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.

Git Cheatsheet - Command Reference | Foxi Dev Reference