-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
282 lines (262 loc) · 9.7 KB
/
index.html
File metadata and controls
282 lines (262 loc) · 9.7 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Git Cheat Sheet</title>
<style>
body {
font-family: arial;
}
code {
background: #e9e9e9;
font-weight: bold;
display: block;
vertical-align: top;
padding: 4px;
margin: 4px 0 20px;
}
h2 {
text-transform: uppercase;
}
.table {
width: 100%;
}
.table td {
vertical-align: top;
padding: 20px;
width: 33%;
}
</style>
</head>
<body>
<table class="table">
<tr>
<td>
<h2>Remove directory</h2>
<code>rm -i -d folder-name</code>
<h2>SEARCH</h2>
Search for a branch
<code>$ git branch | grep 'ECOMIT'</code>
View the change history of a file using Git versioning
<code>$ gitk [filename]</code>
<h2>CREATE</h2>
Clone an existing repository
<code>$ git clone ssh://user@domain.com/repo.git</code>
Create a new local repository
<code>$ git init</code>
<h2>LOCAL CHANGES</h2>
Changed files in your working directory
<code>$ git status</code>
Changes to tracked files
<code>$ git diff</code>
<code>$ git diff > patchfile.patch</code>
diff last commit
<code>$ git diff HEAD^ HEAD</code>
Add all current changes to the next commit
<code>$ git add .</code>
will let you also record the removals
<code>$ git add --all</code>
Add some changes in <file> to the next commit
<code>$ git add -p <file></code>
Commit all local changes in tracked files
<code>$ git commit -a</code>
Commit previously staged changes
<code>$ git commit -m 'message'</code>
<h2>COMMIT HISTORY</h2>
Show all commits, starting with newest
<code>$ git log</code>
<code>git log --pretty=oneline -3</code>
Show changes over time for a specific file
<code>$ git log -p <file></code>
Who changed what and when in <file>
<code>$ git blame <file></code>
<h2>STASH</h2>
create stash
<code>$ git stash</code>
apply stash
<code>$ git stash apply</code>
<code>$ git stash apply stash@{0}</code>
remove a stash
<code>$ git stash drop stash@{0}</code>
remove all stashes
<code>$ git stash clear</code>
list stashes
<code>$ git stash list</code>
</td>
<td>
<h2>Git global setup</h2>
<code>
git config --global user.name "Pavel"<br />
git config --global user.email "mp3-cdrs@ya.ru"<br />
</code>
or edit .gitconfig
<code>
[user]<br />
name = Username<br />
email = user123@gmail.com<br />
[core]<br />
autocrlf = true<br />
editor = 'C:/Users/user/Dropbox/apps/Sublime Text Build 3143 x64/sublime_text.exe' -w<br /><br />
[mergetool]<br />
prompt = false<br />
keepBackup = false<br />
keepTemporaries = false<br /><br />
[merge]<br />
tool = winmerge<br /><br />
[mergetool "winmerge"]<br />
name = WinMerge<br />
trustExitCode = true<br />
cmd = "/c/Users/user/Dropbox/apps/WinMerge/WinMergeU.exe" -u -e -dl \"Local\" -dr \"Remote\" $LOCAL $REMOTE $MERGED<br /><br />
[diff]<br />
tool = winmerge<br /><br />
[difftool "winmerge"]<br />
name = WinMerge<br />
trustExitCode = true<br />
cmd = "/c/Users/user/Dropbox/apps/WinMerge/WinMergeU.exe" -u -e $LOCAL $REMOTE<br /><br />
[alias]<br />
st = status<br />
ci = commit<br />
</code>
<h2>Diff with external tool</h2>
<code>
git difftool
</code>
<h2>Resolve conflict with external tool</h2>
<code>
git mergetool
</code>
<h2>Create a new repository</h2>
<code>
git clone https://gitlab.com/mp3-cdrs/spinner.git<br />
cd spinner<br />
touch README.md<br />
git add README.md<br />
git commit -m "add README"<br />
git push -u origin master<br />
</code>
<h2>Existing folder</h2>
<code>
cd existing_folder<br />
git init<br />
git remote add origin https://gitlab.com/mp3-cdrs/spinner.git<br />
git add .<br />
git commit<br />
git push -u origin master<br />
</code>
<h2>Existing Git repository</h2>
<code>
cd existing_repo<br />
git remote add origin https://gitlab.com/mp3-cdrs/spinner.git<br />
git push -u origin --all<br />
git push -u origin --tags<br />
</code>
<h2>BRANCHES & TAGS</h2>
Delete a Git branch remotely
<code>$ git push origin --delete branchName</code>
List all existing branches
<code>$ git branch -av</code>
Switch HEAD branch
<code>$ git checkout <branch></code>
Create a new branch based
on your current HEAD
<code>$ git branch <new-branch></code>
New branch <b>myFeature</b> from the <b>dev</b> branch
<code>$ git checkout -b myFeature dev</code>
<code>$ git branch -u origin/myFeature</code>
<code>$ git push -u origin bugfix/jira-issue</code>
Delete a local branch
<code>$ git branch -d <branch></code>
Mark the current commit with a tag
<code>$ git tag <tag-name></code>
<h2>UPDATE & PUBLISH</h2>
List all currently configured remotes
<code>$ git remote -v</code>
Show information about a remote
<code>$ git remote show <remote></code>
Add new remote repository, named <remote>
<code>$ git remote add <shortname> <url></code>
Download all changes from <remote>,
but don‘t integrate into HEAD
<code>$ git fetch <remote></code>
Download changes and directly
merge/integrate into HEAD
<code>$ git pull <remote> <branch></code>
Publish local changes on a remote
<code>$ git push <remote> <branch></code>
Delete a branch on the remote
<code>$ git branch -dr <remote/branch></code>
Delete a remote branch
<code>$ git push origin --delete <branchName></code>
</td>
<td>
<h2>MERGE & REBASE</h2>
Merge just <strong>one specific commit</strong> from another branch to your current branch.
<code>$ git cherry-pick <commit></code>
Merge <branch> into your current HEAD
<code>$ git merge <branch></code>
Merge <branch> into your current HEAD but do not actually make a commit
<code>$ git merge <branch> --squash</code>
Merge <branch> file into your current HEAD
<code>$ git checkout <branch> <path to file></code>
Rebase your current HEAD onto <branch>
Don‘t rebase published commits!
<code>$ git rebase <branch></code>
Abort a rebase
<code>$ git rebase --abort</code>
Continue a rebase after resolving conflicts
<code>$ git rebase --continue</code>
Use your configured merge tool to
solve conflicts
<code>$ git mergetool</code>
Use your editor to manually solve conflicts
and (after resolving) mark file as resolved
<code>$ git add <resolved-file></code>
<code>$ git rm <resolved-file></code>
before merging changes, you can also preview them by using
<code>$ git diff <source_branch> <target_branch></code>
<h2>UNDO</h2>
# Reset the index and working tree to the desired tree
# Ensure you have no uncommitted changes that you want to keep
<code>git reset --hard 56e05fced</code>
# Move the branch pointer back to the previous HEAD
<code>git reset --soft HEAD@{1}</code>
<code>git commit -m "Revert to 56e05fced"</code>
discard changes in my working copy that are not in the index
<code>$ git stash save --keep-index</code>
<code>$ git stash drop</code>
Remove untracked files from the working tree and delete files or directories
<code>$ git clean --force</code>
<code>$ git clean --f -d</code>
Discard all local changes in your working directory
<code>$ git reset --hard HEAD</code>
Unstage all files
<code>$ git reset</code>
Discard local changes in a specific file
<code>$ git checkout HEAD <file></code>
Revert a commit (by producing a new commit with contrary changes)
<code>$ git revert <commit></code>
Revert a commit but do not make a commit
<code>$ git revert --no-edit --no-commit <commit></code>
This will move your current HEAD to the given revision
<code>$ git checkout HEAD~1</code>
<code>$ git checkout <sha></code>
Undo a merge. This will get you back to commit_sha
<code>$ git reset --hard commit_sha</code>
Change last commit message
<code>git commit --amend</code>
<h2>NPM PACKAGES</h2>
version of all installed packages
<code>$ npm list</code>
version of sintalled package
<code>$ npm list (package)</code>
install version of package
<code>$ npm install (package)@(version)</code>
show all versions of package
<code>$ npm view (package) versions</code>
DEBUG gulp task
<code>DEBUG=* gulp [task]</code>
</td>
</tr>
</table>
</body>
</html>