class: title-slide # Collaboration & Version Control using Git ### Eric Stemmler ### 04. April 2022 --- class: center <img src="https://www.explainxkcd.com/wiki/images/4/4d/git.png" width="400px" /> --- ## ... the problem - many people changing the same file(s) - development is trial-and-error: How to go back? -- ## ... the solution - tracking changes (who/ when/ what/ why) - backup (revert changes) --- class: center # Setting up Git (on Windows) <img src="img/git_1.PNG" width="400px" /> [Start] → Git GUI --- class: center ## Generate an SSH key pair <img src="img/git_2_ssh.PNG" width="50%" /> Help → Show SSH Key --- class: center ## Generate an SSH key pair <img src="img/git_3_key.PNG" width="50%" /> Generate key → Enter a password → Click "Copy To Clipboard" --- class: center ## Import key into GitLab profile <img src="img/git_3_profile.png" width="90%" /> Go to https://git.tirana.al → log in → click "Edit Profile" --- class: center ## Import key into GitLab profile <img src="img/git_4_import.png" width="75%" /> SSH Keys → paste ssh key → click "Add key" --- class: center ## Import key into GitLab profile <img src="img/git_5_fingerprint.png" width="75%" /> --- class: center ## Clone a repository <img src="img/git_6_clone.PNG" width="75%" /> --- class: center <img src="img/git_7_base.PNG" width="75%" /> --- class: center ## Git Bash <img src="img/git_8_start_bash.PNG" width="75%" /> --- class: center ## Pull latest changes <img src="img/git_6_bash.PNG" width="75%" /> Type into the bash console ``` git pull ``` --- # Memorize these shell commands ... ## ... to track of changes ```bash # do your changes to file "bcmt.xlsm" git add bcmt.xlsm git commit -m "implemented feature A, solving issue #3" git push ``` --
--- # Memorize these shell commands ... ## ... to revert changes **Find commit** ```bash git log ``` ``` ## bash: line 1: cd: ../bcmt-excel/: No such file or directory ## commit 9a88b976eba3ca44558a0decfc3c11d618383b40 ## Author: Eric Stemmler <eric.stemmler@cimonline.de> ## Date: Mon Apr 4 16:16:00 2022 +0200 ## ## minor ## ## commit d7a08cd316818eafa82a7637678e8928f19d2a91 ## Author: Eric Stemmler <eric.stemmler@cimonline.de> ## Date: Mon Apr 4 16:14:16 2022 +0200 ## ## cleaned ``` --- # Memorize these shell commands ... ## ... to revert changes ``` ## bash: line 1: cd: ../bcmt-excel/: No such file or directory ## commit d7a08cd316818eafa82a7637678e8928f19d2a91 ## Author: Eric Stemmler <eric.stemmler@cimonline.de> ## Date: Mon Apr 4 16:14:16 2022 +0200 ## ## cleaned ``` (Excel sheets are binary files) ```bash # short commit-hash: d07800e git revert --no-commit d07800e git checkout --ours bcmt.xlsm git revert --continue ``` --- class: middle # first day ```bash git config --global user.name "Eric Stemmler" git config --global user.email "eric.stemmler@cimonline.de" git clone "https://git.tirana.al/suti/bcmt" ``` Tells git who you are. Downloads the current state **and** the entire history Creates new folder *bcmt* in the current directory --- class: middle # in the morning ```bash git pull ``` Downloads all changes that have been pushed by others. --- class: middle # in the afternoon ```bash git push ``` Share your changes --- class: center, middle <img src="img/qr.svg" width="500" />