Skip to content

Commit 2dc8b72

Browse files
authored
Create git-command.adoc
1 parent d380af0 commit 2dc8b72

File tree

1 file changed

+290
-0
lines changed

1 file changed

+290
-0
lines changed

git-command.adoc

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
== version
2+
3+
git --version
4+
5+
== config :변수설정
6+
7+
git config --global user.name "benelog"
8+
9+
git config --global user.email "[email protected]"
10+
11+
git config --global --list
12+
13+
git config --global i18n.commitEncoding cp949
14+
15+
git config --global i18n.logOutputEncoding cp949
16+
17+
git config --local user.email [email protected]
18+
19+
== add
20+
21+
git add -i
22+
23+
git add -am
24+
25+
git add --patch : 파일의 일부분만 스테이징
26+
27+
== log
28+
29+
git shortlog
30+
31+
git log -p -2 : 최근 2개의 로그 결과 보여줌
32+
33+
git log --stat : 통계 정보 포함
34+
35+
git log --since="6 hours"
36+
37+
git log --before="6 hours"
38+
39+
git log -1 HEAD^^^
40+
41+
git log -1 HEAD^~2
42+
43+
git log -1 HEAD~1^^
44+
45+
git log -1 HEAD~3
46+
47+
git log -10
48+
49+
git log --pretty=oneline
50+
51+
git blame index.html
52+
53+
git log --pretty=oneline --graph
54+
55+
git log contrib --not master
56+
57+
git log --abbrev-commit --pretty=oneline
58+
59+
git rev-parse topic1
60+
61+
git reflog
62+
63+
git show HEAD@{5}
64+
65+
git show master@{yesterday}
66+
67+
git log -g master : reglog결과를 git log 명령과 같은 형태로 보여줌
68+
69+
git log --left-right master...experiment
70+
71+
git log -S<string> : search through all history. (find a deleted method)
72+
73+
git log --diff-filter=D --summary : lists all deleted files
74+
75+
=== blame
76+
77+
git blame -L 12,22 simplegit.rb
78+
79+
git blame -C -L 12,22 simplegit.rb : 파일명 포함
80+
81+
== diff
82+
83+
git diff --stat
84+
85+
git diff --check : 공백문자에 대한 오류 확인
86+
87+
git diff --cached : staged에 대한 변경사항
88+
89+
git diff --staged : --cached와 같음
90+
91+
git mergetool
92+
93+
git diff master...contrib : 두 브랜치의 차이
94+
95+
git merge-base contrib master + git diff [commit이름] : 두 브랜치의 차이
96+
97+
== 파일 관리
98+
99+
git rm
100+
101+
git mv
102+
103+
== stash
104+
105+
git stash
106+
107+
git stash list
108+
109+
git stash apply
110+
111+
git stash apply --index : 스테이징 상태까지 만들어줌
112+
113+
git stash drop : 삭제
114+
115+
git stash pop : 적용 후 삭제
116+
117+
git stash show -p stash@{0} | git apply -R : 취소
118+
119+
git stash branch testchanges
120+
121+
== branch
122+
123+
==== 이동
124+
125+
git checkout dev
126+
127+
git checkout -b dev : 생성 + 이동
128+
129+
==== 보기
130+
131+
git branch : 지역 브랜치보기
132+
133+
git branch -r : 원격 브랜치 보기
134+
135+
git branch -a : 모든 브랜치 보기
136+
137+
git branch -v : 마지막 커밋메시지 같이 보여주기
138+
139+
git branch --no-merged : 아직 머지 안 된 브랜치 보기
140+
141+
git branch --merged : lists branches already merged
142+
143+
==== 생성
144+
145+
git branch dev master (뒤쪽이 from)
146+
147+
git checkout -b alternative master : 생성하고 checkout
148+
149+
git branch newBranch : 현재 브랜치에서 새로운 브랜치 생성
150+
151+
git branch -f <기존브랜치> [<브랜치를 생성할 위치>] : 기존 브랜치를 새로운 브랜치로 덮어쓰기
152+
153+
git rebase --onto master contact search
154+
155+
==== 삭제
156+
157+
git branch -d mybranch
158+
159+
git branch -D mybranch : 강제삭제
160+
161+
git push origin :heads/ISSUE-16 : remote branch 삭제
162+
163+
=== 이름 변경
164+
165+
git branch -m master mymaster
166+
167+
git branch -M master mymaster (이미 존재해도 덮어쓰면서 강제로 이름 변경)
168+
169+
== tag
170+
171+
git tag mytag
172+
173+
git tag -l 'v1.4.2.*'
174+
175+
git tag -d mytag
176+
177+
git tag -a v1.4 -m 'my version 1.4'
178+
179+
git tag -a v1.2 9fceb02
180+
181+
git push origin --tags
182+
183+
git push origin :refs/tags/TAGNAME
184+
185+
== rebase
186+
187+
checkout master
188+
189+
git rebase [branch명]
190+
191+
== merge
192+
193+
git merge <브랜치> : 다른 브랜치를 현재 브랜치로 합치기
194+
195+
git merge --squash mybranch
196+
197+
git cherry-pick 321d76f
198+
199+
git merge --no-comit <브랜치> : commit하지 않고 합치기
200+
201+
git merge origin/master
202+
203+
== commit
204+
205+
git commit --amend
206+
207+
git commit -C HEAD -a --amend
208+
209+
git commit -m "메시지" --amend
210+
211+
git commit -C HEAD --amend : 마지막 commit 수정하고 commit 메시지 재활용
212+
213+
Contribution
214+
215+
git rebase upstream/master
216+
217+
==== 취소
218+
219+
git rest --hard HEAD^
220+
221+
git revert
222+
223+
git revert -n (commit 하지 않고 돌려놓기)
224+
225+
==== submodule
226+
227+
git submodule
228+
229+
==== 색상표시
230+
231+
git config --global color.diff auto
232+
git config --global color.status auto
233+
git config --global color.branch auto
234+
235+
== remote (원격저장소)
236+
237+
git remote add <원격 저장소> <저장소 url> : 새로운 원격 저장소 추가하기
238+
239+
git remote -v
240+
241+
git remote show origin
242+
243+
git remote rename
244+
245+
git checkout -b serverfix origin/serverfix
246+
247+
== push
248+
249+
git push origin publish_with_bloc
250+
251+
git push origin serverfix:awesomebranch
252+
253+
git push origin :serverfix : remote 브랜치 삭제
254+
255+
git format-patch -M origin/master
256+
257+
== alias
258+
259+
git config --global alias.co checkout
260+
git config --global alias.br branch
261+
git config --global alias.ci commit
262+
git config --global alias.st status
263+
264+
git config --global alias.last 'log -1 HEAD'
265+
266+
git clone http://url/[http://url] : 복재 생성
267+
268+
git clone --depth 200 : 마지막 200개의 커밋만 포함하여 저장소 복제하기
269+
git branch <새로운 브랜치> <원격 브랜치> : 원격 브랜치에서 지역 브랜치 생성하기
270+
git fetch : origin 저장소에서 합치지 않고 지역 브랜치로 변경 가져오기
271+
272+
git fetch <원격 저장소> : 원격 저장소에서 합치지 않고 지역 브랜치로 변경사항 가지고 오기
273+
274+
git pull : origin 저장소에서 변경사항을 가져와 현재 브랜치에 합치기
275+
276+
git push <원격저장소> <지역 브랜치>:<원격브랜치> : 지역 브랜치를 원격 브랜치에 푸싱하기
277+
278+
git push <원격저장소> <지역 브랜치> : 지역 브랜치를 동일한 이름의 원격 브랜치에 푸싱하기
279+
280+
git push <원격 저장소> <지역브랜치> : 새로운 로컬 브랜치를 원격 저장소에 푸싱하기
281+
282+
git push : 지역 변경 사항을 origin 저장소에 푸싱하기
283+
284+
git push <원격저장소>:<원격브랜치> : 원격 브랜치 삭제하기
285+
286+
git remote prune <원격저장소> : 원격 저장소에서 쓸모가 없어진 원격 브랜치 제거하기
287+
288+
git remote rm <원격저장소> : 원격 저장소를 제거하고 관련된 브랜치도 제거하기
289+
290+
git pull <원격저장소> <지역브랜치>: git pull origin master

0 commit comments

Comments
 (0)