Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1695759
  • 博文数量: 584
  • 博客积分: 13857
  • 博客等级: 上将
  • 技术积分: 11883
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-16 09:34

分类: WINDOWS

2011-04-06 09:23:33

Git 的使用
2011-01-28 10:36

折腾了很久,也没有征服git这个东东,摸索了一点经验,记下,防止下一次找不到:

创建一个新的git 的 repository的步骤:

1,mkdir new

2, cd new

3, git init

4, git remote add origin tinderbox:/git/new (这步很重要 建立远程仓库)

5, 就是这样之后,在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 t

remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int

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 som

remote: error: other way.

remote: error:

remote: error: To squelch this message and still keep the default behaviour, se

remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

To tinderbox:/git/newnightly

 ! [remote rejected] master -> master (branch is currently checked out)

error: failed to push some refs to 'tinderbox:/git/newnightly'

研究了很久不得其解,然后找到一条命令凑合着能用了:
登录到远程的那个文件夹,使用
git config --bool core.bare true

就搞定了。

 

贴一段参考文章:

Create a bare GIT repository

A small rant: git is unable to create a normal bare repository by itself. Stupid git indeed.

To be precise, it is not possible to clone empty repositories. So an empty repository is a useless repository. Indeed, you normally create an empty repository and immediately fill it:

git init git add .

However, git add is not possible when you create a bare repository:

git --bare init git add .

gives an error "fatal: This operation must be run in a work tree".

You can't check it out either:

Initialized empty Git repository in /home/user/myrepos/.git/ fatal: not found: did you run git update-server-info on the server? git --bare init git update-server-info # this creates the info/refs file chown -R : . # make sure others can update the repository

The solution is to create another repository elsewhere, add a file in that repository and, push it to the bare repository.

mkdir temp; cd temp git init touch .gitignore git add .gitignore git commit -m "Initial commit" git push master cd ..; rm -rf temp
阅读(1242) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~