【Git】—— How to install Git and use it easily

        Git is an open source distributed version control tool that can better manage your projects.

1. Linux operating system

        If you are using the Ubuntu system, just open the shell interface and enter:

        sudo apt-get install git-core

        Press enter to complete the installation.

2. Windows operating system

        The Windows operating system is different from the Linux system, and the installation may be a little troublesome.

1. Download Git

       First download the Git installation package, URL: Git for Windows .

 After the download is complete, open it as follows:

 

2. Create a code warehouse

1) Configure identity

        Git installed on Windows can be operated on a graphical interface or using commands. Novices are best to start with using commands.

        First of all, you should configure the identity, so that Git knows who submitted the code when submitting the code. The command is as follows:

git config --global user.name "zhang"
git config --global user.email "[email protected]"

        After entering, enter the same command again to check whether the configuration is successful, just remove the name and email address.

2) Create a code base

        The warehouse is used to save the information required for version management, and all locally submitted code will be submitted to the code warehouse.

        Now try to create a code warehouse for a project, first enter the directory of the project, as follows:

 

         Then enter the following command:

git init

 

        After the warehouse is created, a hidden .git folder will be generated under the project directory. This folder is used to record all local Git operations, which can be viewed through the following command, as follows:

ls -al

To delete the local warehouse, just delete this folder.

3) Submit local code

        To submit the code, you only need to use the add and commit commands, add is used to add the code, and commit is used to perform the commit operation.

        Let's try to submit the build.gradle file to experiment.

        Enter the following command:

        Here's how to add files individually.

git add build.gradle

        Here's how to add a directory.

git add app

        Here's how to add all the files at once.

git add .

        The following is the submission operation of the file. After the addition is completed, it can be submitted.

        There must be parameters describing the information after -m.

git commit -m "name commit."


The above is just a simple study of the installation and use of Git, and I will continue to update the Git operation under this column later.

Guess you like

Origin blog.csdn.net/Tir_zhang/article/details/130176183