创建带工作区的版本库

在开始一个新项目时,首先就要创建并初始化代码库。如果是在本机的工作目录中,那么:

$ 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 也是一样的。

Git 初始化版本库的更多相关文章

  1. 关于git远程版本库的一些问题之解决

    Part1:CentOS6.5免密码登录 修改/etc/ssh/sshd_config RSAAuthentication yesPubkeyAuthentication yesAuthorizedK ...

  2. git学习(一):git的版本库在哪儿

    查看版本 git --version # 查看git的版本 设置或者查看用户名和邮箱 git config --global user.name "tuhooo" // 如果后面没 ...

  3. 使用GitHub(二):配置并使用Git创建版本库

    使用GitHub(二):配置并使用Git创建版本库 本文简单介绍使用GitHub对代码进行版本控制,包括添加SSHkey.配置Git.使用Git创建版本库并在GitHub上进行管理,主要目的是对学习内 ...

  4. Git:版本库建立与状态查看

    版本库又名仓库,英文名repository,可以简单理解成一个目录,这个目录里面的所有文件都可以被Git管理起来,每个文件的修改.删除,Git都能跟踪,以便任何时刻都可以追踪历史,或者在将来某个时刻可 ...

  5. git创建版本库 小白操作 (看图)

    1.什么都没记住,各种试 pwd   --查看当前路径 cd /e   --进入E盘 mkdir test  --在E盘下创建test空文件夹 git init   -- 初始化,编程git可以管理的 ...

  6. Git 学习(三)Git 创建版本库

    获取 Git 仓库 什么是 Git 仓库呢,仓库又名版本库,我们可以把他理解为一个文件夹.这个文件夹里的所有东西都需要被 Git 给管理起来,对立面每个文件的修改.编辑.删除都将被 Git 记录,以便 ...

  7. git 远程版本库,github提供服务原理,git自动更新发送邮件

    1.安装好Linux,安装好Git(192.168.1.239) 2.创建一个用户zph(让此用户提供git on server),密码设置为12345678 # useradd zph # pass ...

  8. git 创建版本库

    服务器安装后git后 1.在repositories仓库文件夹中执行git init aa.git --bare  创建aa的中心库(注意建立aa版本库时当前登录用户必须为git的相关用户,并保证/d ...

  9. git 远程版本库

    [root@localhost workspace]# cd repos/ [root@localhost repos]# ll 总用量 drwxr-xr-x root root 12月 : hell ...

随机推荐

  1. 【转】ubuntu下最好用的输入法fcitx-sunpinyin

      http://www.freetstar.com/index.php/ubuntu-most-use-friendly-fcitx-sunpinyin 今天难得折腾一会儿输入法,对于系统美化方面的 ...

  2. Information Management Policy(信息管理策略)的使用范例

    基础知识 很多人都会定期收拾自己的书架或者抽屉,把里面过旧的资料拿走,为新的资料腾出空间来,这样既可以节省空间,而且当冗余资料过多的时候也会降低你查找的速度和效率.那么,在企业的SharePoint中 ...

  3. 剑指Offer面试题:8.斐波那契数列

    一.题目:斐波那契数列 题目:写一个函数,输入n,求斐波那契(Fibonacci)数列的第n项.斐波那契数列的定义如下: 二.效率很低的解法 很多C/C++/C#/Java语言教科书在讲述递归函数的时 ...

  4. 前端展望:取avalon,弃angular

    打给比方,如果说angularJS是剑,那么avalon就是匕首.匕首比剑更易学,更快,更适合快速作战... 我们还是直接来实际的吧:   目前项目开发中有以下几个通用需求: 有前端路由系统,用来划分 ...

  5. Android什么时候进行View中Background的加载

    对大多数Android的开发者来说,最经常的操作莫过于对界面进行布局,View中背景图片的加载是最经常做的.但是我们很少关注这个过程,这篇文章主要解析view中背景图片加载的流程.了解view中背景图 ...

  6. 从零3D基础入门XNA 4.0(1)——3D开发基础

    [题外话] 最近要做一个3D动画演示的程序,由于比较熟悉C#语言,再加上XNA对模型的支持比较好,故选择了XNA平台.不过从网上找到很多XNA的入门文章,发现大都需要一些3D基础,而我之前并没有接触过 ...

  7. ASP.NET Web API中的Controller

    虽然通过Visual Studio向导在ASP.NET Web API项目中创建的 Controller类型默认派生与抽象类型ApiController,但是ASP.NET Web API框架本身只要 ...

  8. Chrome开发者工具不完全指南(二、进阶篇)

    上篇向大家介绍完了基础功能篇,这次分享的是Chrome开发工具中最有用的面板Sources.  Sources面板几乎是我最常用到的Chrome功能面板,也是在我看来决解一般问题的主要功能面板.通常只 ...

  9. python基础总结篇——使用Mysql

    python操作Mysql,很方便,使用的MySQLdb的库,基本的操作如下: 查询: try: conn = MySQLdb.connect(host=self.ip, user=self.user ...

  10. 【深入浅出Linux网络编程】 “基础 -- 事件触发机制”

    回顾一下“"开篇 -- 知其然,知其所以然"”中的两段代码,第一段虽然只使用1个线程但却也只能处理一个socket,第二段虽然能处理成百上千个socket但却需要创建同等数量的线程 ...