Home System Tutorial LINUX Play with Git

Play with Git

May 06, 2024 pm 02:37 PM
linux git linux tutorial Red Hat linux system linux command it service linux certification red hat linux linux video

git introduction

The biggest difference between distributed and centralized is that developers can submit to local, and each developer copies one on the local machine by cloning (git clone)

complete Git repositories. Compared with the SVN centralized code management that most of us have used, git is more secure for managing code. If the svn server hangs up,

Then its data is likely to be in danger of being lost, but for git, there is no such thing. The code is all git to local, even if the server hangs up,

The code is still intact. Git is a version controller, which is completely different from the traditional svn. svn is a difference comparison, and code cannot be submitted offline. And git saves

With the complete code base local, the code is more secure. Code can be submitted at any time. I have already introduced to you how to build a git server. Next I will

Let’s take a look at the specific use of git commands! I will introduce some commonly used ones here, and for the rest I will recommend a website to everyone, which has a detailed introduction to git

Shao, if you forget, you can check it at any time!

git installation

The installation method on windows is to download a git client called git bash tool and install it directly! You can also download the git version of Little Turtle! I’ll introduce it here

is git bash, so that everyone can become familiar with git commands.

The installation method under Linux is simpler, just yum -y install git!

git use

We created a new project TestProject

on the server

Play with Git

First, you will be assigned a group and username and password, which means you have permission to access this project. Our first step is to set up our username and email address.

Play with Git

Create a new folder to store the project, enter the file, right-click and select Git Bash Here to enter our git command line interface. The next operation will be performed inside.

Play with Git

git config -l (view configuration file)

Play with Git

The first case is that the project is uploaded in advance, we only need to pull it locally and use git clone http://172.16.81.91/oe/TestProject.git (equivalent to svn checkout)

Play with Git

Play with Git

git status Check the status of the code at any time, a very useful command

Play with Git

Next let’s modify the test1 file and check the status

Play with Git

Prompt test1 has been modified, then we need to use git add or git commit -a to submit the code

Play with Git

git add. Add modified files to git operation; git commit (submit code, usually followed by -m parameter, indicating adding comments)

The current status of git status is git push (when we complete the submission, we can upload the code to the server)

Play with Git

Let’s go to the server to view the submitted code

Play with Git

Submission completed!

The second situation is that the project files on our server are deleted. We can use git pull locally to update to the latest files (equivalent to svn update)

Play with Git

In the third case, to submit the code to the newly created empty project, we delete the TestProject project from the server and create it again.
Play with Git

We re-create a folder in the TestP directory, name it project2, and create the test1 file in the directory

Play with Git

We need to initialize the folder git init before uploading the local code to the server

Play with Git

Add local code to the remote server git remote add origin http://172.16.81.91/oe/TestProject.git
Play with Git

Submit code

Play with Git

Upload code
Play with Git

View server project verification
Play with Git

The above introduction is what we commonly use. Next, you can check other commands:

查看分支:git branch

创建分支:git branch name

切换分支:git checkout name

创建+切换分支:git checkout –b name

合并某分支到当前分支:git merge name

删除分支:git branch –d name
Copy after login

Finally, I will introduce you to a website with detailed information about git: https://git-scm.com/book/zh/v2

You can also download the pdf of the website and read it locally. After reading the first few pictures, you will be a master!

Play with Git

Please point out any errors! Thanks! Let’s learn together!

The above is the detailed content of Play with Git. 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

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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 start apache How to start apache Apr 13, 2025 pm 01:06 PM

The steps to start Apache are as follows: Install Apache (command: sudo apt-get install apache2 or download it from the official website) Start Apache (Linux: sudo systemctl start apache2; Windows: Right-click the "Apache2.4" service and select "Start") Check whether it has been started (Linux: sudo systemctl status apache2; Windows: Check the status of the "Apache2.4" service in the service manager) Enable boot automatically (optional, Linux: sudo systemctl

What to do if the apache80 port is occupied What to do if the apache80 port is occupied Apr 13, 2025 pm 01:24 PM

When the Apache 80 port is occupied, the solution is as follows: find out the process that occupies the port and close it. Check the firewall settings to make sure Apache is not blocked. If the above method does not work, please reconfigure Apache to use a different port. Restart the Apache service.

How to restart the apache server How to restart the apache server Apr 13, 2025 pm 01:12 PM

To restart the Apache server, follow these steps: Linux/macOS: Run sudo systemctl restart apache2. Windows: Run net stop Apache2.4 and then net start Apache2.4. Run netstat -a | findstr 80 to check the server status.

How to solve the problem that apache cannot be started How to solve the problem that apache cannot be started Apr 13, 2025 pm 01:21 PM

Apache cannot start because the following reasons may be: Configuration file syntax error. Conflict with other application ports. Permissions issue. Out of memory. Process deadlock. Daemon failure. SELinux permissions issues. Firewall problem. Software conflict.

How to learn Debian syslog How to learn Debian syslog Apr 13, 2025 am 11:51 AM

This guide will guide you to learn how to use Syslog in Debian systems. Syslog is a key service in Linux systems for logging system and application log messages. It helps administrators monitor and analyze system activity to quickly identify and resolve problems. 1. Basic knowledge of Syslog The core functions of Syslog include: centrally collecting and managing log messages; supporting multiple log output formats and target locations (such as files or networks); providing real-time log viewing and filtering functions. 2. Install and configure Syslog (using Rsyslog) The Debian system uses Rsyslog by default. You can install it with the following command: sudoaptupdatesud

How to fix apache vulnerability How to fix apache vulnerability Apr 13, 2025 pm 12:54 PM

Steps to fix the Apache vulnerability include: 1. Determine the affected version; 2. Apply security updates; 3. Restart Apache; 4. Verify the fix; 5. Enable security features.

How to upgrade Zookeeper version on Debian How to upgrade Zookeeper version on Debian Apr 13, 2025 am 10:42 AM

Upgrading the Zookeeper version on Debian system can follow the steps below: 1. Backing up the existing configuration and data Before any upgrade, it is strongly recommended to back up the existing Zookeeper configuration files and data directories. sudocp-r/var/lib/zookeeper/var/lib/zookeeper_backupsudocp/etc/zookeeper/conf/zoo.cfg/etc/zookeeper/conf/zookeeper/z

How to solve nginx403 How to solve nginx403 Apr 14, 2025 am 10:33 AM

How to fix Nginx 403 Forbidden error? Check file or directory permissions; 2. Check .htaccess file; 3. Check Nginx configuration file; 4. Restart Nginx. Other possible causes include firewall rules, SELinux settings, or application issues.

See all articles