GIT学习笔记一git init

来源:互联网 发布:生态监测网络 编辑:程序博客网 时间:2024/05/16 17:13

建立裸仓库

git --bare init --shared

--bare:裸仓库
--shared:
--shared[=(false|true|umask|group|all|world|everybody|0xxx)]share 指定为true 时:可以通过配置“core.sharedRepository”来改变$GIT_DIR中目录和文件的访问权限默认的share权限根据umask生成

操作实例:

King@ROYAL /d/gitworkspace/rep$ mkdir test.gitKing@ROYAL /d/gitworkspace/rep$ cd test.gitKing@ROYAL /d/gitworkspace/rep/test.git$ git --bare init --sharedInitialized empty shared Git repository in d:/gitworkspace/rep/test.git/King@ROYAL /d/gitworkspace/rep/test.git (BARE:master)$ lsHEAD  branches/  config  description  hooks/  info/  objects/  refs/King@ROYAL /d/gitworkspace/rep/test.git (BARE:master)$ cd ..King@ROYAL /d/gitworkspace/rep$ lstest.git/
这样我们就建立了一个裸仓库,可以作为远程仓库。
这样项目成员就可以克隆这个仓库,开始项目开发。这可是从零开始。。。
一般情况下项目都不是从零开始,管理员可以将项目已有成功提交到远程仓库,给项目成员克隆。
cd ../worktree
git clone ../rep/test.git
echo "this is h file">test.h
<pre id="best-content-1095419186" class="best-text mb-10" name="code" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 10px; padding: 0px; font-family: arial, 'courier new', courier, 宋体, monospace; background-color: rgb(241, 254, 221);">echo "this is c file">test.c
git add .
git commit -m "init"
git push origin master:TEST_main_branch
这样我们就完成了项目的初始化动作,主分支为TEST_main_branch。
</pre><pre id="best-content-1095419186" class="best-text mb-10" name="code" style="white-space: pre-wrap; word-wrap: break-word; margin-top: 0px; margin-bottom: 10px; padding: 0px; font-family: arial, 'courier new', courier, 宋体, monospace; line-height: 24px; background-color: rgb(241, 254, 221);">git init
使用这个命令创建的仓库不是裸仓库,而是在当前目录下生成.git目录,该目录为仓库;而当前目录为工作空间。


http://blog.csdn.net/laurawan/article/details/38611255

0 0
原创粉丝点击