This is the 20th day of my participation in the November Gwen Challenge. Check out the details: The last Gwen Challenge 2021

preface

Git is one of the most common tools we use in multi-party collaborations. Let’s briefly explain how to install and use Git on the Mac.

Install Git

1. Search git in your browser and go to the official website

2. Click Download

3. There are several official download methods (we use the first one)

4. If you have not installed Homebrew, install It first

https://brew.sh/index_zh-cn 
Copy the code

5. Then install Git

$ brew install git
Copy the code

6. Check whether the installation is successful

$ git
Copy the code

It is displayed after the installation is successful

These are common Git commands used in various situations: start a working area (see also: git help tutorial) clone Clone a repository into a new directory init Create an empty Git repository or reinitialize an existing one work on the current change (see also: git help everyday) add Add file contents to the index mv Move or rename a file, a directory, or a symlink restore Restore working tree files rm Remove files from the working tree and from the index sparse-checkout  Initialize and modify the sparse-checkout examine the history and state (see also: git help revisions) bisect Use binary search to find the commit that introduced a bug diff Show changes between commits,  commit and working tree, etc grep Print lines matching a pattern log Show commit logs show Show various types of objects status Show the working tree status grow, mark and tweak your common history branch List, create, or delete branches commit Record changes to the repository merge Join two or more development histories together rebase Reapply commits on top of another base tip reset Reset current HEAD to the specified state switch Switch branches tag Create, list, delete or verify a tag object signed with GPG collaborate (see also: git help workflows) fetch Download objects and refs from another repository pull Fetch from and integrate with another repository or a local branch push Update remote refs along with associated objects 'git help -a' and 'git help -g' list available subcommands and some concept guides. See 'git help <command>' or 'git help <concept>' to read about a specific  subcommand or concept. See 'git help git' for an overview of the system.Copy the code

Initialize the Git

1. Open the terminal, create a folder (for example, testGit) as the Git local repository, and run the CD command to access the folder

cd /Users/username/Desktop/testGit
Copy the code

2. Create the.git directory

git init
Copy the code

3. Run commands to set the user name and email address

git config --global user.name "username"
Copy the code
git config --global user.email [email protected] 
Copy the code

4. Check Git configuration

git config --l
Copy the code