diff --git a/learning-git/README.md b/learning-git/README.md index 83a34e56cf8b59909c3c72981df940655ed6137a..f8b19d53d999ceb71e8cef0130fab247c225b98a 100644 --- a/learning-git/README.md +++ b/learning-git/README.md @@ -40,7 +40,7 @@ git config --global push.default simple Clone the Git_Training repository : ```bash -git clone https://forge.uclouvain.be/barriat/learning-git +git clone https://forge.uclouvain.be/elic/learning.git ``` ### Windows or Mac @@ -50,7 +50,7 @@ git clone https://forge.uclouvain.be/barriat/learning-git Clone the Git_Training repository: ```bash -https://forge.uclouvain.be/barriat/learning-git +https://forge.uclouvain.be/elic/learning.git ``` For instance, paste the URL into **gitforwindows** and it will clone the repo locally on your computer: diff --git a/learning-git/exercices/ex1/README.md b/learning-git/exercices/ex1/README.md new file mode 100644 index 0000000000000000000000000000000000000000..4977fe1f2f7a5a22b422e652084d5618af96728b --- /dev/null +++ b/learning-git/exercices/ex1/README.md @@ -0,0 +1,9 @@ +You have accidentaly put `first.txt` in the **staging area** + +While you actually want to only commit `second.txt`. + +You need to, from the current state, only commit `second.txt`: + +- remove the file `first.txt` (Use `git status` to get the appropriate command) +- add `second.txt` +- commit diff --git a/learning-git/exercices/ex1/linux_create.sh b/learning-git/exercices/ex1/linux_create.sh new file mode 100755 index 0000000000000000000000000000000000000000..adf801c28a5953fff59647cc06507ba5d67b93cc --- /dev/null +++ b/learning-git/exercices/ex1/linux_create.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +rm -f first.txt second.txt 2> /dev/null + +echo "un" > first.txt +echo "deux" > second.txt + +git add first.txt diff --git a/learning-git/exercices/ex1/win_create.bat b/learning-git/exercices/ex1/win_create.bat new file mode 100755 index 0000000000000000000000000000000000000000..01f1edd279acfee1279f72341bd4e288923d7e77 --- /dev/null +++ b/learning-git/exercices/ex1/win_create.bat @@ -0,0 +1,18 @@ +@echo off + +SET SOME_VAR=.\first.txt +DEL /S "%SOME_VAR%" || echo "file not found" +SET SOME_VAR=.\second.txt +DEL /S "%SOME_VAR%" || echo "file not found" +CALL :_ex + +EXIT /B %ERRORLEVEL% + +:_ex +echo "2 files have been created !" +echo un> first.txt +echo deux> second.txt +dir *.txt +git add first.txt +EXIT /B 0 + diff --git a/learning-git/exercices/ex2/README.md b/learning-git/exercices/ex2/README.md new file mode 100644 index 0000000000000000000000000000000000000000..ba4a9b796d4df9fb9436fe22d5a092f21fd6c20d --- /dev/null +++ b/learning-git/exercices/ex2/README.md @@ -0,0 +1,12 @@ +You just wrote a cpp program that reads it config from a file named `conf.ini` + +As you don't want to bother adding all files manualy, you have decided to use `.gitignore` + +You need to create a `.gitignore` file that will: +- ignore all files that end with suffix `.swp` (backup files) +- ignore every files in the `out` directory except `conf.ini` + +In other words, once the `.gitignore` file written, the command `git add .` should only stage: +- .gitignore +- main.cpp +- out/conf.ini diff --git a/learning-git/exercices/ex2/linux_create.sh b/learning-git/exercices/ex2/linux_create.sh new file mode 100755 index 0000000000000000000000000000000000000000..87f5c0e05e58d1e70d874d7a3bd66f30e99355c0 --- /dev/null +++ b/learning-git/exercices/ex2/linux_create.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +rm -rf out main.cp* 2> /dev/null + +touch main.cpp +touch main.cpp.swp + +mkdir out +touch out/main.o +touch out/a.out +touch out/conf.ini diff --git a/learning-git/exercices/ex2/win_create.bat b/learning-git/exercices/ex2/win_create.bat new file mode 100755 index 0000000000000000000000000000000000000000..95388e77c4d1e810776f636cfc1c8ac9ee897232 --- /dev/null +++ b/learning-git/exercices/ex2/win_create.bat @@ -0,0 +1,21 @@ +@echo off + +SET SOME_VAR="main.cpp" +DEL /S "%SOME_VAR%" || echo "file not found" +SET SOME_VAR="main.cpp.swp" +DEL /S "%SOME_VAR%" || echo "file not found" +SET SOME_VAR=out +RD /S /Q "%SOME_VAR%" || echo "file not found" +CALL :_ex + +EXIT /B %ERRORLEVEL% + +:_ex +echo >"main.cpp" +echo >"main.cpp.swp" +mkdir "out" +echo >"out\main.o" +echo >"out\a.out" +echo >"out\conf.ini" +EXIT /B 0 + diff --git a/learning-git/exercices/ex3/README.md b/learning-git/exercices/ex3/README.md new file mode 100644 index 0000000000000000000000000000000000000000..e785e2eb6acb4db97e44ec0878907b48335bd755 --- /dev/null +++ b/learning-git/exercices/ex3/README.md @@ -0,0 +1,9 @@ +You just realized that you have commited a backup file: `main.cpp.swp` + +Backup files should not be commited, let's correct that mistake : + +- delete the file with `rm` +- add all changes, including deleted files with `git add -A` +- write a gitignore that will correct your mistake +- add it +- commit diff --git a/learning-git/exercices/ex3/linux_create.sh b/learning-git/exercices/ex3/linux_create.sh new file mode 100755 index 0000000000000000000000000000000000000000..1c35ed23be10d1c72c0fed0e438dc8368d5bd83b --- /dev/null +++ b/learning-git/exercices/ex3/linux_create.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +rm -f main.cp* 2> /dev/null + +touch main.cpp +touch main.cpp.swp +git add . +git commit -m "first commit" diff --git a/learning-git/exercices/ex3/main.cpp b/learning-git/exercices/ex3/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/learning-git/exercices/ex3/main.cpp.swp b/learning-git/exercices/ex3/main.cpp.swp new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/learning-git/exercices/ex3/win_create.bat b/learning-git/exercices/ex3/win_create.bat new file mode 100755 index 0000000000000000000000000000000000000000..9c1b8b42ec09887468ef50fae7c82a0657909dec --- /dev/null +++ b/learning-git/exercices/ex3/win_create.bat @@ -0,0 +1,17 @@ +@echo off + +SET SOME_VAR="main.cpp" +DEL /S "%SOME_VAR%" || echo "file not found" +SET SOME_VAR="main.cpp.swp" +DEL /S "%SOME_VAR%" || echo "file not found" +CALL :_ex + +EXIT /B %ERRORLEVEL% + +:_ex +echo >"main.cpp" +echo >"main.cpp.swp" + +git add . +git commit -m "first commit" +EXIT /B 0 diff --git a/learning-git/exercices/ex4/README.md b/learning-git/exercices/ex4/README.md new file mode 100644 index 0000000000000000000000000000000000000000..229c5b8e96476b8ad5bde1047be4e7d8f0624b0c --- /dev/null +++ b/learning-git/exercices/ex4/README.md @@ -0,0 +1,10 @@ +You just ran a `git fetch` and realize someone has modified the exact file at the exact line that you just worked on. + +You want the current state of your working directory to be saved. + +Conflict seems inevitable. + +- create a commit with the new version of first.txt +- use `git pull` to merge origin/master into your master +- resolve the conflict in first.txt +- commit diff --git a/learning-git/exercices/ex4/first.txt b/learning-git/exercices/ex4/first.txt new file mode 100644 index 0000000000000000000000000000000000000000..814f4a422927b82f5f8a43f8fab6d3839e3983f2 --- /dev/null +++ b/learning-git/exercices/ex4/first.txt @@ -0,0 +1,2 @@ +one +two diff --git a/learning-git/exercices/ex4/linux_create.sh b/learning-git/exercices/ex4/linux_create.sh new file mode 100755 index 0000000000000000000000000000000000000000..b91f9b6cd750615bdc4030b24cfb34dab86969a7 --- /dev/null +++ b/learning-git/exercices/ex4/linux_create.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +rm -f first.txt 2> /dev/null + +touch first.txt +git add . +git commit -m "First commit" +echo "one" >> first.txt +git commit -am "Added one" +echo "two" >> first.txt +git commit -am "Added two" +git push -u origin master +git reset --hard HEAD~1 +echo "three" >> first.txt diff --git a/learning-git/exercices/ex4/win_create.bat b/learning-git/exercices/ex4/win_create.bat new file mode 100755 index 0000000000000000000000000000000000000000..62fe65f2a60328414f84283952c88025ca18af28 --- /dev/null +++ b/learning-git/exercices/ex4/win_create.bat @@ -0,0 +1,20 @@ +@echo off + +SET SOME_VAR="first.txt" +DEL /S "%SOME_VAR%" || echo "file not found" +CALL :_ex + +EXIT /B %ERRORLEVEL% + +:_ex +echo >first.txt +git add . +git commit -m "First commit" +echo "one">>first.txt +git commit -am "Added one" +echo "two">>first.txt +git commit -am "Added two" +git push -u origin master +git reset --hard HEAD~1 +echo "three">>first.txt +EXIT /B 0 diff --git a/learning-git/exercices/ex5/README.md b/learning-git/exercices/ex5/README.md new file mode 100644 index 0000000000000000000000000000000000000000..bfe91b9f5edd1d5bc9f0144fd249e9e5c8c12794 --- /dev/null +++ b/learning-git/exercices/ex5/README.md @@ -0,0 +1,57 @@ +## PART 1 + +You have worked hard and the result is beautiful. +But somehow there's a bug. + +It's late, your partner wants you to go home. + +Hell, maybe a good night sleep (or a good night something else) will help you find that stupid bug. + +So you want to go home, but you don't want to leave the work unsaved, that would be unprofessional. And you're a pro. + +So, as the code cannot be merged into master yet, you decide to create a branch. + +- create and checkout a new branch named "file-second" +- commit the current state +- push it (remember, the branch does not exists yet on origin) + +## PART 2 + +Your mind is clear and ready to tackle that nasty bug. +As you march to your desk like the conquerant you are, your boss stops you. + +There's an urgent fix that needs to go out in prod just right now. + +- checkout the branch master +- pull it to get the last version +- add a "three" to the file first.txt +- commit and push the changes to that new file + +## PART 3 + +Now is the time to tackle the problem, let's get back to your work. + +- checkout the branch file-second + + +## PART 4 + +Of couuuuurse ! +You found it, the 'E' is missing between 'D' and 'F' + +After fixing the bug, the awesomeness can be mnerged into master. + +- modify the file so that it's beauty is complete +- commit the difference +- push it +- merge it into master +- push master +- brag + + +## PART 5 + +You are a good citizen (or at least in this story we assume you are). +You are not working anymore on the branch file-second + +- delete the branch file-second both localy and in origin diff --git a/learning-git/exercices/ex5/linux_create.sh b/learning-git/exercices/ex5/linux_create.sh new file mode 100755 index 0000000000000000000000000000000000000000..bfbd71feba89b4759b3973e4711edbfb326cc1b6 --- /dev/null +++ b/learning-git/exercices/ex5/linux_create.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +rm -f first.txt second.txt 2> /dev/null + +touch first.txt +git add . +git commit -m "First commit" +echo "one" >> first.txt +git commit -am "Added one" +echo "two" >> first.txt +git commit -am "Added two" +git push -u origin master +git reset --hard HEAD~1 +echo "A B C D F G" >> second.txt diff --git a/learning-git/exercices/ex5/win_create.bat b/learning-git/exercices/ex5/win_create.bat new file mode 100755 index 0000000000000000000000000000000000000000..3f5b0315eccb53f470683c2dce92e140644e2b00 --- /dev/null +++ b/learning-git/exercices/ex5/win_create.bat @@ -0,0 +1,22 @@ +@echo off + +SET SOME_VAR="first.txt" +DEL /S "%SOME_VAR%" || echo "file not found" +SET SOME_VAR="second.txt" +DEL /S "%SOME_VAR%" || echo "file not found" +CALL :_ex + +EXIT /B %ERRORLEVEL% + +:_ex +echo >"first.txt" +git add . +git commit -m "First commit" +echo "one">>first.txt +git commit -am "Added one" +echo "two">>first.txt +git commit -am "Added two" +git push -u origin master +git reset --hard HEAD~1 +echo "A B C D F G">second.txt +EXIT /B 0 diff --git a/learning-git/project/linux/README.md b/learning-git/project/linux/README.md index d71890d94588b20115978b454c51b0563f91457a..166d61c96c8d6c677a1a25e8c75184a605ad703a 100644 --- a/learning-git/project/linux/README.md +++ b/learning-git/project/linux/README.md @@ -19,10 +19,10 @@ It is very simple, only consists in a couple of files written in bash and you wi In this tutorial you will learn how to make commits in the Git project, to create several branches, to push things to Gogs, and to follow a standard procedure to develop collaboratively. Afterwards, you should apply the same methods to any other collaborative development inside the ELIC department. The objectives will be achieved gradually following these topics: -1. [Set up your working environment](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/linux/working_environment) -2. [Prepare issues on Gogs](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/linux/gogs_issues) -3. [Prepare branches](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/linux/branches) -4. [Add new functions](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/linux/functions) -5. [Create pull request](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/linux/pull_request) -6. [Review and test others' branches](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/linux/review) -7. [Pull master changes](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/linux/pull_master) +1. [Set up your working environment](https://forge.uclouvain.be/elic/learning/-/tree/main/learning-git/project/linux/working_environment) +2. [Prepare issues on Gogs](https://forge.uclouvain.be/elic/learning/-/tree/main/learning-git/project/linux/gogs_issues) +3. [Prepare branches](https://forge.uclouvain.be/elic/learning/-/tree/main/learning-git/project/linux/branches) +4. [Add new functions](https://forge.uclouvain.be/elic/learning/-/tree/main/learning-git/project/linux/functions) +5. [Create pull request](https://forge.uclouvain.be/elic/learning/-/tree/main/learning-git/project/linux/pull_request) +6. [Review and test others' branches](https://forge.uclouvain.be/elic/learning/-/tree/main/learning-git/project/linux/review) +7. [Pull master changes](https://forge.uclouvain.be/elic/learning/-/tree/main/learning-git/project/linux/pull_master) diff --git a/learning-git/project/windows/README.md b/learning-git/project/windows/README.md index 5d31b7a01e2b67c11fe15c9c353a83b1df3d7c6d..e398206c9dc22ab6f132e7e19cfb49de56e8a5af 100644 --- a/learning-git/project/windows/README.md +++ b/learning-git/project/windows/README.md @@ -5,10 +5,10 @@ It is very simple, only consists in a HTML file and a CSS file and you will have In this tutorial you will learn how to make commits in the Git project, to create several branches, to push things to GitHub, and to follow a standard procedure to develop collaboratively. Afterwards, you should apply the same methods to any other collaborative development inside your department. The objectives will be achieved gradually following these topics: -1. [Set up your working environment](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/windows/working_environment) -2. [Prepare issues](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/windows/issues) -3. [Prepare branches](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/windows/branches) -4. [Add new content](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/windows/functions) -5. [Create pull request](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/windows/pull_request) -6. [Review and test others' branches](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/windows/review) -7. [Pull master changes](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/project/windows/pull_master) +1. [Set up your working environment](https://forge.uclouvain.be/elic/learning/-/tree/main/learning-git/project/windows/working_environment) +2. [Prepare issues on Gogs](https://forge.uclouvain.be/elic/learning/-/tree/main/learning-git/project/windows/gogs_issues) +3. [Prepare branches](https://forge.uclouvain.be/elic/learning/-/tree/main/learning-git/project/windows/branches) +4. [Add new functions](https://forge.uclouvain.be/elic/learning/-/tree/main/learning-git/project/windows/functions) +5. [Create pull request](https://forge.uclouvain.be/elic/learning/-/tree/main/learning-git/project/windows/pull_request) +6. [Review and test others' branches](https://forge.uclouvain.be/elic/learning/-/tree/main/learning-git/project/windows/review) +7. [Pull master changes](https://forge.uclouvain.be/elic/learning/-/tree/main/learning-git/project/windows/pull_master) diff --git a/learning-git/resources/README.md b/learning-git/resources/README.md index a1abb510accba6caed7f90ea8715b203ea959e96..a9ec3bb9401a94f553f255c44d483be13df5c5b8 100644 --- a/learning-git/resources/README.md +++ b/learning-git/resources/README.md @@ -15,7 +15,7 @@ Cloning into 'learning-git'... Username for 'https://forge.uclouvain.be': barriat Password for 'https://barriat@forge.uclouvain.be': remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password. See https://forge.uclouvain.be/help/topics/git/troubleshooting_git#error-on-git-fetch-http-basic-access-denied -fatal: Authentication failed for 'https://forge.uclouvain.be/barriat/learning-git.git/' +fatal: Authentication failed for 'https://forge.uclouvain.be/elic/learning.git/' ``` You must create and use a token: diff --git a/learning-git/resources/forge_token.md b/learning-git/resources/forge_token.md index f3988809d7fd6f407a353cbbd0036c0291426126..0085ef2021035fb8d1f7c6626426301ceb141239 100644 --- a/learning-git/resources/forge_token.md +++ b/learning-git/resources/forge_token.md @@ -7,13 +7,13 @@ Cloning into 'learning-git'... Username for 'https://forge.uclouvain.be': barriat Password for 'https://barriat@forge.uclouvain.be': remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password. See https://forge.uclouvain.be/help/topics/git/troubleshooting_git#error-on-git-fetch-http-basic-access-denied -fatal: Authentication failed for 'https://forge.uclouvain.be/barriat/learning-git.git/' +fatal: Authentication failed for 'https://forge.uclouvain.be/elic/learning.git/' ``` You must create and use a token. Instead of: ```bash -git clone https://forge.uclouvain.be/barriat/learning-gitlab.git +git clone https://forge.uclouvain.be/elic/learning.git Username for 'https://forge.uclouvain.be': <UCLouvain_username> Password for 'https://barriat@forge.uclouvain.be': <UCLouvain_password> ``` @@ -21,7 +21,7 @@ Password for 'https://barriat@forge.uclouvain.be': <UCLouvain_password> Use: ```bash -git clone https://forge.uclouvain.be/barriat/learning-gitlab.git +git clone https://forge.uclouvain.be/elic/learning.git Username for 'https://forge.uclouvain.be': <UCLouvain_username> Password for 'https://barriat@forge.uclouvain.be': <a_token> ``` @@ -32,7 +32,7 @@ So first, create a token for your repository. See the 4 steps below: ||| | -------- | -------- | -| | | -| | | +| | | +| | | Once done, you can now clone the repository (and pull/push in it) with your username and the "key token" instead of your account's password. \ No newline at end of file diff --git a/learning-git/slides/slides.md b/learning-git/slides/slides.md index c850ec1bc44fb18d323b924b8e195b182c5e428c..e648d514c98a0eaa544c0b3f79349aec4757b5b2 100644 --- a/learning-git/slides/slides.md +++ b/learning-git/slides/slides.md @@ -5,7 +5,7 @@ author: P.Y. Barriat #description: https://dev.to/nikolab/complete-list-of-github-markdown-emoji-markup-5aia backgroundImage: url('assets/back.png') _backgroundImage: url('assets/garde.png') -footer: 19/04/2024 | Version control with Git +footer: 20/05/2025 | Version control with Git _footer: "" paginate: true _paginate: false @@ -14,14 +14,12 @@ _paginate: false Version control with `git` for scientists <!--fit--> === -https://forge.uclouvain.be/barriat/learning-git +https://forge.uclouvain.be/elic/learning.git  **Pierre-Yves Barriat & François Massonnet** -ACELI Training Sessions `April 19th, 2024` - -###### some parts inspired on slides from CISM +ACELI Training Sessions `May 20th, 2025` --- @@ -219,7 +217,7 @@ To use `git` in VSCode, first make sure you have `git` [installed on your comput >create a local working copy of a remote repository ```bash -git clone https://forge.uclouvain.be/barriat/learning-git +git clone https://forge.uclouvain.be/elic/learning.git ``` **add** & **commit** @@ -309,9 +307,9 @@ git config --global core.editor "vim" git config --list ``` -Now, clone https://forge.uclouvain.be/barriat/learning-git +Now, clone https://forge.uclouvain.be/elic/learning.git > Theses are very simple exercices to learn to manipulate git. -> In each folder, simply run `./create.sh` and follow the guide :sunglasses: +> In each folder, simply run `./create.sh` in `learning-git` folder, and follow the guide :sunglasses: --- diff --git a/learning-git/slides/slides_git.pdf b/learning-git/slides/slides_git.pdf index 193a16143166a9044d2435e2beb339b856150e1c..afbe8d6fa5386d8c7611c81148ff785f3488497c 100644 Binary files a/learning-git/slides/slides_git.pdf and b/learning-git/slides/slides_git.pdf differ