Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lecture materials
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
generic software skills
lecture materials
Commits
982138b0
Commit
982138b0
authored
1 year ago
by
Lukas Kluft
Browse files
Options
Downloads
Plain Diff
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
!48
Improve git lecture
Pipeline
#64396
passed
1 year ago
Stage: test
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lectures/git/slides.qmd
+50
-7
50 additions, 7 deletions
lectures/git/slides.qmd
lectures/git/static/mr.png
+0
-0
0 additions, 0 deletions
lectures/git/static/mr.png
with
50 additions
and
7 deletions
lectures/git/slides.qmd
+
50
−
7
View file @
982138b0
...
...
@@ -28,7 +28,9 @@ There are many version control systems out there (e.g. Subversion, CVS, Mercuria
{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.
I
nitialize a
n empty
Git repository
2.
Create a directory and i
nitialize 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

...
...
This diff is collapsed.
Click to expand it.
lectures/git/static/mr.png
+
0
−
0
View replaced file @
6307db85
View file @
982138b0
213 KiB
|
W:
|
H:
487 KiB
|
W:
|
H:
2-up
Swipe
Onion skin
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment