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是分布式版本控制系统,那么它就没有中央服务器的,每个人的电脑就是一个完整的版本库,这样,工作的时候就不 需要联网了,因为版本都是在自己的电脑上.既然每个人的电脑都有一个完整的版本库,那多个人如何 ...
随机推荐
- selenium webdriver API详解(一)
本系列主要讲解webdriver常用的API使用方法(注意:使用前请确认环境是否安装成功,浏览器驱动是否与谷歌浏览器版本对应) 一:打开某个网址:get() from selenium import ...
- JMeter怎样测试WebSocket
一.安装WebSocket取样器 1.从JMeter插件管理器官网下载: https://jmeter-plugins.org/ 把这6个jar包放到C:\JMeter\apache-jmeter-3 ...
- hession矩阵的计算与在图像中的应用
参考的一篇博客,文章地址:https://blog.csdn.net/lwzkiller/article/details/55050275 Hessian Matrix,它有着广泛的应用,如在牛顿方法 ...
- [转]50 Tips for Working with Unity (Best Practices)
About these tips These tips are not all applicable to every project. They are based on my experience ...
- Struts2(一.基本介绍,环境搭建及需求分析)
Struts2框架开发 前言 开发工具:eclipse struts1:老项目使用较多,维护时需要用到 struts2:新项目使用较多 一.特点 1. 无侵入式设计 struts2 与 struts ...
- 附加题程序找bug
private: void Resize(int sz){ ){ return; } if(maxSize != sz){ T *arr = new T[sz]; if(arr == NULL){ r ...
- 软工1816 · BETA 版冲刺前准备
任务博客 组长博客 总的来讲Alpha阶段我们计划中的工作是如期完成的.不过由于这样那样的原因,前后端各个任务完成度不算非常高,距离完成一个真正好用.完美的软件还有所差距. 过去存在的问题 测试工作未 ...
- Kafka集群无法外网访问问题解决攻略
Kafka无法集群外网访问问题解决方法 讲解本地消费者和生产者无法使用远程Kafka服务器的处理办法 服务搭建好Kafka服务后,机本.测试 OK,外面机器却无法访问,很是怪异. 环境说明: Ka ...
- elementUI使用本地变量进行验证,监测不到本地变量的变化 的问题
对于饿了么组件自定义验证规则,组件库文档已经非常详细了:http://element-cn.eleme.io/#/zh-CN/component/form 我这里将验证中固定的值提取出来使用变量进行保 ...
- php奇葩错误:htmlspecialchars处理中文丢失
$value = "中文中文"; $res = htmlspecialchars($value); 经过这个函数处理之后,$res就直接变成了空的字符串. 奇葩错误啊!后来发现要这 ...