Follow three important **rules to prevent conflicts** in the source code:
***Never change files that you do not have to change** according to the assignment (or, at least, return back the changes before requesting the final merge).
* Always **work on** working **branch `submit-0X`** (i.e. never work in the *master* branch).
* Always **commit your changes** before pulling new iteration (i.e. precisely follow the workflow instructions listed below).
> Follow three important **rules to prevent conflicts** in the source code:
> * **Never change files that you do not have to change** according to the assignment (or, at least, return back the changes before requesting the final merge).
> * Always **work on** working **branch `submit-0X`** (i.e. never work in the *master* branch).
> * Always **commit your changes** before pulling new iteration (i.e. precisely follow the workflow instructions listed below).
## Getting new iteration
## Download new iteration
Before you continue, **make sure that your previous *merge request* has been accepted!**
**(3)**Switch to the master branch and update it with your private GitLab repository.
**(3)**Make sure that your previous *merge request* has been accepted! Then switch to the master branch and update it with your private GitLab repository.
```bash
git checkout master
git pull origin master
```
**(4)** Download assignment of required iteration (0X means 01, 02, 03, etc.) from the _munijava_ repository to your local computer
**(4)** Download assignment of a new iteration (0X means 01, 02, 03, etc.) from the _munijava_ repository to your local computer.
Then, **vim** editor has opened. Type `:wq` or `:x` + Enter to save and close it.
> HINT: Use `git status` whenever you want to check that everything is okay.
**If there are any other problems, use [FAQ](/pb162/pb162-course-info/wikis/faq)**.
> On *aisa* use `git pull -s recursive -X theirs munijava iteration-0X`
> If the **vim** editor has opened, type `:wq` + `Enter` to close the editor.
> Use `git status` whenever you want to check that everything is okay.
> If you are in troubles, see [FAQ](/pb162/pb162-course-info/wikis/faq).
**(5)** Upload the assignment into your private repository on GitLab:
...
...
@@ -41,51 +37,66 @@ Then, **vim** editor has opened. Type `:wq` or `:x` + Enter to save and close it
git push origin master
```
**(6)** You did the *pull* request in branch *master*. Now create a branch called **submit-0X**. This branch will contain your solution to assignment 0X. **Make sure the branch name is exactly submit-0X!**. Use only small letters, dash, and two numbers.
> When submitting a homework, use branch name **submit**.
The following commands create a new branch, switch to it, and then upload it to the private repository on GitLab:
**(6)** In the step (4) you download new iteration into the *master* branch on your PC. Now create a branch called **submit-0X**, where you will provide your solution. Switch to this branch and then upload the branch to your private repository on GitLab:
```bash
git checkout -b submit-0X
git push --set-upstream origin submit-0X
```
Now you should see the new iteration assignment on GitLab.
## Working on the solution, saving the work regularly
> Make sure the branch name is exactly *submit-0X*! Use only small letters, dash, and two numbers to name the branch.
> When submitting a homework, use branch name *submit*.
## Switching between computers (optional)
If you are switching between computers, e.g., the school PC and your home PC, it is necessary to synchronize the current *submit-0X* branch in those computers.
* Push your code to the GitLab whenever you leave the computer (see the step (7)).
* If you haven't cloned your repository yet in the current PC, [clone it](git-advanced-setup#2-download-your-repository-to-pc) first.
* Type `git branch` in the project directory. Do you see the branch you want to continue (e.g. submit-05) in the list of branches?
* If yes, then switch to that branch and update it:
```bash
git checkout submit-0X
git pull
```
* Otherwise, create that branch from the remote repository:
```bash
git fetch
git checkout -b submit-0X origin/submit-0X
```
## Work on the solution, save the work regularly
**(7)** When you want to save your work, you need to do 3 steps as follows. We suppose that you work in the correct working branch submit-0X.
**(7)** Whenever you want to save your work, you need to do 3 steps as follows. We suppose that you work in the correct working branch *submit-0X*!
- _commit_ creates "checkpoint", saves changes on your local PC; commit **must** contain **short** message describing what have you done
- _push_ uploads all commits to origin GitLab, into branch _submit-0X_
- Please, **write appropriate commit message** to describe what have you done. Shortcut WIP means "Work In Progress".
-`add` = Adds changed files to the commit. The `-A` parameter adds all changed files to the commit.
-`commit` = Creates "checkpoint". Saves/accepts changes previously added to the commit. This "checkpoint" is stored only locally on your computer. A commit **must** contain **short** message describing what have you done (the `-m` parameter)
-`push` = Uploads commits/changes to GitLab (into branch *submit-0X*) so that you can see them in the GitLab, download them to another computer, etc.
> If you want to see what you are going to commit, use `git diff --cached` after you called `git add -A` and then use PageUp/Down, to finish press **q**.
> **Write appropriate commit message** to describe what have you done. Shortcut WIP means "Work In Progress".
> If you want to see what you are going to commit, use `git diff --cached` after you called `git add -A` and then use PageUp/Down. To finish press **q**.
### Automatic testing (GitlabCI)
Whenever you push code to GitLab, it is tested automatically on the server. If there are some failures, you can open the pipeline:
Your code is tested in the IDE whenever you rebuild the project. Moreover, the same tests are run whenever you push the code to GitLab. If there are some failures, you can open the pipeline:
the assignment is in the _master_ branch, your solution is in _submit-0X_ branch.
## Submit the solution to the tutor
**(8)** Go to the GitLab and create a *merge request* (MR) –
request for accepting your code and copying it from submit-0X to branch master.
**(8)** Go to the GitLab and create a *merge request* (MR). By requesting the merge you declare that you finished the iteration, your code has passed all test (both local unit tests and automated tests on the GitLab), the tutor should check the code, and, if satisfied, merge your changes to the production muster branch.
Go to _Merge Requests_ -> _New merge request_.
* Source branch: _submit-0X_
...
...
@@ -97,15 +108,13 @@ Click _Compare branches and continue_.
* Assignee: **your teacher**
* Make sure you have branches `submit-0X` and `master`.
* _click _Submit merge request_
* Now you should see the _Merge_ button, but **don't click that**, because **your teacher will do that**. Your tutor either accepts your solution or adds some notes on what you should change.
* Make sure you really submitted what you wanted to by clicking on tab _Changes_ containing all changes.
* Congratulations! You have successfully submitted your iteration!
> Did you really assigned your teacher? Check _Asignee_ on the right side.
Now you should see button _Merge_, but **don't click that**, because **your teacher will do that**. Your tutor either accepts your solution or adds some notes on what you should change.
2) Make sure you really submitted what you wanted to by clicking on tab _Changes_ containing all changes.
3) Congratulations! You have successfully submitted your iteration!
> Did you really assigned your teacher? Check _Asignee_ on the right side. Otherwise, he or she will not know that your code is ready for assessment.
> When your Merge request is accepted, changes from **submit-0X** will be copied to **master** branch.
**Does your teacher wrote a note?** Well, if your MR wasn't accepted yet, then just add the code into submit-0X branch and push it. Then, it should be okay to accept your own merge request and start working on another iteration.
## Check results of the tutor's assessment
* Did your teacher wrote a note? Well, if your MR wasn't accepted yet, then just add the code into the *submit-0X* branch and commit+push it again. Then, it should be okay to accept your own merge request and start working on another iteration.