환경설정
git config --global core.editor "nvim" 편집기를 기본값 vim이 아닌 neovim 사용
로그 보기
옵션 설명
--oneline 한 줄로 요약해서 보여줌--graph 브랜치가 갈라지고 합쳐진 것을 보여줌-(숫자) 해당 수만큼 최신 로그를 보여줌용례
git log --graph --oneline
관련 내용 StackOverflow: Revert a range of commits in git
A -> B -> C -> D -> E -> HEAD
현재부터 B로 돌아가기 위해선
git revert B^..D
git rebase <target> = "Rebase myself after head of target"git rebase main// before
feature: A---B---C---D ← feature's commits (you are here)
main: A---B---E---F ← main's head
// after `git rebase main`
feature: A---B---E---F---C'---D' ← rebase myself after main's head
main: A---B---E---F ← main's head
rebase를 하면 해당 브랜치의 commit 이력이 재작성된다. 이는 다른 공동 작업자가 이 브랜치에 pull, push 할 때 충돌을 일으킨다.
# Safe: Rebasing private work onto public base
git checkout private-branch
git rebase public-branch # ✅ okay
# Dangerous: Rebasing public commits
git checkout public-branch
git rebase any-branch # ❌ DANGEROUS!
push -ugit push, git pull 에서 remote/branch 명시 불필요# Without -u, you have to specify remote and branch every time
git push origin main
git pull origin main
# After using -u:
# First time with -u
git push -u origin main
# Now Git remembers the connection, so you can just use:
git push # Git knows to push to origin/main
git pull # Git knows to pull from origin/main
git status # Shows "ahead/behind" info relative to origin/main