Git configuration and setup

  When getting started with Git, it's important to configure it so that it works properly in a specific environment. We're also able to manage content and interact with Git the way we like

1. Execute commands in Git

  A common form of the Git command line. Usually as follows:

    git <git-options> <command> <command-options> <operands>

  The following table describes the different parts of this form

element describe Example Remark
git command to run git git  
<git-options> Global options for Git itself, which can also specify functions to execute

git --worktree

git --version

Some of these options may be intended for stand-alone operation (git --version), while others modify values ​​used by other commands (git --worktree)
<command> Git command to execute git --push  
<command-options> options for the specified command git commit -m "comment" Default options may be used if not specified, options may also have values ​​that can be selected to further qualify the option
<operands> The operand to be operated on by the command git add *.c Specific to the command to be executed; examples include a file in the working directory, a branch or SHA1 in the repository, or a specific setting or value

  1. Operand type

    Git can take different types of operands, which are specifications of the objects to be operated on. When no operands are specified, the command operates on all eligible items it finds in the repository, staging area, or working tree range.

  

  2. Comparison of high-level commands and low-level commands

    High-level commands are intended to be user-facing, they are more commonly used and more convenient, and usually provide higher-level functionality. The low-level commands work at a lower level, and are not intended to be used by ordinary users. Some functions in Git can be performed using either high-level or low-level commands. However, it usually takes several specific low-level commands to complete the task performed by a high-level command

    The following table lists the high-level commands available in Git

Order Purpose
add Add file content to index
bisect Binary search to find changes involving defects
branch List, create or delete branches
checkout Switch branches or restore working tree files
cherry Find out commits to be applied upstream
cherry-pick Apply some of the changes involved in an existing commit
clone Clone the repository to a new directory
commit Log changes to the warehouse
config Get and set repository or global options
diff Show changes between commits, between commits and the working tree, etc.
fetch Download objects and references from another repository
grep print lines matching a pattern
help show help
log show commit log
merge Merge two or more development histories together
mv Move or rename a file, directory or symbolic link
pull Fetch or integrate from another repository or local branch
push Update remote references and related objects
rebase Forward local commits to updated upstream headers
reset Reset the current head to the specified state
revert revert some existing commits
rm Remove files from working tree and index
show Display various types of objects
status Show working tree status
submodule Initialize, update or check submodules
subtree Merge subtrees and divide repositories into subtrees
tag Create, list, delete, or validate tag objects
worktree Manage multiple work trees

    The list of low-level commands is omitted here

  3. Specify parameters

  4. Autocomplete

 

 

 

2. Configure Git

  1. Tell git your identity

  2. Configuration range

  3. The default editor

  4. Set the line terminator

  5. Aliases

  6. Windows file system cache

 

 

3. Initialize the warehouse

  1、git init

  2、git clone

 

 

4. Advanced Topics

  1. The secret of git init

  2. Further in-depth understanding of the Git repository

  3. Map the config command to the configuration file

  4. Create parameterized aliases

 

Guess you like

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