简体   繁体   English

git如书所说,但会发生错误

[英]git as the book said but error occur

1.I just create and initialized a folder and make it a repository, and add 2 folder which are in it. 1.我只是创建并初始化一个文件夹并使其成为存储库,然后添加其中的2个文件夹。 I commit them together by once. 我一次将它们提交在一起。 Then I add the remote repository, but when I begin to push it, error come out: here is the code I made and the error below: 然后,我添加了远程存储库,但是当我开始推送它时,就会出现错误:这是我编写的代码以及以下错误:

git init
git add 2048-personal
git add canvas-time-counter
git commit
git remote add origin git@github.com:CharlesLN/front_end.git
git push -u origin master

Then the error come out: 然后错误出来了:

To git@github.com:CharlesLN/front_end.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:CharlesLN/front_end.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

then I keyed git pull then the info: 然后我键入git pull然后输入信息:

warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 3
Unpacking objects: 100% (3/3), done.
From github.com:CharlesLN/front_end
*[new branch] master     -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=origin/<branch> master

Then I keyed git pull remote : 然后我键入git pull remote

fatal: 'remote' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Then git status 然后git status

So, I don't know where is wrong and who can tell me the problem? 所以,我不知道哪里出了问题,谁能告诉我问题所在? Thank you! 谢谢!

I have tried over 3 times and it's still the same wrong! 我已经尝试了3次以上,但还是一样错误! please give me some help, thank you !!! 请给我一些帮助,谢谢!!!

It looks like you should do 看来你应该做

git pull origin master

You need to get everything from github, which is your origin. 您需要从github获得所有内容,这就是您的起源。

When vim opens, press i and write a short message and then press escape. 当vim打开时,按i并写一条短消息,然后按ESC。 To save the message press 要保存消息,请按

:wq

Which means write and quit. 这意味着写并退出。 After that you should be able to do that push. 之后,您应该能够执行该推送。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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