Table of Contents
Git Version Control
Development Problems
Mainstream version control products
Introduction
Composition structure diagram
Command quick check
Common commands
Code Cloud Configuration Environment
Register Account
Login
Install GIT
Set font
Query git
Create warehouse on code cloud
Create remote warehouse (on code cloud official website)
Create a local repository (in your disk)
Daily tasks
New files
推送
拉取/下载
常见错误
Authentication failed for
failed to push some refs to…
fatal: remote origin already exists
SSL certificate problem: unable to get local issuer certificate
邮箱是私有的报错
IDEA整合Git
在Gitee创建新的仓库
进入workspace
打开IDEA的工程中,你会发现直接就能提交或者拉取代码了
Home Development Tools git Detailed examples of common Git operations

Detailed examples of common Git operations

Mar 25, 2022 pm 07:31 PM
git

This article brings you relevant knowledge about Git, which mainly introduces some common operations, including setting fonts, creating remote warehouses, creating local warehouses, etc. I hope it will be helpful to everyone helpful.

Detailed examples of common Git operations

Recommended study: "Git Tutorial"

Git Version Control

Development Problems

In actual development, we will encounter some problems, such as computer blue screen and lost code. Do you regret it? The disk is broken and the files are gone. Do you regret it? It’s been a long time and I can’t find the file. Do you regret it? I'm sorry, the code was running fine before, but I had to optimize it, but the result is not as good as before. I'm full of confidence. I didn't save the previous code. Do you regret it? How to solve it? Version control can solve these problems.

Version Control System is powerful. It can not only back up your files, but also achieve many things:

  • Record all historical changes of files
  • Error recovery to a certain historical version
  • Multiple people collaborate to develop and edit the same file
  • Realize functional difference versions (branch), such as: mysql, mariadb, percona three branches

Mainstream version control products

** Network Protocol**** Atomic**Client-serverMergeChangesetFilePserver,ssh NoClient-server3-way merge, recursive merge, octopus mergeChangeset and SnapshotTreecustom (svn), custom (svn) over ssh, HTTP and SSL (usingWebDAV)Yes#DistributedMerge or lockSnapshotTreecustom, custom over ssh, rsync, HTTP/HTTPS, email, bundlesYes

In short, each has its own advantages and disadvantages. Git must cooperate with the github remote warehouse to avoid distributed damage. Obviously the biggest difference is that git is distributed. svn has permission control to prevent everything from being cloned. Git is suitable for pure code, and svn is suitable for comprehensive document management. The combination of git svn is perfect.

Introduction

Detailed examples of common Git operations

Linus created open source Linux in 1991. Since then, the Linux system has continued to develop and has become the largest server System software. Although Linus created the core of Linux, the growth of Linux relies on the participation of enthusiastic volunteers from all over the world. With so many people writing code for Linux around the world, how is the Linux code managed?

The fact is that before 2002, volunteers from all over the world sent source code files to Linus through diff, and then Linus himself merged the code manually! You may be thinking, why doesn't Linus put the Linux code into the version control system? Aren’t there free version control systems like CVS and SVN? Because Linus firmly opposes CVS and SVN, these centralized version control systems are not only slow, but also require an Internet connection to be used. There are some commercial version control systems. Although they are easier to use than CVS and SVN, they are paid and inconsistent with the open source spirit of Linux. However, by 2002, the Linux system had been developed for ten years. The code base was so large that it was difficult for Linus to continue to manage it manually. Brothers in the community also expressed strong dissatisfaction with this method, so Linus chose a commercial The version control system BitKeeper. BitMover, the owner of BitKeeper, authorizes the Linux community to use this version control system for free out of humanitarian spirit.

The good situation of stability and unity was broken in 2005. The reason was that the Linux community gathered a lot of talented people, which inevitably tainted the quaint habits of some Liangshan heroes. Andrew, who developed Samba, tried to crack the BitKeeper protocol (actually he was not the only one to do this), but was discovered by BitMover (the monitoring work was well done!), so BitMover became angry and wanted to take back the free use rights of the Linux community. Linus can apologize to BitMover and promise to strictly discipline his brothers in the future. Well, this is impossible. The actual situation is this: Linus spent two weeks writing a distributed version control system in C. This is Git! Within a month, the source code of the Linux system has been managed by Git! How is a cow defined? People who eat melons can experience it.

Git quickly became the most popular distributed version control system. Especially in 2008, the GitHub website was launched, which provided free Git storage for open source projects. Countless open source projects began to migrate to GitHub, including jQuery, PHP, Ruby and so on. History is so accidental. If BitMover hadn't threatened the Linux community back then, we might not have free and super easy-to-use Git now.

Composition structure diagram

Detailed examples of common Git operations

  • Workspace: A place used to save the metadata and object database of the project. This is the most important part of Git. When you clone a repository from another computer, it is the data here that is copied.
  • Local index: Saves the file list information to be submitted next time, usually in the Git warehouse directory. Sometimes it is also called an "index", but it is generally called a staging area.
  • Local warehouse, the reason why git is fast is that most submissions are for the local warehouse, do not rely on the network, and will be pushed to the remote warehouse for the last time.
  • Remote warehouse: It can be regarded as github. It is a remote warehouse that provides web services for everyone to conveniently download, view, submit, and store.

Command quick check

Detailed examples of common Git operations

Common commands

Detailed examples of common Git operations

  • Clone the warehouse (the first time) clone clone
  • Add, modify, and delete files in the working directory
  • Temporarily store files and put snapshots of files into Staging area add new
  • Submit the contents of the staging area to the local warehouse commit
  • Submit the contents of the local warehouse to the remote warehouse push
  • From the remote warehouse Download the latest content pull

Code Cloud Configuration Environment

Register Account

Detailed examples of common Git operations

Everyone must have their own account, First register an account on the official website:

https://gitee.com/

Login

Detailed examples of common Git operations

Install GIT

Git -2.27.0-64-bit, go all the way to next. After installation, the desktop right-click menu has the following two items, and the installation is complete. Select Git Bash and enter the git client.

Windows Start Menu:

Detailed examples of common Git operations

Detailed examples of common Git operations

Set font

Detailed examples of common Git operations

Detailed examples of common Git operations

Query git

Detailed examples of common Git operations

Create warehouse on code cloud

Create remote warehouse (on code cloud official website)

Detailed examples of common Git operations

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-1gg9jRd2-1623157728805)(RackMultipart20210608-4-134iydv_html_b0844519a8530850.png)] [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-rWgE9Vyn-1623157728806)(RackMultipart20210608-4-134iydv_html_48bbed748fd9ffd2.png)]
Detailed examples of common Git operations

Create a local repository (in your disk)

Create the test file and install it locally Execute the following command in the warehouse:

git config --global user.name "cgblpx" #配置注册时的用户名
git config --global user.email "2250432165@qq.com"  #配置注册时的邮箱
git config --list #检查配置信息
mkdir j2ee
cd j2ee
git init								#初始化
在本地仓库中,创建文件1.txt
git add 1.txt						#新增文件到git中处理
git commit -m "first commit"			#提交,设置说明信息
git remote add origin https://gitee.com/nutony/j2ee.git	#远程仓库
git push -u origin master #把本地仓库的资源 提交给Git服务器
Copy after login

The first time it is executed, the following user name and password boxes will pop up. Fill in the code cloud account information and you can

Detailed examples of common Git operations

refresh Page, if created successfully, the interface on Git will change as follows, and the environment will be completed

Detailed examples of common Git operations

Daily tasks

Pull before starting work every morning Get the content submitted by other members of the latest team and submit available content before get off work every day

New files

Create a project directory, create a new file, or copy an existing file or directory:

Detailed examples of common Git operations

推送

把本地文件上传到远程仓库中:

$ git add .								#添加当前目录下文件
$ git commit -m "j2ee part"				#提交,设置备注
$ git push -u origin master				#推送到远程仓库
Copy after login

Detailed examples of common Git operations

拉取/下载

把远程仓库中的内容下载到本地:

$ git pull										#从服务器拉取最新内容
Copy after login

Detailed examples of common Git operations

常见错误

Authentication failed for

Detailed examples of common Git operations

任何路径下输入都可以:

git config --system --unset credential.helper

然后提交操作时,会出现询问框,重新输入用户名提示

failed to push some refs to…

Detailed examples of common Git operations

这是是因为readme.md 没有存在在本地git中

git pull --rebase origin master #

$ git push -u origin master #推送到远程仓库

–rebase用在合并代码的时候其作用就是在一个随机创建的分支上处理冲突,避免了直接污染原来的分区。

fatal: remote origin already exists

1、先输入$ git remote rm origin(删除关联的origin的远程库)

2、再输入重新执行 git push -u origin master

3、如果输入第1步 还是报错的话,error: Could not remove config section 'remote.origin'. 我们需要修改gitconfig文件的内容

4、找到你的github的安装路径,我的是C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc

5、找到一个名为gitconfig的文件,打开它把里面的[remote "origin"]那一行删掉就好了!

SSL certificate problem: unable to get local issuer certificate

	--执行命令解决: git config --global http.sslVerify false
	--重新push: git push -u origin master
Copy after login

邮箱是私有的报错

Detailed examples of common Git operations
需要在码云上,把邮箱改成公开的才行
Detailed examples of common Git operations

IDEA整合Git

在Gitee创建新的仓库

在网页中创建仓库名称:cgb2109-3

进入workspace

进入workspace,再进入你的项目目录,直接执行clone命令:

git clone https://gitee.com/cgblpx/cgb2109-3.git
也许:
需用执行其他的账号密码等命令
Copy after login

打开IDEA的工程中,你会发现直接就能提交或者拉取代码了

Detailed examples of common Git operations

推荐学习:《Git教程

Name Model Concurrency** Mode** ** History**Mode ##Changes** Scope** Committability
CVS
SVN
Git

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

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to install deepseek How to install deepseek Feb 19, 2025 pm 05:48 PM

There are many ways to install DeepSeek, including: compile from source (for experienced developers) using precompiled packages (for Windows users) using Docker containers (for most convenient, no need to worry about compatibility) No matter which method you choose, Please read the official documents carefully and prepare them fully to avoid unnecessary trouble.

Summary of FAQs for DeepSeek usage Summary of FAQs for DeepSeek usage Feb 19, 2025 pm 03:45 PM

DeepSeekAI Tool User Guide and FAQ DeepSeek is a powerful AI intelligent tool. This article will answer some common usage questions to help you get started quickly. FAQ: The difference between different access methods: There is no difference in function between web version, App version and API calls, and App is just a wrapper for web version. The local deployment uses a distillation model, which is slightly inferior to the full version of DeepSeek-R1, but the 32-bit model theoretically has 90% full version capability. What is a tavern? SillyTavern is a front-end interface that requires calling the AI ​​model through API or Ollama. What is breaking limit

What are the Grayscale Encryption Trust Funds? Common Grayscale Encryption Trust Funds Inventory What are the Grayscale Encryption Trust Funds? Common Grayscale Encryption Trust Funds Inventory Mar 05, 2025 pm 12:33 PM

Grayscale Investment: The channel for institutional investors to enter the cryptocurrency market. Grayscale Investment Company provides digital currency investment services to institutions and investors. It allows investors to indirectly participate in cryptocurrency investment through the form of trust funds. The company has launched several crypto trusts, which has attracted widespread market attention, but the impact of these funds on token prices varies significantly. This article will introduce in detail some of Grayscale's major crypto trust funds. Grayscale Major Crypto Trust Funds Available at a glance Grayscale Investment (founded by DigitalCurrencyGroup in 2013) manages a variety of crypto asset trust funds, providing institutional investors and high-net-worth individuals with compliant investment channels. Its main funds include: Zcash (ZEC), SOL,

Delphi Digital: How to change the new AI economy by parsing the new ElizaOS v2 architecture? Delphi Digital: How to change the new AI economy by parsing the new ElizaOS v2 architecture? Mar 04, 2025 pm 07:00 PM

ElizaOSv2: Empowering AI and leading the new economy of Web3. AI is evolving from auxiliary tools to independent entities. ElizaOSv2 plays a key role in it, which gives AI the ability to manage funds and operate Web3 businesses. This article will dive into the key innovations of ElizaOSv2 and how it shapes an AI-driven future economy. AI Automation: Going to independently operate ElizaOS was originally an AI framework focusing on Web3 automation. v1 version allows AI to interact with smart contracts and blockchain data, while v2 version achieves significant performance improvements. Instead of just executing simple instructions, AI can independently manage workflows, operate business and develop financial strategies. Architecture upgrade: Enhanced A

As top market makers enter the crypto market, what impact will Castle Securities have on the industry? As top market makers enter the crypto market, what impact will Castle Securities have on the industry? Mar 04, 2025 pm 08:03 PM

The entry of top market maker Castle Securities into Bitcoin market maker is a symbol of the maturity of the Bitcoin market and a key step for traditional financial forces to compete for future asset pricing power. At the same time, for retail investors, it may mean the gradual weakening of their voice. On February 25, according to Bloomberg, Citadel Securities is seeking to become a liquidity provider for cryptocurrencies. The company aims to join the list of market makers on various exchanges, including exchanges operated by CoinbaseGlobal, BinanceHoldings and Crypto.com, people familiar with the matter said. Once approved by the exchange, the company initially planned to set up a market maker team outside the United States. This move is not only a sign

Significantly surpassing SFT, the secret behind o1/DeepSeek-R1 can also be used in multimodal large models Significantly surpassing SFT, the secret behind o1/DeepSeek-R1 can also be used in multimodal large models Mar 12, 2025 pm 01:03 PM

Researchers from Shanghai Jiaotong University, Shanghai AILab and the Chinese University of Hong Kong have launched the Visual-RFT (Visual Enhancement Fine Tuning) open source project, which requires only a small amount of data to significantly improve the performance of visual language big model (LVLM). Visual-RFT cleverly combines DeepSeek-R1's rule-based reinforcement learning approach with OpenAI's reinforcement fine-tuning (RFT) paradigm, successfully extending this approach from the text field to the visual field. By designing corresponding rule rewards for tasks such as visual subcategorization and object detection, Visual-RFT overcomes the limitations of the DeepSeek-R1 method being limited to text, mathematical reasoning and other fields, providing a new way for LVLM training. Vis

Bitwise: Businesses Buy Bitcoin A Neglected Big Trend Bitwise: Businesses Buy Bitcoin A Neglected Big Trend Mar 05, 2025 pm 02:42 PM

Weekly Observation: Businesses Hoarding Bitcoin – A Brewing Change I often point out some overlooked market trends in weekly memos. MicroStrategy's move is a stark example. Many people may say, "MicroStrategy and MichaelSaylor are already well-known, what are you going to pay attention to?" This is true, but many investors regard it as a special case and ignore the deeper market forces behind it. This view is one-sided. In-depth research on the adoption of Bitcoin as a reserve asset in recent months shows that this is not an isolated case, but a major trend that is emerging. I predict that in the next 12-18 months, hundreds of companies will follow suit and buy large quantities of Bitcoin

The latest tutorial on how to install the ios version installation package of Ouyi The latest tutorial on how to install the ios version installation package of Ouyi Feb 21, 2025 pm 07:36 PM

This guide will provide a comprehensive overview of how to install the latest installation packages from EV Exchange on iOS devices. Ouyi Exchange is a leading cryptocurrency trading platform that provides a wide range of cryptocurrency trading, asset management and investment services. By following the step-by-step instructions provided in this guide, users can easily and easily install the Euyi Exchange app on their iPhone or iPad. This guide is suitable for all iOS devices, from older models to the latest generation, and includes clear screenshots and detailed instructions to ensure a seamless installation process.

See all articles