Centralized version control system, the repository is centrally stored in the central server, with their own computers, so the first from the central server to obtain the latest version, and then began to work, finished work, and then put their lives to the central server. Centralized version control system The biggest problem is the need to network to work, if it is OK in the LAN, the bandwidth is big enough, fast enough, but if on the Internet, it is very slow. as the earliest open source and free centralized version control system, CVS has been used by many people until now. Due to the problem of the design of CVS, the file is incomplete and the repository is inexplicably corrupted. Also open source and free SVN fixes some of the stability issues of CVS, which is currently the most used centralized repository control system.
Distributed (GIT) Distributed version control system does not have a "central server", everyone's computer is a full version of the library, when working, do not need to network, because the repository is on your own computer. Since everyone has a full repository on their computers, how can multiple people collaborate? For example, you change the file a on your computer, your colleague also changed the file a on his computer, when you two just push their changes to each other, you can see each other's changes. compared with centralized version control system, the security of Distributed version control system is much higher, because everyone's computer has a complete version of the library, a person's computer is broken do not matter, casually from other people to copy one. Centralized version control system central server if there is a problem, everyone can not work. in the actual use of Distributed version control system, in fact, rarely in the computer between the two people to push the revision of the Repository, because maybe you two are not in a LAN, two computers can not access each other. Therefore, the distributed version control system usually also has a "central server" computer, but the role of this server is only to facilitate "exchange" everyone's changes, without it everyone also work, just exchange changes inconvenient.
For installation Please refer to: http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/ 00137396287703354d8c6c01c904c7d9ff056ae23da865a000
Command Description:1. git clone [email protected]192.168.5.86:/srv/sample.git//get all branches from a remote library2. git add readme.txt//add a file to the pause zoneReadme.txt changed to. Point//Add all modified and non-incremented files under this directory (including subdirectories)3. Git commit//submit the file to the warehouse-M "This submission notes"//commit instructions, executing this statement must first execute the git addIf you need to wrap a line, you can use single quotation marks-am "This note"//how git Add and git commit are merged (automatic git add only for modified files)executing this command after a file modification requires that the Git Add workspace pause zone concept be executed first4. git commit--amend//Cancel last commit and resubmit5. git status//View Status 6. Git diff readme.txt//is to see the difference between the readme.txtde of the work area and the suspended area. If you do not write the file, compare allgit diff test//shows the difference between the current directory and another branch called ' Test 'git diff HEAD//is to see the difference between the workspace and commit. (You must not forget that the head represents the latest commit information)git diff HEAD--readme.txt//view the differences between Readme.txt and last commit in the current directorygit diff SHA1 SHA2//compare the direct differences between two versionsgit diff--cached//is to see the difference between a deferred zone and a commit. 7. git log//show the submitted log--pretty=oneline//Show Brief information--graph//Show Branch Merge details--abbrev-commit//use a short commit and a unique value to displayMore Information--pretty=Oneline shows a brief message this is commit_id, which is different from SVN. SVN is a pure number. But Git is a string after the SHA1. To prevent conflicts between members8. git reset//Fallback Operation--hard head^ fallback to previous version. HEAD is the latest version. Head^ is the previous. head^^ is the last. Of course, if the fallback version more can be written as head~ -of course, you can also write commit_id directly, do not write full. Git automatically retrieves, for example,--Hard B3e4ba--hard effect: from the repository at the same time to cover the suspended area, the work area. If not added only to the suspended area, you need to use checkout from the suspended area to cover the work area9. git revert//undo an operation, the commit will be preserved before and after this operationTen. Git reflog//Show all executed commandsThis command is mainly used when you are not going back after the reset operation. You can view the commit_id and then backtrack . One. Git checkout--file//Use the pause zone to overwrite the workspace, and use the data in the repository to overwrite the suspended area as empty--very important, no--, it becomes the command command "choose a new branch" Git checkout--readme.txt meaning is, the Readme.txt file in the workspace changes are all revoked, here are two cases: one is Readme.txt since the modification has not been put to the pause area, now, undo changes back to the same state as the repository, one is Readme.txt has been added to the temporary After the slow zone has been modified, the undo modification is now returned to the state after it has been added to the suspended zone. Simply put, the git reset function is to overwrite the repository to the suspend area of git checkout to the workspace, if the pause area is empty. Read from the repository and overwrite the workspace directly A. git checkout-b Dev//Switch to the dev branch,This command is equivalent to executing git branch dev git checkout dev-B//Create and switch branches -. git rm test.php//Delete the file. Of course, after the deletion to execute the next git commit, do not need git add-r Delete a folder--cached removed from suspended zone -. Git branch [-d] [branch name]//View all Branches//selected branches are marked with a * number-D//Delete branches, checkout to other branches before deleting them. Cannot be deleted-D//forces the deletion of a branch.-D cannot be deleted if no merge. You can use-D to force delete the. git merge Dev//merges the specified dev branch onto the current branch. Before merging, it's usually checkout to make sure there's no conflict.-M"Merge" //Tips for Merging*********************************************************************************************see the following situation to pay attention to conflict. Don't forget to resolve the conflict.*********************************************************************************************master should be published directly. So there should be no conflict when merging to master, so it is not recommended that multiple people merge master at the same time. You can create a dev (developer) Branch. Use to troubleshoot errors such as code submission conflicts for members. When all issues are ensured to be resolved, merge to Master by the end-privileged administrator********************************************************************************************* -. Git stash//"Store" the current job site . -. git stash List//list all "stored" work sites . -. git stash apply [email protected]{0}//Restore the work site, but after the recovery, stash content is not deleted, you need to use git stash drop to delete +. Git stash pop//Restore the work site and remove the stashStash Application Scenario: When the hand work is not completed. But there is a bug that needs urgent repair. You can store it on the job site. Create a bug branch. Bug fixes, Delete the bug branch. Then the pop resumes the scene to continue to work. The main function is to not create a new folder. You can do a series of actions in the original folder. -. Git remote//View Remote repositories-V//View more informationshows the address of origin that can be crawled and pushed. If you do not have push permissions, you cannot see the address of the push +. Git push Origin Master//Push the local library master branch to the remote libraryappropriate permissions (Git does not support permissions.) But you can use other software to support the permissions function via hooks) Master//administrators from Dev checkout to local confirm that there are no problems after the merge to master. It's best if there's only one person to operate.Dev//All Members commit code (similar to SVN now) and need to be synchronized frequentlybug- on //local bug resolution. You only need to push when the solution is complete. Of course, you only need to push the bug-01 when your dev is half-written. Otherwise, it's usually a merge with Dev and push Devwhether to push the branch. In fact, mainly according to requirements and team agreement A. git checkout-b Dev Origin/dev//Create a dev branch from the Dev branch of the remote library. (to clone the full repository first) at. Git pull//crawls the latest contents of a remote branch with the same name as the current branch. Merge if conflict occurs. When two people modify the file at the same time. You can commit after the merge resolve conflict is modified locally . -. Git pull < remote host name > < remote branch name >:< local branch name >//grasping a fixed branch of a -. Git push origin (remote address) branch-name (local branch name)//push a local branch to the remote library -. GIT push < remote host name > < local branch name >:< Remote Branch name > -. Git push origin (here is a space):d EV//Delete a branch of a remote -. git tag [-a] [-s] [-d] [v1.0] [commit_id] [-M ' explanatory text] [fec145a]//View all tags (not typed in the order they were created.)-S//Use the private key fec145a to sign the tag, signed with PGP signature need to install GnuPG-M//Description-A//specifies a commit_id tag. Usually used with-M. Add descriptive text to a labelV1.0 //Add a new label-D//Delete the specified labelthe created labels are stored locally only and are not automatically pushed to the remote. So, the wrong tag can be safely deleted locally. in. Git show v0.1 //View the details of a note (signature. Description text) -. Git push Origin v1.0 //push specific tags to remote libraries to. Git push Origin--tags//push all tags to remote library +. git push origin:refs/tags/v0.9 //deletes a remote label. (first delete the local. Equivalent to a synchronous operation locally and remotely)
Normal development process: Step git action clone code git clone [EMA Il protected]192.168.56.101:/srv/sample Create Dev branch from remote master into git Checkout–b dev Origin/Master develops no review code in the branch without the first round of functional testing No add code to branch staging area git add somefile commit code to branch git commit-M"comments for this submission"switch to main version git checkout master gets the latest code for the remote master branch Git pull origin Master:master Merge Dev branch to master branch git merge dev resolve conflicts arising from merge when you refer to branch merge conflict resolution No second-round combined test No get remote latest code GIT pull Origin master:master push local master branch to remote Dev branch Git push origin master:dev admin get Dev version and test no admin merge remote Dev branch to remote master branch
1 ) untracked files→ file is not tracked; 2 ) changes to be committed→ file is staged, this is the next commit, 3 ) changes bu not updated→ file was modified, but was not added to the staging area. If the commit is not with-a option, the file in this state will not be submitted. Clone from the master branch of origin on the remote library and create a dev branch. At this point, three commits are committed to the local library. A git push push to the remote library Test.txt file is modified. Git required Add to the hold area. Or you can use checkout– to overwrite the workspace from the local library. Changes cannot be commit because you need to add
first
Ignore rules 1. Create a file in the workspace. Gitignore *windows could not be created. You are prompted to enter a file name. Save As 2 using the editor. For example, to ignore database.php, as long as you add database.php in. Gitignore, Git has a ignore list for most languages, which ignores compilation-generated middleware from https:// Github.com/github/gitignore view and add to. Gitignore
git Getting Started documentation