English 中文(简体)
将文件推进到新建的 git 重发文件失败
原标题:Failed to pushing files into newly created git repo
  • 时间:2012-05-24 15:16:15
  •  标签:
  • git
  • git-push

也许是一个重复的问题,虽然我试图从现有问题中找到答案,但失败了。

我在服务器上创建了一个 Git repo 命令 :

mkdir gitrepo
cd gitrepo
git init

然后从另一台机器上 我试图将文件推到回购中,但失败了

git init
git clone user@server:~/gitrepo/.git
cd gitrepo
touch test
git add test
git commit -a

用户端现在不存在错误。 当我试图将更改推到服务器时, 会发生以下错误 :

>git push
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
error: failed to push some refs to  user@server:~/gitrepo/.git 

以前有没有遇到过这个问题?

I found an blog which explains well the difference between non-bare and bare repo. http://www.bitflop.com/document/111 Those who gets the same problem may refer to this.

最佳回答

在第一个机器上, 您创建了一个非空的仓库, 或者一个有工作副本的仓库 。 向非空的回波推进可以变得有点刺激, 所以确保您想要的东西真正存在 。

在第二台机器上,您在当前目录( git init )中创建了一个新的存储器,然后将 gitrepo 复制为子目录,作为第二台重写。再次,这很好,只要确定这是你想要的。

在这里,它如何工作 与赤裸的回购 第一机器和一个回购 在第二:

第一台机器:

git init --bare gitrepo.git

第二台机器:

git clone user@server:~/gitrepo.git
cd gitrepo
touch test
git add test
git commit -a

#  -u  tells git to track the remote master branch with your local master branch
git push -u origin master
问题回答

git push [remote-name] [blanch-name] ,例如 push 源源主控

查询“ a href=” https://stackoverflow.com/ questions/6157730/ why- cant-i-push-to-this-bare- repository” “为什么我不能推到这个光着的仓库? ”

尝试做 : git push -- set- 上流源源源主控





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...