Skip to content

Commit d6c445d

Browse files
committed
Finish up all examples in case study 1
1 parent 5da4b8e commit d6c445d

14 files changed

Lines changed: 62 additions & 6 deletions

docs/chapters/chapter_04.md

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ As discussed previously, there are a wide variety of hosting services. Here, onl
1111
In this example, we will make a fresh repository on GitHub, make some changes from the browser, and clone a local copy so that we can work on it offline.
1212

1313
!!! info Note
14-
If you already have a local repository, like we have done in the previous chapter, go to chapter 4.2.
14+
Chapter 4.2 describes the variation if you already have a local repository (like we have done in the previous chapter).
1515

1616
### Create a repo on GitHub
1717

@@ -55,7 +55,9 @@ Now there are several options:
5555

5656
![Clone GHD](images/clone-repo-ghd.png)
5757

58-
- Otherwise, copy the line of link (with the button on the right). Go to your preferred IDE and clone the repo there. ===Screenshots!===
58+
- Otherwise, copy the line of link (with the button on the right). Go to your preferred IDE and clone the repo there.
59+
60+
![Clone PyCharm](images/clone-pyc.png)
5961

6062
- If you work with commandlines, go to the parent folder where you want the new repo to be copied into, and then use the `git clone` command (replacing `<some-parent-folder>` and `<your-github-id>`):
6163

@@ -68,16 +70,48 @@ Look inside the `learn-git` folder. You have the new repo cloned onto your compu
6870

6971
### Make changes locally and keep the remote updated
7072

71-
As you make new changes in this folder, you can make local commits just as you did in #3.6. As long as you are on a single branch, the only extra step to take to update the remote is "pushing". Here is an example:
73+
As you make new changes in this folder, you can make local commits just as you did in #3.6.
74+
75+
!!! example "Exercise"
76+
If you want to make an edit to the `README.md` file, what steps do you need to take to make the commit?
77+
78+
??? success "Solution"
79+
1. Edit with an editor of your choice.
80+
![Edit file](images/edit-readme.png)
81+
2. Stage `README.md` file.
82+
![Adding changed file](images/stage-readme-ghd.png)
83+
3. Make commit.
84+
![Adding changed file](images/commit-readme-ghd.png)
85+
86+
As long as you are on a single branch, the only extra step to take to update the remote is "pushing".
87+
88+
In GitHub Desktop, this is done by simply clicking the `Push` button on the top banner:
7289

73-
===screenshots====
90+
![GitHub Desktop push](images/push-origin-ghd.png)
7491

92+
Have a look on the GitHub website. It's updated with the local changes!
93+
94+
![GitHub website updated](images/github-updated.png)
7595

7696
## 4.2 Setting up a new online repository for an existing local repository
7797

7898
Sometimes, we may have already written some code and created a local repository (like what we did in #3.6). Now we want to set up a remote repository and send our code to it, so that our local work is backed up online, and later be shared.
7999

80-
If you have followed through #4.1 as well, you will find this very familiar, except in some small details.
100+
Here we use an example of `learn-git1` local repository with 2 files already commited.
101+
102+
### Publish with GitHub Desktop
103+
104+
If you use GitHub Desktop, the process is very easy. On the top banner, click the `Publish repository` button.
105+
106+
![Publish banner button](images/publish-banner-ghd.png)
107+
108+
Then enter descriptions and click publish! All done.
109+
110+
![Publish](images/publish-ghd.png)
111+
112+
### Without GitHub Desktop
113+
114+
The whole process is similar to Chapter 4.1, except in some small details.
81115

82116
### Create a repo on GitHub
83117

@@ -87,11 +121,33 @@ First, log in to GitHub. Click the "+" and then "New repository" on the top righ
87121

88122
Then, give the new repo a meaningful name (probably sensible to be the same as your local folder name). To make life simple, do NOT initialize or add any files.
89123

124+
![Create new repo](images/create-repo-noinit.png)
125+
90126
!!! example "Exercise"
91127
What will happen if we initialized with, e.g. a README file?
92128

93129
??? success "Solution"
94130
The remote repo on Github will have the README file, while our local repo does not. On the other hand, remember that our local repo has some existing codes that the remote does not have. Therefore, as soon as we try to link the two together, there will be a conflict.
95131

96-
Click the big green button at the bottom. Simple as that, we made a repository on GitHub.
132+
Click the big green button at the bottom to create the repo.
133+
134+
### Connect to the local repo
135+
136+
Since the new online repository is completely empty, GitHub then shows you exactly how to connect to the local repository.
137+
138+
With your IDE, go to the version control tab and look for `Manage remote`.
139+
140+
![Manage remote](images/pyc-manageremote.png)
141+
142+
Click `Add remote`, and paste in the URL to the GitHub repository page.
143+
144+
![Add remote](images/pyc-add-remote.png)
145+
146+
Now, do a *push*, which will update all the existing local commits to the remote.
147+
148+
![Push to new repo](images/pyc-push-to-new-remote.png)
149+
150+
That's all done! Have a look on the GitHub website. It's updated with the local changes!
151+
152+
![GitHub website updated](images/github-updated-1.png)
97153

docs/chapters/images/clone-pyc.png

125 KB
Loading
24 KB
Loading
98.5 KB
Loading
31.9 KB
Loading
42.6 KB
Loading
43.7 KB
Loading
27.2 KB
Loading
58 KB
Loading
26.1 KB
Loading

0 commit comments

Comments
 (0)