简体   繁体   中英

How do I add files to a git repository?

I am working on something in github, sharing a repository.

I took the following steps:

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

(yes, I realize the repos is empty. I am supposed to add files to it, but can't:)

 $ 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

(So that file seems to be in.)

Now I do:

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

Nothing is uploaded to the repository! If I clone it again, the files are not there.

EDIT: following someone's request:

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

Are you sure the github repository is linked in as remote origin? Without it push has no target.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM