-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit.txt
More file actions
109 lines (87 loc) · 4.6 KB
/
Copy pathgit.txt
File metadata and controls
109 lines (87 loc) · 4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
$ git --help
usage: git [--version] [--help] [-C <path>] [-c name=value]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status
grow, mark and tweak your common history
branch List, create, or delete branches
checkout Switch branches or restore working tree files
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
tag Create, list, delete or verify a tag object signed with GPG
collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git he
git status
git log
git branch {브런치명}
git branch --list : 브런치 리스트
git branch -d {브런치명} : 브런치 삭제
git branch -D {브런치명} : 브런치 삭제 + 커밋 내역이 있어도 삭제
git branch -v : 브런치마다 마지막 커밋키 표출
git branch --merged : merged 된 브런치 표출
git branch --no-merged : nomered 된 브런치 표출
git checkout {브런치명} : 브런치 이동(체크아웃)
git checkout -b {브런치명} : 브랜치가 없으면 브랜치를 생성하고 이동한다.
--diff
git diff : 스테이지에 올라와 있는거 비교
git diff {커밋키1} {커밋키2} : 2개의 커멋키 비교
git diff {브런치1} {브런치2} : 2개의 브란치 비교
--add
git add . : 스테이지 전체 올리기
git add {디렉토리/파일명} : 특정 파일 스테이지에 올리기
--discard
git checkout -- {파일명} :특정 파일 폐기
--reset
git reset : 스테이지 내리기
git reset {디렉토리/파일명} : 특정 파일 스테이지에 내리기
git reset HEAD^ : 최종 커밋을 취소. 작업내역 보존됨. (커밋은 했으나 push하지 않은 경우 유용)
git reset HEAD~2 : 마지막 2개의 커밋을 취소. 작업내역 보존됨.
git reset --hard HEAD~2 : 마지막 2개의 커밋을 취소. index 및 워킹트리 모두 원복됨.
git reset --hard ORIG_HEAD : 머지한 것을 이미 커밋했을 때, 그 커밋을 취소. (잘못된 머지를 이미 커밋한 경우 유용)
git revert HEAD : HEAD에서 변경한 내역을 취소하는 새로운 커밋 발행(undo commit). (커밋을 이미 push 해버린 경우 유용)
--commit
git commit -m{메시지} : 해당 메시지로 커밋
git commit -a -m{메시지} : 스테이징 올리고 , 해당 메시지로 커밋
--push
git push : 푸쉬
--pull
--merge
git merge {브런치명} : 해당 브런치 master에 머지
--stash git
git stash : 현재상태 저장
git stash save {스테이시명}: 스테이지명으로 현재상태 저장
git stash (pop|apply) stash@{0} : 해당 스테이지로 불러옴
git stash pop : 가장 최근꺼 복구
git stash apply : stash 에서 복구 하지만 stash list 에서 빠지지 않는다
git stash drop : git stash 특정 삭제
git stash clear : 전체 삭제
--log
git log => git diff
git log -n {숫자} : n개의 커밋 리스트
git log -p : 커밋 리스트와 비교를 동시에
git log follow {디렉토리}: 특정 디렉토리 커밋 리스트
git log --name-status --branches --graph --decorate --oneline : 로그에 모든 브랜치를 표시하고, 그래프로 표현하고, 브랜치 명을 표시하고, 한줄로 표시할 때
aa
gg