github将本地项目与gitHub相关联
2019-04-22 本文已影响0人
Arnoux
首先在项目目录下初始化本地仓库
git init
添加所有文件
git add .
提交所有文件到本地仓库
git commit -m "备注信息"
连接到远程仓库
git remote add origin 你的远程仓库地址
(建议)拉取,更新本地仓库,防止冲突
git pull origin master
将项目推送到远程仓库
git push -u origin master
如果此时提示
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/abc/abc.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
说明文件版本不是最新的,此时先更新本地文件仓库至最新再push
两种方法
git pull --rebase origin master
这种方法可以自动合并一些冲突?(貌似)