SVN and GIT
Both are a version management tool
The difference between
SVN: centralized
1. The central server to be connected is damaged, all versions are lost, and the loss is serious; 2. Slow pull code based on file transfer;Copy the code
Git: distributed
1. No networking; 2. Every developer is a versioned repository (all with historical releases); 2, based on file stream transmission, fast speed;Copy the code
Second, git actual operation flow
Git has three regions:
-
Workspace: Where code is written
-
Temporary storage area: temporary storage
-
History area: Version record information
When installing Git for the first time, run the following command to configure git config -l: Git config --global user.name "XXX" git config --global user.email "XXXCopy the code
Git git
git init // Create a local repository
git status // Check the file status
git add . // All files are submitted to the staging areaGit add file name// Commit a single file to the staging area
git commit -m"Comment" // Submit to the history section
git log // Check the historical version
git reflog // View all versionsGit reset --hard first seven digits of the version number// Roll back to a version
git remote -v // Check whether the local is connected to the remote repositoryGit remote add Origin// Connect to the remote repository
git pull origin master // Pull the remote repository code
git push -u origin master // Push code to remote repositoryGit clone address// Clone remote repository code (equivalent to local and remote repository connection)
git branch // View the branchGit barnch branch name// Create a branchGit Checkout branch name// Switch branchesGit checkout -b// Create the branch and switch to it
Copy the code
Merge branch dev code into primary branch master:
git checkout master // Switch to the main branch first
git merge dev / / merge
git push origin master// Push code
Copy the code