如何将文件添加到git存储库?

时间:2014-02-15 15:27:38

标签: git repository

我在github上工作,共享一个存储库。

我采取了以下步骤:

 $ 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@host.com>
 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 you@example.com

 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
  #

1 个答案:

答案 0 :(得分:0)

您确定github存储库是作为远程源链接的吗?没有它推动没有目标。