Home >Development Tools >git >Git basic operations

Git basic operations

日久见人心不古
日久见人心不古Original
2020-04-28 18:04:38197browse

Conceptual question

What is the difference between a centralized version control system (SVN, etc.) and a distributed control system (git)? The version library of a centralized version control system exists on the "central server". When team collaboration is developed, it must be started from A "central server" fetches code and commits changes [[1]]. There is no "central server" in the distributed version control system. Each computer has a complete version library. In this way, you do not need to connect to the Internet to submit changes. You only need to connect to the remote server when pulling or pushing. Once the "central server" of the centralized controller is damaged, team members will be unable to pull and submit code. On the contrary, a distributed control system is equivalent to copying a version library on each computer. Damage to a single computer's version library does not interfere with the work of other team members. The distributed controller also has a server that acts as a "central server", but it only exists to facilitate team members to "exchange" everyone's data.

Git download and installation

Download address: Official website download (recommended method) https://git-scm.com/downloadsTencent Software Center download https://pc.qq.com/ detail/13/detail_22693.html Configuration after downloading: git config --global user.name "Name"git config --global user.email "Email Address"

Git operation

Basic Please refer to the operation: Liao Xuefeng's official website

Git remote library addition and push

1. To associate a remote library, use the command git remote add remote library custom name remote library custom address 2. After association, use the command git push -u origin master to push all the contents of the master branch for the first time. 3. After that, after each local submission, as long as necessary, you can use the command git push origin master to push the latest changes

Git branch operation

View all branches git branchCreate branch git branch branch name switch branch git checkout branch name or git switch branch name (recommended method, the former can easily cause misunderstandings with rollback operations) Create and switch Branch git checkout -b branch name or git switch -c branch name branch merge git merge branch name to be merged delete branch git branch -d branch name [1]: Liao Xuefeng's official website

The above is the detailed content of Git basic operations. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn