From ab54351409132a4cc0bfcb2e7dadde1ca339ec69 Mon Sep 17 00:00:00 2001
From: MB <michael.blaschek@univie.ac.at>
Date: Wed, 2 Apr 2025 09:28:16 +0200
Subject: [PATCH] Enhance Git documentation with additional resources and setup
 instructions

---
 Git/README.md | 100 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 98 insertions(+), 2 deletions(-)

diff --git a/Git/README.md b/Git/README.md
index ee6cd89..be9739f 100644
--- a/Git/README.md
+++ b/Git/README.md
@@ -7,11 +7,16 @@ Some examples:
 - [ZID Introduction to git](https://phaidra.univie.ac.at/detail/o:1403751)
 - [Gitlab - Learn Git](https://docs.gitlab.com/ee/tutorials/learn_git.html)
 - [Git cheatsheet](./git%20cheat%20sheet.pdf)
+- [Git Tutorial](https://gitlab.phaidra.org/imgw/gitlab-tutorial) and [Git Introduction @IMGW](../../external/Presentation.html)
+- [git scm book (multiple languages)](https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control)
+- interactive [git branching](https://learngitbranching.js.org/?locale=en_US)
+- video [Youtube Introduction](https://www.youtube.com/watch?v=8JJ101D3knE)
+- Cheat Sheet [GitHub Education](https://gitlab.phaidra.org/imgw/gitlab-tutorial/-/raw/master/Images/git-cheat-sheet-education.pdf)
 
 Don't be overwhelmed. Everyone learns as they go along, but make sure you have a nice [setup](https://docs.gitlab.com/ee/tutorials/learn_git.html) and understand the [basics](https://docs.gitlab.com/ee/tutorials/learn_git.html).
 
 
-## HowTo add a specific ssh-key for your git account
+## How To add a specific ssh-key for your git account
 Sometimes it might be useful to have different ssh-keys per project or have a special ssh-key just for github/gitlab.
 
 Steps:
@@ -46,7 +51,86 @@ These urls should not show `https`, if there is a `https` then you will need to
 Every git repository can be cloned using https, but for ssh-key access you need the `git@...` version (usually there are two options: `ssh`, and `https`).
 
 
-## HowTo Sync a GitHub and a GitLab repository
+## How To Setup an Access Token in Git?
+
+In your [GitLab account](https://gitlab.phaidra.org/-/profile/preferences) you can define *Access Tokens*, which can be used to share git access to your projects with some API or Server. This is preferred to storing you GitLab credentials. The best option is of course to use ssh-keys with a passphrase (even a simple one).
+
+Steps:
+
+1. Account Settings
+2. Access tokens
+3. add new token
+4. Specify *Token Name*
+5. Specify *Expiration date*
+6. Specify *scope*, which can be full access (**api**) or just read (**read_api**). There are multiple options. [docs](https://gitlab.phaidra.org/help/user/profile/personal_access_tokens.md#personal-access-token-scopes)
+7. Create
+8. Clone the repo with **HTTPS** url.
+9. Store this token for easy access:
+	```sh
+	# Store or cache (in .git-credentials)
+	# or use an personal access token (can only be used for git operations)
+	$ git config --global credential.helper store
+	# this will ask your username 
+	# Use the access token as password.
+	$ git clone https://gitlab.phaidra.org/Group/RepositoryName.git
+	```
+
+## How To Sync a Branch?
+
+When you create a branch on the commandline or in GitLab and you want to push local changes to the remote, you need to det the remote first:
+
+```sh
+$ git branch test
+# Modify something
+$ vim README.md
+$ git commit -a -m 'Updated the README.md'
+$ git push
+fatal: The current branch test has no upstream branch.
+To push the current branch and set the remote as upstream, use
+
+    git push --set-upstream origin test
+
+To have this happen automatically for branches without a tracking
+upstream, see 'push.autoSetupRemote' in 'git help config'.
+# What you need to do is run that command:
+$ git push --set-upstream origin test
+Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
+remote: 
+remote: To create a merge request for test, visit:
+remote:   https://gitlab.phaidra.org/Group/RepositoryName/-/merge_requests/new?merge_request%5Bsource_branch%5D=test
+remote: 
+To gitlab.phaidra.org:Group/RepositoryName.git
+ * [new branch]      test -> test
+branch 'test' set up to track 'origin/test'.
+# done
+$ git push
+Everything up-to-date
+```
+
+## How To Configure Git?
+
+There are a lot of options, but there are the basic options that you should set:
+
+```sh
+# set you username and mail address
+$ git config --global user.name "Wind Cloudy"
+$ git config --global user.email wcloudy@univie.ac.at
+# set that you want to merge conflicts.
+$ git config pull.rebase false
+# set your default editor
+$ git config core.editor [vim/nano/...]
+# edit your Configuration
+$ git config -e
+```
+
+Optional:
+
+```sh
+
+```
+
+
+## How To Sync a GitHub and a GitLab repository
 It is easy to import a GitHub repo into GitLab and the otherway around. However, if you want to make sure you can have both repos at the same state, you need to syncronize them.
 
 How to call: `./git-repos-sync [URL1] [URL2] [Branch]`
@@ -93,3 +177,15 @@ chmod +x git-repos-sync
 # execute the script
 ./git-repos-sync [URL] [URL] [Branch]
 ```
+
+## How To Sync Gitlab and GitHub Repositories?
+
+You can set up some CI/CD yourself, but Gitlab will automatically do this for you:
+
+1. Go to *"Settings > Repository > Mirroring repositories"*
+2. Enter your Github repo with your username in front `https://<github username>@github.com/path/to/your/repo.git`
+3. In the password field, enter your Github token
+4. push is the only option for our GitLab
+5. Press Mirror repository
+
+Whenever you push something to GitLab it will automatically sync that with GitHub, if it can. If there are different commit on both repos, then it does not do it.
\ No newline at end of file
-- 
GitLab