Skip to content

Commit 751d035

Browse files
committed
1
1 parent 81d0cfd commit 751d035

File tree

3 files changed

+149
-17
lines changed

3 files changed

+149
-17
lines changed

web/page-git/page1-gitbash.png

50.9 KB
Loading

web/page-git/page1.md

Lines changed: 144 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,177 @@
11
# git 명령어
22

33

4+
## 최초 git 설정
5+
6+
* https://git-scm.com/ 설치
7+
* git bash 열기
48

5-
## 덮어쓰기
69
```
7-
git reset --hard origin
8-
git reset --soft origin
9-
git reset --soft HEAD~{커밋수}
10-
git reset --hard origin/{브랜치-이름}
10+
git config --global user.name "{사용자-이름}"
11+
git config --global user.email "{사용자-이메일}"
12+
git config --list
1113
```
14+
![gitbash](./page1-gitbash.png "git bash")
1215

1316

1417

15-
## 커밋합치기
18+
19+
## 새 저장소 만들기
20+
1621
```
17-
git rebase -i HEAD~{커밋수}
22+
echo "# test" >> README.md
23+
git init
24+
git add README.md
25+
git commit -m "first commit"
26+
git branch -M master
27+
git remote add origin https://github.com/code1009/{저장소-이름}.git
28+
git push -u origin master
29+
```
30+
31+
32+
## 기존 저장소 푸시
33+
34+
```
35+
git remote add origin https://github.com/code1009/{저장소-이름}.git
36+
git branch -M master
37+
git push -u origin master
38+
```
39+
40+
41+
42+
## 원격 연결 확인
43+
44+
* 명령어
45+
```
46+
git remote -v
47+
```
48+
49+
* 출력결과
50+
```
51+
origin https://github.com/code1009/{저장소-이름}.git (fetch)
52+
origin https://github.com/code1009/{저장소-이름}.git (push)
53+
```
54+
55+
56+
## 복제(clone)
57+
58+
```
59+
git clone {저장소-주소} {로컬-폴더}
60+
```
61+
62+
63+
64+
## 로컬에서 브랜치 생성 및 전환
65+
66+
```
67+
git checkout -b {브랜치-이름}
68+
```
69+
> `-b` 생성 옵션
70+
71+
72+
## 로컬에서 브랜치 생성 및 전환 후 푸쉬
73+
74+
```
75+
git push --set-upstream origin {브랜치-이름}
76+
```
77+
78+
> 최초 푸시 시 필요함
79+
80+
81+
82+
## 원격 동기화
83+
84+
```
85+
git fetch origin
1886
```
1987

2088

2189

22-
## 로컬에서 브랜치전환
90+
## 로컬에서 브랜치 전환
91+
2392
```
2493
git checkout {브랜치-이름}
2594
```
2695

2796

97+
## 충돌(conflict) 이후 해결 예시
98+
99+
* develop 브랜치 최신 내용 feature 브랜치에 병합
100+
101+
```
102+
git checkout develop
103+
git pull origin develop
104+
git checkout feature
105+
git merge develop
106+
```
107+
108+
* 충돌 해결 후 커밋 및 푸시
109+
110+
```
111+
git add .
112+
git commit -m "resolve conflicts"
113+
git push
114+
```
115+
116+
117+
118+
## 서로 다른 저장소 이력 병합
28119

29-
## 새 저장소의 초기 커밋을 기존 저장소와 병합
30120
```
31121
git pull origin {브랜치-이름} --allow-unrelated-histories
32122
```
33123

34124

35125

36-
## 저장소의 초기화
126+
## 저장소 초기화
127+
37128
```
38-
{.git 폴더 삭제}
129+
{.git 폴더 삭제(`rmdir /s /q .git`}
39130
git init
40131
git add --all
41132
git commit -m "init"
42-
git remote add origin https://github.com/code1009/{저장소 이름}.git
133+
git remote add origin https://github.com/code1009/{저장소-이름}.git
43134
git push -f origin master
44135
```
45136

137+
138+
139+
## 커밋 이력 확인
140+
141+
```
142+
git log
143+
```
144+
145+
146+
147+
## 저장소 상태 확인
148+
149+
```
150+
git status
151+
```
152+
153+
154+
155+
## 덮어쓰기
156+
157+
```
158+
git reset --hard origin
159+
git reset --soft origin
160+
git reset --soft HEAD~{커밋수}
161+
git reset --hard origin/{브랜치-이름}
162+
```
163+
164+
165+
166+
## 커밋 합치기
167+
168+
```
169+
git rebase -i HEAD~{커밋수}
170+
```
171+
> 가급적 금지
172+
> > 협업 중인 브랜치에서 rebase는 충돌 및 이력 꼬임 위험
173+
174+
175+
176+
177+

web/page-git/page3.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
## 브랜치 이름의 예시와 의미
44
- main 또는 master: 기본 브랜치, 배포 가능한 안정된 코드가 위치합니다.
55
- develop: 개발 중인 코드가 모이는 브랜치입니다.
6-
- feature/기능명: 새로운 기능 개발용 브랜치입니다. 예) feature/login
7-
- bugfix/이슈명: 버그 수정용 브랜치입니다. 예) bugfix/login-error
6+
- feature/기능명: 새로운 기능 개발용 브랜치입니다. 예) feature/{이슈번호}-login
7+
- bugfix/이슈명: 버그 수정용 브랜치입니다. 예) bugfix/{이슈번호}-login-error
88
- hotfix/이슈명: 긴급 수정이 필요한 경우 사용하는 브랜치입니다.
99
- release/버전명: 배포 준비를 위한 브랜치입니다. 예) release/v1.2.0
1010

@@ -15,8 +15,8 @@
1515

1616
## 예시
1717
- main
18-
- feature/user-profile
19-
- bugfix/payment-error
20-
- release/2025-07
18+
- feature/123-user-profile
19+
- bugfix/123-payment-error
20+
- release/2025-07-08-v1.0.0.0a
2121

2222

0 commit comments

Comments
 (0)