github - Issues in git creating new project
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-06-26 10:49:31
0
3
891

There was a problem when creating the project, please see where I went wrong

  1. Writing code locally

  2. Create a new project on github and create readme.md directly using github

  3. git remote add origin git@github.com:xxx/xxx

  4. git push -u origin master
    Here, the error starts:

error: failed to push some refs to 'git@github.com:xxx'
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, git pull, another error was reported:

warning: no common commits
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From github.com:xxx
 + 8324a8d...8c9fdd4 master     -> origin/master  (forced update)
fatal: refusing to merge unrelated histories

What's wrong with this? What's the correct way to push a git project

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(3)
某草草
//第一步创建仓库
//第二步 git clone 
//第三步 把你的项目代码添加到clone出的文件夹里面
//第四步 push代码到远端仓库
阿神

The solution to your second error is as follows

[问题]fatal: refusing to merge unrelated histories

[解决]git pull origin master --allow-unrelated-histories

The correct way to use git is


1. git init

2.git add .

3.git commit -m '注释'

4. git remote add origin httpsxxxx

5.git pull origin master

6. git push -u origin master

小葫芦

Generally speaking, a warehouse can only have one initial submission point. If you create an initial submission through Github and create an initial submission locally, naturally an error will be reported when pushing locally.

If you choose to initialize the warehouse through a readme or the like when creating a project on Github, you should clone the remote warehouse locally instead of creating a new warehouse and binding the remote warehouse.

If you did not select the warehouse initialization option when you created the project on Github, you can create a new warehouse locally, bind it to the remote warehouse, and push the local initial submission to the remote warehouse.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template