2012-07-20 64 views
8

我有我的本地機器上的一個項目,我一直獨自工作,我想推送到遠程服務器(運行Ubuntu &的gitosis)GIT推新項目首次

在遠程服務器我做

git init 
Initialized empty Git repository in /home/stefan/.git/ 

本地git status

git status 
# On branch master 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
# .DS_Store 
# .travis.yml 
# license.txt 
# nbproject/ 
# bla/.DS_Store 
# bla/cache/ 
nothing added to commit but untracked files present (use "git add" to track) 

我也做

git remote add origin [email protected]:psdemo.git 

現在:當我嘗試推,將發生以下情況

git push origin master 
fatal: 'psdemo.git' does not appear to be a git repository 
fatal: The remote end hung up unexpectedly 

這是有道理的方法,因爲我只是一個空混帳回購協議。

如何將我的文件推送到此遠程服務器?我想我需要的是從本地機器克隆到遠程機器,不知何故?

回答

7

字符串

[email protected]:psdemo.git 

應該是一個有效的ssh路徑。至於我在前面行看到:

git init 
Initialized empty Git repository in /home/stefan/.git/ 

您在/ home /斯特凡創建一個存儲庫/所以我希望是這樣的:

[email protected]:~ 

,不過也許它不是」你想要什麼。您應該在遠程服務器的家中創建一個文件夾psdemo.git。對於這一點,做一個

git init --bare ~/psdemo.git 

在這,然後用添加遠程:

[email protected]:~/psdemo.git 

那麼你應該能夠推動!

1

遠程存儲庫的路徑可能不完整。而不是psdemo.git,嘗試像/home/stefan/.git/之類的東西,然後再試一次。

1

看看Initialized empty Git repository in /home/stefan/.git/部分,您的遠程repo不是psdemo.git,而是/ home/stefan(或者可能是/home/stefan/.git會起作用)。

順便說一句:你通常在遙控器上使用裸存儲器(git init --bare),以便他們在那裏沒有工作副本。

3

您無法將空項目推送到上游。您必須通過git add添加一些文件,並使用git commit在本地進行提交。只有在此之後,您才能將更改推向上游。

確保遠程存儲庫可以接受提交。

1

通過這樣的:在/home/stefan/.git/

初始化空Git倉庫

它看起來像你的遠程服務器作爲存儲庫上啓動你的主目錄。

但這:

git的遠程添加原產[email protected]:psdemo.git

是增加你的${HOME}/psdemo.git作爲遠程URL。這不匹配,這就是爲什麼你會得到錯誤。

在遙控器上嘗試git init /home/stefan/psdemo.git