Slowbeam.dev
Software Development

내가 쓰려고 기록해두는 Git 명령어 사용법(+remote)

language
kor
date
Jan 1, 2026
slug
GitCommand
author
status
Public
tags
Git
Remote
summary
내가 가끔 필요한 터미널에서의 Git 명령어를 정리한 글
type
Post
thumbnail
다운로드.png
category
Software Development
updatedAt
Dec 31, 2026 05:43 PM
하루 종일 개발만 하고 있고 소프트웨어 개발이 Main 업무라면 헷갈릴 일도 없을텐데, 대부분 Visual Studio나 VS code에서 제공하는 Git GUI에 익숙해져서 Git 명령어가 생각나지 않을 때가 많다. 일반적인 개발 및 버전 관리는 그런 IDE에서 제공하는 수준으로도 충분하기 때문에 큰 문제가 없지만 한 번씩 터미널에서 명령어를 입력해야할 때마다 인터넷 검색을 하거나 ChatGPT의 도움을 받아서 사용을 하다보니 불필요한 시간이 걸린다. 시간을 내서 내가 필요한 부분만 정리해보았다.

0) 최초 1회 – 사용자 환경 설정

git config --global user.name "홍길동" git config --global user.email "gildong@example.com" # (윈도우 권장) 체크아웃은 CRLF, 커밋은 LF git config --global core.autocrlf true
SSH 쓰면:
# 키 없으면 생성 ssh-keygen -t ed25519 -C "gildong@example.com" # 공개키를 Gitea 웹 > Settings > SSH Keys에 등록 type ~/.ssh/id_ed25519.pub # Windows PowerShell cat ~/.ssh/id_ed25519.pub # Linux/macOS

1) 새 프로젝트 시작(로컬에 코드 O)

Gitea 웹에서 New Repository → 빈 레포 생성(예: vision-utils).
cd ~/work/vision-utils # 프로젝트 폴더 git init git add . git commit -m "Initial commit" git branch -M main # SSH URL 예시(회사마다 다름) git remote add origin ssh://git@<gitea_host>:222/<org>/<repo>.git git push -u origin main
▶ HTTPS를 쓰면:
git remote add origin https://<gitea_host>/<org>/<repo>.git git push -u origin main # 비밀번호 대신 Personal Access Token 입력

2) 기존 프로젝트 참여(클론 → 브랜치 → PR)

git clone ssh://git@<gitea_host>:222/<org>/<repo>.git cd <repo> # 작업용 브랜치 git switch -c feature/cali-ui # 수정/저장 후 git add . git commit -m "Add calibration overlay" git push -u origin feature/cali-ui
→ Gitea 웹에서 Pull Request 열고 리뷰/머지.

3) 매일 쓰는 기본 명령(치트시트)

업데이트 받기

git switch main git pull --ff-only # fast-forward로 최신 반영 kaka

변경 작업

git switch -c fix/bug-101 # 또는 기존 브랜치로 이동: git switch feature/xxx # 파일 수정 git add <파일/폴더> # 전부: git add . git commit -m "설명" git push # 최초 푸시는 -u 생략 가능(이미 upstream 설정했으면)

최신 main과 맞추기(충돌 최소화)

git fetch origin git rebase origin/main # 내 브랜치를 main 위로 재정렬 # 충돌나면 파일 수정 → git add <수정파일> → git rebase --continue git push --force-with-lease

리뷰 반영 후 머지 버튼 대신 로컬에서 머지하고 싶을 때

git switch main git pull --ff-only git merge --no-ff feature/cali-ui git push

되돌리기(실수 방지형)

git restore <파일> # 워킹트리 변경 취소 git restore --staged <파일> # add 취소 git revert <커밋해시> # 되돌리는 새 커밋 생성(공유 브랜치 안전)

태그/릴리스

git tag -a v1.0.0 -m "first release" git push origin v1.0.0 # Gitea Releases 탭에서 릴리스 노트 작성 가능

4) Git LFS(대용량 파일) – 서버에서 LFS가 켜져 있을 때

git lfs install # 최초 1회 git lfs track "*.bin" "*.pt" # 추적 패턴 git add .gitattributes git add large_model.pt git commit -m "Track with LFS" git push

5) .gitignore 빠르게 만들기(예: C++/Python 혼합)

레포 루트에 .gitignore 생성:
# build outputs build/ dist/ *.o *.obj *.exe # Python __pycache__/ *.pyc .venv/ # IDE .vscode/ .idea/
커밋:
git add .gitignore git commit -m "Add .gitignore" git push

6) .gitignore(Visual Studio 용)

# --- Build / Binaries --- build/ build-*/ out/ bin/ obj/ *.o *.obj *.so *.dll *.lib *.a *.exe *.pdb *.ilk *.exp # --- CMake --- CMakeFiles/ CMakeCache.txt cmake-build-*/ install_manifest.txt _compile_commands.json Makefile CTestTestfile.cmake *.cmake.user # --- Visual Studio / MSBuild --- .vs/ Debug*/ Release*/ x64/ x86/ ipch/ *.sdf *.opensdf *.vcxproj.user *.vc.db *.user *.log # --- Visual Studio Code / JetBrains --- .vscode/ .vscode-test/ .idea/ *.iml # --- Python --- __pycache__/ *.pyc *.pyo *.pyd *.egg-info/ .eggs/ .venv/ venv/ .env .env.* dist/ build/ pip-wheel-metadata/ # --- Notebooks / data (원하면 주석 해제) --- # *.ipynb_checkpoints/ # data/ # datasets/ # --- Tests / coverage --- .coverage htmlcov/ .pytest_cache/ # --- Images / Models (LFS 사용 시 주석 해제) --- # *.pt # *.onnx # *.bin # *.weights # --- OS / Tools --- .DS_Store Thumbs.db desktop.ini # --- Logs / temp --- *.log *.tmp tmp/ .cache/
 
MFC나 특정 개발 프레임워크 별로 gitignore는 템플릿을 만들어놓으면 좋은데, 필요할 때마다 추가로 업데이트할 예정.
← Back

Related posts

Tailscale을 사용해서 원격 ssh를 사용해보자

Dec 17, 2025

보안 사고를 겪은 뒤 찾은 해답, Tailscale로 안전하고 편리한 원격 SSH 환경을 구축한 경험기