Home Computing Basic usage of Git for Windows

Basic usage of Git for Windows

by Yasir Aslam
0 comment

Explains how to use the distributed version control system ” Git for windows “. I will explain the minimum necessary settings for using “Git” locally and the basic usage of “Git Bash”. If you haven’t installed “Git” yet, please install it by referring to the related article below.

Related document: How to install Git on Windows
Related document: How to use Git ~ Creating and committing repository ~
1 Related document: How to use Git ~ How to record changes in repository ~

table of contents

1. Initial setting of “Git”

1.1. Check the version of Git installed with
“Git Bash” 1.2. Check the command list with
“Git Bash” 1.3. Set the user name and email address with
“Git Bash” 1.4. Set with “Git Bash” checking the content

2. Basic command usage

2.1. Create a folder at the “Git Bash” command prompt
2.2. Create a file at the “Git Bash” command prompt

1. Initial setting of “Git”

1.1. Check the version of Git installed with “Git Bash”

First, let’s check if the installed “Git for Windows” is installed correctly. As for the environment of this column, “Git for Windows 2.11.1” is installed on Windows 10 (64bit).

From the Windows Start menu, select [All apps] → [Git] → [Git Bash] .

● [Git Bash]

Git’s “Bash Console” will be launched. In “Bash”, various operations are performed on a command basis. Enter the command after the dollar mark ” $ ” at the command prompt.

● Git Bash console

Basic usage of Git for Windows Freelance engineer project information | Professional engineer git2-2

The command to check the installed Git version is

git –version

is. Type at the Git Bash command prompt and press Enter. If “git version 2.11.1.windows.1” is displayed after the command, it is proof that the installation was successful.

● Check the version of Git

Basic usage of Git for Windows Freelance engineer project information | Professional engineer

1.2. Check the command list with “Git Bash”

You can check the command list of ” Git Bash ” in the help of “Git”.

git –help

A list of commands will appear, so please refer to it. In addition to Git-specific commands, there are also Linux-based commands used in “Git”. In the next chapter, we will create folders and files so that you can get used to using commands, so please learn how to use commands little by little.

● Check Git help

Basic usage of Git for Windows Freelance engineer project information | Professional engineer

1.3. Set your username and email address in Git Bash

Next, let’s set the “user name” and “email address” used in “Git”.

Of the command to set the user name

git config –globaluser.name “Taro Yamada”

And the command to set the email address

git config –globaluser.email [email protected]

At the prompt and press the “Enter” key. Please replace the user name “Taro Yamada” and the email address ” [email protected] ” with your own.

● Username and email address settings

Basic usage of Git for Windows Freelance engineer project information | Professional engineer git2-5

1.4. Check the settings in “Git Bash”

Let’s check the “user name” and “email address” set earlier with the command to check the “Git” settings.

git config –list

● Check settings (git config)

Basic usage of Git for Windows Freelance engineer project information | Professional engineer git2-6

You can confirm that the user name and e-mail address set by the command are registered in “user.name” and “user.email”.

You can also check the values ​​set in ” git config ” individually.
When checking only the user name

git config user.name

mail address is,

git config user.email

When you type and press the “Enter” key, the value set under the command is displayed.

● Confirmation of individual settings “git config”

Basic usage of Git for Windows Freelance engineer project information | Professional engineer git2-12

2. Basic command usage

2.1. Create a folder at the “Git Bash” command prompt

Create a folder in Git Bash . The home directory when “Git Bash” is started is “C: \ Users \ UserName “. “User Name” is the folder of the login account name. Let’s create a new folder in the “Documents” folder inside the “User Name” folder.

First, use the folder move command ” cd (change directory) “. At the command prompt of “Git Bash”

cd Documents

Enter.

● Move folders

Basic usage of Git for Windows Freelance engineer project information | Professional engineer

Now that you’ve moved to the “Documents” folder inside your user folder, run the command to create a “Git-ws” folder. The command to create a folder is ” mkdir (make directory) “. At the command prompt,

$ mkdir Git-wss

Enter.

● Creating a folder

Basic usage of Git for Windows Freelance engineer project information | Professional engineer git2-8

2.2. Create a file at the “Git Bash” command prompt

Go to the created “Git-ws” folder and create a “git-sample.txt” file. If you move to the Git-ws folder with “cd Git -ws” and look at the information in the folder with the ” ls (list segments) ” command, nothing will be displayed because it is a newly created folder. The current folder is displayed in the prompt part starting with “~”, so if you typed the command to move the folder but you do not know which folder it is in, check the yellow letters. Since “~” is the home directory, the current folder display is “~ / Documents / Git-ws”.

● Move files

Basic usage of Git for Windows Freelance engineer project information | Professional engineer git2-9

Use the ” touch ” command to create a new file . The “touch” command is a command to change the time stamp of a file, but if the file specified by the argument does not exist, a new file is created. At the command prompt

touch git-sample.txt

And press the “Enter” key. If you look at the information in the folder again using the “ls” command, you will see “git-sample.txt” following the command.

● Create a new file (git-sample.txt)

Basic usage of Git for Windows Freelance engineer project information | Professional engineer git2-11

If you actually check the folder hierarchy of Windows, you can see that a new file “git-sample.txt” has been created in the “C: \ Users \ UserName \ Documents \ Git-ws” folder.

● Create a new file (git-sample.txt)

You may also like

Leave a Comment