Commit 15ccd1e3 authored by Noeska Smit's avatar Noeska Smit
Browse files

Update LAB-3_I_GIT.md 1.1 and 1.2

parent 4987c505
# Lab 3 Part I
[Lab Overview](LAB-3.md)
Please note: This first part starts with more information about Git and its use in general. If you know all of this already, feel free to skip ahead to 'Your Task *(todo!)*'!
## Part I: Git
### 1.0. More Git Background
......@@ -9,34 +10,32 @@ Git is a [distributed version control system](https://en.wikipedia.org/wiki/Dist
* Modern version control systems are collaborative, and let multiple people work independently on their own copy of the files, before the changes are integrated / synchronised. Since all the changes are recorded in the history it's easy for the version control system to see what each developer has done, and merge changes from multiple developers more or less automatically. Typically, this synchronisation happens when a developer *pulls* from or *pushes* to the server (sometimes called *update* and *check in*). (In [really](https://en.wikipedia.org/wiki/Source_Code_Control_System) [old](https://en.wikipedia.org/wiki/Revision_Control_System) systems, there was little or no support for multiple developers, and you might be required to *lock* the files you were editing, so that no one else could modify them at the same time. If you then went on vacation without unlocking, your co-workers would be very upset.)
* A *distributed* version control system like Git also supports decentralised collaboration: there isn't really a central server that everyone synchronises with – instead each developer has a complete *clone* of the entire project, and developers can exchange their commits peer-to-peer, without any server. For practical reasons (e.g., backups and easier interaction), we typically want a server anyway and this is the role of our GitLab-installation at https://retting.ii.uib.no/. Your local clone of your INF101 labs are just as good and complete as those on the server, but the server also does backups, lets your teachers look at and help you with your code, has a nice web interface and does automatic integration testing whenever you push to it.
Collaboration and distribution has two consequences that we will deal with now:
* Someone else can have made changes while you were working, and these changes must be integrated with yours. (Step 1.1 below, and [Lab 1, oppg. 7](https://retting.ii.uib.no/inf101.v19.oppgaver/inf101.v19.lab1/blob/master/README.md#oppgave-7-rot-med-merge).)
* We change change what we consider to be the “server” (upstream) or even have multiple ones. (Step 1.3 below.)
Collaboration and distribution has two consequences:
* Someone else could have made changes while you were working, and these changes must be integrated with yours. (Step 1.1 below.)
* We change what we consider to be the “server” (upstream) or even have multiple ones. (Step 1.3 below.)
### 1.1. Always *pull* before *push* *(todo!)*
As seen in [Lab 1, oppg 4](https://retting.ii.uib.no/inf101.v19.oppgaver/inf101.v19.lab1/blob/master/README.md#oppgave-4-pushe-til-gitlab-rettingiiuibno) you should check the response you get whenever you *push*, because it can actually go wrong.
You should always check the response you get whenever you *push*, because it can actually go wrong.
If you see the message *rejected – non-fast-forward*, someone else has made and pushed changes before you. This could be someone yourself, if you're using multiple computers or if you've made multiple copies of your Git files on your computer – but in real life it's often another developer on the same project (less likely for INF101 students, but sometimes Anya or someone else will push to your repository on retting.ii.uib.no.).
So, if you go and make some changes to your *Lab 2* solution, then select *Team → Commit...*, fill in the commit form or staging view form and hit *Commit and Push*...
So, for example, if you go and make some changes to your *Lab 2* solution, then select *Team → Commit...*, fill in the commit form or staging view form and hit *Commit and Push*...
![](img/git-staging.png)
...you should see a message like this (but with a different repository name, of course):
...you could see a message like this (but with a different repository name, of course):
![](img/push-rejected.png)
* **Go and do this now**, with your `inf101.v19.lab2` project. If you don't have any changes to commit or push, just do a tiny change to any of your java files (insert an extra line, for example).
* You get the *rejected* message because the server's copy has changes that you haven't seen. It's your responsibility to integrate those changes from the server into your local repository (this is called *merging*), before you can push the combined changes back to the server.
* You get the *rejected* message because the server's copy has changes that you haven't seen (mainly just a few corrections in the exercise text). It's your responsibility to integrate those changes from the server into your local repository (this is called *merging*), before you can push the combined changes back to the server.
* First, right-click on your Lab 2 project, and select *Team → Pull* from the menu. You should get an OK message similar to the one below (possibly after entering your password again):
* That's when you should *Pull* first:
![](img/pull-result.png)
* The list will include all the changes that have been integrated into your project. In your case it should be the top three commits from the [Lab 2 commits log](https://retting.ii.uib.no/inf101.v19.oppgaver/inf101.v19.lab2/commits/master).
* The list will include all the changes that have been integrated into your project.
* If the message says *Failed*, some of our changes are in conflict with some of your changes (unlikely unless you've changed the text of the README.md file). You'll have to resolve this as seen in [Lab 1](https://retting.ii.uib.no/inf101.v19.oppgaver/inf101.v19.lab1/blob/master/README.md#oppgave-7-rot-med-merge).
* If the message says *Failed*, some of our changes are in conflict with some of your changes. You'll have to resolve this as described in [Lab 1](https://retting.ii.uib.no/inf101.v19.oppgaver/inf101.v19.lab1/blob/master/README.md#oppgave-7-rot-med-merge).
If you're working on the command line, the message will look like this:
```
......
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