Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common operations in Git

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article will share with you about the common operations in Git. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Git version control development problems

In the actual development, we will encounter some problems, the computer blue screen, code lost, do you regret it? The disk is broken and the file is gone. Do you regret it? After a long time, the file can't be found. Do you regret it? Lack of hands, before the code runs well, must be optimized, the result is not as good as before, full of confidence, before the code did not save, remorse? How to solve it? Version control can solve these problems.

Version control (Version Control System), which is powerful, not only can back up your files, but also can achieve a lot:

Record all historical changes in the file

Error restore to a historical version

Multiple people collaborate to develop and edit the same file

Implement functional differential versions (branches), such as mysql, mariadb, and percona

Mainstream version control product name model concurrency * * model history * * pattern change * * scope * * network protocol * atom * * submission CVSClient-serverMergeChangesetFilePserver,sshNoSVNClient-server3-way merge, recursive merge, octopus mergeChangeset and SnapshotTreecustom (svn), custom (svn) over ssh, HTTP and SSL (usingWebDAV) YesGitDistributedMerge or lockSnapshotTreecustom, custom over ssh, rsync, HTTP/HTTPS, email, bundlesYes

In short, each has its own advantages and disadvantages. Git should cooperate with github remote warehouse to avoid distributed damage. Obviously the biggest difference is that git is distributed. Svn has permission control to avoid being cloned by clone. Git is suitable for pure code, svn is suitable for comprehensive document management, and git+svn is perfect.

Introduction

Linus created the open source Linux in 1991. Since then, the Linux system has evolved into the largest server system software. Although Linus created the core of Linux, the growth of Linux depends 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 truth is, before 2002, volunteers around the world sent source code files to Linus via diff, and then Linus himself merged the code manually! You might wonder, why doesn't Linus put Linux code in the version control system? Aren't there free version control systems like CVS and SVN? Because Linus is firmly opposed to CVS and SVN, these centralized version control systems are not only slow, but also must be connected to the Internet before they can be used. There are some commercial version control systems that are easier to use than CVS and SVN, but they are paid for and are not in line with the open source spirit of Linux. However, in 2002, the Linux system had been developed for ten years, and the size of the code base made it difficult for Linus to continue to manage it manually, and the brothers in the community expressed strong dissatisfaction with this way, so Linus chose a commercial version control system, BitKeeper,BitKeeper 's owner, BitMover, in a humanitarian spirit, authorized the Linux community to use the version control system free of charge.

The good situation of stability and unity was broken in 2005, due to the gathering of cattle people in the Linux community, which inevitably contaminated the habits of some Liangshan heroes. Andrew, who developed Samba, tried to crack BitKeeper's protocol (and he wasn't the only one), and was discovered by BitMover (good monitoring work! ), so BitMover got angry and wanted to take back the free right to use the Linux community. Linus can apologize to BitMover and promise to discipline the brothers strictly in the future. Well, this is impossible. The reality is this: it took Linus two weeks to write a distributed version control system in C, which is called Git! Within a month, the source code of the Linux system has been managed by Git! How do you define a cow? Onlookers can feel it.

Git quickly became the most popular distributed version control system, especially in 2008, when the GitHub website was launched, which provided free Git storage for open source projects, and numerous open source projects began to migrate to GitHub, including jQuery,PHP,Ruby, and so on. History is so accidental that if BitMover hadn't threatened the Linux community, we might not have a free and super-useful Git now.

Composition structure diagram

Workspace: the place where the metadata and object databases of the project are stored. This is the most important part of Git, where data is copied when cloning repositories from other computers.

Local index: saves the list of files that will be submitted next time, usually in the Git repository directory. It is sometimes called an "index", but it is generally called a temporary storage area.

Local warehouse, the reason why git is fast, most of the 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: can be seen as github, it is a remote warehouse, it provides web services for everyone to download, view, submit, storage.

Command quick check

Common command

Clone repository (for the first time) clone clone

Add, modify and delete files in the working directory

Save a file temporarily, put a snapshot of the file in the scratch area, add added

Submit the contents of the temporary storage area to the local warehouse commit for submission

Submit the content of the local warehouse to the remote warehouse push push

Download the latest content from the remote repository pull pull

Register an account for the cloud configuration environment

Everyone must have their own account. Register the account on the official website first:

Https://gitee.com/

Log in

Install GIT

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

Windows start menu:

Set font

Query git

Create a warehouse to create a remote warehouse (on the official website of Ma Yun)

Create a local warehouse (on your disk)

Create a test file and execute the following command in the local warehouse:

Git config-- global user.name "cgblpx" # configure user name git config at registration-- global user.email "2250432165@qq.com" # configure mailbox git config at registration-- list # check configuration information mkdir j2eecd j2eegit init # initialize in the local warehouse Create a file 1.txtgit add 1.txt # add a file to git to handle git commit-m "first commit" # submission Setup description information git remote add origin https://gitee.com/nutony/j2ee.git # remote warehouse git push-u origin master # submit resources from the local warehouse to the Git server

The first execution will pop up the following user name and password box, and you can fill in the account information of the password cloud.

Refresh the page. If created successfully, the interface on Git will change as follows, so that the environment is complete.

Daily task

Pull the latest content submitted by the rest of the team before starting work every morning, and submit available content by the end of the day.

New document

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

Push

Upload local files to the remote repository:

$git add. # add the file $git commit-m "j2ee part" in the current directory # submit, set remarks $git push-u origin master # push to the remote warehouse

Pull / download

Download the content from the remote repository locally:

$git pull # pull the latest content from the server

Common errors Authentication failed for

You can enter it under any path:

Git config-system-unset credential.helper

Then, when you submit the action, a query box appears to re-enter the user name prompt

Failed to push some refs to...

This is because readme.md does not exist in the local git

Git pull-- rebase origin master #

$git push-u origin master # push to remote warehouse

-rebase is used when merging code to handle conflicts on a randomly created branch, avoiding direct contamination of the original partition.

Fatal: remote origin already exists

1. Enter $git remote rm origin first (delete the remote library of the associated origin)

2. Type again to execute git push-u origin master

3. If you enter step 1 or report an error, error: Could not remove config section 'remote.origin'. We need to modify the contents of the gitconfig file

4. Find the installation path of your github. Mine is C:\ Users\ ASUS\ AppData\ Local\ GitHub\ PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\ etc

5. Find a file called gitconfig, open it and delete the line [remote "origin"] from it.

SSL certificate problem: unable to get local issuer certificate-- execute command solution: git config-- global http.sslVerify false-- re-push: git push-u origin master mailbox is a private error report

You need to change your mailbox to a public one on Qyun.

IDEA integrates Git to create a new warehouse in Gitee

Create a warehouse name in the web page: cgb2109-3

Enter workspace

Go to workspace, enter your project directory, and execute the clone command directly:

Git clone https://gitee.com/cgblpx/cgb2109-3.git may: need to execute other account passwords and other commands to open the IDEA project, you will find that you can directly submit or pull the replacement code thank you for reading! This is the end of this article on "what are the common operations in Git?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report