knowledge
What is Version control version control software Git base Git installation Git region and status Common Git operations
1. Version control
File version
In our daily writing code and the process of using ps, each operation (copy, paste, rename) will update file version, but we don’t know the specific file made what changes, if the computer hard disk failure or accidentally deleted, then the file is very easy to lose, the important file is missing is powerless, to sum up: Troublesome operation, non-standard naming, easy loss, and difficulty in collaboration, which leads to version control software
2. Version control software
Concept: Version control software is used to record changes to files for easy access to historical changes and backup, also called version control system
Advantages: Simple operation: you only need to be familiar with common commands to record the change information: you can record the change log of a complete version of the history. Easy to trace back: you can trace back to the specified version.
Origin: Linus created Linux in 1991. Because it was open source, until 2002, the source code submitted by volunteers around the world was manually merged by Linus. Linus was staunchly opposed to version control systems like CVS and SVN. Linus chose a commercial version control system, BitKeeper (free for humanitans), which the Big Linux guys were trying to crack after 2005. After the attempt, Linus took back the right to use it for free. Originally, Linus apologized and promised to manage the brothers well, but all the big guys had temper, Linus did not lower his head, and used two weeks to write a distributed management system git with C to replace the original system in one month. Thus, Git developed free and open source. Distributed management has made Git the most popular distributed management system in the world. (Sigh big nb)
Version control system classification (three types) :
1. Distributed version control system: Network operation, multi-person collaborative development, excellent performance, good user experience [Git] 2. Centralized version control system: Network operation, support collaborative development, poor performance, poor user experience [SVN] 3. Local version control system: A single machine runs locally
Distributed version control systems are currently the most used of the three categories
Advantages and disadvantages of the three systems
1. Local version control system, the earliest version control system, replaced manual record files. At that time, it was also very bad: single machine operation, not network coordinated development only one database (that is, the local database), all records will be lost if lost
2. The key point of centralized version control system is: server and client mode server only saves the update log value of the file and the client saves the latest version of the file
The downside: you can’t commit version updates when you’re offline. The database on the server can only be updated if it’s connected to the Internet and if it crashes and everyone can’t work, the previous update records are gone after the version of the database fails.
Both of them have flaws and I’m sure you’re thinking about putting the two together soon enough? Yeah, sure. Distributed version control systems are a combination of the two
3 The distributed version control system is still based on the server client operating mode 1, the server saves all the updated versions of files, not only the update log 2. Each client is a complete backup of the server, and the historical version has advantages: It can be developed in collaboration with many people on the Internet, and the new version can be submitted locally after the network is disconnected. After the unified submission after the network is connected, any client can be used for data recovery when the server has problems. The data stored by each client is larger than that of SVN (but today’s computers are very large, which can be ignored).
SVN will not focus on the introduction, there are big guy articles written in detail
3. Git basics
Git concept:
Git is an open source distributed version control system, which is the most advanced and popular version control system in the world. It can be processed quickly and efficiently from small to large projects
Git characteristics
1: records a snapshot. Not difference comparison 2: Nearly all operations are performed locally.
Git snapshots
Git snapshots is on the basis of the original file version to generate a new file, similar to the backup, if the file is not modified, not regenerate, retain a connection point to previously stored file of advantages: version switching rapidly, each version has a complete file, rather than according to the change log to modify the original file Defect is disk space occupied large (ignore)
Git local
Git performs most of its operations locally. You only need to access local files and resources. This is why you can manage your project locally even if it is disconnected from the Internet
The above is a basic overview of Git
4. Git installation and creation
This point also has the big guy to write better, I directly put the link Git download, installation and environment configuration
5. Git region and status
Git has three regions:
Workspace, staging area, Git repository
There are three states in Git
Git workflow:
1. Modify files at work
2, save the changes that need to be committed next time
Git basic Operations (16)
The following steps are performed after the Git environment is installed.
Git help: git help
Git help config git help config
Git config-h git config-h
4, Initialize repository in existing directory:
If you have a project without version control and want to control it with Git, there are two steps:
1. Right-click git bash in the project directory
2. Run the git init command to convert the current directory into a Git repository
The git init command creates a hidden directory named.git, which is the git repository for the current project. It contains the initial necessary files that are a necessary part of a Git repository,
5. Check the current file status
Git status command to check the status of the file
6 Display file status in simplified mode
git status -s
7. Track new files
git add
After tracing, you can continue to use git status to check the status
New files added to the staging area are preceded by A green A mark
8. Commit updates
Git commit -m “Messages to display”
9. Modify files that have been submitted
The red M indicates that it has been modified recently but has not been placed in the staging area
10. Save the modified file temporarily
11. Submit documents on hold
11. Undo the changes to the file
6, summary
Git add add multiple files. Git commit complete
Git status Check the result git diff Check the modified contents
Git reflog Check the command history. Git reset –hard commit_id
Scenario 1: When you want to discard workspace changes that clutter up your workspace, you can directly use Git Checkout –file scenario 2. Git reset HEAD file (1) Then follow scenario 1 if you’ve already committed to the version library, which is not the worst thing, you can use version rollback.
Git rm is used to delete only one file. If a file has been recently committed to the repository, do not worry about deleting it by mistake. Note that only the latest version of the file can be restored, and the contents modified after the last commit will be lost
I’m done here. GIT is also related to Github, but I will write it next time when I have time. Put a couple of big shots at the end. Git Git Git Git Git Git Git Git Git