Local operation of git!

1.1 Local operation

1.1.1       git status

 

1.1.2       git add

 

1.1.3       git commit

                       

1.1.4 Ignore files

Create a hidden file .gitignore in the workspace, write the name of the file to be ignored by git to the file, and then submit .gitignore to the repository.

1.1.5 View the difference

(1) Compare the workspace and the staging area git diff

 

(2) Compare the staging area with the local library git diff --cached

 

1.1.6 Undo changes

(1) Modify git checkout only in the workspace --

If the content of a file has only been modified in the workspace without adding, the modified content can be undone by this command.

(2) git reset HEAD has been modified in the staging area

If the modified content of a file has been added to the temporary storage area, you can use this command to undo the modification in the temporary storage area.

 

1.2 Fall back to previous version

1.2.1 View historical version git log

(1) Basic commands

(2)   git log --pretty=oneline

Display commits and logs in one line, but commit-id in long format.

(3)   git log --pretty=oneline --abbrev-commit

The commit-id is displayed in short format.

(4) Page turning and exit

l Enter: Display one line at a time

l Space: turn pages

l q key: quit command

1.2.2 HEAD pointer

HEAD: Points to the current version.

HEAD^: Points to the previous version of the current version.

HEAD^^: Points to the first two versions of the current version.

HEAD^^^: Points to the first third version of the current version.

……

HEAD^~20: Points to the first 20th version of the current version.

 

1.2.3 View citable historical versions gitreflog

1.2.4 version rollback

                     When the file is submitted to the branch area, there is no way to not be recorded and modified, but you can also return to the unmodified version according to the git log view ID, which is called "rollback version" operation, but even if you roll back to the previous version , the branch area also has some records.

(1) git reset --soft (soft rollback)

The contents of the branch area are rolled back, but the contents of the staging area and the work area are not rolled back.

(2) git reset --mixed (mixed rollback)

The contents of the branch area and the staging area are rolled back, but the contents of the work area are not rolled back.

--mixed is the default option, which can be omitted.

(3) git reset --hard (hard rollback)

The contents of the branch area, temporary storage area and work area are all rolled back.

1.1 Delete files


1.1.1 Setting up the environment

1.1.2 View the staging area file list gitls-files

View the staging area file list only.

1.1.3 View the sum of the "temporary and this" file list git ls-files--with-tree=HEAD

View the sum of the staging area and the branch area file list, not just the branch area file list.

1.1.4 Delete only the specified file in the staging area gitrm --cached

1.1.5 Restore deleted files git resetHEAD <file>

1.1.6 Completely remove git rm

The specified files in the work area and the staging area are deleted, but the files in the branch area are not deleted.

1.1.7 Recover deleted files

1.2 Branch management

1.2.1 Git branch theory

(1) Git trunk

(2) Git branch

(3) Branch merge

(4) Deletion after merger

1.2.2 Basic branch operations

(1) Create and switch branches git checkout -b <branch>

git chechout --bdev is equivalent to a combination of the following two commands:

git branchdev // create dev branch

git checkoutdev // switch to the dev branch

(2) View the system branch git branch

(3) Switch branch git checkout <branch>

(4) Delete branch git branch –d <branch>

(5) Merge branch git merge <branch>

                

              For files created under the Dev branch, the master branch cannot check the files before committing;

             If you want to merge, you must be under the master branch to merge dev and master; if under the deve branch, merge the debug and Dev branches intelligently;


Guess you like

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