Why git is called a distributed source control system?

前端 未结 5 835
猫巷女王i
猫巷女王i 2021-02-15 23:23

It seems after committing code to the local repository, every programmer will run the command.

git push origin master

to push the local file to

5条回答
  •  無奈伤痛
    2021-02-16 00:23

    Tools such as CVS and SVN offer a centralised repository model. Everybody commits their changes to the same central repository. Each committer keeps a copy of the latest version of the central repository. When they commit changes they send that change back to the main repository.

    The limitations here are that you always need to have the latest code on your local repository, and to see the history of changes you will need to ask the server for that information. You also always need to be able to access the remote repository to commit.

    A distributed SCN can emulate this model, but it offers so much more. Instead of just having one central repository that you send changes to, every committer has their own repository that has the entire commit history of the project. You don't need to connect to a remote repository, the change is just recorded on your local repository. You can still push to a centralised repository but you don't need to.

    (Source: Pragmatic Version Control using Git by Travis Swicegood)

    One big benefit of this is that you can start a repository at any time on your local computer. Generally when ever I start a new project I'll git init and start committing updates straight away. Later on if I decide I want to share this project with another developer I can easily set up a centralised repository that we can both access. Or it might never leave my computer but I'll have local version control in place and can easily view my commit history.

    Another big benefit (perhaps less so with cloud computing now) is redundancy. If one copy of the repository is lost for whatever reason, any of the other repositories will contain the complete history so you could only potentially lose any work since your last push.

    There's some more information on Wikipedia: Distributed revision control

    I'd also highly recommend the above mentioned Pragmatic Programmers book on Git.

提交回复
热议问题