Version Control
Version Control
Tracks code change history. Git is the standard. The foundation of collaboration.
Version Control
Tracks code change history. Git is the standard. The foundation of collaboration.
Version Control is a system that tracks and manages the change history of files. Beginning with SCCS (Source Code Control System) in 1972, and passing through CVS and Subversion, Git is now the de facto standard. In 2005, Linus Torvalds created Git for developing the Linux kernel.
The core concepts of version control are the commit, the branch, and the merge. A commit is a snapshot at a specific point in time, and a branch is an independent line of development. You use a branch to develop a new feature in an isolated environment, and when it is complete, you merge it into the main branch.
Git, a distributed version control system (DVCS), gives every developer the entire history locally. You can commit, create branches, and view history even without a network, and recovery is easy even if the central server fails. GitHub, GitLab, and Bitbucket provide Git hosting and collaboration features.
In practice, branching strategies such as Git Flow, GitHub Flow, and Trunk Based Development are used. Code review is conducted through Pull Requests (Merge Requests), and integration with CI/CD runs automated testing and deployment. Meaningful commit messages and atomic commits are the key to collaboration.
# Git ๊ธฐ๋ณธ ์ํฌํ๋ก์ฐ
# ์ ์ฅ์ ์ด๊ธฐํ/ํด๋ก
git init
git clone https://github.com/org/repo.git
# ์ํ ํ์ธ
git status
git log --oneline --graph -10
# ๊ธฐ๋ฅ ๋ธ๋์น ์์ฑ ๋ฐ ์์
git checkout -b feature/user-auth
git checkout -b feat/JIRA-123-login-api # JIRA ์ฐ๋ ์
# ๋ณ๊ฒฝ์ฌํญ ์คํ
์ด์ง ๋ฐ ์ปค๋ฐ
git add -p # ๋ณ๊ฒฝ์ฌํญ ๋ถ๋ถ ์ ํ
git add src/auth/
git commit -m "feat: implement JWT authentication
- Add JWT token generation and validation
- Configure token expiration to 24 hours
- Add refresh token rotation
Closes #123"
# ์๊ฒฉ ์ ์ฅ์์ ๋๊ธฐํ
git fetch origin
git rebase origin/main # ์ต์ main ์์ rebase
git push origin feature/user-auth
# Pull Request ์์ฑ ํ ๋จธ์ง
# (GitHub/GitLab UI์์ ๋ฆฌ๋ทฐ ๋ฐ ์น์ธ)
git checkout main
git pull origin main
git branch -d feature/user-auth # ๋ก์ปฌ ๋ธ๋์น ์ญ์
# ์ ์ฉํ ๋ช
๋ น์ด๋ค
git stash # ์์ ์ ์ฅ
git stash pop # ๋ณต์
git cherry-pick abc123 # ํน์ ์ปค๋ฐ๋ง ๊ฐ์ ธ์ค๊ธฐ
git revert abc123 # ์ปค๋ฐ ๋๋๋ฆฌ๊ธฐ (ํ์คํ ๋ฆฌ ์ ์ง)
git reset --soft HEAD~1 # ์ง์ ์ปค๋ฐ ์ทจ์ (๋ณ๊ฒฝ์ฌํญ ์ ์ง)
# ๋ธ๋์น ์ ๋ต ์์ (GitHub Flow)
# main: ํญ์ ๋ฐฐํฌ ๊ฐ๋ฅํ ์ํ
# feature/*: ๊ธฐ๋ฅ ๊ฐ๋ฐ
# hotfix/*: ๊ธด๊ธ ๋ฒ๊ทธ ์์
# .gitignore ์์
cat << 'EOF' > .gitignore
# Dependencies
node_modules/
vendor/
# Build output
dist/
build/
*.pyc
# Environment
.env
.env.local
*.local
# IDE
.idea/
.vscode/
*.swp
# OS
.DS_Store
Thumbs.db
# Logs
*.log
logs/
# Test coverage
coverage/
.nyc_output/
EOF
# Conventional Commits ํ์
# feat: ์ ๊ธฐ๋ฅ
# fix: ๋ฒ๊ทธ ์์
# docs: ๋ฌธ์ ๋ณ๊ฒฝ
# style: ์ฝ๋ ํฌ๋งทํ
# refactor: ๋ฆฌํฉํ ๋ง
# test: ํ
์คํธ ์ถ๊ฐ/์์
# chore: ๋น๋/์ค์ ๋ณ๊ฒฝ
Senior: "If a feature branch lives too long, conflicts are hard to resolve. It's better to merge frequently in small units."
Junior: "The feature isn't finished yet. Is it okay to merge?"
Senior: "You can use a Feature Flag. The code is in main, but if you disable it with the flag, users won't see it."
Interviewer: "Please describe your experience resolving Git conflicts."
Candidate: "When a conflict occurs during git rebase, I open the conflicted file and work out the intent of both changes. I fix simple text conflicts directly, and I discuss logic conflicts with the author of the code in question. Using VSCode's 3-way merge viewer or git mergetool makes it easier to resolve them visually."
Take a mock interview on this topic โ WIA SOOM AI Interview ยท Start for free
Reviewer: "The commit message only says 'fix bug'. Please write what you fixed and why."
Developer: "I'll change it to 'fix: prevent duplicate user registration' and write the cause and the solution in the body."