您的位置:首页 > 其它

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