Skip to content

Commit 7cba128

Browse files
authored
Merge pull request #264 from emiliom/git-prep-fixes
Fixes and improvements to Git Preparation page
2 parents 0053188 + c0601f5 commit 7cba128

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

resources/prep/git.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
[Git](https://git-scm.com/) is a popular version control system that is the foundation of most open source software development. You are not required to be a Git pro in advance of this event, but come prepared to learn a lot about it! [GitHub](https://github.com) is a hosting service for Git repositories, enabling us to share code across teams in a web environment.
66

7-
We will use Git and GitHub for collaborative work. Be sure to arrive at OceanHackWeek with your own [GitHub](https://github.com/) account.
7+
We will use Git and GitHub for collaborative work. Be sure to arrive at OceanHackWeek with your own [GitHub](https://github.com) account.
88

99
## Git Installation
1010

1111
* Windows
1212
* Install Git for Windows from this [link](https://gitforwindows.org/). For more setup details follow these [instructions](https://carpentries.github.io/workshop-template/#shell)
1313
* Mac OS
1414
* Download the [git installer](https://git-scm.com/download/mac) and run it.
15-
* Linux (Debian): `sudo apt install git-all`
15+
* Linux (Debian/Ubuntu): `sudo apt install git-all`
1616

1717
To test, open the terminal (on Windows, Git Bash) and setup your username and email:
1818

@@ -29,7 +29,7 @@ During the hackweek it will be useful to know how to navigate between files from
2929

3030
## Terminal (command line) text editor
3131

32-
When working on the command line (the terminal or shell), it is often handy to modify file content directly from there. For that you can use a command line editor such as [nano](https://linuxize.com/post/how-to-use-nano-text-editor/). On Mac and Linux it is usually pre-installed, but for Windows you can follow the instructions in this [link](http://carpentries.github.io/workshop-template/#editor) to set it up. Test your installation by opening a terminal and running `nano --version`. If it works you can link your git configuration with `nano`:
32+
When working on the command line (the terminal or shell), it is often handy to modify file content directly from there. For that you can use a command line editor such as [nano](https://linuxize.com/post/how-to-use-nano-text-editor/). On Mac and Linux it is usually pre-installed, and on Windows it is installed when you install Git (see [here](http://carpentries.github.io/workshop-template/#editor) for more information about nano and its configuration). Test your installation by opening a terminal and running `nano --version`. If it works you can link your git configuration with `nano`:
3333

3434
```bash
3535
git config --global core.editor "nano -w"
@@ -42,10 +42,9 @@ git config --global core.editor "nano -w"
4242
Steps 1-5 focus on the Git "centralized workflow". We present it here as an illustration, but **the workflow we recommend for use in OceanHackWeek is the Git Fork - Clone workflow, discussed in Step 6.**
4343
```
4444

45-
4645
### 1. Create a project repository
4746

48-
On your own or someone in your project group (preferably one who has never done it before), create a repository for the project under the {OceanHackWeek organization, [https://github.com/oceanhackweek](https://github.com/oceanhackweek)
47+
On your own or someone in your project group (preferably one who has never done it before), create a repository for the project under the `oceanhackweek` organization, `https://github.com/oceanhackweek`
4948

5049
![New Repo](../img/newRepo.png)
5150

@@ -58,13 +57,13 @@ Click `New` and follow the steps: check yes to create a `README.md` file.
5857

5958
### 2. Clone the repository
6059

61-
Each participant should clone the repository so they have their copy on their JupyterHub account space (and locally in the participant's computer, if desired). Navigate through the terminal to the folder where you want to keep {OceanHackWeek work (`cd path_to_oceanhackweek`).
60+
Each participant should clone the repository so they have their copy on their JupyterHub account space (and locally in the participant's computer, if desired). Navigate through the terminal to the folder where you want to keep OceanHackWeek work (`cd path_to_oceanhackweek`).
6261

6362
```bash
6463
git clone https://github.com/oceanhackweek/ohw22-proj-myprojectname.git
6564
```
6665

67-
This will create a new folder called `ohw22-proj-myprojectname`. Navigate to the new folder, `ohw22-proj-myprojectname`.
66+
This will create a new folder called `ohw22-proj-myprojectname`. Navigate (`cd`) to this new folder.
6867

6968
### 3. Update the README with your name
7069

@@ -82,11 +81,10 @@ Make sure your change appears online.
8281
`git status` to observe the changes made into your repository. Pay attention to the colors. To see the changes in the files run `git diff`.
8382
```
8483

85-
8684
### 4. Update your local repository (local clone) with the changes of your collaborators
8785

8886
```bash
89-
git pull origin master
87+
git pull origin main
9088
```
9189

9290
```{admonition} "Short names for repositories:"
@@ -98,21 +96,23 @@ To continue practicing these steps, make more changes to the title and the descr
9896

9997
![Centralized Workflow](../img/centralized_workflow.png)
10098

101-
*Ran into a problem?*
10299

103-
When working with several people sometimes you
100+
```{admonition} *Ran into a problem?*
101+
:class: attention
104102
105-
* cannot push because changes have been made that have not been incorporated: need to first pull
106-
* when pulling you arrive into a merge conflict: need to resolve the conflict manually
103+
When working with several people sometimes you
107104
105+
* Cannot push because changes have been made that have not been incorporated: need to first pull
106+
* When pulling you arrive into a merge conflict: need to resolve the conflict manually
107+
```
108108

109109
### 5. Resolving the merge conflict
110110

111111
```bash
112112
git status
113113
```
114114

115-
You will see the file/s which caused the merge conflict in green.
115+
You will see the file(s) which caused the merge conflict in green.
116116

117117
Open it and detect the conflict by the special format:
118118

@@ -129,7 +129,7 @@ Decide which changes you want to keep, and modify the file so it looks as you wi
129129
```bash
130130
git add README.md
131131
git commit -m "resolving merge conflict"
132-
git push origin master
132+
git push origin main
133133
```
134134

135135
You can continue working on as usual.
@@ -138,7 +138,6 @@ You can continue working on as usual.
138138
... to avoid messing with complicated merges and keep your repo up-to-date.
139139
```
140140

141-
142141
### 6. Avoiding problems: forking workflow
143142

144143
So far you collaborated using what is called a "centralized git workflow": i.e. every collaborator makes directly changes to the repo.
@@ -160,18 +159,18 @@ Forks are public copies of the main repo, from which you can submit changes to t
160159
* Fork the public repo (click on the *Fork* button)
161160
![](../img/fork_button.png)
162161
* Note it looks the same but the web address contains your username
163-
[https://github.com/myghusername/ohw21-proj-ProjectName](https://github.com/myghusername/ohw21-proj-ProjectName)
162+
`https://github.com/myghusername/ohw22-proj-myprojectname`
164163
* Go to your local repo and rename your `origin` to point to the fork:
165164

166165
```bash
167166
git remote rm origin
168-
git remote add origin https://github.com/myghusername/ohw21-proj-ProjectName.git
167+
git remote add origin https://github.com/myghusername/ohw22-proj-myprojectname.git
169168
```
170169

171170
* Add a new remote to talk to the main repo:
172171

173172
```bash
174-
git remote add upstream https://github.com/oceanhackweek/ohw21-proj-ProjectName.git
173+
git remote add upstream https://github.com/oceanhackweek/ohw22-proj-myprojectname.git
175174
```
176175

177176
From now on you will push to `origin`, but pull from `upstream`.
@@ -192,7 +191,7 @@ Make some changes to a file and commit and publish them.
192191
```bash
193192
git add README.md
194193
git commit -m "more changes"
195-
git push origin master
194+
git push origin main
196195
```
197196

198197
```{admonition} Note
@@ -240,6 +239,7 @@ git revert HEAD
240239
Your files in the local repo will still be there.
241240
```
242241

242+
243243
## References and Resources
244244

245245
Git and GitHub are very powerful tools but no doubt the learning curve is steep. Learning is an iterative process so below we list some resources which can help you be better prepared:

0 commit comments

Comments
 (0)