-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic_usage.txt
102 lines (74 loc) · 2.27 KB
/
basic_usage.txt
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
GIT Basic Usage
-> git log related
git log
git log -p
git log --pretty=format:'%h:%s' --topo-order --graph
git log --pretty=format:'%h:%s' --date-order --graph
git reflog
git log -g
-> git tag releated
git tag -a tagname -m "comments"
git tag -d tagname
git push origin --tags
git push origin tagname
git push origin --delete tagname
- sync tags
git tag -l | xargs git tag -d
git fetch --prune
-> git branch related
git branch -a
git push origin --delete <branchName>
git branch -m oldbranch newbranch
# add remote branch to local
git remote add <repo> <remote_git_repo>
git fetch <repo>
e.g.
git remote add qingmin https://github.com/qingmin-liu/mtcp.git
git fetch qingmin
-> Drop/Clean all untracked modifications
git reset --hard
git reset --hard commit_id
git reset --soft commit_id
# Remove untracked directories in addition to untracked files.
git clean -xdf
# Donot actually remove anything, just show what would be done.
git clean -xnd
-> patch related
git format-patch -1 commit_id
git diff commit_previous commit > mypatch.diff
-> git commit
git commit --amend
-> git cherry-pick from different repository
git format-patch
git am
-> git configuration
git config --global user.name "Qingmin Liu"
git config --global user.email "[email protected]"
git config user.name "Qingmin Liu"
git config user.email "[email protected]"
git config --global color.diff true
git config --global color.status true
git config --global color.branch true
git config --global color.ui true
git config --global core.editor vim
git commit --amend --author="Qingmin Liu <[email protected]>"
git config --global push.default simple
-> ignore filemode change
git config --global core.filemode false ==>~/.gitconfig
git config core.filemode false ==>.git/config
-> build a git server
git init --bare <git_server_path>
-> change git server path
git remote set-url origin <new_path>
-> checkout a single branch
git clone -b branch_name --single-branch <git_server>
-> check only the specified depth
git clone --depth=N <git_path>
If want to check old history, use:
git fetch --unshallow
-> git hash id abbrev configuration
git config core.abbrev 10
# Note:
Linux kernel script will automatically append it to UTS_RELEASE.
By default it's 7 digits. However you could change it with above
commands.