git上传github出现一大堆问题
一开始创建了一个GitHub仓库,也和本地链接了,上传完后,都没什么问题
问题出在,我使用自己的域名之后
我觉得网页得改改,于是修改了本地代码,当我
git commit -m
报错
On branch main
nothing to commit, working tree clean
当我git push时
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
网上的很多方法都试了,都没什么用,每次都是把仓库删除然后重新键仓库重新链接,但是只要绑定域名再修改就这样
请问有什么解决方法吗
那不是写了吗 提交代码之前 要先pull 再commit 再push
使用ssh-keygen -t rsa -C ‘github的邮箱地址’
生成特定的公钥和私钥,出现的提示一路回车就行。
在~/.ssh目录下,生成了公钥(带.pub)和私钥,其中私钥要保存好,务必不要泄露。
然后把公钥内的内容整个复制,拷贝到对应github账户下的SSH keys中,
然后获取仓库的ssh 地址,如下:
修改已有仓库地址,在仓库目录下的.git/config 文件:
注意,这是在已克隆下来的仓库目录内操作的,
将 仓库ssh地址 替换原有地址:
保存后,退出,在重新push 你的代码就可以成功了。
撤消对文件的修改(git --checkout)
git checkout -- file