Git installation and use under windows10

0 Introduction

Git (pronounced / gɪt /) is a distributed version control system open source, can efficiently at high speed process from small to very large version of the project management. Git is Linus Torvalds To help manage Linux kernel development and the development of an open source version control software.
Git Quick Start

1 Git download and install

Git windows system's Download
My system is 64-bit, 64-bit version so I chose
Here Insert Picture Description
to download the installation package Git click to start the installation.
Here Insert Picture Description
Here Insert Picture Description

Select the default editor, I downloaded notepad ++ on a computer, so I chose notepad ++.

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
This interface is the end of the line disposed symbol conversion.

The first option is the "end of the line to check out Windows-style, submit Unix-style." When you check out a text file, Git will convert LF to CRLF. When submitting a text file, CRLF is converted to LF. For cross-platform project, which is the recommended setting on Windows ( "core.autocrlf" is set to "true")

The second option is the "end of the line as it is checked out, submitted Unix style." When you check out a text file, Git does not perform any conversion. When submitting a text file, CRLF is converted to LF. For cross-platform project, which is the recommended setting on Unix ( "core.autocrlf" is set to "input")

The third option is "as is checked out, as is submitted." When you check out, or submit a text file, Git does not perform any conversion. Cross-platform project does not recommend this option is selected ( "core.autocrlf" is set to "false")

I choose the first option and click "Next" button to continue under the map interface:
Here Insert Picture Description
The interface is configured with Git Bash terminal emulator to be used together.

The first option is "using MinTTY (MSYS2 default terminal)." Git Bash MinTTY as using a terminal emulator, the emulator has a resizable window, select and non-rectangular Unicode font. Windows console application (such as an interactive Python) must be run in MinTTY by "winpty" to start.

The second option is "Use the default Windows console window." Git will use the default Windows console window ( "cmd.exe"), this window can be used with Win32 console program (such as interactive Python or node.js), but the default rollback is very limited, need to be configured to use unicode font to display the correct non-ASCII characters, and before Windows 10, its window can not be resized freely, and only allows text selection rectangle.

I chose the second option and click "Next" button to continue under the map interface:
Here Insert Picture Description
Here Insert Picture Description
to complete the installation

2 verify the installation

Enter in cmd git --versiondisplays the version number.
Here Insert Picture Description

Based on the use of 3 Git

Find the git-bash in the application inside the lower left corner of the
Here Insert Picture Description
familiar command line will appear.
Email configure your own name and in the Git-Bash:
git config --global user.name "your name"
git config --global user.email "[email protected]"

Warehouse: repository (the English word, no other meaning)
create a repository: mkdir fengshao
Change directory: cd
back one directory: cd ...
View repository path: pwd
will become git directory can manage repository: git init
to view hidden files directory : ls -ah
Here Insert Picture Description
you can download a notepad ++ editor, compiler inside a first1.txt,

Before you put into the establishment of a warehouse.
Here Insert Picture Description
Re-use git add first1.txt add files to the repository, "submission" using git commit -m file
into the repository. (Submissions can also write content, easy to find later)
when you change the contents of the file, the file is added to the inside:
view the current status: git status (described here first1.txt been modified)
Here Insert Picture Description
to view the contents Last modified: git diff first1.txt (modified but not submitted to the git to view, otherwise no show)
Here Insert Picture Description
Here Insert Picture Description
again introduce git log, use this command to display the furthest from the most recent commit log to.
Here Insert Picture Description
If you feel that the above information is too much, it can also reduce the amount of information, git log --pretty = this command oneline,

It will reduce the amount of information that appears.

Suppose you want to return to the previous version, then we can enter git reset --hard HEAD ^, if you think of the previous version, it

You can enter the RESET --hard HEAD ^ git , meaning that you want to return to that version, you can add a few behind HEAD on the line.

You can also use cat first1.txt to see you to view the contents of the current version. Of course, your editor will change the contents inside.
Here Insert Picture Description
Here Insert Picture Description
Time could turn the clock back, then you can return to the real world. But only if you want to keep in mind before you commit. Then use

git reset --hard commit can return to reality. (Commit just a bunch of numbers, just as the house number).
Here Insert Picture Description
When forgot to commit Would not it be never returned to reality. No, no, the method can still find, as long as you remember

git reflog command on the line, is used to view the command history.
Here Insert Picture Description
Work area and staging area the two are very different, when you see this step, when everyone understands editor, the so-called editor

Is the work area, staging area below the stage is this picture, it is through git add content into the workspace stage, as

At this time if you have to modify the contents of the work area, but did not git add to the staging area, and then you git commit to commit up content

You will be stored in a temporary area of ​​content, rather than the content of your changes. If you do not believe it, you can follow to do experiments.

Finally, git diff HEAD by - submitted to the editor git content and the content of the difference between "file" to view the current.
Here Insert Picture Description
Here Insert Picture Description
If at the time of writing files to a higher level, there will inevitably wrong place, wrong is not terrible, and it's just not submitted can be withdrawn,

When you're wrong in the workspace, you can use git checkout - "file" to withdraw to the place last saved. If you

When you add files to the staging area, it would have to first return the file to a workspace, use git reset HEAD "file" command,

Be withdrawn in the work area.
Here Insert Picture Description
Files can also be deleted using the command rm "file", you can delete the file file, whether or submitted up in a temporary area

The can be used, including the work area, you can delete the file. There will have to delete the natural recovery, but the recovery this experiment I

Try several times, in addition to the work area, the other can, command git checkout - "file". After much practice, but occasionally

In the work area are successful, there is no reason to find out, when the probability is minimal.
Here Insert Picture Description

Published 21 original articles · won praise 1 · views 1105

Guess you like

Origin blog.csdn.net/Elenstone/article/details/105313782