15
Starting with git and GitLab Zeger-Jan van de Weg

Zeger-Jan van de Weg Starting with git and GitLab · Lets use the terminal again. Working together You need a source of truth GitLab! First, let’s setup GitLab for our team. Working

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Zeger-Jan van de Weg Starting with git and GitLab · Lets use the terminal again. Working together You need a source of truth GitLab! First, let’s setup GitLab for our team. Working

Starting with git and GitLabZeger-Jan van de Weg

Page 2: Zeger-Jan van de Weg Starting with git and GitLab · Lets use the terminal again. Working together You need a source of truth GitLab! First, let’s setup GitLab for our team. Working

What is git?

Version Control System

- Contains history of the codebase

- Directed graph state to all other states

- Offline

- But online single source of truth

- Distributed

- Using snapshots

Page 3: Zeger-Jan van de Weg Starting with git and GitLab · Lets use the terminal again. Working together You need a source of truth GitLab! First, let’s setup GitLab for our team. Working

● (I use the CLI exclusively recommend you to do the same)

Let’s get started

Page 4: Zeger-Jan van de Weg Starting with git and GitLab · Lets use the terminal again. Working together You need a source of truth GitLab! First, let’s setup GitLab for our team. Working

● Diverge from a chosen point in history

○ Isolates changes

○ Feature branches

○ git can track how to merge

Branching

Page 5: Zeger-Jan van de Weg Starting with git and GitLab · Lets use the terminal again. Working together You need a source of truth GitLab! First, let’s setup GitLab for our team. Working

New Branch

● $ git branch iss53

● $ git checkout iss53

Page 6: Zeger-Jan van de Weg Starting with git and GitLab · Lets use the terminal again. Working together You need a source of truth GitLab! First, let’s setup GitLab for our team. Working

After one commit

Page 7: Zeger-Jan van de Weg Starting with git and GitLab · Lets use the terminal again. Working together You need a source of truth GitLab! First, let’s setup GitLab for our team. Working

Another feature branch

● $ git checkout -b hotfix

● $ vim email.rb

● $ git commit -a -m ‘Fixed the broken email address’

Page 8: Zeger-Jan van de Weg Starting with git and GitLab · Lets use the terminal again. Working together You need a source of truth GitLab! First, let’s setup GitLab for our team. Working

Basic merge - Fast forward merging

● $ git checkout master

● $ git merge hotfix

Page 9: Zeger-Jan van de Weg Starting with git and GitLab · Lets use the terminal again. Working together You need a source of truth GitLab! First, let’s setup GitLab for our team. Working

Basic merge - Merge commit

● $ git checkout master

● $ git merge iss53

○ How does git resolve this?

Page 10: Zeger-Jan van de Weg Starting with git and GitLab · Lets use the terminal again. Working together You need a source of truth GitLab! First, let’s setup GitLab for our team. Working

Basic merge - Merge commit

● Cleanup:

○ $ git branch --delete iss53

Page 11: Zeger-Jan van de Weg Starting with git and GitLab · Lets use the terminal again. Working together You need a source of truth GitLab! First, let’s setup GitLab for our team. Working

Basic merge - Merge Conflicts

● What if multiple commits edit the same file?

○ Merge conflicts!

● Lets use the terminal again

Page 12: Zeger-Jan van de Weg Starting with git and GitLab · Lets use the terminal again. Working together You need a source of truth GitLab! First, let’s setup GitLab for our team. Working

Working together

● You need a source of truth

○ GitLab!

● First, let’s setup GitLab for our team

Page 13: Zeger-Jan van de Weg Starting with git and GitLab · Lets use the terminal again. Working together You need a source of truth GitLab! First, let’s setup GitLab for our team. Working

Working with Remotes

● $ git remote add [email protected]:group/project.git

● $ git push

○ $ git clone

Page 14: Zeger-Jan van de Weg Starting with git and GitLab · Lets use the terminal again. Working together You need a source of truth GitLab! First, let’s setup GitLab for our team. Working

Syncing changes

● Your changes to upstream

○ $ git push --set-upstream origin <branch-name>

● Pulling changes from upstream

○ $ git pull