在使用Git初始化版本库的时候,使用"git init"命令和使用"git init --bare"命令有什么区别呢?
用"git init"初始化的版本库(暂且称之为working repository)将会生成2类文件:“.git“版本库目录(记录版本历史)和实际项目文件的拷贝。你可以把这类版本库叫做“工作目录”。工作目录是一个包含有版本历史目录“.git"和源文件的目录。你可以在工作目录修改你的源文件并使用"git add"和"git commit"命令进行版本管理。
用“git init --bare"初始化的版本库(暂且称之为bare repository)仅包含".git"目录(记录版本历史),不含项目源文件拷贝。如果你进入版本目录,你会发现仅有".git"目录,没有其他文件。版本库仅包含记录着版本历史的文件。
什么情况下使用“git init"和"git init --bare"呢?
working repository适合于实际编辑生产过程中,在工作目录下,你将会进行实际的编码、文件管理操作和保存项目在本地工作。如果你开始创建一个项目将包含有源代码和和版本跟踪记录的时候你可以使用"git init".或者,如果你克隆"git clone"一个已经存在的版本库的时候,你也可以得到一个working repository,它也将包含".git"目录和源文件的拷贝。
bare repository主要是用作分享版本库。开发者使用bare repository可以向其他人分享存储在本地的版本库,以便于实时分享代码更新和团队协作 。通过使用"git push"命令,你可以将你的本地更新提交至“中心版本库”(其他开发者可访问的中心库)。其他开发者可以使用“git pull"命令者接受你提交的版本更新。如果你正在一个多人协作的项目团队或者同一个项目需要在不同电脑上面完成的时候,bare repository可以满足你的分布式开发需求。
总结:“工作目录”是通过使用“git init“或“git clone”创建的本地项目拷贝。我们可以在工作目录下面修改和测试代码。通过测试后我们可以使用“git add“和”git commit“命令本地提交修改,然后使用“git push”命令向远程 bare repository库提交更新,通常bare repository指定其他服务器,其他开发者将可以及时看到你的更新。当我们想去更新本地工作目录的时候,我们可以使用“git pull”命令去接受其他开发者提交的更新。
原文:what is a bare git repository? http://www.saintsjd.com/2011/01/what-is-a-bare-git-repository/
译By: 直来直往 http://hi.baidu.com/aboutstudy/blog/item/8cec7226e3c101098a82a1c6.html
分享到:
相关推荐
Git-2.21.0-64 for windows Git 2.23 Release Notes ====================== Updates since v2.22 ------------------- Backward compatibility note * The "--base" option of "format-patch" computed the ...
$ git clone --bare https://github.com/user/repo.git $ cd /tmp/repo.git 下载 您可以在发行页面上下载与您的平台匹配的应用程序。 安装 将可执行文件放置在您的Git存储库中。 最好将其放在PATH以便可以在系统中...
”git init –-bare”方法创建一个所谓的裸仓库,之所以叫裸仓库是因为这个仓库只保存git历史提交的版本信息,而不允许用户在上面进行各种git操作 git config --global $ git config --global user.name author #...
git-copy 用于将远程/本地 git repo 复制到另一个远程/本地目标的 Git 插件...git 服务器 git init --bare git-copy.gitgit copy https://github.com/cybertk/git-copy.git $PWD/git-copy.git贡献任何贡献都更受欢迎!
git-lfs-rewrite ... 将存储库解压为松散文件:在 msysgit bash shell 中: $ mkdir 松散仓库$ cd 松散回购$ git init --bare $ for P in $(find <path> -name '*.pack'); 做 git unpack-objects < "$P"; 完毕
CoreOS 初始化工具 - 原始级别git-init 为裸 git 创建一个目标存储库,如果 git 有新的提交,您可以注册一个 shell 命令以从 git 的post-receive事件中获取事件。 git-init [TARGET_REPO_PATH] [POST_RECEIVE_EVENT_...
1.检查git是否安装 终端下输入”git”,查看提示: usage: git [--version] [--... [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare] [--git-dir=] [--work-tree=] [--namespace=] [] 2.安装git
nginx 提供)的地方 mkdir -p ~/www/versions这是日志将去的地方: mkdir -p ~/log设置部署分支 cd ~/deploy/example.comgit init --bare将 post-receive hook 复制到 repo cp ~/projects/git-deploy-node/p
git submodule add https://github.com/orf/bare-hugo-theme.git themes/bare # This is required: git submodule update --init --recursive 如果使用Netlify,请将以下内容添加到您的netlify.toml文件中: [ ...
从git git clone https://aur.archlinux.org/yay.git make pkg cd yay && makepkg -si 创建“ git --bare”存储库: 将dotfile克隆到“裸”存储库中$ git clone --bare https://github.com/kokoteen/arch-bspwm.git...
GitPython 是一个 Python 库用来和 Git 资料库进行交互,提供各种级别的操作,例如高级的 git-...repo = Repo.init("/var/git/git-python.git", bare=True) assert repo.bare == True 标签:GitPython
- possible internal error related to bare repositories - Index Editor: did not show a warning if a file could not be saved, e.g. because it was locked by another application - i18n: variable text ...
克隆 repo: git clone https://github.com/payne92/bare-metal-arm.git 抓取并解压 GCC ARM 工具链: 在 Ubuntu 上: sudo apt-get install gcc-arm-none-eabi 在 Mac 和 Linux 上: cd bare-metal-arm; make ...
textlint-rule-no-dropping-i这是一个检测丢失单词的... 创建功能分支: git checkout -b my-new-feature 提交更改: git commit -am 'Add some feature' 推送到分支: git push origin my-new-feature 提交请求请求:
转到在您的帐户下创建一个新的仓库。 选择一个名称(例如private-bustub ),并确保将其选择为private 。 在您的开发机器上,克隆公共BusTub: $ git clone --depth 1 https://github.com/cmu-db/bustub.git ...
安装为了让它工作,在你的远程服务器上创建一个裸仓库,并将post-receive hook 脚本放在它的 hooks 目录中: $ git init --bare ~ /project.git$ curl -L -o ~ /project.git/hooks/post-receive ...
git init --bare 库名称 2. 在用户文件夹下把资源clone下来 git clone <仓库目录> /g/software/repository/git/itheima <用户目录> . 注意:clone时候用户目录必须为空 3. 创建一个文件,纳入到版本控制中。 ...
使用Node.js和Express构建网站 该存储库包含上我的课程...git config --bool core.bare false git reset --hard git branch 其他所有内容都将在我的课程中讨论。 Usobásico const express = require ( 'express' ) ;
跑步git clone --bare git@github.com:danielkhan/building-website-nodejs-express.git .gitgit config --bool core.bare falsegit reset --hardgit branch 其他所有内容都将在我的课程中讨论。
git init --bare $HOME /.cfg alias cfg= ' git --git-dir=$HOME/.cfg/ --work-tree=$HOME ' cfg remote add origin git@github.com:HongLong40/cfg.git 克隆到另一个系统 git clone --bare ...