You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/topics/01-setting_up/git_overview.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ git Overview
6
6
7
7
git is a very complex and powerful system. However, it can be very useful even if you only use a small portion of its functionality. This page should be bring you up to speed enough to make good use of git for the Python Certificate class.
8
8
9
-
Note that in the certificate program we will be using git in conjunction with gitHub, a cloud-based service that provides a collaboration environment for software development based on the git version control system.
9
+
Note that in the certificate program we will be using git in conjunction with gitHub (in particular gitHub Classroom), a cloud-based service that provides a collaboration environment for software development based on the git version control system.
10
10
11
11
gitHub provides a web service and web interface that hosts projects and supports collaboration among teams and the open source community. It adds other features, but is very much built on the source control system, git. So a basic understanding of git is required to make proper use of gitHub.
Copy file name to clipboardExpand all lines: source/topics/01-setting_up/github_classroom.rst
+15-3Lines changed: 15 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ Initial setup
30
30
=============
31
31
32
32
You will need an account on GitHub to participate in this course.
33
-
If you don't have already have a GitHub account or if you would prefer to use create a new one for this course, make sure you setup a new account on `GitHub <https://github.com/>`_. Always keep in mind that your account name will be part of the private repositories that will be created for each of your assignments and it will be visible to both your instructors and your classmates.
33
+
If you don't have already have a GitHub account or if you would prefer to create a new one for this course, make sure you setup a new account on `GitHub <https://github.com/>`_. Always keep in mind that your account name will be part of the private repositories that will be created for each of your assignments and it will be visible to both your instructors and your classmates.
34
34
35
35
You will need to have git setup on the computer you will use for developing your code for this course.
36
36
You can find instructions for setting up git (and the rest of your development environment) here:
@@ -88,12 +88,24 @@ Type the following to add all files and subdirectories in the folder to your com
88
88
89
89
git add .
90
90
91
-
Commit your code by typing the following::
91
+
NOTE: this can be a bit dangerous, as it will add everything! It's usually a bit safer to specifically add the file(s) you want to add::
92
+
93
+
git add some_code.py
94
+
95
+
After adding the file(s), you can commit your code by typing the following::
92
96
93
97
git commit -m "Commit message"
94
98
95
99
Note that the commit message should be replaced with something descriptive of what that commit includes ("added new functionality", "fixed floating point error", "ready for review", etc.) that will later help you remember what that particular commit was about.
96
100
101
+
After every change to the file, you will need to "commit" the changes.
102
+
103
+
You can always know what state git is in by using the "git status" command::
104
+
105
+
git status
106
+
107
+
It's a good idea to do that before committing, so you know what will happen.
108
+
97
109
98
110
Pushing Your Code
99
111
=================
@@ -108,7 +120,7 @@ You can push your code immediately after every commit or do it once a day (in wh
108
120
109
121
The first time you push your code to a repository, GitHub will ask you to select the remote repository (i.e., your GitHub repository). Just copy the suggested push command (you will only need to do this once per assignment).
110
122
111
-
git will also askyou for your gitHUb usernameand passwork the firsttime -- it should remember them after that -- until you try on a new machine.
123
+
git will also ask you for your gitHUb username and password the first time -- it should remember them after that -- until you try on a new machine.
@@ -91,21 +91,21 @@ repository that serves as the one to rule them all. This simply means that all r
91
91
However, to keep things sane, there is generally one "central" repository chosen that users check with for changes. For us this is the one hosted on GitHub in the UWPCE-PythonCert-ClassRepos organization.
92
92
93
93
94
-
Working with Remotes
95
-
--------------------
94
+
..Working with Remotes
95
+
..--------------------
96
96
97
-
With git, you work with *local* repositories and the *remotes* that they are connected to.
97
+
..With git, you work with *local* repositories and the *remotes* that they are connected to.
98
98
99
-
Git uses shortcuts to address *remotes*. When you *clone* a repository from its remote location to your local machine, you get an *origin* shortcut for free:
99
+
..Git uses shortcuts to address *remotes*. When you *clone* a repository from its remote location to your local machine, you get an *origin* shortcut for free:
This shows that the local repo on my machine *originated* from one in
108
-
the UWPCE-PythonCert-ClassRepos GitHub account (it shows up twice, because there is a shortcut for both ``fetch`` from and ``push`` to this remote).
107
+
..This shows that the local repo on my machine *originated* from one in
108
+
..the UWPCE-PythonCert-ClassRepos GitHub account (it shows up twice, because there is a shortcut for both ``fetch`` from and ``push`` to this remote).
109
109
110
110
GitHub forks
111
111
------------
@@ -116,194 +116,16 @@ When you *fork* a repository, you make a copy of that repository in your own (Gi
116
116
117
117
When you have made changes that you believe the rest of the community will want to adopt, you make a *pull request* to the original project. The maintainer(s) of that project than have the option of accepting your changes, in which case your changes will become part of that project.
118
118
119
-
This is how we will be working in this class. When you are ready to submit an assignment, you will make a *pull request* to main class repo, and your instructors can review it.
120
-
121
-
The class repositories are on *GitHub* in the *UWPCE-PythonCert-ClassRepos* organization:
122
-
123
-
.. figure:: /_static/remotes_start.png
124
-
:width:50%
125
-
:class:center
126
-
127
-
https://github.com/UWPCE-PythonCert-ClassRepos
128
-
129
-
Each class will have a repository created specifically for it, called something like: "Wi2018-Online".
130
-
131
-
In examples below it is called YourClassRepoNameHere, so replace that in your head with the name of your class' repository.
132
-
133
-
This class repository will include examples and relevant materials (and some exercise solutions) will be added throughout the class.
134
-
135
-
There will be a folder called students at the top level, and everyone will create their own directory within it.
136
-
137
-
Note that you can use any name you want for your personal working directory -- it can be your first name, you full name, or maybe your gitHub handle if you want to remain anonymous. Just make sure you let your instructors know what name you've used so that they can credit you for your work.
138
-
139
-
Everyone will commit to this repository, and everyone will have access to everyone's code.
140
-
141
-
This will make it easier to collaborate. Weirdly enough, collaborating is important for developing code, both for class and in the *real world*.
142
-
143
-
Setting up Your Fork of the Class Repository
144
-
--------------------------------------------
145
-
146
-
The first thing we have to do is on the GitHub website. You will create a fork of the class repository from the ``UWPCE-PythonCert-ClassRepos`` account on GitHub into your personal account.
147
-
148
-
Before you can do that, you need to create a GitHub account, if you don't have one already. Your gitHub id will be associated with this class' public repo, so it is up to you if you want to use your real name for your gitHub account, or an alias to maintain your privacy.
149
-
150
-
Once you are logged in to your gitHub account, go to the appropriate class repository here:
151
-
152
-
https://github.com/UWPCE-PythonCert-ClassRepos
153
-
154
-
Make sure you find the right repo for YOUR class!
155
-
156
-
Once in the repo for your class, click on the "fork" button in the upper right of the page to create a fork in your gitHub account. You will now have a copy of the class repo, and can then set up your personal machine to connect to that copy.
157
-
158
-
.. figure:: /_static/remotes_fork.png
159
-
:width:50%
160
-
:class:center
161
-
162
-
Yoy should now have a copy of the class repository in your account on the GitHub website.
163
-
164
-
The next step is to make a *clone* of your fork on your own computer, which means that **your fork** in GitHub is the *origin*:
165
-
166
-
.. figure:: /_static/remotes_clone.png
167
-
:width:50%
168
-
:class:center
169
-
170
-
Begin in a directory on your computer where you want to keep your cloned version of the class repository.
171
-
This can live anywhere on your file system but this outer directory should not be tracked in git.
Be sure to replace "YourClassRepoNameHere" with the name of your class repository (you can get the url by going to the class repo on gitHub and clicking "clone or download").
180
-
181
-
This will download the repository from your GitHub account into the local directory that you ran the git *clone* command from.
182
-
183
-
Adding a remote
184
-
...............
185
-
186
-
Since you are working on a repository that you do not own, you will need to make a git shortcut to the original repository, so that you can get changes made by other contributors (i.e. the instructors and other students) before you start working.
187
-
188
-
You can add *remotes* at will, to connect your *local* repository to other copies of it in different remote locations.
189
-
190
-
This allows you to grab changes made to the repository in these other
191
-
locations.
192
-
193
-
For this class, you will add an *upstream* remote to our local copy that points to the original copy of the material in the
194
-
``UWPCE-PythonCert-ClassRepos`` account, and we will call it, appropriately, "upstream".
195
-
Change directories into your local version of the class repository:
196
-
197
-
.. code-block:: bash
198
-
199
-
$ cd YourClassRepoNameHere
200
-
201
-
and run (remembering to use the name of your class):
119
+
For this class, we are using gitHub classroom -- whihc does the creating and forkin go repos for you, so you proably dont need to use this feature now.
202
120
121
+
With one exception: your instructor may use a gitHub repository to manage note3s, examples, and solutions for the class -- if so, it may be helpful to make a fork of that repo, particularly if you want to make suggestions etc.
So you may want to fork that repo in order to make suggestions.
252
128
253
-
This is **really really** important. Take the time to ensure you are where you think you are, in other words, that your origin is your own GitHub repository and that you are working on master from that remote.
254
-
You can use `git remote -v` and `git branch -a` to verify.
255
-
256
-
Now, fetch the upstream master branch and merge it into your master.
257
-
You can do this in one step with:
258
-
259
-
.. code-block:: bash
260
-
261
-
$ git pull upstream master
262
-
Updating 3239de7..9ddbdbb
263
-
Fast-forward
264
-
Examples/README.rst | 4 ++++
265
-
...
266
-
create mode 100644 Examples/README.rst
267
-
...
268
-
269
-
270
-
Now all the changes from *upstream* are present in your local clone.
271
-
You should do this pull every time you start to work on code.
272
-
273
-
In order to preserve the changes made by others in your fork on GitHub, you'll have to push:
274
-
275
-
.. code-block:: bash
276
-
277
-
$ git status
278
-
On branch master
279
-
Your branch is ahead of 'origin/master' by 10 commits.
280
-
(use "git push" to publish your local commits)
281
-
$ git push origin master
282
-
Counting objects: 44, done.
283
-
...
284
-
$
285
-
286
-
(A simple ``git push`` will usually do the right thing)
287
-
288
-
You are now set up to work with this repository, and the next steps will be similar every time you work on code.
289
-
290
-
Go now to this page: :ref:`git_workflow`, where you will learn what to do each time you have work to submit for review.
291
-
292
-
293
-
Privacy Note:
294
-
.............
295
-
296
-
Because of the way we have set up the class, you will be able
297
-
to see all work submitted to us from everyone in the class in
298
-
the students directory on your machine. This is not a bad thing.
299
-
And the files tend to be small.
300
-
301
-
We encourage sharing of knowledge in this class. Helping your
302
-
fellow students will also help you to better understand. Share
303
-
your code, and get used to giving / receiving feedback on how to
304
-
improve your code, if you are not already.
305
-
306
-
However, you are free to use any name you like for your working directory -- it does not have to be your real name, if you want to keep your privacy.
0 commit comments