Git for Windows
Install
Install Git for Windows on Windows 10 Pro and manage version control with Git Bash. It is assumed that the compilation and execution will be done on Ubuntu 18.04 LTS on WSL on Windows 10 Pro. Therefore, the linefeed code should always be in Linux format. This linefeed code stuff is a trap for beginners, so be careful.
Download Git for Windows from here and start installation by double-clicking. Basically, the default is OK, but in the question about line endings appearing nearly at the end (Configuring line ending conversions), click the third option below. This allows you to work while always maintaining the Linux linefeed code.
Checkout as-is, commit as-isGit for Windows can be updated in Git Bash as follows. If a new version is available, you will be asked like Download and install Git for Windows 2.27.0 [N/y]?; type y. The download will start and will be installed automatically.
$ git update-git-for-windowsDisplay file names in Japanese
Follow the steps below to prevent garbled Japanese file names when using ls. If there are no files having Japanese characters, skip the following.
Open the registry editor with regedit and change the value of FaceName in Git Bash of Console of HKEY_CURRENT_USER to "*MS Gothic".
In the home directory of Git Bash (usually /c/Users/your_name/), Create .bashrc containing the following and restart Git Bash.
$ alias ls='ls --show-control-chars'Initial setting
When you use Git Bash for the first time, do the following only once. The first is the setting of the editor, which is optional, but if you set a familiar one, it will be easier to enter a comment when committing.
git config --global core.editor "'/C/Program Files/Hidemaru/Hidemaru.exe' //fu8"
git config --global user.name "Jun Sasaki"
git config --global user.email "your@email.com"
git config --global core.quotepath falseGit clone from remote repository
In an appropriate directory, copy the address of Clone with SSH in a remote repository and execute as follows.
$ git clone git@gitlab.com:usename/project.gitproject directory will be created under the current directory and copied into it.
Create a new local repository
To create a repository for the first time in a local repository instead of cloning it from a remote repository, after moving to the directory where you want to manage version control, execute the following:
$ git init.git directory (hidden directory) is created; configuration files and repository data are stored.
Register files in local repository
Register the files you want to manage in various ways.
Register all files with extension of F, including those in sub directories
$ git add *.FFile of makefile in subdirectory BIO_source is indexed
$ git add BIO_source/makefileIndex all files, including those in subdirectories
$ git add -ARemove file from version control (file itself remains)
$ git rm --cached test.FCheck the status of index registration
$ git status Add -s option for shortened display 
$ git status -sCommit to local repository
An editor will open, so enter a comment.
$ git commitUncommit
It is a method of canceling the commit or returning the repository to the specified previous commit due to missing file registration.
Restore the last commit
If you just want to cancel the commit and continue working, do the following.
$ git reset --soft HEAD^--soft can be omitted. If you switch --soft to --hard, the index working tree will also revert to the previous commit. That is, the work just before the present commit will be lost; the state immediately after the previous commit will be restored.
Check history of past commits
Check the commit status with git reflog.
$ git reflogReturn to a specified commit status
Use git reflog to figure out the commit number such as HEAD@{2} of the commit you want to restore; do the following. If you specify --hard, the index working tree will be completely restored to the state at the previous commit.
$ git reset --hard HEAD@{2}Display repository file list
git ls-filesIndex and commit all changes to files under version control
There is no new addition or deletion of files, only changes of files are targeted.
$ git add -u
$ git commitNext is the same as above.
$ git commit -aReflect to remote repository (push)
The contents such as changes in the local repository are reflected in the remote repository.
$ git pushDisplay change history
$ git logTag with ### v1.0
$ git tag v1.0List tags
$ git tagRemove v1.0 tag
$ git tag -d v1.0Check out tag v1.0
If option -f is added, it will be forcibly switched even during work.
$ git checkout [-f] v1.0Branch operations
Create a new devel branch
Create and switch it to the current branch.
$ git checkout -b develList branches
Add -a to display including remote repositories. The current branch will be marked with *.
$ git branch [-a]Switch to existing devel branch
$ git checkout develSwitch to master branch
$ git checkout masterDisplay branch information
Append -a to display all pieces of branch information.
$ git show-branch [-a]Remove branch devel
$ git branch -d devel

