This is the 12th day of my participation in the First Challenge 2022

Hello everyone, MY name is Starqin and I have learned Git these days.

Install git

To use Git, you need to install Git. Git-scm.com/

After installing Git, you need to run git –version in CMD to check the git version

Note: Win +R open run, enter CMD, enter the command above in the next window

If the version number is displayed, the installation is successful. If you press Enter and the message “Git is not an internal or external command, and it is not a runnable program” is displayed, you need to configure environment variables

WIN10 Configure git environment variables

1. Right-click the computer –> Properties

2. Click Advanced System Settings -> Environment Variables -> Find Path -> Edit

3. Enter the git installation directory

Once the environment variables are configured,A certainTo close all the pages you just opened, click ok in turn

Use the git

Initialize git repository

Right click in the local project folder –>Git Bash Here

Enter a value in the command window that is displayedgit init

When you press Enter, a.git folder will be created in the local project folder. This folder is hidden, and you need to do some operations to see it

2. Synchronize to cache

Git has three partitions: a workspace that you can see and manipulate, and a cache and repository that you can’t see

Git saves files from the workspace to the cache, and from the cache to the repository

Take a look at the git command to save files from your workspace to the cache

Git add. Or git add filename

Tell me the difference between the two commands

  1. git add .Submits all files
  2. Git add file nameIndicates the submission of a file

Note: The records saved in the cache will be lost due to computer shutdown, restart, or manually clearing the memory. Therefore, every time you shut down the computer or leave work, you should check whether there are any records submitted to the repository in the cache. Here, we use git status command to check the working status of Git

If you have a situation like mine, there are files in your cache waiting to be committed to the repository

3. Submit to the warehouse

Git commit -m

Using the command above we can formally commit the cache file to the repository, note that the comment must be written oh

After submitting to the repository, take a look at the state of the cache

If the content shown above shows that our cache is clean and there are no files to be submitted

That’s all the process and basic commands for saving your local project to your local Git repository

Sync to Gitee online hosting

The first step, of course, is to set up a Gitee account! Sign up at gitee.com

Step 2: Create an online library

Step 3: After you click Create, the two lines of code that I captured will be generated automatically. Let’s copy these two lines of code to Git Bash Here for execution

Note that two Windows pop up asking us to enter the password for the gitee account

If Git Bash Here is in the following state after you enter the account and password, the synchronization is successful

Let’s just go back to Gitee and refresh the page

This is because gitee defaults to synchronizing repositories that are private and not open source. If you want your repository to be open source, you need the following Settings

This makes your repository open source

Up (end)

For details on how to back up and branch git, please see the next article: “How to use Git in the eyes of the front end”