How much do you know about Git?

 

 1. What is Git?

        Git is a version control system created byLinus Torvalds. It is designed to manage changes to a project's code so that team members can collaborate to develop and maintain the code base. Git allows users to track code changes, roll back incorrect changes, merge code, and more. Git also has the function of branches and tags, allowing team members to integrate code on the basis of independent development. Unlike other version control systems, Git does not rely on a central server to collaborate on development, which makes it more flexible and distributed.

 2. Why is there Git?

        Git is a version control system that appears tosolve collaboration and management issues in the development process. In software development, it often happens that multiple people develop the same code at the same time. These people may be in different locations and use different computers and operating systems. Therefore, a person who can coordinate the work of these people, monitor code changes, and ensure Tools for code reliability and maintainability. Git provides a reliable way to track code changes and helps teams collaborate, thereby greatly improving the efficiency and quality of software development. 

3. Basic concepts and usage of Git

        Git is a distributed version control system that can record the historical changes of a project, including the addition, deletion and modification of code and file operations, to facilitate team collaborative development and version management.

3.1 Basic concepts and usage of Git:

1. Repository: Git uses repositories to save project code and its historical changes. Each repository has a unique identifier.

2. Branch: In Git, a branch refers to a different version of the code, which can be separated from the main branch (usually master) at a certain moment and developed as an independent branch.

3. Commit: Commit in Git refers to the operation of saving code changes to the warehouse. Each submission has a unique identifier that can be used to distinguish different submission records.

4. Merge: In Git, merging refers to merging code on different branches together to maintain code consistency.

5. Clone: ​​Git allows users to copy the code of the remote warehouse to the local. This process is called cloning.

6. Push: Push in Git refers to pushing local code changes to the remote warehouse so that others can obtain these changes.

7. Pull: Pull in Git refers to getting the latest code changes from the remote warehouse and merging them into the local code base.

3.2 The method of using Git is as follows:

1. First, you need to install Git locally. You can download the installation program from the Git official website and install it.

2. Create a new repository or clone an existing repository from the remote repository.

3. Modify and develop the code locally, use the git add command to add the modified files to the staging area, and use the git commit command to submit the code in the staging area to the warehouse.

4. Use the git push command to push the local repository to the remote repository so that others can obtain the latest code changes.

5. In team collaboration development, when branch conflicts occur, you can use the git merge command to merge the codes of different branches together to ensure code consistency.

4. Installation of Git tools

Git can be downloaded from the official website:https://git-scm.com/downloads

Installation steps:
1. Download the installation package (select the corresponding version according to your operating system).
2. Double-click the installation package and follow the installation wizard to install. The default options are sufficient, but you need to pay attention to some options, such as PATH environment variable settings.
3. After the installation is complete, enter `git --version` in the terminal or command line window. If a message similar to "git version 2.30.1" appears, the installation is successful.

After the installation is complete, you can start using Git for version control.

5. List of common Git commands

The following is a list of commonly used Git commands:

1. git init: Initialize a Git repository.

2. git add <file>: Add the file to the staging area.

3. git commit -m "commit message": Submit the files in the temporary storage area to the local warehouse and attach the submission information.

4. git status: View the status of the warehouse, including operations such as adding, modifying, and deleting.

5. git log: View submission history, including submitter, submission time, submission information, etc.

6. git branch: List all local branches.

7. git checkout <branch>: Switch to the specified branch.

8. git merge <branch>: Merge the specified branch into the current branch.

9. git remote add <name> <url>: Add a remote warehouse.

10. git pull: Pull the latest code from the remote warehouse.

11. git push: Push the local warehouse to the remote warehouse.

12. git clone <repo>: Clone a repository locally.

13. git fetch: Pull the latest code from the remote warehouse to the local one, but do not merge it.

14. git reset <file>: Cancel modifications to the file.

15. git stash: Temporarily store uncommitted modifications in the current staging area, which can be restored later.

The above are only some of the commonly used Git commands. More Git commands can be found in the official documentation.

6. Documentation from Git official website:

https://git-scm.com/book/zh/v2

        This is the official Git document, which is detailed and provides very detailed instructions for using Git, from basic commands to advanced functions. Moreover, the official documents are available in Chinese, which is convenient for domestic users to read and is very friendly to friends who are not good in English!

7. Git learning materials (strongly recommended)

https://www.liaoxuefeng.com/wiki/896043488029600

        This is a Git tutorial by teacher Liao Xuefeng. It comprehensively explains the basic knowledge and common commands of Git from entry to submission. It not only describes the use of Git, but also explains the design ideas and principles of Git, which is very suitable for beginnerslearning 

 

 Thanks for watching, I hope it helps you guys! !

Guess you like

Origin blog.csdn.net/A1546553960/article/details/134450210