创建带工作区的版本库
在开始一个新项目时,首先就要创建并初始化代码库。如果是在本机的工作目录中,那么:
$ git init
也就够用了。如果想要初始化的版本库不在当前目录,需要为 git init 命令指定版本库所在的目录:
$ git init hello
执行完命令,在当前目录或您指定的目录下会创建一个名为 .git 的目录,这就是版本库了。
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQMAAAC1CAIAAADUVw1AAAATXklEQVR4nO3dy3PTSB7Acf8F3Klibhz4G7hx5cR9LjnNH8CBM8e5UMWRKo7DfzAZdlk2wzAwEEh4JOzM7vAI4eEktvVqdatb6pbUe2hblmRJlmMbt6zft1RTDHGCSvTH3S07oSO1yTx3vtHHqq8fNFedVZ/AuJUPZZDQ5kACSICk1FPCqk9kthp62lCuzt/alAypVZ/IbDX0tKFcMCfMW0NPG8oFEuatoacN5QIJ89bQ04ZygYR5a+hpQ7kaLMEwjAsXLuzt7dV8WM3HzxpIWI+mS1jSAJoMJEArTEcJ9+7dC8NwUScGEqA6darHnGEYZ8+e7XQ6nU5nY2NDSrm3t3fmzJlOp3P27FnDMNTw+umnn9Rvbm5u3rhxQz3+xo0bcjQQkweo3ywsGVLXr1+/c+fOVAxlX7nwDHMSkseoc571qhWe9jxfBFp5naljLj2A0r9Wg15RuXTpEqV0c3MzGZGbm5vJQEwesLe3991335U9KydD6s6dO3Uw5P7o3LhPn2FOgvpEBaD6lOoEEtajzvXr1x8+fFjxiLKnUjVLlDkpW5NsbGyUPQcnQyoIgh9//HGmE0t+XXGG6cdcuHDBMIypp1QnkLAezTYn5MaQLJ8xCiVQSi9dujRVQv05oVBC2RmCBKiiKfsEOTHgzp49m17r15GQfMrkME13un1CxR+Xe1jZ6qjilOoEEtajWq8nbGxsTO6YZ1odff/991O3p/PcOypbwhWujtKPOXPmzJx3k0DCerT0V9bq37ts6JBq6GlDuUDCvDX0tKFcIGHeGnraUK4Gv+9Ikxp62lAukDBvDT1tKBdImLeGnjaUCyTMW0NPG8ql43f0N/RY9fWD5krHOaGhx6q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4zG+bubFzsZCRLmBCjdWkt4d/PieKhPAgAJ0DiQsILzUoEErVpLCemxDqsjqFbrLUFZKNwxpz4IO2ZoTSUU9e7mxVUN+ZJ0uTKQlLI9Eu7+0NHjleVxmlwZSLXeEkavJqxwDVQeSNCq9ZagdXBltAokrCy4MloFElYWXBmtAgkrC66MVoGElQVXRqtAwsqCK6NVIGFlwZXRqm8nAY6yY+6/RGgBgYTVH3P/JUILCCSs/pj7LxFaQEuXAEGNCCRAkJQgAYJUIAGCpAQJEKQCCRAkJUiAIBVIgCApQQIEqUACBEkJEiBIBRIgSEqQAEEqkABBUoIECFKBBAiSEiRAkAokQJCUIAGCVP8HB5ezf2QXWFQAAAAASUVORK5CYII=" alt="" />
带工作区的版本库主要用于日常工作。其工作模式为:先把代码提交到本地的版本库中,然后通过本地库推送到服务器上的版本库中。
创建裸版本库
相对于带工作区的版本库,裸版本库主要存在于服务器上,作为集中式的版本仓库存在。因为没有人会在服务器上修改代码并提交,所以这类版本库不需要工作区。当然其创建方式也略微不同与带工作区的版本库。
$ git init --bare
选项 --bare 用于创建裸版本库,打开当前目录您会看到 git 创建了一些目录和文件。
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAADoCAIAAADALa66AAAP/klEQVR4nO3dTU8b1x7H8XkF2SOlOxZ5Dd5lcUlCfBXu7lbdeFNvrpQF0mWBFIXmqSTBjZO2KYSGhEBRpOxaZLVCCCVN2/SBpqhKpQgF6appIGCaAKof8NBzF2PP8/gB+2Tm2N+PLETmwcxY88s5c5jzRxMApNHCPgCgnREwQKKoB2zzYHenvcL+yNFKBCxyr7A/crQSAYvcK+yPHK2kPY0287IL+0Ck65wz7SjKtGBhH4h0nXOmHYWARUXnnGlHIWBR0Tln2lEIWFR0zpl2lLYKWDabPXTo0NLSUp2b1bm9r6Wlpbfeemt/+/oiYG1pPwFr5rpsVGQD1ugPrYmAtSUrYLlc7quvvtJ1veY+oQSshQcWSsBqfrwErC1ZAfvyyy+Hhoamp6erX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CJggEQUvQEkougNIBFFbwCJKHoDSKRo0ZsWzS6pvwAOpXKwL4oWvXkz07eYJIZmKVr0hoBBDUoVvfGtUeMuhOMpjONekklqsWQypmnJjGvCWMZ8f0epHPcfWa+r0g4ghFJFb3wnIDtmT8bSy2blgAr/edC2GZe2UjnGt476OdXmQdeqtAOoVfTGW0LDPuPEuMRds/99ZlLWnPJctbxHA4VAALWK3vgHzKe5MHKXzOwvYOY+BAzNUqjoTVAX0f9yruTRt4vo3/ErL61dP6fOSjuAWkVvfGvUuOYle+rieErlBLZgyWTMf8/AQY7qlXYAit6UkQpIQdEbAwGDFJ1c9MaOgEEKJlwCEhEwQCICBkhEwACJCBggEUVvAIkoegNIRNEbQCKK3gASKVT0xvuwhXO6pN9fIvLMfnRsybMbkE2hojfVA+YXluV0LJZMxuyrXI+9M/kYcilU9KbhgBlTwhwTNV1b8pdjIZlCRW8aDZhtyqV3KrS1DQmDRIoVvfHw3oPZaklZU5SDZkMSMMilTtGbBlswe6psMfIGjJEOSKRO0ZvGAuZt7rzFM2jAIJ1aRW/qDph7QVChKOIFuRQqelPv78Fi6WXvppWE2bekcwjpKHoDSETRG0Aiit4AEjHhEpCIgAESETBAIgIGSETAAIkIGCARAQMkImCARAQMkIiAARIRMEAiAgZIRMAAiQgYIBEBAyQiYIBEBAyQiIABEhEwQCICBkhEwACJCBgg0f8BeFjbbyqbvjoAAAAASUVORK5CYII=" alt="" />
为了方便查看,一般会把裸版本库的目录名称中加上 .git 后缀:
$ git init –bare hello.git
这样无论是看起来还是使用起来都清晰了很多。
使用已有库初始化裸版本库
由于裸版本库没有工作区,所以无法直接把代码提交到裸版本库中。通用的做法是先克隆裸版本库,在本地库中提交,然后推送到裸版本库中。
那么,如何用已有的库去初始化裸版本库呢?
条条大道通罗马,我们可以通过不同的方式来实现。
方法 1,从现有库克隆出来一个裸版本库:
$ git clone –bare hello hellobare.git
用 git log 命令查看版本库 hellobare.git,它的历史记录和版本库 hello 是一样的。
方法 2,把已有库推送到裸版本库:
$ git push –all hellobare2.git
用 git log 命令查看 hellobare2.git 库,它的历史记录和版本库 hello 也是一样的。