全部博文(584)
分类: WINDOWS
2011-04-06 09:23:33
折腾了很久,也没有征服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'
就搞定了。
贴一段参考文章:
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 -RThe 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