git无法提交代码

github是一个挺好的网站,可以进行开源代码的托管。可是最近在提交代码的时候遇到问题 ,使用了git的三个通用命令:

git add 源文件名词
git commit 源文件名词 -m 注释
git push -u origin master

但是代码并没有如期的提交到github上面,而是出现一下错误信息。
错误信息如下:

maya@maya-g450:~/myVimrc$ git add tag_vim.sh 

maya@maya-g450:~/myVimrc$ git commit tag_vim.sh -m "add a script for ctags and cscope generation"

[master bfe6081] add a script for ctags and cscope generation
 1 file changed, 11 insertions(+)
 create mode 100755 tag_vim.sh

maya@maya-g450:~/myVimrc$ git push -u origin master

Warning: Permanently added the RSA host key for IP address '192.30.255.112' to the list of known hosts.
To git@github.com:astbl123/myVimrc.git
 ! [rejected]        master -> master (fetch first)
error: 无法推送一些引用到 'git@github.com:astbl123/myVimrc.git'
提示:更新被拒绝,因为远程仓库包含您本地尚不存在的提交。这通常是因为另外
提示:一个仓库已向该引用进行了推送。再次推送前,您可能需要先整合远程变更
提示:(如 'git pull ...')。
提示:详见 'git push --help' 中的 'Note about fast-forwards' 小节。
maya@maya-g450:~/myVimrc$ git status
位于分支 master
您的分支领先 'origin/master'1 个提交。
  (使用 "git push" 来发布您的本地提交)

无文件要提交,干净的工作区
maya@maya-g450:~/myVimrc$ git commit  -m "add a script for ctags and cscope generation"
位于分支 master
您的分支领先 'origin/master'1 个提交。
  (使用 "git push" 来发布您的本地提交)

无文件要提交,干净的工作区
maya@maya-g450:~/myVimrc$ git push -u origin master
Warning: Permanently added the RSA host key for IP address '192.30.255.113' to the list of known hosts.
To git@github.com:astbl123/myVimrc.git
 ! [rejected]        master -> master (fetch first)
error: 无法推送一些引用到 'git@github.com:astbl123/myVimrc.git'
提示:更新被拒绝,因为远程仓库包含您本地尚不存在的提交。这通常是因为另外
提示:一个仓库已向该引用进行了推送。再次推送前,您可能需要先整合远程变更
提示:(如 'git pull ...')。
提示:详见 'git push --help' 中的 'Note about fast-forwards' 小节。

根据提示 “更新被拒绝,因为远程仓库包含您本地尚不存在的提交。这通常是因为”,由此可知github上面可能和本地的代码不同步,需要把远程服务器的代码更新到本地才行。
解决方法:输入命令git pull即可把github上的代码更新到本地。

maya@maya-g450:~/myVimrc$ git pull
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 3
Unpacking objects: 100% (3/3), done.
来自 github.com:astbl123/myVimrc
   eba0b74..6f02bc7  master     -> origin/master
添加了 cscope 数据库 /home/maya/cscope.out
请按 ENTER 或其它命令继续
Merge made by the 'recursive' strategy.
 README.md | 1 +
 1 file changed, 1 insertion(+)
maya@maya-g450:~/myVimrc$ 
maya@maya-g450:~/myVimrc$ 
maya@maya-g450:~/myVimrc$ 
maya@maya-g450:~/myVimrc$ 
maya@maya-g450:~/myVimrc$ git push -u origin master
Counting objects: 8, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 879 bytes | 0 bytes/s, done.
Total 5 (delta 0), reused 0 (delta 0)
To git@github.com:astbl123/myVimrc.git
   6f02bc7..5b168fc  master -> master
分支 master 设置为跟踪来自 origin 的远程分支 master。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值