C.W.K.
Stream
Lesson 05 of 05 · published

identity, default, .gitignore

~18 min · config, gitignore, setup

Level 0Untracked 새싹
0 XP0/47 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

identity, default, ignore file

모든 프로젝트보다 오래 가는 setup 세 가지가 있어: commit 안에서 너 누구인지, default 어떤 거 받아들일지, 뭘 추적 거부할지. 이거 건너뛰면 나중에 bug 로 다시 만나. 몇 년치 commit 에 잘못된 author, master branch 가 깜짝 등장, secret token 이 history 에 새는 식으로.

Git 은 모든 commit 에 이름과 email 을 박아. global 로 한 번 설정해. email 은 실제 거 안 써도 돼 — GitHub noreply 주소 많이 써서 scraping 피해. 하는 김에 init.defaultBranchmain 으로, 합리적인 default editor 설정, pull.rebase 를 true 로 해서 blind git pull 이 mystery merge 안 만들게. config 는 system / global / local 세 층이고 local 이 항상 이겨. git config --list --show-origin 은 각 값이 어느 파일에서 왔는지 알려줘 — 깜짝 놀랄 때 디버깅 황금이야.

.gitignore 는 '이거 history 에 들어가면 안 돼' 의 답이야. repo 안 그냥 파일이고 한 줄에 한 pattern: build output, dependency 폴더, OS 쓰레기, editor swap file, 그리고 결정적으로 .env, private key, credential dump 같은 secret. 함정: .gitignore 는 untracked file 만 영향 줘. .env 한 번이라도 commit 했으면 ignore 추가해도 추적 계속돼. git rm --cached .env 먼저 해야 해. 그리고 진짜 secret 이 들어 있었으면 노출됐다고 보고 rotate — Git history 는 영원해, 삭제 후에도.

습관 하나 더: 호스트 하나라도 (default 는 GitHub) SSH key 붙여. HTTPS 도 되지만 SSH + agent 가 매일 password 프롬프트 없애주고 표준 개발자 경험이야. ssh-keygen -t ed25519 -C "you@example.com", .pub 절반을 GitHub 에 복사하면 그 다음부터 clone 할 때 credential 안 쳐도 돼.

Code

1회 global setup·bash
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
git config --global pull.rebase true
git config --global core.editor "code --wait"  # 또는 vim, nano

# 각 값 어디서 왔는지?
git config --list --show-origin
출발용 .gitignore·text
# Build & deps
node_modules/
dist/
build/
__pycache__/
*.pyc

# Editor & OS
.vscode/
.idea/
.DS_Store
Thumbs.db
*.swp

# Secret — 절대 commit 금지
.env
.env.*
*.pem
*.key
credentials.json
secret 을 이미 commit 했어. 어떻게?·bash
# 추적 중지 (디스크엔 남김)
git rm --cached .env
echo '.env' >> .gitignore
git add .gitignore
git commit -m "Stop tracking .env and ignore it going forward"

# 중요: secret 은 이전 commit 에 여전히 있어.
# 즉시 rotate. git filter-repo / BFG 로 history rewrite 가능하지만,
# 노출됐다고 가정하고 비밀번호/토큰 자체를 바꿔.

External links

Exercise

실제 머신에서 git config --list --show-origin 돌리고 출력 읽어. 추가하거나 고칠 setting 세 개 결정해 (이름/email/default branch/pull 동작/editor). global 에 박아. 그 다음 git init 으로 새 repo 만들고, 실제 쓰는 언어 기준 .gitignore 시작판 추가하고 commit. git status 가 일부러 추적 안 할 path 적어도 하나는 ignore 하는지 확인해.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.