git使用经验(一)
在使用Git Push代码到数据仓库时,提示如下错误:
[remote rejected] master -> master (branch is currently checked out)
错误原型
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'.
To git@192.168.1.X:/var/git.server/.../web
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'git@192.168.1.X:/var/git.server/.../web'
解决办法:
这是由于git默认拒绝了push操作,需要进行设置,修改.git/config文件后面添加如下代码:
[receive]
denyCurrentBranch = ignore
无法查看push后的git中文件的原因与解决方法
在初始化远程仓库时最好使用
git --bare init
而不要使用:git init
git init 和git --bare init 的具体区别:http://blog.haohtml.com/archives/12265
=================================================
如果使用了git init初始化,则远程仓库的目录下,也包含work tree,当本地仓库向远程仓库push时, 如果远程仓库正在push的分支上(如果当时不在push的分支,就没有问题), 那么push后的结果不会反应在work tree上, 也即在远程仓库的目录下对应的文件还是之前的内容。
解决方法:
必须得使用命令 git reset --hard 才能看到push后的内容.
研究了很久不得其解,然后找到一条命令凑合着能用了:
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: http://repository.example.org/projects/myrepos.git/info/refs 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 <user>:<group> . # 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 <url or path of bare repository> master cd ..; rm -rf temp
git使用经验(一)的更多相关文章
- Git使用经验小结
2012春,开始正式使用SVN,2014年9月加入一起好后,开始使用Git. 有了一些使用经验,也看了下网上关于"Git全胜SVN"的言论. 结合自己的实际情况,简要写几句: 1 ...
- git使用经验
一直想写一点关于git的文章,但是平时太懒了,没有写,现在写些经验这里,方便以后自己忘记了.
- [Tips] Git使用经验
brach 查看目前branch git branch 显示结果: * master *表示这是当前的branch. 建立分支 git branch 分支名 删除分支 git branch -d 分支 ...
- git使用经验for windows
一.本地同步fork的最新版本 二.git命令 一.本地同步fork的最新版本 ①打开Git CMD工具,进入git的主目录 ②使用 git remote -v 查看fork的远程仓库地址 origi ...
- git 使用经验与技巧总结 (不断更新中)
git 使用技巧总结 说明: 本地repo已经有啦,对应的远程repo 为tiger, 本地分支为master. 问题一: 当拉取代码的remote repo仓库为tiger, 而现在要将修 ...
- Git详解之三 Git分支
相关文档 — 更多 Git 基础培训.ppt GIT 使用经验.ppt GIT 介绍.pptx GIT 分支管理是一门艺术.docx Eclipse上GIT插件EGIT使用手册.docx git/gi ...
- GIT 这么好用,为什么还是有人不知道怎么用它提交代码?
客户端代码管理工具的变迁: 从 SVN 到 GIT 截止目前,新版的 APICloud Studio 2 仍然处于公测期.APICloud Studio 2 的代码管理客户端,由 SVN 改为了 GI ...
- git summary
Git 使用经验 缘起 一直想写一篇博文,记录我在使用git时遇到的问题以及解决办法.由于项目忙,偶尔的记录不连续,不成系统.今天有时间记录下来,方便自己以后查看. git 简介及其优势 简单来说,g ...
- git安装使用详解
Git是分布式版本控制系统,那么它就没有中央服务器的,每个人的电脑就是一个完整的版本库,这样,工作的时候就不 需要联网了,因为版本都是在自己的电脑上.既然每个人的电脑都有一个完整的版本库,那多个人如何 ...
随机推荐
- loadrunner-录制脚本,设置代理,参数化,校验点,关联
详细记录一个脚本制作过程相关知识点 制作脚本 因为要做网页所以选择web协议,根据实际需要选择 选择浏览器地址,打开的网页网址,脚本存储地址以及初始化脚本,初始化脚本的目的是执行用例后不再执行此脚本中 ...
- 优化 VR 动作类游戏《Space Pirate Trainer*》以便在英特尔® 集成显卡上实现卓越的表现
Space Pirate Trainer* 是一款面向 HTC Vive*.Oculus Touch* 和 Windows Mixed Reality* 的原创发行游戏.版本 1.0 于 2017 年 ...
- python学习笔记01 --------------hello world 与变量。
1.第一个程序: print('hello world') 输出结果: hello world 2.变量 2.1 变量的作用: 把程序运算的中间结果临时存到内存里,以备后面的代码继续调用. 2.2 变 ...
- Fast R-CNN学习总结
Fast R-CNN是R-CNN的改良版,同时也吸取了SPP-net中的方法.在此做一下总结. 论文中讲到在训练阶段,训练一个深度目标检测网络(VGG16),训练速度要比R-CNN快9倍左右,比SPP ...
- 《Learning scikit-learn Machine Learning in Python》chapter1
前言 由于实验原因,准备入坑 python 机器学习,而 python 机器学习常用的包就是 scikit-learn ,准备先了解一下这个工具.在这里搜了有 scikit-learn 关键字的书,找 ...
- Thunder团队——bug修正
团队:欢迎来怼 发现的问题: 1.首先用户通过爱阅APP内部的网址跳转到各大电子书网站时,需要额外启动手机自身浏览器:就以豆瓣网为例,阅读豆瓣网上的一些书籍,是跳转到手机自带浏览器的,APP内部提供的 ...
- 《linux内核分析》 第二周
20135130 王川东 计算机三个“法宝”:存储程序计算机.函数调用堆栈和中断机制 深入理解函数调用堆栈: 堆栈是C语言运行时必须的一个记录调用路径和参数的空间: 作用包括: 函数调用框架: 保存参 ...
- c++团队作业工作笔记
这周时间还比较充裕,所以就有较多的时间来投入团队作业之中. emmmm,由于组长那边感觉完全没动,于是我完成了选英雄的UI界面,到时候给button加上信号就没什么问题. 虽然界面比较简单,但是还是花 ...
- 线段树-hdu2795 Billboard(贴海报)
hdu2795 Billboard 题意:h*w的木板,放进一些1*L的物品,求每次放空间能容纳且最上边的位子 思路:每次找到最大值的位子,然后减去L 线段树功能:query:区间求最大值的位子(直接 ...
- 博弈---ZOJ 2083 Win the Game(染绳子)
原题:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2083 大意:两个人分别对n条绳子染 每次染m长 最后染不下的输,问先 ...