Git underlying commands and Git branches

1. Introduction

Git is an open source distributed version control system for agile and efficient handling of any project, small or large.

Git is an open source version control software developed by Linus Torvalds to help manage Linux kernel development.

Git is different from the commonly used version control tools CVS, Subversion, etc. It adopts the distributed version library method and does not need server-side software support .

decentralized

 branch

The difference between Git and SVN

Git is not only a version control system, it is also a content management system (CMS), work management system, etc.

If you're someone with a background in using SVN, you'll need to do a bit of a mental shift to get used to some of the concepts and features that Git provides.

The differences between Git and SVN:

  • 1. Git is distributed, SVN is not : This is the core difference between Git and other non-distributed version control systems, such as SVN, CVS, etc.

  • 2. Git stores content as metadata, while SVN stores content as files: all resource control systems hide the metainformation of files in a folder like .svn, .cvs, etc.

  • 3. Git branches are different from SVN branches: branches are not special in SVN at all, in fact, they are just another directory in the repository.

  • 4. Git does not have a global version number, but SVN has: so far this is the biggest feature that Git lacks compared to SVN.

  • 5. Git's content integrity is better than SVN: Git's content storage uses the SHA-1 hash algorithm. This ensures the integrity of the code content and ensures less damage to the repository in the event of disk failures and network issues.

2. Download and install

download link:

Git - Downloadshttps://git-scm.com/downloads

After the download is complete:

 Create the start menu directory name, the default is git, no need to modify

 

 Choose the editor used by git

 

 End-of-line newline conversion, use default value

 

 Install

 To check that the installation is successful, you can right-click on any window or desktop, and the following two options will appear.

3. Git common commands

Account mailbox configuration

Git bash here
git config --list
git config --global user.name "xiaozhou"
git config --global user.email "[email protected]"

#https protocol submission fails repeatedly. The reason is that I have used Git to submit different code cloud account codes before and the passwords are inconsistent. You can choose to reset the password
git config --system --unset credential.helper

 Use scenarios of each command

1.Git file status and work area

The file status of git is the core content of git. Understanding it will be of great help to subsequent operations. Different file statuses are stored in different work areas.

  1. File status  

   Files in git have the following statuses

​ Untracked (untrack): Indicates that the file is newly added

Modified: Indicates that the file has been modified but has not been saved to the git repository.

Staged: Indicates that the current version of a modified file has been marked so that it can be included in the next submitted snapshot.

​Committed: Indicates that the file has been saved in the git repository.

   

  2.Working area

   According to the division of local computer and remote computer, the working area has the following types

   1)Local computer

   Working Directory: The status of the file being edited. The file status is untracked and modified in this area.

   Staging Area: Saves the file list information to be submitted next time. The file status is staged in this area.

   Repository (local warehouse): Files submitted to the local warehouse.

   2) Remote computer

   Repository: Files that have been submitted to the remote computer.

 2. Common commands

  git clone: ​​Clone the remote repository to the local computer.

  git status: Displays files in different statuses in the workspace and staging area.

  git add: Add content from the working directory to the staging area.

  git commit: All files staged through git add are submitted to the local warehouse.

  git push: Submit the records of the local warehouse to the remote warehouse.

  git reset HEAD <file>: Remove the specified file from the staging area.

  git checkout -- <file>: Restore the specified file from the local repository.

  git pull: Pull data from the remote warehouse.

  git init

 3. Practical operation of commands

Guess you like

Origin blog.csdn.net/m0_54546762/article/details/122143171