Commit 41701432 authored by jcechace's avatar jcechace
Browse files

Added second scenario

parent e26f371e
Loading
Loading
Loading
Loading
+90 −18
Original line number Diff line number Diff line
@@ -6,10 +6,10 @@
> Everytime I want to version my project, I can create local git repository and start versioning it.
It could be Java project, but it could be my bachelor thesis written in latex as well :)


**Goal**: Create new maven project with your IDE and push it into new gitlab repository.

* create new maven project
### Steps
* create new maven project in IntelliJ idea
* initialize new local git repo in this project
* create file `.gitignore` and ignore `target/` folder and IDE project files.
* init commit (all source files, `pom.xml`, `.gitignore`, ...)
@@ -18,7 +18,7 @@ It could be Java project, but it could be my bachelor thesis written in latex as
* done ;)


## Scenario 2: 
## Scenario 2: Work with multiple repositories

> Imagine you want to contribute to some opensource project.
You found a bug in a library you use and you want to share your fix with the community.
@@ -28,7 +28,7 @@ You fork this repository and then open Merge Request back to original (upstream)
Only difference is that you want to push your implementation to your private fork instead of upstream.


Origin: usually the name of your repository on gitlab/github
**Origin**: usually the name of your repository on gitlab/github
Upstream: usually the main community repository


@@ -37,12 +37,84 @@ You usually fork upstream repository and you call your copy origin.
**Goal**: Excercise working with multiple repositories like we do in PB162

### Steps
* Student forks upstream and clone his copy (origin)
* Student A implements feature A in branch bA
* Student B implements feature B in branch bB
* Studnet A adds remote for B (add link to A's origin repository into his local git)
* Student B adds remote for A (add link to B's origin repository into his local git)
* A pulls from B:bB
* B pulls from A:bA
* A & B push new branch to origin:bX 
* A & B will crete merge restest from Origin:bX into ORIGIN:master
 No newline at end of file
1. Create a fork of this repository
1. Clone *your* repository
1. Find yoursef a friend -- one of your will be group A, the other one group B
1. Enter your repository and check it's current state

```bash
$ cd git-workshop
$ git status
```

### Steps for group A
1. Create new branch ```dollar-convertor``` based on ```master```
1. Implement the class ```DollarConvertor```
1. Commit your work

    ```bash
    $ git status
    $ git add .
    $ git status
    $ git commit -m "Implementation of dollar converter"
    ```

1. Now push ```dollar-convertor``` branch to **your** repository

    ```bash
    $ git push origin master
    ```

Now imagine you also need a euro converter, however your colleage from group B already implemented it.
How do we "borrow" that code and how do we move it to your repository?

1. Get the address of your clleague's repository
1. Add that repository as another **remote** to **your local** repositor, name it ```sneaky```

    ```bash
    $ git remote add another <place the address here>
    ```
1. Conviniently place Euro convertor into your ```dollar-convertor``` branch

    ```bash
    $ git pull sneaky eur-convertor
    ```
1. Inspect the current state of your repository
1. Push to your ```dollar-convertor``` branch at Gitlab
1. Go your Gitlab repository and create merge-request to your **master** branch.


### Steps for group B
1. Create new branch ```euro-convertor``` based on ```master```
1. Implement the class ```EuroConvertor```
1. Commit your work

    ```bash
    $ git status
    $ git add .
    $ git status
    $ git commit -m "Implementation of euro converter"
    ```
1. Now push ```euro-convertor``` branch to **your** repository

    ```bash
    $ git push origin master
    ```

Now imagine you also need a dollar converter, however your colleage from group A already implemented it.
How do we "borrow" that code and how do we move it to your repository?

1. Get the address of your clleague's repository
1. Add that repository as another **remote** to **your local** repositor, name it ```sneaky```

    ```bash
    $ git remote add another <place the address here>
    ```
1. Conviniently place Euro convertor into your ```eur-convertor``` branch

    ```bash
    $ git pull sneaky eur-convertor
    ```
1. Inspect the current state of your repository
1. Push to your ```eur-convertor``` branch at Gitlab
1. Go your Gitlab repository and create merge-request to your **master** branch.