2014-02-15 129 views
0

我正在github上工作,共享一個存儲庫。如何將文件添加到git存儲庫?

我採取了以下措施:

$ git clone https://github.com/Company/repos 
Cloning into repos... 
Username: 
Password: 
warning: You appear to have cloned an empty repository. 

(是的,我知道的回購是空的,我應該將文件添加到它,但不能:)

$ cd repos 
$ echo hello > README.txt 
$ git add README.txt 
[no output] 

$ git commit -m "commit" 

[master (root-commit) 824324d] commit 
Committer: User <[email protected]> 
Your name and email address were configured automatically based 
on your username and hostname. Please check that they are accurate. 
You can suppress this message by setting them explicitly: 

    git config --global user.name "Your Name" 
    git config --global user.email [email protected] 

After doing this, you may fix the identity used for this commit with: 

    git commit --amend --reset-author 

    1 files changed, 1 insertions(+), 0 deletions(-) 
    create mode 100644 README.txt 

(。因此,該文件似乎是在)

現在我做:

$ git push 
    Username: 
    Password: 
    Everything up-to-date 

沒有內容上傳到存儲庫!如果我再次克隆它,文件不在那裏。

編輯:關注的人的請求:

$ git add README2.txt 
    $ git status 
    # On branch master 
    # Changes to be committed: 
    # (use "git reset HEAD <file>..." to unstage) 
    # 
    #  new file: README2.txt 
    # 
+0

README.txt是一個現有的非空文件,還是您嘗試通過'git add'創建它? – marionebl

+0

@marioebl它是一個現有的文件,我創建它。 – kloop

+0

你可以在'git add'之後加入'git status'的輸出嗎? – marionebl

回答

0

確定GitHub的庫被鏈接在遠程起源?沒有它推動沒有目標。

+0

我不知道。我沒有創建存儲庫。我應該告訴那個人做些什麼嗎? – kloop

+0

不,它必須在您的本地克隆中設置。或者您可以在推送後指定完整的網址。不知道確切的語法。 – wumpz

+0

現在這裏是語法:git remote add origin [email protected]:user/repository.git然後你可以嘗試一個 git push origin master – wumpz

相關問題