How is Git used?

How is Git used?

1. Before using git, you must first understand Git and GitHub.
Git is a distributed version management system, which is an important part of any software development project. It is mainly used for code backup and version control. It was developed by Linus, the creator of Linux.
GitHub is a code base hosting site based on git, and it can also be regarded as a programmer's SMS (meeting friends by code). One of the main open source code release or hosting sites git is to perform version management of files to facilitate switching between different versions. Similar files are backed up at different times so that you can retrieve one of them to replace when needed, but it is more convenient to use. To a certain extent, GitHub is the network disk of the code, and there are also open source developers who publish, store, collect bugs and opinions for the code.
2. To use Git, you must first download git.
1. To install git,
we need to go to the official Git website to download, and then cmd command line configuration.
2. To check whether the installation is successful when git, you can use the following commands in the command console

git --version

git check if the installation is successful

  1. After the installation is complete, you need the last step to set up. Enter git config --list in the command console. If the last two lines of information are the same as you entered before, the basic configuration of git is completed.
    Insert picture description here
    Third, you must first understand the git instructions before using git.
    Insert picture description here

How to submit git

git init  ---初始化一个git仓库
git status ---查看当前git仓库的状态,红色的字体代表的
就是你修改过的文件
git add [文件名] 或者 git add . ---将修改的全部文件提
交的时候可以使用git add . ,当你只想将部分文件提交的时候
就可以使用git add [文件名]
git commit -m "提交XXX代码" ---将文件提交到本地git仓库
git pull <远程主机名> <远程分支名> ---取回远程主机某个
分支的更新,再与本地的指定分支合并。
git push <远程主机名> <远程分支名>  把当前提交到git本地
仓库的代码推送到远程主机的某个远程分之上
   

Fourth, understand the difference between Git and Svn.
1. Centralized and distributed
Centralized means that there is only one remote version library, while the distributed version has local and remote version libraries.
Git is currently the most advanced distributed version control system in the world. It does not have a central server. Everyone's computer is a complete version library. When working, you don’t need to connect to the Internet, because everyone’s computer has a complete repository. If there is no Internet, you can still submit files, view historical version records, and create project branches;
Svn is a centralized version control system. This library is centralized on the central server. When you pull the code, you need to connect to the Internet to get the latest version from the central server. , The same goes for submitting code. The centralized version control system must be networked to work.
2. Version number
svn has a global version number, but git does not. Svn has a clear version number. For each version, git uses the SHA1 algorithm to generate a uniquely marked code, which is convenient for tracing back to the previous version.
3. Version control
git is controlled by the .git file version, and the .git file only exists in the local directory file; svn is controlled by the .svn version, and the .svn exists in every folder, if we don’t need it In version control, deleting .svn takes time.
4. Branch
The use range of branch is different. When in Git, you can only branch for the entire repository, and once deleted, it cannot be restored. In SVN, branch can target any subdirectory. It is essentially a copy operation, so you can create a lot and delete it when you don't need it, and you only need to check out the old SVN version when you need it in the future.
5. Authority
Authority management is different. As long as you have an account in git, you can export and import code. And svn has strict authority management, distinguishing read and write authority. And does not support the rollback operation, to ensure that the code is always tracked.
6. Git stores the content in metadata (intermediary data, data describing data), while SVN stores it in files

Guess you like

Origin blog.csdn.net/Glory_05/article/details/111239097