需要Git安装(远程和本地回购)建议 [英] Git Setup (remote and local repo) advice needed

查看:130
本文介绍了需要Git安装(远程和本地回购)建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我买了一个个人开发盒,我将用它来部署笔记本上创建的东西。我认为使用Git进行代码管理是一个好主意。这个想法是,我会继续在我的笔记本电脑上提交,并在需要时将更改推送到远程开发盒。


  1. 我在盒子上初始化了一个Git仓库,并在我的笔记本电脑上克隆了

  2. 但是在做 git push 之后,我得到这个错误:

    remote:错误:拒绝更新签出分支:refs / heads / master
    remote:error:默认情况下,更新非裸仓库中的当前分支
    remote:error:被拒绝,因为它会使索引和工作树不一致
    remote:错误:您推送的内容,并且需要'git reset --hard'匹配


我知道远程仓库不是空的。



我想问一问,的设置是:
$ b


  1. 在服务器上初始化裸回购

  2. 在我的笔记本电脑上克隆它
  3. li>
  4. 将新文件添加到本地笔记本电脑回购站并提交文件

  5. 推送到远程开发盒回购站

即使这种设置也会给我带来错误:

  ;什么也不做。 
也许你应该指定一个分支,比如'master'。
致命:远程终端意外挂起






<编辑



我试过了

  git push origin master 

出现此错误:

 错误:无法为.git / refs / remotes / origin / master创建目录
错误:无法锁定ref'refs / remotes / origin / master'。






哦,认为它是 sudo



sudo让我变得聪明 code>

解决方案

正如您所说,第一条消息是因为远程并非裸露的回购。 p>

第二条消息是因为您创建的裸回购没有分行。当您克隆回购并签出工作副本时,它会为您创建主分支。然而,当你试图推送时,在远程回购站点上没有master分支,所以它抱怨。



尝试使用 git push origin master (或者你的远程被调用),它应该为你创建远程分支。


I bought a personal dev box which I will use for deploying stuff I create on my laptop. I thought it would be a good idea to use Git for code management. The idea was that I will keep committing on my laptop and when needed, will push the changes to the remote dev box.

  1. I initialized a Git repo on the box and
  2. cloned it on my laptop.
  3. But After doing git push I get this error:

    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

I know that the remote repo was not bare.

I want to ask if the only way to go with my kind of setup is:

  1. Initialize a bare repo on Server
  2. Clone it on my laptop
  3. add new files to the local laptop repo and commit the files
  4. push to the remote dev box repo

Even this setup gives me errors:

No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly


EDIT

I tried

git push origin master

Got this error:

error: unable to create directory for .git/refs/remotes/origin/master
error: Cannot lock the ref 'refs/remotes/origin/master'.


Oh dumb me... I think it is sudo as in

sudo make me intelligent

解决方案

The first message, as you said, was because the remote was not a bare repo.

The second message was because the bare repo you created had no branches to begin with. When you cloned the repo and checked out a working copy, it created the master branch for you. When you tried to push however, there was no master branch on the remote repo, so it complains.

Try using git push origin master (or whatever your remote is called) and it should create the branches on the remote for you.

这篇关于需要Git安装(远程和本地回购)建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆