Commit e7416443 authored by Laurent Heirendt's avatar Laurent Heirendt
Browse files

additions of forks and branches

parent b3503820
## Development scheme
<br>
Generally, in a repository, there are guidelines for contributing.
<div class="fragment">
<br>
A common development scheme is dual with a:
- **development** version of the code on `develop`
- **stable** version of the code on `master`
<br>
A **version** of the code is referred to as a **branch**.
<div class="fragment">
<br><br>
(Live Demo)
<br>
<font color="red">In the practice repository, the development branch is called `develop`!</font>
<div class="fragment">
<br>
![bulb](img/bulb.png) Use this dual development scheme for your own repositories!
## Be safe!
First, browse to the cloned practice directory:
```bash
$ cd practice
```
Then, checkout the `develop` version of the code:
```bash
$ git checkout develop
```
<div class="fragment">
<br>
Then, <font color="red">create a new **branch**!</font>
(more details on **branches** in a few minutes)
<br>
```bash
$ git checkout -b first-branch
```
## Branches
Branch-off within the same repository in order to stay safe!
......@@ -101,7 +154,7 @@ Detailed information is on [help.github.com/articles/creating-a-pull-request/](h
<ol start="3">
<li>Assign your peer
<br>
![Assigning a peer](https://help.github.com/assets/images/help/issues/issues_assigning_dropdown.png)
</li>
</ol>
......
......@@ -16,64 +16,3 @@ $ git clone https://github.com/userName/myRepo.git myRepo
<br>
<div class="fragment">
You will be prompted to enter your credentials.
## What is a `fork`?
<div class="fragment">
<img src="img/fork.jpg" class="as-is" />
[//]: <> (http://www.cndajin.com/data/wls/246/22302193.jpg)
## Not really ...
<img src="img/fork-crossed.png" class="as-is" />
## What is a `fork`?
In general, when contributing to a repository, you only have **read** access.
<div class="fragment">
In other words, you can only **pull** (unless it is your own repository or access has been granted).
<div class="fragment">
<br>
In general, you **cannot write** changes. In other words, you do not have **push** access.
<div class="fragment">
You have to work on your **own copy**.
<div class="fragment">
<br>
In other words, you have to work on your own <font color="red">fork</font>.
## Time to practice!
(Live Demo)
<br>
Fork the practice repository: <br><br>
https://git-r3lab.uni.lu/R3.training/git.practice
Then, clone your fork to your home directory!
<div class="fragment">
<br>
```bash
$ git clone ssh://git@git-r3lab-server.uni.lu:8022/yourUserName/
git.practice.git practice
```
<div class="fragment">
<br><br>
<font color="red">
Any other rudimentary method such as
*'I simply download the `.zip` and unzip it - works like a charm!'*
shall **be avoided**!
</font>
<div class="fragment">
<br>Why?
\ No newline at end of file
## The 5 essential commands
<br>
......@@ -19,11 +22,6 @@ $ git push
## Pull the latest version of an existing repository
First, browse to the cloned directory (`git clone [...]`):
```bash
$ cd practice
```
Then, pull the latest revision:
```bash
$ git pull
......@@ -35,36 +33,19 @@ Verify its `status` with:
$ git status
```
## Modify a file
## Be safe and create a new branch
Modify and rename `addTwoNumbers.m` in the folder `src/firstCommit` as `addTwoNumbers_myName`:
(more on branches in a few minutes)
<br><br><br><br><br>
```bash
$ git checkout -b matrix_vect_mult_myName
$ mv firstCommit/addTwoNumbers.m firstCommit/addTwoNumbers_myName.m
```
## Modify a file
Modify and rename `addTwoNumbers.m` in the folder `firstCommit`
<br>
Open the file `addTwoNumbers.m` in the folder `firstCommit` using the `Atom` editor (or any other editor).
<br>
Then, rename the function by adding your name (`addTwoNumbers_myName`)
<br>
Uncomment the line
Open the file using the `Visual Studio Code` editor (or any other editor)
and correct the line
```Matlab
% c = a + b
```
<br>
Save and rename the file by <font color="red">adding your name</font>
```bash
$ mv firstCommit/addTwoNumbers.m firstCommit/addTwoNumbers_myName.m
c = a + b;
```
......
## Forks
You **fork** when you want to work on a public repository or a protected repository.
## What is a `fork`?
<br><br>
Remember:
- A **fork** is your own **copy** of a repository.
- A **fork** can have multiple **branches**.
- A **fork** is not a **branch**, but can have multiple **branches**.
<br><br>
A **fork** is only useful when you want to contribute, e.g., to The COBRAToolbox.
<div class="fragment">
<img src="img/fork.jpg" class="as-is" />
[//]: <> (http://www.cndajin.com/data/wls/246/22302193.jpg)
## Fork via interface
## Not really ...
<img src="img/fork-crossed.png" class="as-is" />
Browse to the original repository and click on the button `Fork`
![Fork the repo](https://help.github.com/assets/images/help/repository/fork_button.jpg)
## What is a `fork`?
In general, when contributing to a repository, you only have **read** access.
<div class="fragment">
In other words, you can only **pull** (unless it is your own repository or access has been granted).
## Clone your fork
<div class="fragment">
<br>
In general, you **cannot write** changes. In other words, you do not have **push** access.
Clone first
```bash
$ git clone https://git-r3lab.uni.lu/myGroup/myRepo.git forkMyRepo
```
<div class="fragment">
You have to work on your **own copy**.
<div class="fragment">
<br>
then, you can change to the directory
```bash
$ cd forkMyRepo
```
In other words, you have to work on your own <font color="red">**fork**</font>.
## Add the address of the original repository
## How to get a fork?
Add the `upstream` address (original/protected repository)
```bash
$ git remote add upstream https://git-r3lab.uni.lu/origGroup/origRepo.git
```
Browse to the original repository and click on the button `Fork`:
<br>
You can then check whether the remote address is set correctly
```bash
$ git remote -v
```
<!-- <img src="img/remote-0-master.png" class="as-is" /> //-->
<!-- <img src="img/remote-1-remote.png" class="as-is" /> //-->
<!--- <img src="img/remote-2-push.png" class="as-is" /> //-->
![Fork the repo](https://help.github.com/assets/images/help/repository/fork_button.jpg)
(Live Demo)
## Synchronize your fork
```bash
$ git checkout master
$ git status
```
## Time to practice!
(Live Demo)
<div class="fragment">
<br>
Fetch the changes from upstream (similar to pull)
```bash
$ git fetch upstream
```
Fork the practice repository: <br><br>
https://git-r3lab.uni.lu/R3.training/git.practice
Then, clone your fork to your home directory!
<div class="fragment">
<br>
Merge the retrieved changes
```bash
$ git merge upstream/master
$ git clone ssh://git@git-r3lab-server.uni.lu:8022/yourUserName/
git.practice.git practice
```
<div class="fragment">
<br>
Push the changes to your own fork
```bash
$ git push origin master
```
<br><br>
<font color="red">
Any other rudimentary method such as
*'I simply download the `.zip` and unzip it - works like a charm!'*
shall **be avoided**!
</font>
<div class="fragment">
<br>Why?
## How to update my fork?
As you have your own fork, it will not automatically update once the original repository is update.
## Pull/Merge Requests
![bulb](img/bulb.png) You have to update it yourself!
**Good news!**
<div class="fragment">
<br>
**More on that later!**
Same procedure as with merging a branch...
......@@ -54,7 +54,7 @@
}
},
{
"filename": "essential_commands.md",
"filename": "forks.md",
"attr": {
"data-background": "img/whiteBG.jpg"
}
......@@ -65,6 +65,18 @@
"data-background": "img/whiteBG.jpg"
}
},
{
"filename": "essential_commands.md",
"attr": {
"data-background": "img/whiteBG.jpg"
}
},
{
"filename": "syncFork.md",
"attr": {
"data-background": "img/whiteBG.jpg"
}
},
{
"filename": "best_practices.md",
"attr": {
......
## Ready to practice?
<br>Go to https://git-r3lab.uni.lu/R3.training/git.practice
<br>And follow the instructions in the `README` file.
## Synchronize your fork
![bulb](img/bulb.png) Remember, we have to regularly update our own copy of the code.
## Add the address of the original repository
Add the `upstream` address (original/protected repository)
```bash
$ git remote add upstream ssh://git@git-r3lab-server.uni.lu:8022/R3.training/
git.practice.git
```
![bulb](img/bulb.png) Note the change in the URL.
<br>
You can then check whether the remote address is set correctly
```bash
$ git remote -v
```
<div class="fragment">
<br>
Fetch the changes from upstream (similar to pull)
```bash
$ git fetch upstream
```
<div class="fragment">
<br>
Merge the retrieved changes on the `master` branch:
```bash
$ git checkout master
$ git merge upstream/master
$ git push origin master
```
<div class="fragment">
<br>
Merge the retrieved changes on the `develop` branch:
```bash
$ git checkout develop
$ git merge upstream/develop
$ git push origin develop
```
## Time to practice!
(Live Demo)
\ No newline at end of file
......@@ -5,7 +5,7 @@
Start the Terminal from your `/Applications` directoy.
*Pro Tip:* Install iTerm2: <br>`https://www.iterm2.com`
![bulb](img/bulb.png) Install iTerm2: `https://www.iterm2.com`
<br>
**Windows users:**
......@@ -15,8 +15,8 @@ Install Git Bash: <br>`https://git-scm.com/download/win`
<br>
**Linux users:**
Launch default terminal.
*Pro Tip:* Install Terminator: <br>`https://launchpad.net/terminator`
Launch default terminal.<br>
![bulb](img/bulb.png) Install Terminator: `https://launchpad.net/terminator`
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment