git初始化git
git初始化有两种模式,一种是git init 这种模式会记录当前库提交的版本以及显示项目文件,一种是git init --bare,称为裸仓库,当前仓库是没法提交的,由于不包含项目文件,只包含版本库,所以这种模式多用于远程仓库的核心仓库(很像SVN中的中央仓库)服务器
若是远程库是一个git init库,则在第一次push到远程库时会提示'receive.denyCurrentBranch' Configuration variable to 'refuse',即拒绝合并到当前分支,需进行以下配置:git config receive.denyCurrentBranch=ignore便可。push成功后,还须要在远程库执行git reset --hard,回滚到最新的提交历史才能够显示最新的提交spa
因此强烈建议先使用git init --bare设置个中央远程库,再从中央远程库拉取ci
还有就是push失败颇有多是权限问题,git用户没有建立目录的权限,因此须要在服务器上受权,要么修改拥有者或组,要么修改权限rem
问题:git push或git pull的时出现以下错误:it
$ git push
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push origin HEAD:<name-of-remote-branch>io
说明:根据上面的提示,直接git push origin master实际并不能解决问题ast
或配置
$ git pull
You are not currently on a branch, so I cannot use any
'branch.<branchname>.merge' in your configuration file.
Please specify which remote branch you want to use on the command
line and try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.file
解决方案:
第一步:git checkout -b temp 切换到一个临时的分支
第二步:git checkout master 再切换回主分支
就能够恢复到master repository的状态,而后就能够push和pull了