push本地代码到github出错
新生儿怎么睡
刚创建的github版本库,在push代码时出错:
别老母$ git push -u origin master
To :******/Demo.git
! [rejected] master -> master (non-fast-forward)班级凝聚力
error: failed to push some refs to ':******/Demo.git'
hint: Updates were rejected becau 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.
⽹上搜索了下,是因为远程repository和我本地的repository冲突导致的,⽽我在创建版本库后,在github
的版本库页⾯点击了创建README.md⽂件的按钮创建了说明⽂档,但是却没有pull到本地。这样就产⽣了版本冲突的问题。
有如下⼏种解决⽅法:
1.使⽤强制push的⽅法:
$ git push -u origin master -f
这样会使远程修改丢失,⼀般是不可取的,尤其是多⼈协作开发的时候。
2.push前先将远程repository修改pull下来
$ git pull origin master
$ git push -u origin master告别薇安
3.若不想merge远程和本地修改,可以先创建新的分⽀:关怎么组词
光脚跑$ git branch [name]
然后push
$ git push -u origin [name]
美丽的小兴安岭教学设计参考:
>便当菜谱