Skip to content
Snippets Groups Projects
Commit 6b44aa05 authored by Sivecano's avatar Sivecano
Browse files

add most of the thing fix some stuff add some exercises

parent 7d77296e
No related branches found
No related tags found
No related merge requests found
......@@ -3,8 +3,12 @@ author:
- Fadri Lardon
title: Git and Gitlab
---
# Git
# Introduction
## Who are we?
\includegraphics[width=\textwidth]{img/logo_blue.pdf}
## What git?
* THE modern distributed version control system
......@@ -231,6 +235,18 @@ git adds conflict-resolution markers
resolve these either manually or with `git mergetool`. mark as resolved with `git add`
## Exercises
* create a second branch in your existing repo
* create another branch and delete it again
* switch between branches and make edits to both
* merge or rebase between branches
advanced:
* create a merge conflict and resolve it
* merge or rebase between branches
* create a branch of a branch and merge or rebase with the original
# GitLab
## working with a remote repository
\begin{tikzcd}[ampersand replacement=\&]
......@@ -281,23 +297,53 @@ but also set it up for use
git push -u origin --all # push to the new remote repository and
git pull -u origin --tags # set it as default to be used with pull & push
## Creating a repository
## Create a repository
Under the Gitlab homepage find the `New Project` option
### Add a README
## Add a README
A README file contains some explanation about your project. Similar to a small landing page.
A README can be invaluable for both others and your future self.
A README should generally support
* A description
* Setup instructions
* Usage instructions
* Contribution Guidelines
* Acknowledgements
### choosing a License
## choose a License
You own whatever you write. Adding a License allows others to use your code.
There are many commonly used Licenses usable as a template.
## Managing Your Project
### Permissions
Gitlab allows you to configure permsissions on a branch-by-branch basis.
find this in your project under `Settings -> Repository`.
### Issues
Gitlab, like many Git hosting providers, has a built-in issue tracker. Use judiciously.
### Merge Requests
Gitlab Supports making merge requests both between branches within the same repository or from a fork.
This allows for collaborative reviewing as well as increased security.
## Exercises
* create a new Project on Gitlab
* basic: clone it (via ssh)
* advanced: link your existing repo to it
* push a commit
* look at the repo in web view
* create and issue
advanced:
* create a second branch and push some changes to it
* make a merge request and merge it
* more advanced: try if you can invite one of your seat neighbors to collaborate on your repo
# Troubleshooting
## Stash and Pop
git does not allow to checkout if it would overwrite local changes.
......@@ -313,7 +359,17 @@ scenario: you've commited something you didn't want to or left out something. Yo
git commit --amend
allows you to add the current staging not as a separate commit but as part of the previous commit.
Allows you to add the current staging not as a separate commit but as part of the previous commit.
## Links
to work with `ssh` you'll want to use ssh links to refer to your remote repository
git@gitlab.ethz.ch:thealternative/courses.git
when you don't need to push any changes you can also clone with https
https://gitlab.ethz.ch/thealternative/courses.git
## Merge conflicts
Remember from earlier:
......@@ -368,11 +424,42 @@ Commit messages should be short and descriptive.
fixed issue #1
## Branches
Branches are a useful tool both for experimenting with rewrites and new feature or for developing a
different version of your project.
# Advanced Topics
## .gitignore
sometimes you may want some files to never get tracked by git.
add a .gitignore file
secret.txt # exclude specific files
*.aux # wildcard excludes
!important.aux # negate pattern
build # exclude directories
build/*.pdf # be specific
## git-lfs
for large binary files you can use git-lfs. You may need to install this seperately.
git lfs track [FILE] # start tracking binary file
otherwise proceed as usual
## Link commit to issue
when creating an issue on Gitlab it will recieve and issue number.
adding the issue number to your commit message will automatically link the commit to the issue.
example:
fix issue #1
\includegraphics[width=\textwidth]{img/tag_issue.png}
# Outlook
......@@ -397,6 +484,14 @@ different version of your project.
* [Github.com](https://github.com) biggest platform. run by Microsoft.
* [codeberg.org](https://codeberg.org) non-commercial platform for open-source code
* [Gitlab.com](https://gitlab.com) open-source alternative for bigger projects and enterprise
* [Gitea.com](https://gitea.com) open-source git provider for self-hosting
## IDE support
* vscodium/vscode
* vim-fugitive (vim/neovim)
* magit (emacs)
* JetBrains IDEs
* Eclipse
## Useful Commands
......@@ -408,3 +503,6 @@ Display a beautiful commit and branch graph
Selectively apply commits
git cherry-pick
##
\bigtext{I hope you learned a lot and thank you for coming!}
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