forked from ndp/git-cheatsheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-cheatsheet.html
254 lines (248 loc) · 14 KB
/
git-cheatsheet.html
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
<!DOCTYPE html>
<html>
<head>
<!-- Google Analytics Content Experiment code -->
<script>function utmx_section(){}function utmx(){}(function(){var
k='2602198-1',d=document,l=d.location,c=d.cookie;
if(l.search.indexOf('utm_expid='+k)>0)return;
function f(n){if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.
indexOf(';',i);return escape(c.substring(i+n.length+1,j<0?c.
length:j))}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;d.write(
'<sc'+'ript src="'+'http'+(l.protocol=='https:'?'s://ssl':
'://www')+'.google-analytics.com/ga_exp.js?'+'utmxkey='+k+
'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='+new Date().
valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+
'" type="text/javascript" charset="utf-8"><\/sc'+'ript>')})();
</script><script>utmx('url','A/B');</script>
<!-- End of Google Analytics Content Experiment code -->
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Git Cheatsheet • NDP Software</title>
<meta name="description"
content="Interactive Git Cheatsheet, categorizing commands based on what they affect.">
<meta name="keywords"
content="Git Cheatsheet Cheat sheet Kuleta chuleta chivo machete torpedo acordeón cribsheet crib sheet antisèche Planquadratangabe Nachschlagewerk"/>
<link rel="author" href="https://plus.google.com/111325326458556506982/posts?rel=author">
<link rel="stylesheet" href="git-cheatsheet/1200.css" type="text/css"/>
<link rel="stylesheet" href="git-cheatsheet/fonts/Impact-Label-fontfacekit/stylesheet.css" type="text/css"/>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.js' type='text/javascript'></script>
<script src='git-cheatsheet/csster.js?v=2'></script>
<script src='git-cheatsheet/styles.js?v=2'></script>
<script src='git-cheatsheet/cookies.js'></script>
<script src='git-cheatsheet/commands.js'></script>
<script src='git-cheatsheet/base.js?v=2'></script>
<script src='git-cheatsheet/git-cheatsheet.js?v=2' type="text/javascript"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1458227-1']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="hd" class="container_16">
<div class="grid_8 alpha">
<h1 data-docs="Categorize Git's commands based on what they affect.">Git Cheatsheet</h1>
<h4>
<a class="lang" data-lang="en">en</a>
<a class="lang" data-lang="fr" data-docs="French translation by Bernard Opic">fr</a>
</h4>
</div>
<div class="grid_8 omega">
<h2 data-docs="another visualization from Andrew Peterson, NDP Software."><a href="http://ndpsoftware.com">an
interaction
from NDP Software</a></h2>
<h6>(c) <a href="https://plus.google.com/b/112580895511032559572/112580895511032559572/about?rel=author">Andrew Peterson</a> 2009-2013 All Rights Reserved.
French translation by <a href="http://blogs.media-tips.com/bernard.opic/">Bernard Opic</a>
</h6>
<h3>
<a href="http://www.amp-what.com?utm_source=Git+Cheatsheet&utm_campaign=Text+Link+Discover%20Your%20Character%20(entity)%26nbsp%3B%26mdash%3B%26nbsp%3BVisit%20%26amp%3Bwhat%26raquo%3B&utm_medium=web"
onclick=" _gaq.push(['_trackEvent', 'git-cheatsheet', 'refer', 'amp-what', null])">Visit &what»</a></h3>
</div>
</div>
<div class="clear"></div>
<div id="diagram" class="container_16">
<section id="stash" class="loc grid_2 alpha"><h5>stash</h5></section>
<section id="workspace" class="loc grid_4"><h5>workspace</h5></section>
<section id="index" class="loc grid_3"><h5>index</h5></section>
<section id="local_repo" class="loc grid_4"><h5>local repository</h5></section>
<section id="remote_repo" class="loc grid_3 omega"><h5>upstream repository</h5></section>
<dl id="commands">
<dt>status</dt>
<dd>Displays paths that have differences between the index file and the current HEAD commit, paths that have
differences between the workspace and the index file, and paths in the workspace that are not tracked by git.
</dd>
<dt>diff</dt>
<dd>Displays the differences not added to the index.</dd>
<dt>diff <em>commit or branch</em></dt>
<dd>View the changes you have in your workspace relative to the named <em>commit</em>. You can use HEAD
to compare it with the latest commit, or a branch name to compare with the tip of a different branch
</dd>
<dt>add <em>file... or dir...</em></dt>
<dd>Adds the current content of new or modified files to the index, thus staging that content for inclusion in the
next commit. Use <code>add --interactive</code> to add the modified contents in the workspace
interactively to the index.
</dd>
<dt>add -u</dt>
<dd>Adds the current content of modified (NOT NEW) files to the index. This is similar to what 'git commit -a' does
in preparation for making a commit.
</dd>
<dt>rm <em>file(s)...</em></dt>
<dd>Remove a file from the workspace and the index.</dd>
<dt>mv <em>file(s)...</em></dt>
<dd>Move file in the workspace and the index.</dd>
<dt>commit -a <span class="optional">-m 'msg'</span></dt>
<dd>Commit all files changed since your last commit, except untracked files (ie. all files that are already listed
in the index). Remove files in the index that have been removed from the workspace.
</dd>
<dt>checkout <em>files(s)... or dir</em></dt>
<dd>Updates the file or directory in the workspace. Does NOT switch branches.</dd>
<dt>reset HEAD <em>file(s)...</em></dt>
<dd>Remove the specified files from the next commit. Resets the index but not the working tree (i.e., the changed
files are preserved but not marked for commit) and reports what has not been updated.
</dd>
<dt>reset --soft HEAD^</dt>
<dd>Undo the last commit, leaving changes in the the index.</dd>
<dt>reset --hard</dt>
<dd>Matches the workspace and index to the local tree. WARNING: Any changes to tracked files in the working tree
since commit are lost. Use this if merging has resulted in conflicts and you'd like to start over. Pass ORIG_HEAD
to undo the most recent successful merge and any changes after.
</dd>
<dt>checkout <em>branch</em></dt>
<dd>Switches branches by updating the index and workspace to reflect the specified branch, <em>branch</em>,
and updating HEAD to be <em>branch</em>.
</dd>
<dt>checkout -b <em>name of new branch</em></dt>
<dd>Create a branch and switch to it</dd>
<dt>merge <em>commit or branch</em></dt>
<dd>Merge changes from <em>branch name</em> into current branch.<br>Use <code>&#8209;&#8209;no-commit</code>
to leave changes uncommitted.
</dd>
<dt>rebase <em>upstream</em></dt>
<dd>Reverts all commits since the current branch diverged from <em>upstream</em>, and then re-applies
them one-by-one on top of changes from the HEAD of <em>upstream</em>.
</dd>
<dt>cherry-pick <em>commit</em></dt>
<dd>Integrate changes in the given commit into the current branch.</dd>
<dt>revert <em>commit</em></dt>
<dd>Reverse commit specified by <em>commit</em> and commit the result. This requires your working tree
to be clean (no modifications from the HEAD commit).
</dd>
<dt>diff --cached <span class="optional"><em>commit</em></span></dt>
<dd>View the changes you staged vs the latest commit. Can pass a <em>commit</em> to see changes relative
to it.
</dd>
<dt>commit <span class="optional">-m 'msg'</span></dt>
<dd>Stores the current contents of the index in a new commit along with a log message from the user describing the
changes.
</dd>
<dt>commit --amend</dt>
<dd>Modify the last commit with the current index changes.</dd>
<dt>log</dt>
<dd>Show recent commits, most recent on top. Options:<br><code>&#8209;&#8209;decorate</code>
with branch and tag names on appropriate commits<br><code>&#8209;&#8209;stat</code> with
stats (files changed, insertions, and deletions) <br><code>&#8209;&#8209;author=<em>author</em></code>
only by a certain author<br><code>&#8209;&#8209;after="MMM DD YYYY"</code> ex. ("Jun 20
2008") only commits after a certain date<br><code>&#8209;&#8209;before="MMM DD YYYY"</code>
only commits that occur before a certain date <br><code>&#8209;&#8209;merge</code> only
the commits involved in the current merge conflicts
</dd>
<dt>diff <em>commit</em> <em>commit</em></dt>
<dd>View the changes between two arbitrary commits</dd>
<dt>branch</dt>
<dd>List all existing branches. Option -r causes the remote-tracking branches to be listed, and option -a shows
both.
</dd>
<dt>branch -d <em>branch</em></dt>
<dd>Delete an specified branch. Use -D to force.</dd>
<dt>branch --track <em>new</em> <em>remote/branch</em></dt>
<dd>Create a new local branch that tracks a remote branch.</dd>
<dt>clone <em>repo</em></dt>
<dd>Download the repository specified by <em>repo</em> and checkout HEAD of the master branch.</dd>
<dt>pull <em>remote</em> <em>refspec</em></dt>
<dd>Incorporates changes from a remote repository into the current branch. In its default mode, <code>git pull</code>
is shorthand for <code>git fetch</code> followed by <code>git merge FETCH_HEAD</code>.
</dd>
<dt>reset --hard <em>remote</em>/<em>branch</em></dt>
<dd>Reset local repo and working tree to match a remote branch. Use <code>reset &#8209;&#8209;hard
origin/master</code> to throw away all commits to the local master branch. Use this to start over on a
failed merge.
</dd>
<dt>fetch <em>remote</em> <em>refspec</em></dt>
<dd>Download objects and refs from another repository.</dd>
<dt>push</dt>
<dd>update the server with your commits across all branches that are *COMMON* between your local copy and the
server.Local branches that were never pushed to the server in the first place are not shared
</dd>
<dt>push <em>remote</em> <em>branch</em></dt>
<dd>Push new (or existing) branch to remote repository</dd>
<dt>push <em>remote</em> <em>branch</em>:<em>branch</em></dt>
<dd>Push new branch to remote repository with a different name</dd>
<dt>branch -r</dt>
<dd>List remote branches</dd>
<dt>push <em>remote</em> :<em>branch</em></dt>
<dd>Remove a remote branch. Literally &quot;push nothing to this branch&quot;</dd>
<dt>clean</dt>
<dd>Cleans the working tree by recursively removing files that are not under version control, starting from the
current directory.
</dd>
<dt>stash save <span class="optional"><em>msg</em></span></dt>
<dd>Save your local modifications to a new stash, and run git reset &#8209;&#8209;hard to revert them. The
<em>msg</em> part is optional and gives the description along with the stashed state. For quickly
making a snapshot, you can omit both "save" and <em>msg</em>.
</dd>
<dt>stash apply <span class="optional"><em>stash</em></span></dt>
<dd>Move changes from the specified stash into the workspace. The latest stash is the default.</dd>
<dt>stash pop</dt>
<dd>Applies the changes from the last (or specified) stash and then removes the given stash.</dd>
<dt>stash list</dt>
<dd>List the stashes that you currently have.</dd>
<dt>stash show <span class="optional"><em>stash</em></span></dt>
<dd>Show the changes recorded in the stash as a diff between the stashed state and its original parent. When no <em>stash</em>
is given, shows the latest one.
</dd>
<dt>stash drop <span class="optional"><em>stash</em></span></dt>
<dd>Remove a single stashed state from the stash list. When no <em>stash</em> is given, it removes the
latest one.
</dd>
<dt>stash clear</dt>
<dd>Remove all the stashed states. Note that those states will then be subject to pruning, and may be impossible to
recover.
</dd>
<dt>stash branch <em>branchname</em> <span class="optional"><em>stash</em></span></dt>
<dd>Creates and checks out a new branch named <em>branchname</em> starting from the commit at which the
<em>stash</em> was originally created, applies the changes recorded in <em>stash</em> to
the new working tree and index. <br>If that succeeds, and <em>stash</em> is a reference of the
form stash@{<em>revision</em>}, it then drops the <em>stash</em>. When no <em>stash</em>
is given, applies the latest one. <br>This is useful if the branch on which you ran git stash save has
changed enough that git stash apply fails due to conflicts. Since the stash is applied on top of the commit that
was HEAD at the time git stash was run, it restores the originally stashed state with no conflicts.
</dd>
</dl>
<div id="info">
<div class="screen"></div>
<div class="cmd"> </div>
<div class="doc"> </div>
</div>
<div>
<g:plusone size="small" annotation="inline" width="120"></g:plusone>
</div>
</div>
<script type="text/javascript">
(function () {
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
</script>
</body>
</html>