Git version management

After the introduction to Git in the previous section, for programmers with a little basic knowledge, the following concepts and knowledge will be learned very quickly. Basically, they are used while learning. difficult.

After making changes to the readme.txt file. We can use git diff to see exactly what changes we have made.

 

We can use the git status command to view the status of three situations in the current workspace .

1. After modifying the file, before git add. At this time, the prompt file has been modified, but it has not been cached.

2. After git add file, before git commit. At this time, it is prompted to modify and prepare to submit, and the modified file has readme.txt.

3. After git commit. At this time, it prompts that the working directory is clean, and no changes need to be submitted.

version rollback

We are making a modification to readme.txt. change to

it is a distributed version control system.
Git is free software distributed under the GPL.

  If after many modifications, we forget what has been modified, then we will use git log to print the historical submission records. The number following the commit is the commit ID , which is a string of numbers generated by the SHA1 algorithm, which can ensure that each commit is different for everyone.

  In Git, use HEADindicates the current version, the previous version is HEAD^, the previous version is HEAD^^, of course, the previous 100 versions can be abbreviated as HEAD~100.

  fallback command

git reset --hard HEAD^

git reset --hard 75d7ff (at least 6-digit commit ID)

git reflog When you want to switch from an old version to a new version, but you don't know the version number, you can use this command to view it.

Concepts of Repository, Workspace and Staging Area

The working directory has a hidden folder .git , which is the repository.

When we modify the files in the directory, the state after git add is the state of the temporary storage area, and git commit is used to submit multiple git add operations at one time.

Undo changes

There are three cases:

1. The modified file is not added to the temporary storage area.

git check -- file  command is --very important, no --, it becomes a "switch to another branch" command

  

**Add to the temporary storage area, and then modify it, execute this command, it will return to the state before the addition.

2. After modifying the file, add it to the temporary storage area.

git reset HEAD file falls  back to before adding a staging area

3. Modify and submit

git reset --hard version rollback command

Delete Files

Git rm is opposite to the effect of git add. One is to enter the temporary storage area after adding, and the other is to enter the temporary storage area after deletion.

Command summary

The git diff command can view the modified content.

The git status command allows us to keep track of the current status of the repository.

git log command to view the historical commit log.

git reflog command to view all records, including deletion or rollback

git reset --hard version number rollback command

The git rm command deletes files. The file will be deleted in the workspace.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325692582&siteId=291194637