Skip to content
Snippets Groups Projects
Commit 982138b0 authored by Lukas Kluft's avatar Lukas Kluft
Browse files

Merge branch 'improve-git' into 'main'

Improve git lecture

Closes #10

See merge request !48
parents 6307db85 b190ecb2
No related branches found
No related tags found
1 merge request!48Improve git lecture
Pipeline #64396 passed
......@@ -28,7 +28,9 @@ There are many version control systems out there (e.g. Subversion, CVS, Mercuria
![](https://git-scm.com/images/logos/downloads/Git-Logo-2Color.svg "Git logo"){height=10%}
## As easy as **1, 2, 3**
```bash
```{.bash code-line-numbers="3-5"}
mkdir my_repo
cd my_repo
git init . # Initialize a repository
git add . # Add the whole directory content (don't do that)
git commit -m "Initial commit" # Commit your changes
......@@ -82,7 +84,7 @@ git config --global user.email "youremail@yourdomain.com"
## Hands-on Session {background-color=var(--dark-bg-color)}
1. Configure the username and email adress in your local git client
2. Initialize an empty Git repository
2. Create a directory and initialize a Git repository
3. Create a file and add it to the repo
3. Change the file, inspect the differences, and commit the changes
......@@ -138,7 +140,7 @@ git diff develop..main
Merge the commits of `develop` into `main`
```bash
git checkout main
git switch main
git merge develop
```
......@@ -154,6 +156,11 @@ gitGraph
merge develop
```
:::{.notes}
After the example: ask about differences to graph and their git log.
By default, git will perform a fast-forward merge and omit the merge commit.
:::
## Hands-on session {background-color=var(--dark-bg-color)}
1. Create a branch
......@@ -267,7 +274,7 @@ git commit
## Hands-on session {background-color=var(--dark-bg-color) .leftalign}
1. Create `file.txt` in two different branches with different content
1. Create `file.txt` in two different branches with different content^[Make sure to **commit** the changes in each branch]
2. Merge both branches into `main` (`CONFLICT`)
3. Resolve the conflict and commit your changes
......@@ -307,8 +314,32 @@ Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Example from [kernel.org](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=90ca6956d3834db4060f87700e2fcbb699c4e4fd)
# Decentralized version control
* Git is a **de**centralized version control system
* Each repository contains the full project history
* _Technically_ there is no single point of truth^[_Practically_ teams agree on one main repo]
## Remotes {auto-animate=true}
* Adding a remote repository
```bash
git remote add origin <PATH_TO_REPO>
```
* List the available remotes
```bash
git remote -v
```
* Push your local references to the remote repo
```bash
git push origin <YOUR_BRANCH>
```
* Pull remote changes to your local repo
```bash
git pull origin <YOUR_BRANCH>
```
# Remotes
## Remotes {auto-animate=true visibility="uncounted"}
* Adding a remote repository
```bash
......@@ -320,14 +351,26 @@ Example from [kernel.org](https://git.kernel.org/pub/scm/linux/kernel/git/torval
```
* Push your local references to the remote repo
```bash
git push origin feature-branch
git push -u origin <YOUR_BRANCH>
```
* Pull remote changes to your local repo
```bash
git pull
```
## Merge request on GitLab DKRZ
## Github and GitLab
* There are many services to host git repositories
* They offer plenty of additional functionality (merge/pull requests, code review, automated testing, ...)
* Github offers by far the largest user base, while GitLab (as opens-source solution) is often self-hosted
:::fragment
We are using **GitLab** for this lecture!
:::
## Merge request on DKRZ GitLab
![](static/mr.png)
......
lectures/git/static/mr.png

213 KiB | W: | H:

lectures/git/static/mr.png

487 KiB | W: | H:

lectures/git/static/mr.png
lectures/git/static/mr.png
lectures/git/static/mr.png
lectures/git/static/mr.png
  • 2-up
  • Swipe
  • Onion skin
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