1
-
2
1
# git
3
2
4
3
a way to keep track of changes you make to files. a very
@@ -46,10 +45,11 @@ https://www.youtube.com/watch?v=u2rZLVWOWvs
46
45
- ` git init `
47
46
- ` git status ` (should be empty)
48
47
- ` git add doge.png wow.html `
49
- - ` git status ` (now git is watching these files for changes!)
50
- - ` git commit -am "first commit" ` (now you've saved a snapshot
51
- of the directory. note: it will only commit changes in the files
52
- you're watching.)
48
+ - ` git status ` (now git is watching these files for
49
+ changes!)
50
+ - ` git commit -am "first commit" ` (now you've saved a
51
+ snapshot of the directory. note: it will only commit
52
+ changes in the files you're watching.)
53
53
- ` git status ` (should be clean)
54
54
55
55
---
@@ -58,9 +58,9 @@ https://www.youtube.com/watch?v=u2rZLVWOWvs
58
58
59
59
make a commit for each bit of progress you make.
60
60
61
- commit messages help track progress - make nice ones!
62
- it sucks to break something and then have a hard time
63
- finding the last working version!
61
+ commit messages help track progress - make nice ones! it
62
+ sucks to break something and then have a hard time finding
63
+ the last working version!
64
64
65
65
don't do ` git add . ` or ` git add * ` - you will add files
66
66
that you didn't mean to add!
@@ -71,21 +71,18 @@ that you didn't mean to add!
71
71
72
72
` git log `
73
73
74
- each commit has a unique identifier called a hash. it'll look
75
- something like this in the log: a5815fb05810bc0ebf53faaa4aba370055bf70d5
74
+ each commit has a unique identifier called a hash. it'll
75
+ look something like this:
76
+ a5815fb05810bc0ebf53faaa4aba370055bf70d5
76
77
77
- for a more compact log, do ` git log --oneline ` . you can also use
78
- the short hashes in that list to look at & revert to
79
- previous versions.
78
+ for a more compact log, do ` git log --oneline ` .
80
79
81
- ` git show 8d9c7f45ca1f1af59061fa64608666abef6cafd6 ` shows what changed
80
+ ` git show 8d9c7f45ca1f1af59061fa64608666abef6cafd6 ` shows
81
+ what changed
82
82
83
- to see what the entirety of a file looked like at a
84
- particular commit, do:
83
+ to see what one file looked like at a particular commit, do:
85
84
86
- ```
87
- git show 8d9c7f45ca1f1af59061fa64608666abef6cafd6:file.js
88
- ```
85
+ ` git show 8d9c7f45ca1f1af59061fa64608666abef6cafd6:file.js `
89
86
90
87
---
91
88
@@ -108,22 +105,18 @@ https://www.youtube.com/watch?v=3cMP4oBKO34
108
105
109
106
# starting a new github repo
110
107
111
- github repos live online, on github.com. you can have a
112
- million projects in local git repos and zero activity on
113
- github. to take your local repo and put it online (where it
114
- will live on forever regardless of what happens to your
115
- computer and where others can see your work & possibly even
116
- help you with it!), you first have to go to github.com.
117
-
118
- - on github: click the big green "new repository" button and
119
- follow the steps. NOTE: do not make a README.
120
- - on github: once your new github repository is ready, the
121
- site will show your new repo & display its git url. it
122
- will look something like this:
108
+ github repos live on github.com. you can have a million
109
+ projects in local git repos and zero activity on github. to
110
+ put your local repo online, first go to github.com.
111
+
112
+ - on github: click the "new repository" button NOTE: do not
113
+ make a README.
114
+ - on github: once your new repo is ready, the site will show
115
+ its git url. it will look like:
123
116
` [email protected] :cyberwizardinstitute/course-map.git`
124
- - in terminal do : `git remote add origin
117
+ - in terminal: `git remote add origin
125
118
[email protected] : cyberwizardinstitute /course-map.git`
126
- - in terminal do : ` git push origin master `
119
+ - in terminal: ` git push origin master `
127
120
128
121
now, when you go to your repo on github, it should have the
129
122
contents of your last commit.
@@ -143,14 +136,15 @@ directly to them.
143
136
- check that everything has copied with ` ls `
144
137
- make whatever changes you want
145
138
- ` git status `
146
- - ` git commit -am "adding xyz" ` (this makes a commit on your
147
- local machine)
148
- - ` git push origin master ` (this pushes your changes back up
149
- to github)
139
+ - ` git commit -am "adding xyz" ` (make a commit on your local
140
+ machine)
141
+ - ` git push origin master ` (push your changes back up to
142
+ github)
150
143
151
144
---
152
145
153
- # collaborating on existing github projects (w/o push access)
146
+ # collaborating on existing github projects (w/o push
147
+ # access)
154
148
155
149
for existing github projects that you'd like to work on but
156
150
that you don't have push access to, or where you'd like your
@@ -160,7 +154,8 @@ branch.
160
154
- on github, fork the repo you want to work with. (this will
161
155
give you your own copy of the repo on github, but not on
162
156
your local machine).
163
- - on github, go to your own fork of the repo and find the git url to clone the repo.
157
+ - on github, go to your own fork of the repo and find the
158
+ git url to clone the repo.
164
159
- in terminal: ` git clone xyz.git ` (this pulls your forked
165
160
copy to your local machine)
166
161
- check that everything has copied with ` ls `
@@ -183,8 +178,8 @@ shared github repo, do `git pull origin master` to make sure
183
178
that you have the most up to date version of the repo.
184
179
185
180
many existing open source projects have code review before
186
- your pull request can be merged. this is why it's a
187
- good idea to fork and work on your own branch of an existing
181
+ your pull request can be merged. this is why it's a good
182
+ idea to fork and work on your own branch of an existing
188
183
project.
189
184
190
185
---
@@ -195,5 +190,5 @@ Your homework is to do the git-it workshop on nodeschool:
195
190
196
191
http://nodeschool.io/#gitit
197
192
198
- and to submit a pull request to a project with a useful fix or
199
- addition.
193
+ and to submit a pull request to a project with a useful fix
194
+ or addition.
0 commit comments