We have a 15 minutes break very 90 minutes.
We have a 15 minutes break every 90 minutes.
git commit --amend
. For more details please see: https://www.atlassian.com/git/tutorials/rewriting-historyYou can control the behaviour using the configuration options core.pager
. From the Git manual:
core.pager
This setting determines which pager is used when Git pages output such as log and diff. You can set it to more or to your favorite pager (by default, it’s less), or you can turn it off by setting it to a blank string:
$ git config --global core.pager ''
If you run that, Git will print the entire output of all commands, no matter how long they are.
In the following, we prepare our working environment to properly use Git from the shell.
A shell (also known as: terminal, command line, console) is a program which allows you to run commands on your computer and to receive their output. We use Git from the shell because it clearer shows the way how Git works.
Git for Windows
.
Please open it via a right-click on your Desktop and selecting Open Git Bash here
.Terminal
via the MacOS search functionality.pwd
:pwd
/home/<USER NAME>
In this case, the shell has been opened in the home directory of a specific user.
Please double-check that you are in the right directory.In the following, we prepare our working environment and try out other useful shell commands:
ls
- This command shows the content (directories and files) of the current directory.ls
command can be executed with a number of options:ls -l -a
total 8
drwxr-xr-x 1 user group 0 Sep 2 16:32 ./
drwxr-xr-x 1 user group 0 Aug 29 14:41 ../
drwxr-xr-x 1 user group 0 Sep 2 16:32 input/
-l
: Shows a more comprehensive overview of the current directory including information such as permissions, the last modification date and time, etc…-a
: Shows hidden directories and files (i.e., names start with .
) as well.
In this case, it adds the special directory references ./
(refers to the current directory) and ../
(refers to the parent directory).mkdir workshop
- Creates a new, empty directory named workshop
in the current directory.
We use this directory to store our local Git repositories later.cd workshop
- We switch into the newly created directory.
Please switch into the directory via your file browser as well.touch test.txt
- We create an empty file test.txt
.
If you “touch” an existing file, the command will only update the last modification date and time.test.txt
in your favorite text file editor, add the content Hello Git/GitLab workshop audience!
and save the file.less test.txt
- Shows the file content of test.txt
and allows scrolling via the arrow-up and the arrow-down keys.
You can quit this view with the help of the q key.
Git also makes use of the command when showing longer output.rm test.txt
- Permanently deletes the file text.txt
.
Please be careful because you cannot (easily) undo deletions via rm
! Additional tips
<command> --help
: For most commands, this option produces a (short) help message on how to use the command.Copy
or Paste
instead.At the end you should have prepared the following:
workshop
directory.In the following, we provide an overview about the main features of the version control system Git.
Please consider the following example review process:
“Piled Higher and Deeper” by Jorge Cham www.phdcomics.com
Quite often such a review process results in a number of similar files with inconspicuous changes. In addition, it is hard to figure out the recent version manually. In such scenarios, tools such as Git can be quite helpful.
In the following, we perform the minimal initial Git setup.
At least, we have to tell Git about our identity because this information is later associated with our commits. Git uses the username and email address settings to represent your identity when creating commits:
git config --global user.name "Last name, first name"
- Sets the default username that Git associates with your commits.
This options represents your real name or pseudonym which you use.
It does not represent your user account on collaboration platforms such as GitLab or GitHub.git config --global user.email "name@organization.org"
- Sets the default email address that Git associates with your commits.
Collaboration platforms such as GitLab and GitHub usually use this information to map commits to user accounts.git config --global --list
- Displays the default configuration settings.
Here you should find your defined username and email address. Configure username and email consistently
Your username and email address are part of the version history of your repository. Please make sure that you configured them consistently across your (client) systems. Usually, you do not want to change this information later because changing it potentially breaks the version history for your collaborators.
How are configuration settings handled in Git?
Git maintains three levels of configuration settings:
.gitconfig
which is usually located in your user home directory and are kept even after Git client updates.
We recommend to set and change these settings via git config --global
instead of editing the file directly.git config
and have to issue these commands inside the repository directory.You can specify a setting on multiple levels.
In such a case, Git uses the setting defined on the lowest level.
For example, you defined your default username you
on the global level and you-special
for the special
Git repository.
If you work in the special
repository, Git will use the username you-special
.
In all other repositories, Git uses the username you
.
Find out more about the Git configuration settings
In the following, we create the Git repository which we use throughout the workshop.
Imagine we work at Universal Missions. Our famous new clients - Dracula, Wolfman and the Mummy - are looking for potential planets to migrate to. We are here to help them make a good decision. For that reason, we collect relevant information about different planets to support them. We store this information in text files and manage them with Git.
The Software Carpentries, CC-BY 4.0
Now, let us create the planets
Git repository:
mkdir planets
- Creates the new, empty directory planets
.cd planets
- Switches into the directory planets
.git init
- Initializes the current directory as a Git repository.
You need to initialize a repository only once.
Afterwards, every file in the planets
directory (or any subdirectory) can be maintained as part of the version history.
Finally, you can also initialize a non-empty directory for version control with Git..git
subdirectory contains all data, metadata, and configuration settings of the Git repository.
Please be careful: If you delete this directory, the history of all your changes is lost!git status
command:git status
On branch main
No commits yet
nothing to commit (create/copy files and use "git add" to track)
git status
command is really useful when working with Git on the shell.
It provides a detailed overview about the repository status and hints about what you could do next.master
in your output instead.
That is because the Git community is trying to adopt more inclusive language.
The default branch will be main
but for compatibility reasons this is not fully the case yet.
We show you how you can change the default name branch later.git init
initializes a new Git repository.In the following, we introduce the basic Git change workflow in context of our example.
First, we want to start collecting information about planet Mars:
mars.txt
:
touch mars.txt
- Creates a new, empty file named mars.txt
.mars.txt
and add the following:
Cold and dry, but everything in my favorite color
cat mars.txt
which prints the actual file content.git status
- Shows the current status of the planets
repository:
git add mars.txt
- Adds the new file to the repository.
Git tracks from now on the changes to this file.git status
- Indicates the changed repository status:
git commit -m "Start notes on Mars as base"
- Creates the first commit (the so-called root commit) which records the changes in the history of the repository.git log
- Displays the history of the planets
repository which shows one commit including its commit ID (full SHA-1 hash), the commit author (your configured name and email address), the commit date, and the commit message (full message).git status
- Indicates that there are no uncommitted changes anymore.Congratulations - You performed your first commit!
Now, we want to collect further information about Mars and focus on Wolfman:
mars.txt
and change the following:
The two moons may be a problem for Wolfman
git status
- Shows that the file mars.txt
has been modified (might be indicated by red colored text output).git diff
- Shows all changes in comparison to the last committed version.mars.txt
.git add mars.txt
- Adds the changes to the repository and marks them for the next commit.git status
- Indicates that these changes go into the next commit (might be indicated by green colored text output).git commit -m "Add concerns about effect of Mars' moons on Wolfman"
- Creates the second commit which records the changes in the version history.git log
- Shows the second entry in the version history.
The first commit is its parent commit.git status
- Indicates that there are no uncommitted changes anymore.We performed the basic Git change workflow for the second time:
The Software Carpentries, CC-BY 4.0
Excurse: Writing good commit messages
-m
option of git commit
command.Add your commit subject here
(e.g., When applied, this change will Discuss Mars climate issues for Dracula
.Finally, we want to add information about the Mummy:
mars.txt
and change the following (Modify):
But the Mummy will appreciate a lack of humidity
git add mars.txt
- Adds the changes to the staging area.git diff
- Indicates no changes because they have been already transferred in the staging area.git diff --staged
- Shows the newly added line.
It shows the differences between the staging area and the last commit.
You can use it to find out about the changes which are part of your next commit.git commit -m "Discuss concerns about Mars' climate for Mummy"
- Creates the third commit which records the changes in the version history.git log
- Shows the third entry in the version history.git log --oneline
- The option --oneline
provides a much more compact view of the history.git status
- Indicates that there are no uncommitted changes anymore.We performed the basic Git change workflow for the third time:
The Software Carpentries, CC-BY 4.0
Additional
git add
tips
git add -i
or git add --interactive
to add only parts of a file to the staging area.
This tutorial provides a brief overview of its usage.git add .
to add multiples changes to staging area at once.
But please be careful with this shortcut as you might end up accidently adding many unwanted changes such as temporary files! Choosing a commit message
Which of the following commit messages would be most appropriate for the last commit made to mars.txt
?
Committing changes to Git
Which command(s) below would save the changes of new-file.txt
to the local Git repository?
git commit -m "Add recent changes"
git init new-file.txt
git commit -m "Add recent changes"
git add new-file.txt
git commit -m "Add recent changes"
git commit -m new-file.txt "Add recent changes"
git add
into the staging area.git commit
in the version history.git status
helps you to keep the overview.In this episode, we want to work with the version history and explain how you can restore older versions.
Let us change the mars.txt
again and see how we can compare a modification with different committed versions:
mars.txt
and change the following:
An ill-considered change
mars.txt
with different versions using the HEAD
pointer which references the most recent commit:
git diff HEAD mars.txt
- Compares the mars.txt
with the last committed version (represented by HEAD
).git diff HEAD~1 mars.txt
- Compares the mars.txt
with the second last committed version (represented by HEAD~1
).git diff HEAD~2 mars.txt
- Compares the mars.txt
with the third last committed version (represented by HEAD~2
).git diff HEAD~3 mars.txt
- Tries to compare the mars.txt
with the fourth last committed version (represented by HEAD~3
).
However, this attempt results in an error because such a commit does not exist.HEAD~<NUMBER>
allows you to navigate the commit history relatively starting from the most recent commit.
In addition, you can use the commit ID directly to reference a specific version:
git show HEAD~2 mars.txt
- Shows the “content” of the commit including the commit ID.git log --oneline
to find out the commit ID.git diff <copied commit ID> mars.txt
- Shows the same output as git diff HEAD~2 mars.txt
You can usually use a commit ID or a HEAD
based expression, if a Git commands expects a reference to a commit.
Imagine that we changed our mind about our last change and want to discard it:
git status
- Shows that the mars.txt
changed but these changes have not yet been staged.
In addition, the output indicates that we can use git restore
to discard the changes.git restore mars.txt
- Discards the changes and restores mars.txt
to the content of the last commit.cat mars.txt
- Shows that mars.txt
is back to last committed version.git status
- Indicates that there no modifications in the repository.Now, we want to restore an even older version of mars.txt
:
git restore -s HEAD~2 mars.txt
- Restores the mars.txt
content of the initial commit.cat mars.txt
- Shows the content of the initial commit.git status
- Shows that mars.txt
has been modified.Finally, we want to restore the last committed version again:
git restore mars.txt
- Restores the last committed version of mars.txt
.cat mars.txt
- Shows the content of the last commit.git status
- Shows no more modifications. Discard local changes
The commands git restore <filename>
or git restore -s <commit ID> <filename>
might permanently remove your local changes without the chance to undo this.
Discard staged changes
You can use git restore -S <file>
or git restore --staged <file>
to remove changes from the staging area.
Afterwards, the changes are still there but no longer staged for the next commit.
In the next step, you could discard the changes entirely by using git restore <file>
.
HEAD
pointer expression.git restore
to discard (staged) changes and restore the content of older versions.Sometimes, you want to make sure that certain files such as temporary files or files containing sensitive data are not added accidently to your Git repository.
Git allows you to define .gitignore
files for this purpose.
First, we create some temporary files which we do not want in our repository:
mkdir results
- Creates the directory results
.touch a.dat b.dat c.dat results/a.out results/b.out
- Creates different temporary files in the results
directory and in the root directory of our repository.git status
- Shows indicates three new files and one new directory.In such a situation, you can quickly do mistakes and accidently add some of these files to your repository.
For example, if you use git add .
.
.gitignore
fileWe can define which files we want to ignore by adding a .gitignore
file:
touch .gitignore
- Creates the file .gitignore
which we can use to specify file name patterns of files we want to ignore.
Please make sure that you do not misspell the file name because otherwise it will not work..gitignore
:
*.dat
results/
.dat
and the directory results
.
You can use the *
character to express an arbitrary number of characters.
Every line can contain one file pattern.
Git evaluates the file line by line from top to bottom.git status
- Indicates that our .gitignore
definition works and only shows the new file .gitignore
.
The other files are no longer indicated as modifications in your repository.Finally, we add the .gitignore
file permanently to our repository:
git add .gitignore
- Adds the .gitignore
file to the staging area.git commit -m "Ignore data files and the results folder"
- Creates a new commit and adds the .gitignore
file to your repository.git status
- Indicates no further modifications in the repository.From now on, everyone who works with your repository already has the proper definition of ignored files.
Tips for working with
.gitignore
files
.gitignore
files but we recommend to have one file in the root repository to avoid confusion.!
character to negate a file pattern.
For example, !*.dat
means that Git should not ignore files with the file ending .dat
.git status --ignored
shows all files that are currently ignored..gitignore
pattern.
Instead you have to remove the file from the repository first.git add -f <filename>
or git add --force <filename>
to add a file even if you ignored it.
But only use it if you have a good reason and know what you are doing..gitignore
file.
It provides sophisticated lists of patterns for a number of tools and programming languages.
The resulting .gitignore
file is licensed under CC0-1.0 and can be used freely..gitignore
files to avoid adding unwanted files to your Git repository.In the following episode, we introduce the concept of branches and how you work with them on the basis of the feature branch workflow.
A branch is a specific series of commits in the repository:
main
which contains all our commits and starts from the root commit.new
from our last commit on the main branch.new
.
Afterwards, all new commits are associated with the new
branch.
You have to explicitly switch to the main
branch to add commits there again.new
branch to the main
branch.
Afterwards, the commits of the new
branch are also part of the main
branch’s history.Branching is a general concept of version controls systems such as Git. There are different reasons to use branches, for example, working in isolation on a specific task. Patterns such as the feature branch workflow provide guidance on how to use branches in a meaningful way.
The main ideas of the feature branch workflow are:
The feature branch workflow is used quite often in context of Git. It also provides the basis for features of code collaboration platforms such as “merge requests” (GitLab) and “pull request” (GitHub).
In the following, we contribute more information about the Mummy concerning Mars by using the feature branch workflow. There are a couple of things which we want to prepare before we start.
pwd
- Should indicate that you are in the planets
directory.git status
- Should indicate that your repository does not contain any modifications.main
if needed:
git status
starts with On branch master
, you need change the branch name as follows:
git branch -m master main
- Manually renames your branch from master
to main
.git status
- Should now indicate that you are On branch main
.git config --global alias.graph "log --oneline --graph --all --decorate"
- Configures a new Git command git graph
which you can use to see a comprehensive summary of the version history of your repository across all branches.git config --global commit.verbose true
- Configures Git to show the changes of a commit when Git launches the editor on committing time.Now we are ready to start!
git graph
should indicate a version history similar to the following figure:
We create a new branch named mummy-info
:
git branch
- Shows all existing branches.
Currently, there is only the main
branch.git branch mummy-info
- Creates a new branch named mummy-info
starting from the last commit.We have created our feature branch but we still have to switch to it:
git switch mummy-info
- Switches to the new branch mummy-info
.git status
- Indicates that you are now On branch mummy-info
.Now, we are ready to start working on our actual task.
Tips for switching branches
git switch -c <branch name>
.git checkout <branch name>
to switch branches.
It still works with recent Git versions but we recommend to use the new command instead. How do I know on which branch I am?
There are several options:
git status
- Indicates that you are On branch <branch name>
.git branch
- Uses the *
character to indicate on which branch you are.git graph
- Uses HEAD -> <branch name>
to indicate on which branch you are.We perform two commits on the feature branch:
mars.txt
and commit the changes:
Mummy will appreciate sand storms on Mars
git add mars.txt
- Add the changes to the staging area.git commit -m "Add advantages for the Mummy"
- Records the change in the version history.
The command output indicates that you performed the commit on branch mummy-info
.mars.txt
and commit the changes:
(for Dracula)
git add mars.txt
- Add the changes to the staging area.git commit -m "Concretize the first fact"
- Records the change in the version history.We are done with our task.
Afterwards, git graph
should indicate a version history similar to the following figure:
main
branchImagine that someone else changed mars.txt
and integrated the changes back to main
.
We perform this change directly on main
for demonstration purposes.
main
:
git switch main
- Switches to the branch main
.git status
- Indicates that you are now On branch main
again.cat mars.txt
- Shows that the content of mars.txt
is back to the content of the fourth commit.Cold and dry, but everything in my favorite color
The two moons may be a problem for Wolfman
But the mummy will appreciate a lack of humidity
mars.txt
and commit the changes:
mars.txt
in your editor, please double-check that it shows the right content.
If in doubt, please close the editor and reopen the file.Generating solar energy is less effective on Mars
git add mars.txt
- Add the changes to the staging area.git commit -m "Add information about energy generation"
- Records the change in the version history.
The command output indicates that you performed the commit on branch main
.git graph
indicates a split in the commit history because there are two different commits which are based on the same parent commit:
Now, we want to integrate our work back into the main branch.
There are several ways to do this.
In this episode, we use the standard way via git merge
which preserves the branching structure.
mummy-info
branch into the main
branch.
For that reason, we have to switch to the main
branch.
Luckily, we are already on the right branch!git merge mummy-info
- Starts the merge process and shows the current result.mars.txt
from both branches.
But it failed because both file versions contain a different line 4.Let us resolve the merge conflict:
git status
- Indicates that you are still in the merge process and that mars.txt
contains conflicts.mars.txt
in your editor and resolve the conflict manually:
mars.txt
should look similar to the following:Cold and dry, but everything in my favorite color (for Dracula)
The two moons may be a problem for Wolfman
But the mummy will appreciate a lack of humidity
<<<<<<< HEAD
Generating solar energy is less effective on Mars
=======
Mummy will appreciate sand storms on Mars
>>>>>>> mummy-info
<<<<<<< HEAD ... ======= ... >>>>>>> <branch name>
are used to indicate each conflict.git add mars.txt
- Tells Git that the conflict has been resolved.git commit
- Opens the configured Git editor and shows a default merge commit message.
In addition, you can see the resulting changes introduced by this commit.
We use the default commit message and close the editor. Configure another editor
core.editor
to specify another editor that Git should use.git graph
shows that both branches have been merged:
The merge operation resulted in a so called merge commit:
mummy-info
including its two commits.Finally, we want to clean up the feature branch:
git branch -d mummy-info
- Removes the branch mummy-info
.
If Git found out that the branch has not been already merged, it would not perform the removal operation.git graph
- Shows the same output but only the label mummy-info
is no longer there.
However, the branch structure is still in place and a permanent part of the version history of the main
branch.git branch <feature branch name>
and git switch <feature branch name>
.git switch <feature branch name>
and git merge <feature branch name>
.git add
.git commit
.In the following, we start using GitLab and take our first steps.
GitLab is a code collaboration platform built on top of the version control system Git. It is focused on software development and adds features for managing projects, team collaboration, and automating tasks around the core Git features. It is a purely Web-based application which means that you are not forced to install Git. However, it can be practical though depending on the project.
There are different similar systems available:
Which GitLab am I using?
While there is also the official GitLab cloud service, companies and research institutions often install GitLab on their own infrastructure. Thus, there many different GitLab instances:
In addition, these instances can vary concerning the available feature set. On the one hand, there are certain features that require substantial infrastructure and special configuration. On the other hand, there are different GitLab tiers. Besides the free, open source tier, GitLab offers different paid tiers as well. These GitLab tiers offer different feature sets.
For that reason, please make sure that you understand which GitLab instance is typically used in your organization!
Now, we want to start working with the GitLab Web interface. In this workshop, we are using the following GitLab instance: Helmholtz GitLab Instance.
https://codebase.helmholtz.cloud
in your Web browser and log in with your credentials.
Your welcome screen can look a bit different depending on the fact whether you already work in some GitLab projects on this instance or not.Help
link). Some general tips
Now, we want to collaborate with others via GitLab.
In the following, we will set up an access token that you can use to authenticate via your Git client.
git-access
read_repository
and write_repository
. The scopes define what you can do with the access token. In our case, we only want to read/write the Git repository.Create personal access token
button.Please note that you cannot retrieve the access token after you closed the Web page. But this is actually no problem as you can remove / add new access tokens at any time.
Click the + => New project/repository
(toolbar on the top) which opens the dialog for creating a new project:
Create blank project
Project name
=> planets-<username>
Pick a group or namespace
=> Select 2025-04-22-introduction-to-git-and-gitlabInitialize repository with a README
Create project
which creates a new GitLab project and redirects you to its overview page.Further remarks:
The Project URL
allows you to select different namespaces (groups, subgroups, your username namespace). We create a project in a group namespace. Later projects can also be moved to other namespaces.
Even if the Project description
is optional, please use them because they make it easier to navigate in project lists later.
You can define different visibility levels:
private
: Only explicitly added project members can see and do something with the GitLab project.internal
: Only authenticated users of the GitLab instance can see/clone/fork the GitLab project.public
: The GitLab project is visible/cloneable even for unauthenticated users.We do not initialize the GitLab project with a README.md
file. Otherwise we have problems pushing our local Git repository directly to our GitLab project.
When creating the GitLab project, GitLab runs a git init --bare
in the background.
GitLab project = Git repository + a lot of further useful tools
On the GitLab project page:
git status
- Please make sure that there are no uncommitted changes and that your on branch main
.git remote
- Only shows the defined remote labels.git remote add origin <copied URL>
- Creates a link to the remote Git repository on Helmholtz GitLab Instance. URL should look similar to: https://codebase.helmholtz.cloud//2025-04-22-introduction-to-git-and-gitlabplanets-<username>.git
Clone => Clone with HTTPS
and use the copy button on your GitLab project page.git remote -v
- Displays two entries for origin
, one where we ‘push’ changes to and another from where we ‘fetch’ changes. These URLs are usually the same. Different URLs and thus repositories are possible, but are only used in special sync workflows. We do not explain them here.git remote set-url <remote name> <new url>
to rename a urlgit push
- pushes the content of our repository but shows an error message because we have not connected the branches. Luckily, Git tells us what to do.git push --set-upstream origin main
- Instructs Git to link the current branch the branch main
in repository called origin
(which is on GitLab). Link is created and data is transferred. Output shows that a new branch was created on the remote repository and that the files were transferred.Hint:
--set-upstream
git push --set-upstream origin main
Username for ‘https://codebase.helmholtz.cloud’: token Password for ‘https://token@codebase.helmholtz.cloud’: Now enter your access token as the password. This does not appear in the window, do not pay attention, simply press Enter.
Hint: Configure a credential manager
In general, on Windows and Linux (in a window manager) a credential manager ist used to cache your password. If it does not work, you can configure a credential manager.
https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage#_credential_caching
History
button in the GitLab file view. It shows the same entries that are shown by git log --oneline
git branch
- Displays only local branches.git branch --all
- Displays remote branches as well.git graph
- Shows where the remote branches are.Repository > Files > Edit Button
you can change files with the web IDE, stage and commit changes. In addition, you will find typical Git functionalities in the Repository
menu as well.mars.txt
via the GitLab Web Interfacemars.txt
.
We have to bring our own oxygen
Add notes about the Mars atmosphere
git graph
- Only shows our local commits but not the changes we did in GitLab. These commits are so far only in the repository on GitLab.
git fetch origin main
- Checks if there is anything new in the remote repository on branch main
. The output shows that something was fetched.
git graph
- Now we see the 1 new commit objects in the graph and our HEAD
still points to the latest local commit.
git status
- Tells us that we are with our local main
branch 1 commits behind the main
on the remote repository (origin/main
). In addition, the output tells us that we can use git pull
to retrieve them.
git pull
- Now we retrieve the commits and apply them to our local main
branch. You normally run git pull
directly. But in this case everything is directly applied to your local branch.git fetch
allows you to view the changes first and then to decide whether the changes are wanted. For example, you could display them via git diff main origin/main
.
If you use git pull
, it implicitly performs a git merge
as well. The git status
hint that it can be fast-forwarded
tells us it will not create a merge commit and more or less treat the two branches as one.
git status
- Indicates that everything is clean again
git graph
- Now both main
branches point to the latest commit.
A contribution workflow regulates how changes to the files of the project get planned, agreed upon, executed and verified.
In this course, a workflow will be presented that is especially suited for GitLab (or GitHub) and can be applied for many types of projects. The following is an overview, the details will be subject of the following episodes.
As a rule of thumb:
Issues => New issue
, fill in details, Create issue
)
My first issue
Issues
)Writing good issues is a valuable soft-skill for teamwork. A good issue draws attention, has high information density and provides all details to get started with solving it.
ToDo
, Planning
, In Progress
, Review
Bug
, Fix
, Feature
, Maintenance
, Chore
, Documentation
, Discussion
Critical
, High
, Medium
, Low
Help Wanted
, Good First Issue
Project information => Labels
, New label
):
Documentation
(color blue)Discussion
(color blue)Issues
, Select the issue)
Discussion
to your issueClose issue
)Issues
)Merge Requests (short MR) visualize the development process on a git branch, including:
They form the basis for reviews
Note: This feature has different names on different platforms:
The interaction principles (commenting, adding files, referencing) are similar to the ones already seen for issues. Particularly, when performing reviews, sticking to a good review practice makes the difference between reviews being a dreaded nuisance or a valuable team experience. We refer to Philpp Hauer’s Blog Post on Code Reviews for further information.
The README is the front page of your project. You can learn more about important files here: https://codebase.helmholtz.cloud/hifis/software/education/hifis-workshops/foundations-of-research-software-publication/workshop-materials/-/blob/master/episodes/03_add-essential-documentation.md
SETUP:
Contributor
and the other one is the Owner
.Owner
adds the Contributor
to his/her GitLab project in the role Developer
.Contributor
starts by cloning the Git repository of the Owner
.Create an issue (Issues => New issue
, fill in details, Create issue
) (role Contributor
):
Add a README
We want to provide an initial README file which serves as an introductory page for the project.
Documentation
Create a merge request from the issue (Create merge request
, leave details as they are, Create merge request
) (role Contributor
)
Contributor
)CHANGE: Change the branch from the local Git repository (role Contributor
)
git pull
)git switch 2-add-a-readme
)README.md
file with the following content:# Planets
This repository contains notes about potential planets for migration.
Add an initial README
git push
)Contributor
section via a second commit and show the results.Go back to the merge request (Click on the link !1
) and watch the changes (role Contributor
)
Mark as ready
)Owner
as reviewerReview and merge the changes: (role Owner
)
Merge
)Check the result in GitLab: (role Owner
)
Merge requests
)Issues
)Repository => Graph
)Update the local Git repository: (role Contributor
)
main
branch: git switch main
Older versions of Git use
git checkout main
git pull
git branch -d 2-add-a-readme
git fetch --prune
(will remove all origin/… branches that no longer exist)Now we want to try out the full contribution workflow practically in pairs of two persons!
Task:
Owner
and Contributor
roles:
Owner
adds the contributor to the project and reviews the changesContributor
solves the actual task14:45
! If you have still some time left, please switch roles and try again and/or experiment with the process on your own :)Project information => Members
and click Invite members
Select a role
menu the role Developer
Invite
buttonOwner
Issues => New issue
, fill in details, Create issue
):
Add information about Venus
We want to collect some basic information about Venus.
Documentation
Create merge request
, leave details as they are, Create merge request
)Clone => Clone with HTTPS
git clone <URL> planets-<OWNER NAME>
cd planets-<OWNER NAME>
git switch 3-add-information-about-venus
(Please double-check the name of the branch in your case!)
Older versions of Git use
git checkout 3-add-information-about-venus
venus.txt
with the content:Venus is full of love
Wolfman will appreciate the absence of moons
git add venus.txt
git commit -m "Add initial information about Venus"
git push
Mark as ready
)Reviewer
Approve
)Merge
)Merge requests
)Issues
)Repository => Graph
)main
branch: git switch main
Older versions of Git use
git checkout main
git pull
git branch -d <BRANCH NAME>
git fetch --prune
(will remove all origin/… branches that no longer exist)The workshop material is based on the swcarpentry/git-novice: Software Carpentry: Version Control with Git, June 2019 lesson which has been created by the Software Carpentries and has been further developed by the German Aerospace Center (DLR) and the Helmholtz-Zentrum Dresden-Rossendorf (HZDR).
If not noted otherwise, all content is licensed under CC-BY 4.0. A detailed overview about the copyright holders and licenses can be found in the workshop materials repository.