2022.12 12 ~
mkdir [new folderName]
rm -rf [delete folderName]
git init
git remote add origin [repo addr]
git add .
git commit -m"[commit comment]"
git log --oneline
git revert [revert version]
git reset --soft/hard/mixed [reset version]
git push/pull origin [branch]
git branch -m [branch]
git clone [repo addr]
VsCode 단축키
ctrl + shift + ~ : TERMINAL ON
git config --global init.defaultBranch main
//git init하면 default branch main으로
git branch -m main
//branch를 main으로
git switch -c [new branchName]
git switch [branchName]
//checkout보다 switch
git branch --list
git branch -d [delete branchName]
rm -rf .git
git merge [merge할 branchName]
//실무에선 command로 merge할 일은 없음
git log --oneline --graph --decorate
git merge [merge할 branchName] --no-ff
//fast-forward로 merge 안 하게
git rebase [rebase할 branchName]
git fetch --prune
//pr하고 삭제된 branch 정리
//로컬 브랜치도 -d로 삭제(띄어쓰기로 구분)
📑 Github default branch 변경하기 (master to main)
git branch -m master main
git push -u origin main
clone의 경우
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a
📑 How do I delete a Git branch locally and remotely?
git push -d [remoteName] [branchName]
git branch -d [branchName]
Note: In most cases, [remoteName] will be origin.
git pull [remoteName] [branchName] --no-ff
//git pull error시
commit 본문을 쓰기보단 PR 본문을 쓰는 게 효율적
📑 How do I undo 'git add' before commit?
git reset [file]
if this tried then
fatal: Failed to resolve 'HEAD' as a valid ref.
solution
git rm -r --cached [file]