github创建并关联
在本地创建了一个Git仓库后,又想在GitHub创建对应仓库,并且让这两个仓库进行远程同步关联同步。
- 在github上创建新的仓库。
接着可以克隆线上新仓库,或者关联本地和线上仓库。
线上关联,在本地的homework仓库下运行命令,需要替换为自己的github账号:
git remote add origin git@github.com:May7th/homework.git把本地库的所有内容推到远程仓库
git push -u origin master一般这样就可以了。
但是我提前在远程库添加了文件。接着我又进行了如下操作:- 提交所有文件
git add . git commit -am "init"
在push 的时候发现不成功,出现以下问题。
error: failed to push some refs to 'git@github.com:May7th/homework.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. changzhendeMacBook-Pro:homework changzhen$ git push -u master fatal: 'master' does not appear to be a git repository fatal: Could not read from remote repository.最后发现是文件版本不同,强制覆盖已有的分支后上传成功,可能会有文件丢失情况。
git push -u origin master -f
本文介绍如何将本地Git仓库与GitHub上的远程仓库进行关联同步。包括创建远程仓库、关联本地仓库、推送本地更改到远程的过程及遇到的问题解决办法。
992

被折叠的 条评论
为什么被折叠?



