1. Configure the name and email address

    1. When changing the account and changing the code, the previous identity information is displayed if it is not reconfigured
    1. –global Indicates the global configuration. You do not need to add this attribute
Git config --global user.name git config --global user.email Specifies the email addressCopy the code

2. Default branch name

    1. Using Git init creates a branch named master by default
    1. Set main as the default branch name
Git config --global init.defaultBranch [main]Copy the code

Check your current Git configuration

    1. Self-operated display (identity, branch, status….)
    git config --list 
Copy the code

4. Obtain command help

    git help config 
Copy the code

5. Git initialization of the project

    git init
Copy the code

6. Submit files, temporarily save files and perform other operations

Documents submitted:

    git add *.c
    git add LINCENSE
    git commit -m "Initial project version"
Copy the code

7. Get an existing repository

    1. The default copied target name is the name of the project
    1. If a new directory is specified, add the name of the new directory after the url
Git clone address [url] | | new directory [name]Copy the code

8. Check the file status

  1. Untracked and tracked files
    git status
Copy the code

9. Ignore files

Description to Be Added

10. View staged and unstaged changes

    git diff
Copy the code

11. Commit changes

    1. -m indicates the master branch
    1. -a: Skip the dock (skip git add section)
Git commit -mCopy the code

12. Delete files

    1. Forcibly delete -f
    git rm 
Copy the code

13, move files | | renaming files

    git mv file_from file_to
Copy the code

14. Record information

    1. Git log –stat abbreviation statistics
    1. git log –pretty = [oneline || short || full || fuller || format]
    git log
Copy the code

15, cancellation

    1. Recommit, temporary other operations: git commit –amend
    1. Git restore HEAD
    1. Unmodify the modified file: git checkout — filename

16. View the remote server

  1. Not very often, need to use, learn by yourself
    git remote
Copy the code

17, mark

    git tag
Copy the code

18, branch

    1. Create a new branch
Git branch Specifies the branch nameCopy the code
    1. Switch branch
Git Checkout branch nameCopy the code
    1. Create a new branch and switch
Git checkbox -b branch nameCopy the code
    1. Merging branches
Git checkbox master 2. Merge Git merge other-branch 3. Delete a branch: git branch -d other-branchCopy the code

Git branch after 2.23

** Git checkbox becomes git switch **

2. Create and switch git switch -c to create a new branch. 3. Return to the previous branch: git switch -Copy the code