Browse Source

Try to convert bash to batch

Pierre-Yves Barriat 2 years ago
parent
commit
ec9e48debd

+ 7 - 10
exercices/README.md

@@ -3,17 +3,14 @@ Simple Git Exercices
 
 Theses are very simple exercices to learn to manipulate git.
 
-These are not even real exercices, more like DIY guides to learn to handle
-very common situations.
+These are not even real exercices, more like **DIY** guides to learn to handle very common situations.
 
-In each folder, simply run ./create.sh and follow the guide ;)
+In each folder, simply :
+- run `./create.sh` for Linux
+- double click on `create.bat` for Windows
 
-*The create script in each folder will completely reset the exercice.*  
-If you want to re-read the instructions of the exercice, just cat
-the file readme.txt.
+and follow the guide :wink:
 
------
+> The create script in each folder will completely reset the exercice.
 
-If you enjoyed those exercices, I strongly encourage you to look further
-into Git as those are very simple situations and there are loads of
-tips and tricks that these exercices do not cover.
+> If you want to re-read the instructions of the exercice, just cat the file README.md.

+ 34 - 0
exercices/_generic_create.bat

@@ -0,0 +1,34 @@
+@echo off
+call:%~1
+goto exit
+
+:_create
+  echo "Removing exercice"
+  DEL /S "repo" "work"
+  echo "creating directories"
+  mkdir "-p" "repo" "work"
+  echo "initializing repository"
+  cd "repo"
+  git "init" "--bare" REM UNKNOWN: {"type":"Redirect","op":{"text":">","type":"great"},"file":{"text":"/dev/null","type":"Word"}}
+  cd "%CD%."
+  echo "cloning repository"
+  cd "work"
+  git "clone" "%CD%.\repo" "%CD%" REM UNKNOWN: {"type":"Redirect","op":{"text":">","type":"great"},"file":{"text":"/dev/null","type":"Word"}} REM UNKNOWN: {"type":"Redirect","op":{"text":">&","type":"greatand"},"file":{"text":"1","type":"Word"},"numberIo":{"text":"2","type":"io_number"}}
+  echo "Initializing exercice"
+  IF "%~2" == "debug" (
+    $1
+  ) ELSE (
+    $1 REM UNKNOWN: {"type":"Redirect","op":{"text":">","type":"great"},"file":{"text":"/dev/null","type":"Word"}} REM UNKNOWN: {"type":"Redirect","op":{"text":">&","type":"greatand"},"file":{"text":"1","type":"Word"},"numberIo":{"text":"2","type":"io_number"}}
+  )
+  cd "%CD%."
+  echo ""
+  echo "Exercice in %undefined%\work\"
+  echo "=========================================="
+  cat "readme.txt"
+  echo "=========================================="
+  echo ""
+goto:eof
+
+:exit
+exit /b 0
+

+ 7 - 6
exercices/ex.1/README.md

@@ -1,8 +1,9 @@
-You have accidentaly put first.txt in the staging area
-While you actually want to only commit second.txt.
+You have accidentaly put `first.txt` in the **staging area**
 
-You need to, from the current state, only commit second.txt.
+While you actually want to only commit `second.txt`.
 
-- Remove the file second.txt (Use `git status` to get the appropriate command`)
-- Add first.txt
-- Commit
+You need to, from the current state, only commit `second.txt`.
+
+- remove the file `second.txt` (Use `git status` to get the appropriate command)
+- add `first.txt`
+- commit

+ 9 - 0
exercices/ex.1/create.bat

@@ -0,0 +1,9 @@
+@echo off
+
+:_ex
+    echo "un" REM UNKNOWN: {"type":"Redirect","op":{"text":">","type":"great"},"file":{"text":"first.txt","type":"Word"}}
+    echo "deux" REM UNKNOWN: {"type":"Redirect","op":{"text":">","type":"great"},"file":{"text":"second.txt","type":"Word"}}
+    git "add" "first.txt"
+exit /b
+
+call _generic_create.bat _create _ex

+ 0 - 1
exercices/ex.1/create.sh

@@ -10,4 +10,3 @@ function _ex() {
 }
 
 _create _ex
-

+ 18 - 23
project/windows/working_environment/README.md

@@ -21,23 +21,17 @@ After completing this step you will need to ask access to the repositories you w
 
 To start working you need to create a clone, called afterward “working copy” of the git_tutorial project from Github in your home (or folder of your choice):
 
-For instance, paste the URL into TortoiseGit and it will clone the repo locally on your computer:
+For instance, paste the URL into git-GUI and it will clone the repo locally on your computer:
 
 ![git_gui.png](../../../resources/img/git_gui.png)
 
-It will ask for your username and password and you will see output like this:
-
-![7.png](../../../resources/img/7.png)
-
-It has created a 'Git_Training' folder and you can browse into it:
-
-![8.png](../../../resources/img/8.png)
+It created a 'Git_Training' folder and you can browse into it.
 
 Git clone allows you to specify parameters such as the target folder. If you don't specify it the working copy will be named as the project.
 
 Hidden inside a 'working copy' resulting from a git clone there is a special '.git' directory that contains internal objects needed by git.
 
-```
+```bash
 branches  description  hooks  info  objects      refs
 config    HEAD         index  logs  packed-refs
 ```
@@ -46,20 +40,21 @@ It is hidden because you are not supposed to worry at all of internals of '.git'
 
 When you are in a working copy you can use regular windows operations such as create file/folder, copy/paste, etc. Additionally you can use whatever git commands.
 
-#### git status
+### git status
 
 The outputs tells you in what branch you are on. By default (if you have not specified in the clone) it clones the master branch.
 
+```bash
 On branch master
 Your branch is up-to-date with 'origin/master'.
 nothing to commit, working directory clean
+```
 
-Git status is very important. It's recommendable to use it every now and then to know the status of your branch.
+`git status` is very important. It's recommendable to use it every now and then to know the status of your branch.
 
-Moreover you can check the history of changes by using git log command:
-git log
+Moreover you can check the history of changes by using `git log` command.
 
-#### git log
+### git log
 
 The outputs is a list of what has been changed recently, in reverse chronological order. It tells the author of the change, when it was made and the log message given.
 
@@ -79,36 +74,36 @@ Date:   Thu Dec 3 19:04:16 2015 +0100
 
 ## Exercise 3 – Basics operation
 
-#### Make some changes new-file.txt
+### Make some changes new-file.txt
 
-![9.png](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/raw/master/resources/9.png)
+![9.png](../../../resources/img/9.png)
 
-#### Commit your local changes to your local repository
+### Commit your local changes to your local repository
 
-Click with the right mouse button and click on “Git Commit”
+Click with the right mouse button and click on **Git Commit**
 
-![10.png](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/raw/master/resources/10.png)
+![10.png](../../../resources/img/10.png)
 
 You should see the following window:
 
-![11.png](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/raw/master/resources/11.png)
+![11.png](../../../resources/img/11.png)
 
 In the message section, write a short summary of your commit. It is good practice to always have meaningful messages. Do not forget to add your files in the bottom part of the window. 
 
 When you are done with these steps, you can click on `[Commit]` and you should see the following window:
 
-![12.png](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/raw/master/resources/12.png)
+![12.png](../../../resources/img/12.png)
 
 In this window, you can see how many files were changed and how many insertions and/or deletions were made. If you are satisfied with the information just click on `[Push]`.
 
 #### Push your changes to the remote repository in GitHub
 
-![13.png](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/raw/master/resources/13.png)
+![13.png](../../../resources/img/13.png)
 
 In this window, you can manage to which branch you are pushing your files, but we will talk about branches later in the exercise. For now, just click on `[OK]` and your file will be pushed to the master branch.
 
 #### Check whether your changes are online
 
-Open your GitHub repository in your browser and click on new-file.txt. In there you should see the content, which you have written. 
+Open your GitHub repository in your browser and click on new-file.txt. In there you should see the content, which you have written.
 
 You can see the commit message is written in the second column of the commit you have made. You can use this column to get more information about which files were changed and what has been changed. That’s why it’s always good practice to write meaningful commit messages.