How should I teach how to use the version control system 'Git'?



Git is a version control tool developed by Linux creator Linus Torvalds and is the most famous version management system in the world. However, some of Git's ideas are obscure for someone who uses it for the first time. Engineer Rachel M. Carmena gathered the basic concept of Git using diagrams.

How to teach Git | Rachel M. Carmena
https://rachelcarmena.github.io/2018/12/12/how-to-teach-git.html

It seems that Mr. Karmen wanted to write commentary that it was triggered that a post - it like the image below was pasted on the monitor of a colleague who started using Git. Post-it has "add", "commit" and "push" commands, but the colleague does not understand the reasons of the three steps and says something has happened.


In writing commentary, Mr. Carmena focuses on teaching vocabulary (daughter). Because it is impossible to understand the meaning of messages displayed in Git unless you know the words used in Git. Mr. Carmena says that it is a good practice to use diagrams to learn such words.

Well, Git has four areas. Three areas, "working directory", "staging area" and "local repository" that exist on your PC, and "remote repository" of servers that exist over the network.



Using the command " git clone <url> " will copy the data from the remote repository to the local repository and working directory.



Files in the working directory are divided into two types. It is " tracked " that Git recognizes existence and " untracked " which is not recognized. For example, a newly created file becomes untracked.



After finishing work on what you want to change in your working directory, next we add the modified file to the staging area using the " add " command. You can then use the " commit " command to create a commit based on the file in the staging area and add the created commit to the local repository. Use the " push " command to send commits made to the local repository to the remote repository.



There is a command called " diff " that allows you to see the file changes, but if you use this command with no options or arguments like " git diff " you will see the changes in the working directory. If you add the --staged option like ' git diff --staged ' you can display the changes in the staging area and if you like ' git diff <commit hash> ' then it will be in the commit and working directory of the local repository You can display different parts.



There are two commands for updating the local environment, " fetch " and " pull ". With the fetch command you can copy the data from the remote repository to the local repository.



In addition to the other one of the "pull" the operation of the fetch, the data of the remote repository to the working directory merge to.



When merge is done, the merge commit log remains, but if you do not want to contaminate the commit log, you can do rebase instead of merge if you say " git pull --rebase ".



Although he seems to have used various version control systems, Mr. Carmena commented that "lack of knowledge is not good on any system, we should also emphasize not only tool selection but also how to use tools" .

in Software, Posted by log1d_ts