git将本地项目与远程仓库进行关联
2017-10-02 22:40
288 查看
首先在本地文件中新建文件,对该文件进行初始化:
git init
该文件就会生成.git文件
下一步就是进行关联了
在gitbub上建立自己的仓库是前提拿到ssh链接地址:比如:git@github.com:你的用户名/你的项目名.git
在git客户端输入以下命令:
git remote add origin git@github.com:你的用户名/你的项目名.git
这样就成功关联你的本地文件了
当执行git push origin master
有时候git提示以下错误:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:lck898989/testG.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.
出错的原因是在本地目录中没有找到README.md文件虽然你的本地文件里面新建了文件README.md文件但是和远程文件不一样,需要执行以下命令
git pull --rebase origin master
执行该命令后就可以提交文件了
git init
该文件就会生成.git文件
下一步就是进行关联了
在gitbub上建立自己的仓库是前提拿到ssh链接地址:比如:git@github.com:你的用户名/你的项目名.git
在git客户端输入以下命令:
git remote add origin git@github.com:你的用户名/你的项目名.git
这样就成功关联你的本地文件了
当执行git push origin master
有时候git提示以下错误:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:lck898989/testG.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.
出错的原因是在本地目录中没有找到README.md文件虽然你的本地文件里面新建了文件README.md文件但是和远程文件不一样,需要执行以下命令
git pull --rebase origin master
执行该命令后就可以提交文件了
相关文章推荐
- 如何将本地项目变成git项目并关联远程仓库
- Git 创建github远程仓库并关联本地项目
- Git上传本地项目到远程仓库
- Git 菜鸟变大神 (四)Github 创建远程仓库以及关联本地仓库
- Git——如何将本地项目提交至远程仓库
- git本地项目创建关联远程
- 本地Git仓库和远程仓库的创建及关联 Coding.net
- Git实现从本地添加项目到远程仓库
- git本地项目代码上传至码云远程仓库总结【转】
- Git实现从本地添加项目到远程仓库
- Git基本使用方法——本地创建一个 git 项目推送到远程空仓库
- Git 将本地代码推送到新建远程项目的 GIT 仓库中
- 用命令将本地项目上传到git 远程仓库
- 如何把本地项目添加到新的git远程仓库
- windows下多个git账号配置并且将本地仓库项目推送到远程仓库
- Git从本地添加项目到远程仓库
- git创建本地仓库,并关联远程仓库,提交代码
- 本地Git仓库关联到远程GitHub仓库
- 怎么把本地项目和远程git仓库相连通
- windows如何设置本地git仓库与远程的github关联