2

我的计算机和FilmReview.gitgithub 中有一个名为“FilmReview”的目录,它是空的,我想将此文件夹推送到https://github.com/siddhartha-ramesh/FilmReview.git.

我尝试了以下方法:

siddhartha@siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git init
Initialized empty Git repository in /home/siddhartha/Desktop/Untitled Folder/.git/
siddhartha@siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git add .
siddhartha@siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git commit -m "The whole Project"
[master (root-commit) 02a49f5] The whole Project
 203 files changed, 39049 insertions(+)
 create mode 100644 film_review/.project
 create mode 100644 film_review/404.html
#Rest of the files in this folder
 create mode 100644 film_review/trailers.html
 create mode 100644 film_review/trailers.html~

siddhartha@siddhartha-Inspiron-545s ~/.ssh $ ls -a
.  ..  key  key.pub  known_hosts
siddhartha@siddhartha-Inspiron-545s ~/.ssh $ cat key.pub
ssh-rsa 
# KEY HERE 

siddhartha@siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git remote add origin git@github.com:siddhartha-ramesh/FilmReview.git
fatal: remote origin already exists.
siddhartha@siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git push origin master
To git@github.com:siddhartha-ramesh/FilmReview.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:siddhartha-ramesh/FilmReview.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

有人请帮帮我

我也这样做了,但没有文件上传到我的 git hub

siddhartha@siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git push origin master
Username for 'https://github.com': siddhartha-ramesh
Password for 'https://siddhartha-ramesh@github.com': 
To https://github.com/siddhartha-ramesh/FilmReview.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/siddhartha-ramesh/FilmReview.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
siddhartha@siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git pill origin master
git: 'pill' is not a git command. See 'git --help'.

Did you mean this?
    pull
siddhartha@siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git pull origin master
warning: no common commits
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From https://github.com/siddhartha-ramesh/FilmReview
 * branch            master     -> FETCH_HEAD
Merge made by the 'recursive' strategy.
 README.md | 4 ++++
 1 file changed, 4 insertions(+)
 create mode 100644 README.md
4

2 回答 2

1

该消息warning: no common commits意味着 github 存储库中已经有一个提交。由于您也在本地创建了自己的存储库,因此这两个存储库没有共同的祖先。这就是为什么你不能推动。

当您创建 github 存储库时,您可能检查了选项Initialize this repository with a README

在此处输入图像描述

我建议您删除 github 上的当前 repo 并创建一个没有初始提交的新 repo,即不要选中上面的复选框。然后你可以开始将你的 repo 推送到远程。

于 2013-06-02T06:00:51.640 回答
0

我猜你想通了,因为你在 GitHub 上的 repo 不再是空的了。

无论如何,我认为您正在寻找的是:

git push origin master -f

如果没有-f(强制),您的推送将不起作用,因为 GitHub 上的存储库和您的本地存储库没有共同的历史记录。(很可能是因为您使用 初始化了 GitHub 存储库README

强制推送,-f即使远程分支与本地分支没有共同祖先,或者两个分支已经分歧。但正如你所说,GitHub 存储库无论如何都应该是空的,所以这样做是安全的。

于 2013-06-02T07:40:59.700 回答