use the command window x64 git finishing 1. Basic Operation

git installed on the windows did not say, download the installation package no brain the next point on the line.

In the Start Menu -> Git -> Git Bash open end of a similar linux

EDITORIAL: command preceded by a $ symbol is linux terminal prompt, enter the command when not actually enter the $ symbol, some do not understand linux prevent the white bar =, =

A: User Configuration

1. Configure Username: git config --global user.name "your username"

$ git config --global user.name "gsp1004"

2. Configure your registered email: git config --global user.email "your registered email"

$ git config  --global user.email "[email protected]"

 

II: New Warehouse

1. Where appropriate, create a new folder

For example, I created a directory is: / c / Users / gsp / Desktop / git / git-test

2. Go to the directory above

$ cd /c/Users/gsp/Desktop/git/git-test

3. The directory to warehouse

$ git init
Initialized empty Git repository in C:/Users/gsp/Desktop/git/git-test/.git/

This time will generate a hidden .git directory in the directory, do not move to this directory

 

Three: to add files to the repository

The following case study examples to test.txt

1. Create an empty file test.txt in the repository directory, you can use the windows right, the new, you can use the following command linux (if it is already written other documents, you can drag the warehouse in a folder)

$ touch test.txt

This process can be understood as the test.txt file on the door of the warehouse, but you have not told administrator warehouse say you want to save the file. The following step is to tell the warehouse manager, let him give you the file management

2. add this file to the repository to manage

$ git add test.txt

3. Modify the formal submission, and add comments, you join / delete / modify a file in the end is what has been done, write some description so look after themselves and others when easy to understand ah

$ Git commit -m "test how to use git add files to the repository"
[Master (root-the commit) efc5b66] test how to use git add files to the repository
1 File changed, 1 Insertion (+)
the Create the MODE 100644 test.txt

 

Four: Modify test.txt, submitted revised test.txt

1. Use the command to view the current status of warehouse

$ git status
On branch master
nothing to commit, working tree clean

Displays the current status is: on the trunk. No need to submit, clean and working tree

 

2. Modify test.txt, add the current time to the end of the file

$ date >> test.txt

 

3. Check warehouse status again

$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: test.txt

no changes added to commit (use "git add" and/or "git commit -a")

google translation as follows:

Uncommitted changes changed:
(use "git add <file> ..." to update the content to be submitted)
(use "git checkout - <file> ... " to discard changes in working directory)

Modify: test.txt

No changes added to commit (use "git add" and / or "git commit -a")

 

At this point let us git test.txt file has been modified.

 

4. Check what specific changes the write (but generally not used, modify the code so much, to see where this modification is to be mad)

$ git diff
warning: LF will be replaced by CRLF in test.txt.
The file will have its original line endings in your working directory
diff --git a/test.txt b/test.txt
index eb03bc8..6ea9bb8 100644
--- a/test.txt
+++ b/test.txt
@@ -1 +1,2 @@
2019年05月31日 15:47:12
+2019年05月31日 16:03:26

 

We can see from the above information, the modified content is increased, "May 31, 2019 16:03:26" line (front + represents an increase of this line)

 

5. The re-added to the above-described modifications to the warehouse

Above the warehouse manager is not found test.txt file and yet not the same as before, this time you have to tell him, said: Brother, all right, this is my modified file, I just want him to change in this way, after this file contents inside is like that.

$ git add test.txt
warning: LF will be replaced by CRLF in test.txt.
The file will have its original line endings in your working directory

6. formal resubmission
$ git commit -m "The Second Amendment"
[Master a0752b8] The Second Amendment
1 file changed, 1 insertion (+ )

 

7. Check warehouse status again

 $ git status

On branch master
nothing to commit, working tree clean

 

8. View commit log:

$ git log
commit a0752b8d68d68076ed17a6c636ac225bbbe52014 (HEAD -> master)
Author: gsp1004 <[email protected]>
Date: Fri May 31 16:20:14 2019 +0800

The Second Amendment

commit efc5b6658e24e783858c75fa3f1d429e8dda9acf
Author: gsp1004 <[email protected]>
Date: Fri May 31 15:53:53 2019 +0800

How to test using git add files to the repository

 

 

Line display

Git log --pretty = oneline $
a0752b8d68d68076ed17a6c636ac225bbbe52014 (the HEAD -> Master) second revision
efc5b6658e24e783858c75fa3f1d429e8dda9acf testing how to use git add files to the repository

 

Five: version rollback

1. fall back to the previous version:

Git the RESET --hard the HEAD ^ $
the HEAD IS AT now how efc5b66 tests using git add files to the repository

 

2. fall back to the previous version:

$ git reset --hard HEAD^^

or

$ git reset --hard HEAD-2


3. fallback specified version

git reset --hard version number (version number is git log --pretty = oneline front of that long string of numbers)

For example: I want to become a "second revision" code:

Git the RESET --hard a0752b8d68d68076ed17a6c636ac225bbbe52014 $
the HEAD IS AT a0752b8 now the second revision

 

Six: Check every version modify records

$ Git The reflog is
a0752b8 (the HEAD -> Master) the HEAD @ {0}: RESET: Moving to a0752b8d68d68076ed17a6c636ac225bbbe52014
efc5b66 the HEAD @ {. 1}: RESET: Moving to the HEAD ^
a0752b8 (the HEAD -> Master) the HEAD @ {2}: the commit: first secondary modify
efc5b66 HEAD @ {3}: commit (initial): test how to use git add files to the repository

 

Seven: checkout

  To be continued. . .

Guess you like

Origin www.cnblogs.com/gsp1004/p/10957328.html