我有一个名为" FilmReview"的目录。在我的计算机上,FilmReview.git
在我的github中,它是空的我想把这个文件夹推到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
答案 0 :(得分:1)
消息warning: no common commits
表示github存储库中已存在提交。由于您也在本地创建了自己的仓库,因此两个仓库没有共同的祖先。这就是你无法推动的原因。
当您创建github存储库时,您可能已选中使用自述文件初始化此存储库
选项
我建议你删除github上的当前回购并创建一个没有初始提交的新回购,即不要选中上面的复选框。然后你可以将你的回购推送到遥控器。
答案 1 :(得分:0)
我猜你想通了,因为你在GitHub上的回购不再是空的了。
无论如何,我认为你在寻找的是:
git push origin master -f
没有-f
(强制)你的推送不起作用,因为GitHub上的回购和你的本地回购没有共同的历史。 (很可能是因为你用README
)
-f
强制推送,即使远程分支没有与本地祖先共同的祖先,或者两个分支已经分叉。但正如你所说的那样GitHub回购应该是空的,所以这样做是安全的。