puppetfactory 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +13 -0
  3. data/README.md +0 -0
  4. data/bin/pfsh +31 -0
  5. data/bin/puppetfactory +153 -0
  6. data/lib/puppetfactory.rb +300 -0
  7. data/lib/puppetfactory/cli.rb +114 -0
  8. data/lib/puppetfactory/dashboard/rake_tasks.rb +69 -0
  9. data/lib/puppetfactory/dashboard/serverspec_helper.rb +84 -0
  10. data/lib/puppetfactory/dashboard/spec_helper.rb +26 -0
  11. data/lib/puppetfactory/helpers.rb +37 -0
  12. data/lib/puppetfactory/monkeypatches.rb +30 -0
  13. data/lib/puppetfactory/plugins.rb +11 -0
  14. data/lib/puppetfactory/plugins/certificates.rb +28 -0
  15. data/lib/puppetfactory/plugins/classification.rb +75 -0
  16. data/lib/puppetfactory/plugins/code_manager.rb +156 -0
  17. data/lib/puppetfactory/plugins/console_user.rb +62 -0
  18. data/lib/puppetfactory/plugins/dashboard.rb +128 -0
  19. data/lib/puppetfactory/plugins/docker.rb +193 -0
  20. data/lib/puppetfactory/plugins/example.rb +88 -0
  21. data/lib/puppetfactory/plugins/github.rb +102 -0
  22. data/lib/puppetfactory/plugins/gitlab.rb +62 -0
  23. data/lib/puppetfactory/plugins/hooks.rb +46 -0
  24. data/lib/puppetfactory/plugins/login_shell.rb +10 -0
  25. data/lib/puppetfactory/plugins/logs.rb +34 -0
  26. data/lib/puppetfactory/plugins/r10k.rb +112 -0
  27. data/lib/puppetfactory/plugins/shell_user.rb +69 -0
  28. data/lib/puppetfactory/plugins/user_environment.rb +77 -0
  29. data/public/dashboard.js +100 -0
  30. data/public/font-awesome/css/font-awesome.css +2199 -0
  31. data/public/font-awesome/css/font-awesome.min.css +4 -0
  32. data/public/font-awesome/fonts/FontAwesome.otf +0 -0
  33. data/public/font-awesome/fonts/fontawesome-webfont.eot +0 -0
  34. data/public/font-awesome/fonts/fontawesome-webfont.svg +685 -0
  35. data/public/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
  36. data/public/font-awesome/fonts/fontawesome-webfont.woff +0 -0
  37. data/public/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
  38. data/public/gitviz/LICENSE.md +20 -0
  39. data/public/gitviz/README.md +13 -0
  40. data/public/gitviz/css/explaingit.css +227 -0
  41. data/public/gitviz/css/vendor/1140.css +130 -0
  42. data/public/gitviz/images/forkme_right_red_aa0000.png +0 -0
  43. data/public/gitviz/images/grippy-close.png +0 -0
  44. data/public/gitviz/images/grippy.png +0 -0
  45. data/public/gitviz/images/prompt.gif +0 -0
  46. data/public/gitviz/index.html +734 -0
  47. data/public/gitviz/js/controlbox.js +459 -0
  48. data/public/gitviz/js/explaingit.js +74 -0
  49. data/public/gitviz/js/historyview.js +979 -0
  50. data/public/gitviz/js/main.js +56 -0
  51. data/public/gitviz/js/vendor/d3.min.js +4 -0
  52. data/public/gitviz/js/vendor/jquery-latest.min.js +6 -0
  53. data/public/gitviz/js/vendor/normalize.css +396 -0
  54. data/public/gitviz/js/vendor/require.min.js +35 -0
  55. data/public/gitviz/memtest.html +44 -0
  56. data/public/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  57. data/public/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  58. data/public/images/ui-bg_flat_10_000000_40x100.png +0 -0
  59. data/public/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  60. data/public/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  61. data/public/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  62. data/public/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  63. data/public/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  64. data/public/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  65. data/public/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  66. data/public/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  67. data/public/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  68. data/public/images/ui-icons_222222_256x240.png +0 -0
  69. data/public/images/ui-icons_228ef1_256x240.png +0 -0
  70. data/public/images/ui-icons_454545_256x240.png +0 -0
  71. data/public/images/ui-icons_ef8c08_256x240.png +0 -0
  72. data/public/images/ui-icons_ffd27a_256x240.png +0 -0
  73. data/public/images/ui-icons_ffffff_256x240.png +0 -0
  74. data/public/jquery-1.11.1.min.js +4 -0
  75. data/public/jquery-ui.css +464 -0
  76. data/public/jquery-ui.min.css +7 -0
  77. data/public/jquery-ui.min.js +13 -0
  78. data/public/jquery-ui.structure.min.css +5 -0
  79. data/public/jquery-ui.theme.min.css +5 -0
  80. data/public/jquery.activity-indicator-1.0.0.min.js +10 -0
  81. data/public/jquery.js +9789 -0
  82. data/public/loginscripts.js +18 -0
  83. data/public/scripts.js +36 -0
  84. data/public/style.css +193 -0
  85. data/public/usermanagement.js +133 -0
  86. data/templates/init_scripts.erb +10 -0
  87. data/templates/puppet.conf.erb +10 -0
  88. data/templates/site.pp.erb +50 -0
  89. data/views/dashboard.erb +62 -0
  90. data/views/home.erb +43 -0
  91. data/views/index.erb +29 -0
  92. data/views/logs.erb +26 -0
  93. data/views/shell.erb +35 -0
  94. data/views/users.erb +69 -0
  95. metadata +256 -0
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Wei Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,13 @@
1
+ explain-git-with-d3
2
+ ===================
3
+
4
+ Use D3 to visualize simple git branching operations.
5
+
6
+ This simple project is designed to help people understand some basic git concepts visually.
7
+
8
+ This is my first attempt at using both SVG and D3. I hope it is helpful to you.
9
+
10
+ I upload the contents of this repository via FTP every once in a while to: http://www.wei-wang.com/ExplainGitWithD3/
11
+ so you can just visit that site to use an (almost) up to date version.
12
+
13
+ UPDATE: the page can now also be accessed via: http://onlywei.github.io/explain-git-with-d3/
@@ -0,0 +1,227 @@
1
+ /* styles */
2
+ body {
3
+ min-width: 1200px;
4
+ }
5
+
6
+ #menuwrapper {
7
+ position: fixed;
8
+ width: 100%;
9
+ min-height: 9px;
10
+ border-bottom: 1px solid #888;
11
+ margin: 0;
12
+ background-color: #dfdfdf;
13
+ opacity: 0.98;
14
+ z-index: 150;
15
+ background: #dfdfdf url(../images/grippy.png) no-repeat bottom center;
16
+ }
17
+
18
+ #menubar {
19
+ background: #dfdfdf url(../images/grippy-close.png) no-repeat bottom center;
20
+ }
21
+
22
+ .intro {
23
+ padding: 10px 4em 0 0;
24
+ }
25
+ .intro p, .concept-container p {
26
+ padding-top: 10px;
27
+ }
28
+
29
+ a.openswitch {
30
+ display: block;
31
+ }
32
+
33
+ a.openswitch.selected {
34
+ font-weight: bold;
35
+ }
36
+
37
+ .command-list, .example-list {
38
+ padding: 10px 0;
39
+ }
40
+
41
+ .command-list a.openswitch {
42
+ font-family: Courier New;
43
+ }
44
+
45
+ .concept-area {
46
+ padding-bottom: 20px;
47
+ min-height: 525px;
48
+ }
49
+
50
+ .concept-container {
51
+ display: none;
52
+ }
53
+
54
+ .playground-container {
55
+ height: 550px;
56
+ margin-top: 20px;
57
+ position: relative;
58
+ }
59
+
60
+ span.cmd {
61
+ background-color: #222222;
62
+ color: #FFFFFF;
63
+ font-family: Courier New;
64
+ padding: 0 0.2em;
65
+ }
66
+
67
+ #footer {
68
+ border-top: 2px dashed #888;
69
+ padding-top: 1em;
70
+ }
71
+ .svg-container {
72
+ display: inline-block;
73
+ border: 1px dotted #AAA;
74
+ }
75
+
76
+ .svg-container.remote-container {
77
+ position: absolute;
78
+ top: 0px; right: 0px;
79
+ background-color: #EFF1FF;
80
+ border-left: 1px dotted #AAA;
81
+ border-bottom: 1px dotted #AAA;
82
+ }
83
+
84
+ .remote-name-display {
85
+ font-weight: bold;
86
+ text-align: right;
87
+ }
88
+
89
+ .control-box {
90
+ display: inline-block;
91
+ width: 250px;
92
+ vertical-align: bottom;
93
+ background-color: #000;
94
+ border: 1px dotted #AAA;
95
+ }
96
+
97
+ .control-box button {
98
+ font-family: Courier New;
99
+ font-size: 12px;
100
+ margin-right: 5px;
101
+ margin-bottom: 5px;
102
+ }
103
+
104
+ .control-box .log {
105
+ overflow-y: auto;
106
+ border-bottom: 1px solid #AAA;
107
+ }
108
+
109
+ .control-box .log,
110
+ .control-box input[type="text"] {
111
+ font-family: Courier New;
112
+ font-size: 14px;
113
+ }
114
+
115
+ .control-box .log .command-entry,
116
+ .control-box input[type="text"] {
117
+ padding-left: 15px;
118
+ color: #FFF;
119
+ line-height: 14px;
120
+ background: url(../images/prompt.gif) no-repeat left center transparent;
121
+ }
122
+
123
+ .control-box .log .info,
124
+ .control-box .log .error {
125
+ font-size: 12px;
126
+ padding: 5px;
127
+ }
128
+
129
+ .control-box .log .info {
130
+ color: #FFC;
131
+ }
132
+
133
+ .control-box .log .error {
134
+ color: #FCC;
135
+ }
136
+
137
+ .control-box input[type="text"] {
138
+ width: 235px;
139
+ border: none;
140
+ }
141
+
142
+ circle.commit {
143
+ fill: #EEEEEE;
144
+ stroke: #888888;
145
+ stroke-width: 3;
146
+ }
147
+
148
+ circle.commit.checked-out {
149
+ fill: #CCFFCC !important;
150
+ stroke: #339900;
151
+ }
152
+
153
+ circle.commit.merge-commit {
154
+ stroke: #663300;
155
+ fill: #FFFFCC;
156
+ }
157
+
158
+ circle.commit.reverted {
159
+ fill: #FFC;
160
+ stroke: #933;
161
+ }
162
+
163
+ circle.commit.rebased {
164
+ stroke: #3300CC;
165
+ fill: #CCCCFF;
166
+ }
167
+
168
+ circle.commit.branchless {
169
+ fill: #FEFEFE;
170
+ stroke: #DDD;
171
+ }
172
+
173
+ .commit-pointer {
174
+ stroke: #666;
175
+ stroke-width: 4;
176
+ }
177
+
178
+ .merge-pointer {
179
+ stroke: #663300;
180
+ stroke-width: 4;
181
+ }
182
+
183
+ .commit-pointer.branchless,
184
+ .merge-pointer.branchless {
185
+ stroke: #DDD;
186
+ stroke-width: 2;
187
+ }
188
+
189
+ text.id-label {
190
+ text-anchor: middle;
191
+ font-family: Courier New;
192
+ fill: #666;
193
+ font-size: 10px;
194
+ }
195
+
196
+ g.branch-tag > rect {
197
+ fill: #FFCC66;
198
+ stroke: #CC9900;
199
+ stroke-width: 2;
200
+ }
201
+
202
+ g.branch-tag.remote-branch > rect {
203
+ fill: #CCC;
204
+ stroke: #888;
205
+ }
206
+
207
+ g.branch-tag > text {
208
+ text-anchor: middle;
209
+ fill: #000;
210
+ font-size: 11px;
211
+ font-family: Arial;
212
+ }
213
+
214
+ g.head-tag > rect {
215
+ fill: #CCFFCC;
216
+ stroke: #339900;
217
+ stroke-width: 2;
218
+ }
219
+
220
+ g.head-tag > text {
221
+ text-anchor: middle;
222
+ fill: #000;
223
+ font-size: 11px;
224
+ font-family: Arial;
225
+ font-weight: bold;
226
+ text-transform: uppercase;
227
+ }
@@ -0,0 +1,130 @@
1
+ /* CSS Resets */
2
+
3
+ html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,address,cite,code,del,dfn,em,img,ins,q,small,strong,sub,sup,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{border:0;margin:0;padding:0}article,aside,figure,figure img,figcaption,hgroup,footer,header,nav,section,video,object{display:block}a img{border:0}figure{position:relative}figure img{width:100%}
4
+
5
+
6
+ /* ==================================================================================================================== */
7
+ /* ! The 1140px Grid V2 by Andy Taylor \ http://cssgrid.net \ http://www.twitter.com/andytlr \ http://www.andytlr.com */
8
+ /* ==================================================================================================================== */
9
+
10
+ .container {
11
+ padding-left: 20px;
12
+ padding-right: 20px;
13
+ }
14
+
15
+ .row {
16
+ width: 100%;
17
+ max-width: 1140px;
18
+ min-width: 755px;
19
+ margin: 0 auto;
20
+ overflow: hidden;
21
+ }
22
+
23
+ .onecol, .twocol, .threecol, .fourcol, .fivecol, .sixcol, .sevencol, .eightcol, .ninecol, .tencol, .elevencol {
24
+ margin-right: 3.8%;
25
+ float: left;
26
+ min-height: 1px;
27
+ }
28
+
29
+ .row .onecol {
30
+ width: 4.85%;
31
+ }
32
+
33
+ .row .twocol {
34
+ width: 13.45%;
35
+ }
36
+
37
+ .row .threecol {
38
+ width: 22.05%;
39
+ }
40
+
41
+ .row .fourcol {
42
+ width: 30.75%;
43
+ }
44
+
45
+ .row .fivecol {
46
+ width: 39.45%;
47
+ }
48
+
49
+ .row .sixcol {
50
+ width: 48%;
51
+ }
52
+
53
+ .row .sevencol {
54
+ width: 56.75%;
55
+ }
56
+
57
+ .row .eightcol {
58
+ width: 65.4%;
59
+ }
60
+
61
+ .row .ninecol {
62
+ width: 74.05%;
63
+ }
64
+
65
+ .row .tencol {
66
+ width: 82.7%;
67
+ }
68
+
69
+ .row .elevencol {
70
+ width: 91.35%;
71
+ }
72
+
73
+ .row .twelvecol {
74
+ width: 100%;
75
+ float: left;
76
+ }
77
+
78
+ .last {
79
+ margin-right: 0px;
80
+ }
81
+
82
+ img, object, embed {
83
+ max-width: 100%;
84
+ }
85
+
86
+ img {
87
+ height: auto;
88
+ }
89
+
90
+
91
+ /* Smaller screens */
92
+
93
+ @media only screen and (max-width: 1023px) {
94
+
95
+ body {
96
+ font-size: 0.8em;
97
+ line-height: 1.5em;
98
+ }
99
+
100
+ }
101
+
102
+
103
+ /* Mobile */
104
+
105
+ @media handheld, only screen and (max-width: 767px) {
106
+
107
+ body {
108
+ font-size: 16px;
109
+ -webkit-text-size-adjust: none;
110
+ }
111
+
112
+ .row, body, .container {
113
+ width: 100%;
114
+ min-width: 0;
115
+ margin-left: 0px;
116
+ margin-right: 0px;
117
+ padding-left: 0px;
118
+ padding-right: 0px;
119
+ }
120
+
121
+ .row .onecol, .row .twocol, .row .threecol, .row .fourcol, .row .fivecol, .row .sixcol, .row .sevencol, .row .eightcol, .row .ninecol, .row .tencol, .row .elevencol, .row .twelvecol {
122
+ width: auto;
123
+ float: none;
124
+ margin-left: 0px;
125
+ margin-right: 0px;
126
+ padding-left: 20px;
127
+ padding-right: 20px;
128
+ }
129
+
130
+ }
Binary file
Binary file
@@ -0,0 +1,734 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
5
+ <title>Visualizing Git</title>
6
+ <script data-main="js/main" src="js/vendor/require.min.js"></script>
7
+ <script type="text/javascript" src="js/vendor/jquery-latest.min.js"></script>
8
+ <script type="text/javascript">
9
+ $( document ).ready(function() {
10
+ $('#menubar').delay(1000).slideUp(500);
11
+
12
+ $("#menuwrapper").hover(
13
+ function() {
14
+ $('#menubar').show();
15
+ $('#menubar-handle').hide();
16
+ },
17
+ function() {
18
+ $('#menubar').slideUp(250);
19
+ $('#menubar-handle').show();
20
+ }
21
+ );
22
+ });
23
+ </script>
24
+ <link rel="stylesheet" href="js/vendor/normalize.css">
25
+ <link rel="stylesheet" href="css/vendor/1140.css">
26
+ <link rel="stylesheet" href="css/explaingit.css">
27
+ </head>
28
+ <body>
29
+ <div id="menuwrapper">
30
+ <div id="menubar">
31
+ <div class="row command-list">
32
+ <div class="twocol">
33
+ <h4>Basic Commands</h3>
34
+ <a id="open-commit" class="openswitch" href="#" onClick="return false;">git commit</a>
35
+ <a id="open-branch" class="openswitch" href="#" onClick="return false;">git branch</a>
36
+ </div>
37
+ <div class="twocol">
38
+ <h4>&nbsp;</h4>
39
+ <a id="open-checkout" class="openswitch" href="#" onClick="return false;">git checkout</a>
40
+ <a id="open-checkout-b" class="openswitch" href="#" onClick="return false;">git checkout -b</a>
41
+ </div>
42
+ <div class="twocol">
43
+ <h4>Undo Commits</h4>
44
+ <a id="open-reset" class="openswitch" href="#" onClick="return false;">git reset</a>
45
+ <a id="open-revert" class="openswitch" href="#" onClick="return false;">git revert</a>
46
+ </div>
47
+ <div class="twocol">
48
+ <h4>Combine Branches</h4>
49
+ <a id="open-merge" class="openswitch" href="#" onClick="return false;">git merge</a>
50
+ <a id="open-rebase" class="openswitch" href="#" onClick="return false;">git rebase</a>
51
+ </div>
52
+ <div class="twocol">
53
+ <h4>Remote Server</h4>
54
+ <a id="open-fetch" class="openswitch" href="#" onClick="return false;">git fetch</a>
55
+ <a id="open-pull" class="openswitch" href="#" onClick="return false;">git pull</a>
56
+ </div>
57
+ <div class="twocol last">
58
+ <h4>&nbsp;</h4>
59
+ <a id="open-push" class="openswitch" href="#" onClick="return false;">git push</a>
60
+ </div>
61
+ </div>
62
+ <div class="row command-list">
63
+ <div class="tencol">
64
+ <h4>Real World Scenarios</h4>
65
+ <a id="open-clean" class="openswitch" href="#" onClick="return false;">Restore Local Branch to State on Origin Server</a>
66
+ <a id="open-fetchrebase" class="openswitch" href="#" onClick="return false;">Update Private Local Branch with Latest from Origin</a>
67
+ <a id="open-deletebranches" class="openswitch" href="#" onClick="return false;">Deleting Local Branches</a>
68
+ </div>
69
+ <div class="twocol last">
70
+ <a id="open-freeplay" class="openswitch" href="#" onClick="return false;">Free Playground</a>
71
+ </div>
72
+ </div>
73
+ </div>
74
+ </div>
75
+ <a href="https://github.com/onlywei/explain-git-with-d3">
76
+ <img style="position: absolute; top: 0; right: 0; border: 0;"
77
+ src="images/forkme_right_red_aa0000.png"
78
+ alt="Fork me on GitHub">
79
+ </a>
80
+ <div class="container">
81
+ <div class="row intro">
82
+ <div class="twelvecol">
83
+ <h1>Visualizing Git Concepts</h1>
84
+ <p>
85
+ This tool is designed to help you understand some fundamental git concepts visually.
86
+ Choose a scenario to explore from the dropdown menu above.
87
+ </p>
88
+ <p>
89
+ Scenario explanations are displayed below the repository viewer.
90
+ </p>
91
+ </div>
92
+ </div>
93
+ <div class="row concept-area">
94
+ <div id="ExplainGitCommit-Container" class="twelvecol concept-container">
95
+ <div class="playground-container"></div>
96
+ <p>
97
+ We are going to skip instructing you on how to add your files for commit in this explanation.
98
+ Let's assume you already know how to do that. If you don't, go read some other tutorials.
99
+ </p>
100
+ <p>
101
+ Pretend that you already have your files staged for commit and enter <span class="cmd">git commit</span>
102
+ as many times as you like in the terminal box.
103
+ </p>
104
+ </div>
105
+ <div id="ExplainGitBranch-Container" class="twelvecol concept-container">
106
+ <div class="playground-container"></div>
107
+ <p>
108
+ <span class="cmd">git branch name</span> will create a new branch named "name".
109
+ Creating branches just creates a new tag pointing to the currently checked out commit.
110
+ </p>
111
+ <p>
112
+ Branches can be deleted using the command <span class="cmd">git branch -d name</span>.
113
+ </p>
114
+ <p>
115
+ Type <span class="cmd">git commit</span> and <span class="cmd">git branch</span> commands
116
+ to your heart's desire until you understand this concept.
117
+ </p>
118
+ </div>
119
+ <div id="ExplainGitCheckout-Container" class="twelvecol concept-container">
120
+ <div class="playground-container"></div>
121
+ <p>
122
+ <span class="cmd">git checkout</span> has many uses,
123
+ but the main one is to switch between branches.</br>
124
+ For example, to switch from master branch to dev branch,
125
+ I would type <span class="cmd">git checkout dev</span>.
126
+ After that, if I do a git commit, notice where it goes. Try it.
127
+ </p>
128
+ <p>
129
+ In addition to checking out branches, you can also checkout individual commits. Try it.</br>
130
+ Make a new commit and then type <span class="cmd">git checkout bb92e0e</span>
131
+ and see what happens.
132
+ </p>
133
+ <p>
134
+ Type <span class="cmd">git commit</span>, <span class="cmd">git branch</span>,
135
+ and <span class="cmd">git checkout</span> commands to your heart's desire
136
+ until you understand this concept.
137
+ </p>
138
+ </div>
139
+ <div id="ExplainGitCheckout-b-Container" class="twelvecol concept-container">
140
+ <div class="playground-container"></div>
141
+ <p>
142
+ You can combine <span class="cmd">git branch</span> and <span class="cmd">git checkout</span>
143
+ into a single command by typing <span class="cmd">git checkout -b branchname</span>.
144
+ This will create the branch if it does not already exist and immediately check it out.
145
+ </p>
146
+ </div>
147
+ <div id="ExplainGitReset-Container" class="twelvecol concept-container">
148
+ <div class="playground-container"></div>
149
+ <p>
150
+ <span class="cmd">git reset</span> will move HEAD and the current branch back to wherever
151
+ you specify, abandoning any commits that may be left behind. This is useful to undo a commit
152
+ that you no longer need.
153
+ </p>
154
+ <p>
155
+ This command is normally used with one of three flags: "--soft", "--mixed", and "--hard".
156
+ The soft and mixed flags deal with what to do with the work that was inside the commit after
157
+ you reset, and you can read about it <a href="http://git-scm.com/2011/07/11/reset.html">here</a>.
158
+ Since this visualization cannot graphically display that work, only the "--hard" flag will work
159
+ on this site.
160
+ </p>
161
+ <p>
162
+ The ref "HEAD^" is usually used together with this command. "HEAD^" means "the commit right
163
+ before HEAD. "HEAD^^" means "two commits before HEAD", and so on.
164
+ </p>
165
+ <p>
166
+ Note that you must <b>never</b> use <span class="cmd">git reset</span> to abandon commits
167
+ that have already been pushed and merged into the origin. This can cause your local repository
168
+ to become out of sync with the origin. Don't do it unless you really know what you're doing.
169
+ </p>
170
+ </div>
171
+ <div id="ExplainGitRevert-Container" class="twelvecol concept-container">
172
+ <div class="playground-container"></div>
173
+ <p>
174
+ To undo commits that have already been pushed and shared with the team, we cannot use the
175
+ <span class="cmd">git reset</span> command. Instead, we have to use <span class="cmd">git revert</span>.
176
+ </p>
177
+ <p>
178
+ <span class="cmd">git revert</span> will create a new commit that will undo all of the work that
179
+ was done in the commit you want to revert.
180
+ </p>
181
+ </div>
182
+ <div id="ExplainGitMerge-Container" class="twelvecol concept-container">
183
+ <div class="playground-container"></div>
184
+ <p>
185
+ <span class="cmd">git merge</span> will create a new commit with two parents. The resulting
186
+ commit snapshot will have the all of the work that has been done in both branches.
187
+ </p>
188
+ <p>
189
+ If there was no divergence between the two commits, git will do a "fast-forward" method merge.</br>
190
+ To see this happen, checkout the 'ff' branch and then type <span class="cmd">git merge dev</span>.
191
+ </p>
192
+ </div>
193
+ <div id="ExplainGitRebase-Container" class="twelvecol concept-container">
194
+ <div class="playground-container"></div>
195
+ <p>
196
+ <span class="cmd">git rebase</span> will take the commits on this branch and "move" them so that their
197
+ new "base" is at the point you specify.
198
+ </p>
199
+ <p>
200
+ You should pay close attention to the commit IDs of the circles as they move when you do this exercise.
201
+ </p>
202
+ <p>
203
+ The reason I put "move" in quotations because this process actually generates brand new commits with
204
+ completely different IDs than the old commits, and leaves the old commits where they were. For this reason,
205
+ you never want to rebase commits that have already been shared with the team you are working with.
206
+ </p>
207
+ </div>
208
+ <div id="ExplainGitFetch-Container" class="twelvecol concept-container">
209
+ <div class="playground-container"></div>
210
+ <p>
211
+ <span class="cmd">git fetch</span> will update all of the "remote tracking branches" in your local repository.
212
+ Remote tracking branches are tagged in grey.
213
+ </p>
214
+ </div>
215
+ <div id="ExplainGitPull-Container" class="twelvecol concept-container">
216
+ <div class="playground-container"></div>
217
+ <p>
218
+ A <span class="cmd">git pull</span> is a two step process that first does a <span class="cmd">git fetch</span>,
219
+ and then does a <span class="cmd">git merge</span> of the remote tracking branch associated with your current branch.
220
+ If you have no current branch, the process will stop after fetching.
221
+ </p>
222
+ <p>
223
+ If the argument "--rebase" was given by typing <span class="cmd">git pull --rebase</span>, the second step of
224
+ pull process will be a rebase instead of a merge. This can be set to the default behavior by configuration by typing:
225
+ <span class="cmd">git config branch.BRANCHNAME.rebase true</span>.
226
+ </p>
227
+ </div>
228
+ <div id="ExplainGitPush-Container" class="twelvecol concept-container">
229
+ <div class="playground-container"></div>
230
+ <p>
231
+ A <span class="cmd">git push</span> will find the commits you have on your local branch that the corresponding branch
232
+ on the origin server does not have, and send them to the remote repository.
233
+ </p>
234
+ <p>
235
+ By default, all pushes must cause a fast-forward merge on the remote repository. If there is any divergence between
236
+ your local branch and the remote branch, your push will be rejected. In this scenario, you need to pull first and then
237
+ you will be able to push again.
238
+ </p>
239
+ </div>
240
+ <div id="ExplainGitClean-Container" class="twelvecol concept-container">
241
+ <div class="playground-container"></div>
242
+ <p>
243
+ One simple example of the use of <span class="cmd">git reset</span> is to completely restore your local repository
244
+ state to that of the origin.</br>
245
+ You can do so by typing <span class="cmd">git reset origin/master</span>.
246
+ </p>
247
+ <p>
248
+ Note that this won't delete untracked files, you will have to delete those separately with
249
+ the command <span class="cmd">git clean -df</span>.
250
+ </p>
251
+ </div>
252
+ <div id="ExplainGitFetchRebase-Container" class="twelvecol concept-container">
253
+ <div class="playground-container"></div>
254
+ <p>
255
+ Below is a situation in which you are working in a local branch that is all your own. You want to receive the latest code
256
+ from the origin server's master branch. To update your local branch, you can do it without having to switch branches!
257
+ </p>
258
+ <p>
259
+ First do a <span class="cmd">git fetch</span>, then type <span class="cmd">git rebase origin/master</span>!
260
+ </p>
261
+ </div>
262
+ <div id="ExplainGitDeleteBranches-Container" class="twelvecol concept-container">
263
+ <div class="playground-container"></div>
264
+ <p>
265
+ <span class="cmd">git branch -d</span> is used to delete branches.
266
+ I have pre-created a bunch of branches for you to delete in the playground below.
267
+ Have at it.
268
+ </p>
269
+ </div>
270
+ <div id="ExplainGitFree-Container" class="twelvecol concept-container">
271
+ <div class="playground-container"></div>
272
+ <p>
273
+ Do whatever you want in this free playground.
274
+ </p>
275
+ </div>
276
+ </div>
277
+ <div id="footer">
278
+ <p>
279
+ In all scenarios, assume that files are staged and ready to commit at all times. If
280
+ you need a refresher on how to add or stage files for commit, please read
281
+ <a href="http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository">Git Basics</a>.
282
+ </p>
283
+ </div>
284
+ </div>
285
+
286
+ <svg version="1.1" baseProfile="full"
287
+ xmlns="http://www.w3.org/2000/svg"
288
+ xmlns:xlink="http://www.w3.org/1999/xlink"
289
+ xmlns:ev="http://www.w3.org/2001/xml-events"
290
+ width="0" height="0">
291
+
292
+ <marker id="triangle" refX="5" refY="5" markerUnits="strokeWidth" fill="#666"
293
+ markerWidth="4" markerHeight="3" orient="auto" viewBox="0 0 10 10">
294
+ <path d="M 0 0 L 10 5 L 0 10 z"/>
295
+ </marker>
296
+ <marker id="faded-triangle" refX="5" refY="5" markerUnits="strokeWidth" fill="#DDD"
297
+ markerWidth="4" markerHeight="3" orient="auto" viewBox="0 0 10 10">
298
+ <path d="M 0 0 L 10 5 L 0 10 z"/>
299
+ </marker>
300
+ <marker id="brown-triangle" refX="5" refY="5" markerUnits="strokeWidth" fill="#663300"
301
+ markerWidth="4" markerHeight="3" orient="auto" viewBox="0 0 10 10">
302
+ <path d="M 0 0 L 10 5 L 0 10 z"/>
303
+ </marker>
304
+ </svg>
305
+
306
+ <script type="text/javascript">
307
+ require(['explaingit'], function (explainGit) {
308
+ var openSwitch = document.getElementById('open-commit'),
309
+ open;
310
+
311
+ open = function () {
312
+ explainGit.reset();
313
+ this.classList.add('selected');
314
+
315
+ explainGit.open({
316
+ name: 'Commit',
317
+ height: 200,
318
+ baseLine: 0.4,
319
+ commitData: [
320
+ {id: 'e137e9b', tags: ['master']}
321
+ ],
322
+ initialMessage: 'Type git commit a few times.'
323
+ });
324
+ };
325
+
326
+ openSwitch.addEventListener('click', open, false);
327
+ });
328
+ </script>
329
+
330
+ <script type="text/javascript">
331
+ require(['explaingit'], function (explainGit) {
332
+ var openSwitch = document.getElementById('open-branch'),
333
+ open;
334
+
335
+ open = function () {
336
+ explainGit.reset();
337
+ this.classList.add('selected');
338
+
339
+ explainGit.open({
340
+ name: 'Branch',
341
+ baseLine: 0.6,
342
+ commitData: [
343
+ {id: 'e137e9b', tags: ['master']}
344
+ ]
345
+ });
346
+ };
347
+
348
+ openSwitch.addEventListener('click', open, false);
349
+ });
350
+ </script>
351
+
352
+ <script type="text/javascript">
353
+ require(['explaingit'], function (explainGit) {
354
+ var openSwitch = document.getElementById('open-checkout'),
355
+ open;
356
+
357
+ open = function () {
358
+ explainGit.reset();
359
+ this.classList.add('selected');
360
+
361
+ explainGit.open({
362
+ name: 'Checkout',
363
+ height: 500,
364
+ commitData: [
365
+ {id: 'e137e9b'},
366
+ {id: 'bb92e0e', parent: 'e137e9b', tags: ['master']},
367
+ {id: 'e088135', parent: 'e137e9b', tags: ['dev']}
368
+ ],
369
+ initialMessage:
370
+ 'Use git checkout, git branch, and git commit commands until you understand.'
371
+ });
372
+ };
373
+
374
+ openSwitch.addEventListener('click', open, false);
375
+ });
376
+ </script>
377
+
378
+ <script type="text/javascript">
379
+ require(['explaingit'], function (explainGit) {
380
+ var openSwitch = document.getElementById('open-checkout-b'),
381
+ open;
382
+
383
+ open = function () {
384
+ explainGit.reset();
385
+ this.classList.add('selected');
386
+
387
+ explainGit.open({
388
+ name: 'Checkout-b',
389
+ height: 500,
390
+ commitData: [
391
+ {id: 'e137e9b'},
392
+ {id: 'f5b32c8', parent: 'e137e9b'},
393
+ {id: 'bb92e0e', parent: 'f5b32c8', tags: ['master']},
394
+ {id: 'e088135', parent: 'e137e9b', tags: ['dev']}
395
+ ],
396
+ initialMessage:
397
+ 'Use git checkout -b and git commit commands until you understand.'
398
+ });
399
+ };
400
+
401
+ openSwitch.addEventListener('click', open, false);
402
+ });
403
+ </script>
404
+
405
+ <script type="text/javascript">
406
+ require(['explaingit'], function (explainGit) {
407
+ var openSwitch = document.getElementById('open-reset'),
408
+ open;
409
+
410
+ open = function () {
411
+ explainGit.reset();
412
+ this.classList.add('selected');
413
+
414
+ explainGit.open({
415
+ name: 'Reset',
416
+ height: 200,
417
+ baseLine: 0.5,
418
+ commitData: [
419
+ {id: 'e137e9b'},
420
+ {id: '0e70093', parent: 'e137e9b'},
421
+ {id: '3e33afd', parent: '0e70093', tags: ['master']}
422
+ ],
423
+ initialMessage: 'Type "git reset HEAD^".'
424
+ });
425
+ };
426
+
427
+ openSwitch.addEventListener('click', open, false);
428
+ });
429
+ </script>
430
+
431
+ <script type="text/javascript">
432
+ require(['explaingit'], function (explainGit) {
433
+ var openSwitch = document.getElementById('open-revert'),
434
+ open;
435
+
436
+ open = function () {
437
+ explainGit.reset();
438
+ this.classList.add('selected');
439
+
440
+ explainGit.open({
441
+ name: 'Revert',
442
+ height: 200,
443
+ baseLine: 0.5,
444
+ commitData: [
445
+ {id: 'e137e9b'},
446
+ {id: '0e70093', parent: 'e137e9b'},
447
+ {id: '3e33afd', parent: '0e70093', tags: ['master']}
448
+ ],
449
+ initialMessage: 'Type "git revert 0e70093".'
450
+ });
451
+ };
452
+
453
+ openSwitch.addEventListener('click', open, false);
454
+ });
455
+ </script>
456
+
457
+ <script type="text/javascript">
458
+ require(['explaingit'], function (explainGit) {
459
+ var openSwitch = document.getElementById('open-merge'),
460
+ open;
461
+
462
+ open = function () {
463
+ explainGit.reset();
464
+ this.classList.add('selected');
465
+
466
+ explainGit.open({
467
+ name: 'Merge',
468
+ height: 500,
469
+ commitData: [
470
+ {id: 'e137e9b'},
471
+ {id: 'bb92e0e', parent: 'e137e9b', tags: ['master']},
472
+ {id: 'f5b32c8', parent: 'e137e9b', tags: ['ff']},
473
+ {id: 'e088135', parent: 'f5b32c8', tags: ['dev']}
474
+ ],
475
+ initialMessage:
476
+ 'Type "git merge dev".'
477
+ });
478
+ };
479
+
480
+ openSwitch.addEventListener('click', open, false);
481
+ });
482
+ </script>
483
+
484
+ <script type="text/javascript">
485
+ require(['explaingit'], function (explainGit) {
486
+ var openSwitch = document.getElementById('open-rebase'),
487
+ open;
488
+
489
+ open = function () {
490
+ explainGit.reset();
491
+ this.classList.add('selected');
492
+
493
+ explainGit.open({
494
+ name: 'Rebase',
495
+ height: 500,
496
+ commitData: [
497
+ {id: 'e137e9b'},
498
+ {id: 'bb92e0e', parent: 'e137e9b', tags: ['master']},
499
+ {id: 'f5b32c8', parent: 'e137e9b'},
500
+ {id: 'e088135', parent: 'f5b32c8', tags: ['dev']}
501
+ ],
502
+ currentBranch: 'dev',
503
+ initialMessage:
504
+ 'Type "git rebase master".'
505
+ });
506
+ };
507
+
508
+ openSwitch.addEventListener('click', open, false);
509
+ });
510
+ </script>
511
+
512
+ <script type="text/javascript">
513
+ require(['explaingit'], function (explainGit) {
514
+ var openSwitch = document.getElementById('open-fetch'),
515
+ open;
516
+
517
+ open = function () {
518
+ explainGit.reset();
519
+ this.classList.add('selected');
520
+
521
+ explainGit.open({
522
+ name: 'Fetch',
523
+ height: 500,
524
+ commitData: [
525
+ {id: 'e137e9b', tags: ['origin/master']},
526
+ {id: '6ce726f', parent: 'e137e9b'},
527
+ {id: 'bb92e0e', parent: '6ce726f', tags: ['master']},
528
+ {id: '0cff760', parent: 'e137e9b', tags: ['origin/dev']},
529
+ {id: '4ed301d', parent: '0cff760', tags: ['dev']}
530
+ ],
531
+ originData: [
532
+ {id: 'e137e9b'},
533
+ {id: '7eb7654', parent: 'e137e9b'},
534
+ {id: '090e2b8', parent: '7eb7654'},
535
+ {id: 'ee5df4b', parent: '090e2b8', tags: ['master']},
536
+ {id: '0cff760', parent: 'e137e9b'},
537
+ {id: '2f8d946', parent: '0cff760'},
538
+ {id: '29235ca', parent: '2f8d946', tags: ['dev']}
539
+ ],
540
+ initialMessage:
541
+ 'Carefully compare the commit IDs between the origin and the local repository. ' +
542
+ 'Then type "git fetch".'
543
+ });
544
+ };
545
+
546
+ openSwitch.addEventListener('click', open, false);
547
+ });
548
+ </script>
549
+
550
+ <script type="text/javascript">
551
+ require(['explaingit'], function (explainGit) {
552
+ var openSwitch = document.getElementById('open-pull'),
553
+ open;
554
+
555
+ open = function () {
556
+ explainGit.reset();
557
+ this.classList.add('selected');
558
+
559
+ explainGit.open({
560
+ name: 'Pull',
561
+ height: 500,
562
+ commitData: [
563
+ {id: 'e137e9b', tags: ['origin/master']},
564
+ {id: '46d095b', parent: 'e137e9b', tags: ['master']}
565
+ ],
566
+ originData: [
567
+ {id: 'e137e9b'},
568
+ {id: '7eb7654', parent: 'e137e9b'},
569
+ {id: '090e2b8', parent: '7eb7654'},
570
+ {id: 'ee5df4b', parent: '090e2b8', tags: ['master']}
571
+ ],
572
+ initialMessage:
573
+ 'Carefully compare the commit IDs between the origin and the local repository. ' +
574
+ 'Then type "git pull".'
575
+ });
576
+ };
577
+
578
+ openSwitch.addEventListener('click', open, false);
579
+ });
580
+ </script>
581
+
582
+ <script type="text/javascript">
583
+ require(['explaingit'], function (explainGit) {
584
+ var openSwitch = document.getElementById('open-push'),
585
+ open;
586
+
587
+ open = function () {
588
+ explainGit.reset();
589
+ this.classList.add('selected');
590
+
591
+ explainGit.open({
592
+ name: 'Push',
593
+ height: 500,
594
+ commitData: [
595
+ {id: 'e137e9b', tags: ['origin/master']},
596
+ {id: '46d095b', parent: 'e137e9b', tags: ['master']}
597
+ ],
598
+ originData: [
599
+ {id: 'e137e9b'},
600
+ {id: '7eb7654', parent: 'e137e9b', tags: ['master']}
601
+ ],
602
+ initialMessage:
603
+ 'Carefully compare the commit IDs between the origin and the local repository. ' +
604
+ 'Then type "git push".'
605
+ });
606
+ };
607
+
608
+ openSwitch.addEventListener('click', open, false);
609
+ });
610
+ </script>
611
+
612
+ <script type="text/javascript">
613
+ require(['explaingit'], function (explainGit) {
614
+ var openSwitch = document.getElementById('open-clean'),
615
+ open;
616
+
617
+ open = function () {
618
+ explainGit.reset();
619
+ this.classList.add('selected');
620
+
621
+ explainGit.open({
622
+ name: 'Clean',
623
+ height: 200,
624
+ baseLine: 0.4,
625
+ commitData: [
626
+ {id: 'e137e9b', tags: ['origin/master']},
627
+ {id: '0e70093', parent: 'e137e9b'},
628
+ {id: '3e33afd', parent: '0e70093', tags: ['master']}
629
+ ],
630
+ initialMessage: 'Type "git reset origin/master".'
631
+ });
632
+ };
633
+
634
+ openSwitch.addEventListener('click', open, false);
635
+ });
636
+ </script>
637
+
638
+ <script type="text/javascript">
639
+ require(['explaingit'], function (explainGit) {
640
+ var openSwitch = document.getElementById('open-fetchrebase'),
641
+ open;
642
+
643
+ open = function () {
644
+ explainGit.reset();
645
+ this.classList.add('selected');
646
+
647
+ explainGit.open({
648
+ name: 'FetchRebase',
649
+ height: 500,
650
+ commitData: [
651
+ {id: 'e137e9b', tags: ['origin/master', 'master']},
652
+ {id: '46d095b', parent: 'e137e9b'},
653
+ {id: 'dccdc4d', parent: '46d095b', tags: ['my-branch']}
654
+ ],
655
+ currentBranch: 'my-branch',
656
+ originData: [
657
+ {id: 'e137e9b'},
658
+ {id: '7eb7654', parent: 'e137e9b'},
659
+ {id: '090e2b8', parent: '7eb7654'},
660
+ {id: 'ee5df4b', parent: '090e2b8', tags: ['master']}
661
+ ],
662
+ initialMessage:
663
+ 'First type "git fetch". Then type "git rebase origin/master".'
664
+ });
665
+ };
666
+
667
+ openSwitch.addEventListener('click', open, false);
668
+ });
669
+ </script>
670
+
671
+ <script type="text/javascript">
672
+ require(['explaingit'], function (explainGit) {
673
+ var openSwitch = document.getElementById('open-deletebranches'),
674
+ open;
675
+
676
+ open = function () {
677
+ explainGit.reset();
678
+ this.classList.add('selected');
679
+
680
+ explainGit.open({
681
+ name: 'DeleteBranches',
682
+ height: 500,
683
+ baseLine: 0.6,
684
+ commitData: [
685
+ {id: 'e137e9b'},
686
+ {id: 'bb92e0e', parent: 'e137e9b'},
687
+ {id: 'd25ee9b', parent: 'bb92e0e', tags: ['master']},
688
+ {id: '071ff28', parent: 'e137e9b', tags: ['protoss']},
689
+ {id: 'f5b32c8', parent: 'bb92e0e'},
690
+ {id: 'e088135', parent: 'f5b32c8', tags: ['zerg']},
691
+ {id: '9e6c322', parent: 'bb92e0e'},
692
+ {id: '593ae02', parent: '9e6c322', tags: ['terran']}
693
+ ],
694
+ currentBranch: 'terran',
695
+ initialMessage:
696
+ 'Delete some branches.'
697
+ });
698
+ };
699
+
700
+ openSwitch.addEventListener('click', open, false);
701
+ });
702
+ </script>
703
+
704
+ <script type="text/javascript">
705
+ require(['explaingit'], function (explainGit) {
706
+ var openSwitch = document.getElementById('open-freeplay'),
707
+ open;
708
+
709
+ open = function () {
710
+ explainGit.reset();
711
+ this.classList.add('selected');
712
+
713
+ explainGit.open({
714
+ name: 'Free',
715
+ height: 500,
716
+ commitData: [
717
+ {id: 'e137e9b', tags: ['origin/master', 'master']}
718
+ ],
719
+ originData: [
720
+ {id: 'e137e9b'},
721
+ {id: '7eb7654', parent: 'e137e9b'},
722
+ {id: '090e2b8', parent: '7eb7654'},
723
+ {id: 'ee5df4b', parent: '090e2b8', tags: ['master']}
724
+ ],
725
+ initialMessage:
726
+ 'Have fun.'
727
+ });
728
+ };
729
+
730
+ openSwitch.addEventListener('click', open, false);
731
+ });
732
+ </script>
733
+ </body>
734
+ </html>