Skip to content
Snippets Groups Projects
Commit 0ffdc2bc authored by Florian Moser's avatar Florian Moser
Browse files

refactor structure

parent 8507faa6
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
body { font-family: sans-serif; }
h1, h2, h3 {
font-family: serif;
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: monospace; }
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Git & Gitlab</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" href="css/remark.css">
</head>
<body>
<textarea id="source">
class: center, middle
# Collaboration with git & Gitlab
<img src="images/UZH-logo.png" width="30%">
<br/>
<img src="images/thealternative-logo.jpg" width="30%">
---
# Why _git_
**Change control**
- keep track of who changed what
- revert changes easily
```bash
no more presentation_v2_final_FINAL.pptx
```
**Backup & distribute**
- store important files remotely
- easily copy and maintain on different devices
- share and edit with collaborators
```bash
no more inconsistent state
```
**Focus**
- strict version control helps you to work goal oriented
```bash
no more chaotic changes
```
---
# Installing _git_
Download *git* for your operating system from [https://git-scm.com/downloads](https://git-scm.com/downloads)
<img src="images/git_download.png" width="100%">
---
# Creating a local repository
open your `Git-Bash`
create a new directory
```bash
mkdir mywebsite
```
change into that directory
```bash
cd mywebsite
```
turn this folder into a git repository
```bash
git init
```
---
# Checking your local repository
you check the status of your repository using
```bash
git status
```
which should give you
```bash
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
```
---
# Change something & commit it
In your folder `mywebsite` create a file `helloworld.html` with the content
```html
<html>
<body>
<h1>Hello World!</h1>
</body>
</html>
```
check how git sees that file
```bash
git status
```
which tells you that there are
```bash
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
helloworld.html
nothing added to commit but untracked files present (use "git add" to track)
```
---
# Change something & commit it
so let's follow the advice and do
```bash
git add helloworld.html
```
and then **commit** this change
```bash
git commit -m 'add my first file'
```
you can always check everything you did with
```bash
git log
```
```bash
commit 3b5616d1ba962e7a2e4af1f1bdd54f5d65d4e22d (HEAD -> master)
Author: Oscan Openness <dini_mueter@gmx.net>
Date: Sun Jan 12 12:20:28 2020 +0100
add my first file
```
---
# Login to gitlab
create an account if you have none
---
# Create a gitlab project (1/2)
<img src="images/gitlab_create_new_project.jpg" width="100%">
---
# Create a gitlab project (2/2)
<img src="images/gitlab_create_new_project_2.jpg" width="100%">
---
# Finish setup gitlab
create a password in the settings
add an SSH key (optional)
<img src="images/gitlab_project_created.jpg" width="100%">
---
# Finish local setup
<img src="images/gitlab_local_setup_account.jpg" width="100%">
<img src="images/gitlab_local_setup_repository.jpg" width="100%">
(skip the `git init`, `git add .` and `git commit -m "Initial commit` steps)
---
# Add a readme
eplain your project for others and your future self
<img src="images/gitlab_add_readme.jpg" width="100%">
---
# Add a license
everything you write has Copyright
Copyright gives you exclusive rights (no one can use it without permission)
use a license to define permissions for others
MIT to allow usage without restrictions
GPL to allow usage if basic freedom granted to users
(many others)
<img src="images/gitlab_add_license.jpg" width="100%">
---
# Install github desktop
download from https://desktop.github.com/
then open your repository folder
<img src="images/github_add_repository.jpg" width="100%">
---
# Pull changes
download the changes made on gitlab
<img src="images/github_pull_pending.jpg" width="100%">
---
# Commit changes
change your local file
then preview the changes and then commit
<img src="images/github_changes.jpg" width="100%">
---
# Push changes
push the changes
<img src="images/github_push_pending.jpg" width="100%">
---
# View history
see the changes you've made in the past
<img src="images/github_history.jpg" width="100%">
---
# Introduction done
play around with it!
we are here to answer questions.
inspiration:
- add some of your documents to git
- change two files but only commit one
- revert changes
ressources:
- https://education.github.com/git-cheat-sheet-education.pdf
- https://git-scm.com/book/en/v2
in 30 Minutes we will start with advanced topics.
---
# Advanced topics
best-practices for commits
create branch & merge request
create issue & mention it in commit
use SSH key
fork & merge back into origin
add different remotes
---
# Best practices for commits
- single purpose
```bash
Improve best practice slide
```
- short, imperative subject line
```bash
Add best practice slide
```
- tell why, not how
```bash
Make wording on slides consistent
```
---
# Create branch & merge request
- create branch
```bash
git checkout -b new-branch
```
- push
```bash
git push --set-upstream origin new-branch
```
- merge (on gitlab)
---
# Create issue & mention it in commit
- create issue on gitlab
- commit local change with `#1` for `1` the issue number
```bash
git commit -m "resolve #1"
```
- push
- go to the issue on gitlab.com and observe
---
# Use SSH key
- create SSH key
```bash
ssh-keygen -t rsa -b 4096 -C "florian.moser3@uzh.ch" && eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa
```
- copy `~/.ssh/id_rsa.pub`
- add the public key on gitlab.com
- clone with SSH
- try out push/pull to see it working
</textarea>
<script src="js/remark.min.js" type="text/javascript"></script>
<script src="js/remark.driver.js" type="text/javascript"></script>
</body>
</html>
git_gitlab_course/images/UZH-logo.png

131 B

git_gitlab_course/images/thealternative-logo.jpg

130 B

var slideshow = remark.create();
\ No newline at end of file
This diff is collapsed.
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