Your branch and 'origin/master' have diverged, and have 1 and 1 different commits each, respectively

本地工程,上传成github仓库:

1,本地工程文件夹下,git init初始化git

$ git init
Initialized empty Git repository in D:/AI_codes/pyvirtualenv/ScrapyPiano/eop/.git/

2. 添加文件,这里全部提交

$ git add .
warning: LF will be replaced by CRLF in eop/items.py.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in eop/middlewares.py.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in eop/pipelines.py.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in eop/settings.py.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in eop/spiders/__init__.py.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in scrapy.cfg.
The file will have its original line endings in your working directory

3.提交

$ git commit -m "Initial commit"
[master (root-commit) 0b771fb] Initial commit
 23 files changed, 299 insertions(+)
 create mode 100644 .vscode/settings.json
 create mode 100644 eop/__init__.py
.............................

4. GitHub远端建立新仓库

5.本地关联GitHub仓库,查看

laoya@DESKTOP-N06PM9O MINGW32 /d/AI_codes/pyvirtualenv/ScrapyPiano/eop (master)
$ git remote add origin https://github.com/yaoyutian/Eop_crawl_spider.git

laoya@DESKTOP-N06PM9O MINGW32 /d/AI_codes/pyvirtualenv/ScrapyPiano/eop (master)
$ git remote -v
origin  https://github.com/yaoyutian/Eop_crawl_spider.git (fetch)
origin  https://github.com/yaoyutian/Eop_crawl_spider.git (push)

6. $ git branch --set-upstream-to=origin/master master
     Branch 'master' set up to track remote branch 'master' from 'origin'.

7. git pull 不能提交

$ git pull
fatal: refusing to merge unrelated histories

******@DESKTOP-****** MINGW32 /d/AI_codes/pyvirtualenv/ScrapyPiano/eop (master)
$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 1 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

nothing to commit, working tree clean

8.使用强制方法git pull origin master --allow-unrelated-histories

https://www.centos.bz/2018/03/git-%E5%87%BA%E7%8E%B0-fatal-refusing-to-merge-unrelated-histories-%E9%94%99%E8%AF%AF/

9.git push 提交

***不能提交,仔细看git 提示,设置本地与远端对应分支。

你可能感兴趣的:(Git)