매우 오랜만에 사용한 깃허브
clone → 브랜치 이동 → 변경 → add → commit → push를 해보도록 하겠습니다
GitHub 저장소 클론(clone)
git clone https://github.com/hurwan0629/ornably.git
먼저 원격 저장소를 로컬로 가져옵니다
기능 : 원격(GitHub) 저장소를 로컬 컴퓨터로 복제(clone)
결과 : ornably라는 폴더가 생성되고, 저장소 내 파일과 커밋 기록을 가져옴
로컬 브랜치 확인
git branch
기능 : 로컬 저장소의 브랜치 목록 확인을 한다
결과 : 처음엔 .git 정보가 없어서 오류가 발생했다 ➡ clone 직후 cd를 잘못한 상태거나 루트가 아닌 곳에서 실행하면 그럴 수 있다
cd ornably
방금 clone한 ornably 폴더로 이동한다
git branch
현재 디렉토리가 Git 저장소인지 확인 후 브랜치 목록 조회를 한다
결과 : "detected dubious ownership" 오류 발생
이유 : Windows의 파일 시스템 특성 때문에 Git이 소유권 문제를 감지
해결: 다음 명령어로 안전한 디렉토리로 추가
안전한 디렉토리 설정
git config --global --add safe.directory
E:/DATA_P/gitFlow/ornably
Git에게 여기 안전한 저장소라고 알려주는 설정이다
결과 : ownership 문제 해결
원격 브랜치 확인
git branch -a
모든 브랜치 확인 (-a는 원격 포함)
그러면
🔹 * main → 현재 로컬 브랜치
🔹 remotes/origin/... → 원격 저장소 브랜치 목록
기능 브랜치 체크아웃
git checkout feature/yoojincustard
feature/yoojincustard 브랜치로 이동
결과 : 브랜치를 새로 만들면서 원격 브랜치와 연결(track)
git branch
현재 브랜치 확인
결과 : * feature/yoojincustard → 현재 작업 브랜치
변경 사항 스테이징
git add .
변경된 파일 전체를 스테이징 영역에 추가
결과: 커밋 준비 완료
git status
현재 Git 상태 확인
결과 : 2 files changed → 두 파일이 commit 대상
커밋 생성
git commit -m "yoojincustard/2026-02-06: test commit"
스테이징된 변경 사항을 로컬 커밋 생성
메시지: "yoojincustard/2026-02-06: test commit"
결과: 2 files changed, 341 insertions(+), 1 deletion(-) → 실제 변경사항 기록
원격 저장소로 푸시
git push -u origin feature/yoojincustard
설명: 로컬 브랜치를 원격(origin) 브랜치에 업로드
-u → 로컬 브랜치와 원격 브랜치를 추적하도록 설정
결과: 커밋이 GitHub에 업로드, 이제 git push만 해도 자동으로 이 브랜치에 올라감
다음부터는 git push만으로 자동 업로드 가능
[ 전체 실습 코드 ]
Microsoft Windows [Version 10.0.19045.2673]
(c) Microsoft Corporation. All rights reserved.
E:\DATA_P\gitFlow>git clone https://github.com/hurwan0629/ornably.git
Cloning into 'ornably'...
remote: Enumerating objects: 145, done.
remote: Counting objects: 100% (145/145), done.
remote: Compressing objects: 100% (109/109), done.
remote: Total 145 (delta 14), reused 144 (delta 14), pack-reused 0 (from 0)
Receiving objects: 100% (145/145), 43.90 KiB | 290.00 KiB/s, done.
Resolving deltas: 100% (14/14), done.
E:\DATA_P\gitFlow>git branch
fatal: not a git repository (or any of the parent directories): .git
E:\DATA_P\gitFlow>cd ornably
E:\DATA_P\gitFlow\ornably>git branch
fatal: detected dubious ownership in repository at 'E:/DATA_P/gitFlow/ornably'
'E:/DATA_P/gitFlow/ornably' is on a file system that does not record ownership
To add an exception for this directory, call:
git config --global --add safe.directory E:/DATA_P/gitFlow/ornably
E:\DATA_P\gitFlow\ornably>git branch -a
fatal: detected dubious ownership in repository at 'E:/DATA_P/gitFlow/ornably'
'E:/DATA_P/gitFlow/ornably' is on a file system that does not record ownership
To add an exception for this directory, call:
git config --global --add safe.directory E:/DATA_P/gitFlow/ornably
E:\DATA_P\gitFlow\ornably>git config --global --add safe.directory E:/DATA_P/gitFlow/ornably
E:\DATA_P\gitFlow\ornably>git branch -a
* main
remotes/origin/HEAD -> origin/main
remotes/origin/develop
remotes/origin/feature/heeiin
remotes/origin/feature/hurwan
remotes/origin/feature/seohwa
remotes/origin/feature/yoojincustard
remotes/origin/main
E:\DATA_P\gitFlow\ornably>git checkout feature/yoojincustard
branch 'feature/yoojincustard' set up to track 'origin/feature/yoojincustard'.
Switched to a new branch 'feature/yoojincustard'
E:\DATA_P\gitFlow\ornably>git branch
* feature/yoojincustard
main
E:\DATA_P\gitFlow\ornably>git add .
E:\DATA_P\gitFlow\ornably>git status
On branch feature/yoojincustard
Your branch is up to date with 'origin/feature/yoojincustard'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: ornably/src/main/java/bugsandwich/ornably/account/AccountDTO.java
modified: ornably/src/main/java/bugsandwich/ornably/account/AccountRepository.java
E:\DATA_P\gitFlow\ornably>git commit -m "yoojincustard/2026-02-06: test commit"
[feature/yoojincustard afc03a2] yoojincustard/2026-02-06: test commit
2 files changed, 341 insertions(+), 1 deletion(-)
E:\DATA_P\gitFlow\ornably>git push -u origin feature/yoojincustard
Enumerating objects: 21, done.
Counting objects: 100% (21/21), done.
Delta compression using up to 12 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (11/11), 3.24 KiB | 3.24 MiB/s, done.
Total 11 (delta 3), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To https://github.com/hurwan0629/ornably.git
7dadaea..afc03a2 feature/yoojincustard -> feature/yoojincustard
branch 'feature/yoojincustard' set up to track 'origin/feature/yoojincustard'.
E:\DATA_P\gitFlow\ornably>
다음부터는 git push만으로 자동 업로드 가능
저장소 폴더로 이동 : cd E:/DATA_P/gitFlow/ornably
현재 브랜치 확인(선택) : git branch
원격 브랜치 최신 상태 가져오기 (선택, 안전하게) : git pull
코드 수정 후 스테이징
- 모든 변경 파일을 커밋 준비 : git add .
- 현재 상태 확인 : git status
커밋 생성 : git commit -m "yoojincustard/2026-02-06: 추가 기능 작업"
원격 브랜치로 푸시 : git push
'🍏 개발일기' 카테고리의 다른 글
| 커넥션 풀(Connection Pool) (0) | 2026.02.08 |
|---|---|
| Git Bash 설치하고 간단하게 이름, 이메일 설정해보기 (0) | 2026.02.08 |
| Visual Studio Code(VS Code) 기초 정리 (0) | 2026.02.05 |
| Spring 개발자가 IntelliJ를 써야 하는 이유 (0) | 2026.02.04 |
| 초보 개발자를 위한 도커(Docker) 입문 가이드 (0) | 2026.02.03 |