Skip to content
Snippets Groups Projects
Commit be5ee786 authored by Laurent Heirendt's avatar Laurent Heirendt :airplane:
Browse files

additions of forks and branches

parent 472a6e81
No related branches found
No related tags found
No related merge requests found
## 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 ## Branches
Branch-off within the same repository in order to stay safe! 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 ...@@ -101,7 +154,7 @@ Detailed information is on [help.github.com/articles/creating-a-pull-request/](h
<ol start="3"> <ol start="3">
<li>Assign your peer <li>Assign your peer
<br> <br>
![Assigning a peer](https://help.github.com/assets/images/help/issues/issues_assigning_dropdown.png) ![Assigning a peer](https://help.github.com/assets/images/help/issues/issues_assigning_dropdown.png)
</li> </li>
</ol> </ol>
......
...@@ -16,64 +16,3 @@ $ git clone https://github.com/userName/myRepo.git myRepo ...@@ -16,64 +16,3 @@ $ git clone https://github.com/userName/myRepo.git myRepo
<br> <br>
<div class="fragment"> <div class="fragment">
You will be prompted to enter your credentials. 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 ## The 5 essential commands
<br> <br>
...@@ -19,11 +22,6 @@ $ git push ...@@ -19,11 +22,6 @@ $ git push
## Pull the latest version of an existing repository ## Pull the latest version of an existing repository
First, browse to the cloned directory (`git clone [...]`):
```bash
$ cd practice
```
Then, pull the latest revision: Then, pull the latest revision:
```bash ```bash
$ git pull $ git pull
...@@ -35,36 +33,19 @@ Verify its `status` with: ...@@ -35,36 +33,19 @@ Verify its `status` with:
$ git status $ 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 ```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> <br>
Uncomment the line Open the file using the `Visual Studio Code` editor (or any other editor)
and correct the line
```Matlab ```Matlab
% c = a + b 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
``` ```
......
## Forks
You **fork** when you want to work on a public repository or a protected repository. ## What is a `fork`?
<br><br> <div class="fragment">
Remember: <img src="img/fork.jpg" class="as-is" />
[//]: <> (http://www.cndajin.com/data/wls/246/22302193.jpg)
- 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.
## 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 <div class="fragment">
```bash You have to work on your **own copy**.
$ git clone https://git-r3lab.uni.lu/myGroup/myRepo.git forkMyRepo
```
<div class="fragment">
<br> <br>
then, you can change to the directory In other words, you have to work on your own <font color="red">**fork**</font>.
```bash
$ cd forkMyRepo
```
## Add the address of the original repository ## How to get a fork?
Add the `upstream` address (original/protected repository) Browse to the original repository and click on the button `Fork`:
```bash
$ git remote add upstream https://git-r3lab.uni.lu/origGroup/origRepo.git
```
<br> ![Fork the repo](https://help.github.com/assets/images/help/repository/fork_button.jpg)
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" /> //-->
(Live Demo)
## Synchronize your fork
```bash ## Time to practice!
$ git checkout master
$ git status (Live Demo)
```
<div class="fragment">
<br> <br>
Fetch the changes from upstream (similar to pull)
```bash Fork the practice repository: <br><br>
$ git fetch upstream https://git-r3lab.uni.lu/R3.training/git.practice
```
Then, clone your fork to your home directory!
<div class="fragment"> <div class="fragment">
<br> <br>
Merge the retrieved changes
```bash ```bash
$ git merge upstream/master $ git clone ssh://git@git-r3lab-server.uni.lu:8022/yourUserName/
git.practice.git practice
``` ```
<div class="fragment"> <div class="fragment">
<br> <br><br>
Push the changes to your own fork <font color="red">
```bash Any other rudimentary method such as
$ git push origin master
``` *'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...
slides/img/bulb.png

4.72 KiB

...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
} }
}, },
{ {
"filename": "essential_commands.md", "filename": "forks.md",
"attr": { "attr": {
"data-background": "img/whiteBG.jpg" "data-background": "img/whiteBG.jpg"
} }
...@@ -65,6 +65,18 @@ ...@@ -65,6 +65,18 @@
"data-background": "img/whiteBG.jpg" "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", "filename": "best_practices.md",
"attr": { "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 @@ ...@@ -5,7 +5,7 @@
Start the Terminal from your `/Applications` directoy. 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> <br>
**Windows users:** **Windows users:**
...@@ -15,8 +15,8 @@ Install Git Bash: <br>`https://git-scm.com/download/win` ...@@ -15,8 +15,8 @@ Install Git Bash: <br>`https://git-scm.com/download/win`
<br> <br>
**Linux users:** **Linux users:**
Launch default terminal. Launch default terminal.<br>
*Pro Tip:* Install Terminator: <br>`https://launchpad.net/terminator` ![bulb](img/bulb.png) Install Terminator: `https://launchpad.net/terminator`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment