Git init --bare - 不工作在工作树上 [英] Git init --bare - Not Working on working tree

查看:130
本文介绍了Git init --bare - 不工作在工作树上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在此处查看示例
http://wiki.dreamhost.com/Git

基本上我想创建一个git仓库,我可以从桌面上推到服务器上...
在主机上:

  [host〜] $ mkdir project.git 
[host〜] $ cd project.git
[host project.git] $ git init --bare
[host project.git] $ exit

然后在本地:

  [local〜] $ cd project 
[local project] $ git init
[local project] $ touch .gitignore
[local project] $ git add。
[local project] $ git commit

我显示了以下文件(通常位于.git目录中)

  HEAD分支配置描述挂钩信息对象引用

在本地创建一个远程推送:
git remote add origin ssh:// XXX @ XXX / home / XXX / XXX /
推送说它已经工作了......

 计数对象:3,完成。 
写入对象:100%(3/3),210字节,完成。
总计3(delta 0),重用0(delta 0)

然而,当我走回到服务器上的工作文件夹,这里没有任何东西......它只是上面列出的.git文件。



我之前完成了这个工作,并且这样工作......这一次我必须做错事。



更新



如果我尝试在服务器上创建不带-bare的回购库,那么我在推送时遇到这个错误

  remote :错误:拒绝更新签出分支:refs / heads / master 
remote:error:默认情况下,更新非裸仓库中的当前分支
remote:error:被拒绝,因为它会使索引和工作树不一致
remote:错误:用你推送的内容,并且需要'git reset --hard'来匹配
remote:error:工作树到HEAD。
remote:错误:
remote:错误:您可以在远程存储库中将'receive.denyCurrentBranch'配置变量设置为
remote:error:'ignore'或'warn',以允许推入
remote:错误:当前分支;然而,除非你
remote:error:安排它更新它的工作树来匹配你在
remote:error:other方面推送的内容,否则不建议这样做。
remote:error:
remote:error:为了压制此消息并保持默认行为,请将
remote:error:'receive.denyCurrentBranch'配置变量设置为'拒绝'。

更新和解决方案....



我发现这个效果很好
http://toroid.org/ams/git -bbb-howto



基本上使用--bare然后有一个钩子将你的最新提交复制到工作目录!
git init --bare 创建一个裸的仓库 - 一个没有工作目录的仓库与之相关联。你所看到的是预期的。如果您希望单独的存储库具有与其关联的检出工作目录,请不要使用 - bare 选项,但请注意,这样做会产生额外的影响,因为 当远程不是裸存储库时,git push 会有不同的作用,以保护您不会丢失您在远程中可能存在的未分配/未提交的更改。 b $ b

I am following the examples here http://wiki.dreamhost.com/Git

Basically I want to create a git repo i can push to on a server from my desktop... On host:

[host ~]$ mkdir project.git
[host ~]$ cd project.git
[host project.git]$ git init --bare
[host project.git]$ exit

Then locally:

[local ~]$ cd project
[local project]$ git init
[local project]$ touch .gitignore
[local project]$ git add .
[local project]$ git commit

On host if i CD into the directory.. I am shown the following files (which usually sit in the .git dir)

HEAD  branches  config  description  hooks  info  objects  refs

On local I then create a remote push: git remote add origin ssh://XXX@XXX/home/XXX/XXX/ It pushes says it has worked...

Counting objects: 3, done.
Writing objects: 100% (3/3), 210 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)

However when I go back to the working folder on the server, there is nothing there.. it is just the .git files listed above.

I have done this before and it worked this way... just this time I must be doing something wrong.

UPDATE

If I try to create the repo on the server without --bare ... then I get this error on push

remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

UPDATE AND RESOLUTION....

I found this which works really well http://toroid.org/ams/git-website-howto

Essentially use a --bare then have hook which copies your latest commit to a working directory!

解决方案

git init --bare creates a "bare" repository - one that does not have a working directory associated with it. What you are seeing is what is expected. If you want a separate repository that has a checked out working directory associated with it, don't use the --bare option, but note that doing so has additional implications, because git push acts differently when the remote is not a bare repository, in order to protect you from losing any unstaged/uncommitted changes you may have in the remote.

这篇关于Git init --bare - 不工作在工作树上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆