Skip to content

Commit d18d645

Browse files
committed
updated the git intros a bit.
1 parent 0001259 commit d18d645

File tree

4 files changed

+34
-199
lines changed

4 files changed

+34
-199
lines changed

source/topics/01-setting_up/git.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
Git
33
===
44

5-
Git is a very powerful and useful tool. WE only use a few of its features for this program, but it is well worth getting more familiar with it.
5+
Git is a very powerful and useful tool. We only use a few of its features for this program, but it is well worth getting more familiar with it.
66

77
.. toctree::
88
:maxdepth: 1
99

1010
intro_to_git
11+
github_classroom
1112
git_overview
1213
feature_branching
1314
git_hints
14-
github_classroom

source/topics/01-setting_up/git_overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ git Overview
66

77
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.
88

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.
1010

1111
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.
1212

source/topics/01-setting_up/github_classroom.rst

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Initial setup
3030
=============
3131

3232
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.
3434

3535
You will need to have git setup on the computer you will use for developing your code for this course.
3636
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
8888

8989
git add .
9090

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::
9296

9397
git commit -m "Commit message"
9498

9599
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.
96100

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+
97109

98110
Pushing Your Code
99111
=================
@@ -108,7 +120,7 @@ You can push your code immediately after every commit or do it once a day (in wh
108120

109121
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).
110122

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.
112124

113125
Asking Coding Questions
114126
=======================

source/topics/01-setting_up/intro_to_git.rst

Lines changed: 16 additions & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,21 @@ repository that serves as the one to rule them all. This simply means that all r
9191
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.
9292

9393

94-
Working with Remotes
95-
--------------------
94+
.. Working with Remotes
95+
.. --------------------
9696
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.
9898
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:
100100
101-
.. code-block:: bash
101+
.. .. code-block:: bash
102102
103-
$ git remote -v
104-
origin https://github.com/UWPCE-PythonCert-ClassRepos/ExampleRepo.git (fetch)
105-
origin https://github.com/UWPCE-PythonCert-ClassRepos/ExampleRepo.git (push)
103+
.. $ git remote -v
104+
.. origin https://github.com/UWPCE-PythonCert-ClassRepos/ExampleRepo.git (fetch)
105+
.. origin https://github.com/UWPCE-PythonCert-ClassRepos/ExampleRepo.git (push)
106106
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).
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).
109109
110110
GitHub forks
111111
------------
@@ -116,194 +116,16 @@ When you *fork* a repository, you make a copy of that repository in your own (Gi
116116

117117
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.
118118

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.
172-
173-
From that directory, run
174-
175-
.. code-block:: bash
176-
177-
$ git clone https://github.com/your_github_id/YourClassRepoNameHere
178-
179-
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.
202120

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.
203122

204-
.. code-block:: bash
205-
206-
$ git remote add upstream https://github.com/UWPCE-PythonCert-ClassRepos/YourClassRepoNameHere
207-
208-
You can get that full url by going to GitHub, finding the repo, and copying the "clone" url. then you can type the command, and simply paste the url.
209-
210-
Your local setup should now look something like this:
211-
212-
.. code-block:: bash
213-
214-
$ git remote -v
215-
origin https://github.com/your_github_id/YourClassRepoNameHere (fetch)
216-
origin https://github.com/your_github_id/YourClassRepoNameHere (push)
217-
upstream https://github.com/UWPCE-PythonCert-ClassRepos/YourClassRepoNameHere (fetch)
218-
upstream https://github.com/UWPCE-PythonCert-ClassRepos/YourClassRepoNameHere (push)
219-
220-
This should leave you in a situation that looks like this:
221-
222-
.. figure:: /_static/remotes_upstream.png
223-
:width: 50%
224-
:class: center
225-
226-
To get the updates from your new remote, you'll need first to fetch everything:
123+
Another possiblity is if you notice an error, or can suggest a claification in these very pages. They are managed on gitUb as well, in this repo:
227124

228-
.. code-block:: bash
229-
230-
$ git fetch --all
231-
Fetching origin
232-
Fetching upstream
233-
...
234-
235-
Then you can see the branches you have locally available:
236-
237-
.. code-block:: bash
238-
239-
$ git branch -a
240-
* master
241-
remotes/origin/HEAD -> origin/master
242-
remotes/origin/master
243-
remotes/upstream/master
244-
245-
Finally, you can fetch and then merge changes from the upstream master.
246-
247-
Start by making sure you are on your own master branch:
248-
249-
.. code-block:: bash
125+
https://github.com/UWPCE-PythonCert/ProgrammingInPython
250126

251-
$ git checkout master
127+
So you may want to fork that repo in order to make suggestions.
252128

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.
307129

308130
Structure of multiple git repos
309131
-------------------------------
@@ -327,3 +149,4 @@ https://try.github.io/levels/1/challenges/1
327149

328150
basic git commands:
329151
https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.html
152+

0 commit comments

Comments
 (0)