git初步使用中的bug及正常解决

简单记录git初步使用中遇到的问题 ,希望可以帮到大家,当然如果有不正确的还请大家指正。。。


1 error: src refspec master does not match any 

当前目录是个空目录 无法提交  add  ---  commit  文件


2 Warning: Permanently added the RSA host key for IP address '192.30.255.112' to t                             he list of known hosts.
警告本地host文件中没有 该IP 添加 即可
192.30.255.112  github.com  


3 Could not resolve hostname github.com: Non-recoverable failure in name resolution
fatal: Could not read from remote repository.

未知的GitHub.com 主机名 

step1. ping github.com 

eg


获取到github.com的ip为192.30.252.128 
step2. 在/etc/hosts中添加一行如下: 
192.30.252.128 github.com


4 RT ! [rejected] master -> master (fetch first)
在push远程服务器的时候发现出现此错误;原因是没有同步远程的master
所以我们需要先同步一下


 git commit 过程中Changes not staged for commit:
需要先git add 后在commit 然后 push
整个流程:
$ git add menudd //其中 menudd 是一个目录 也可以是文件 会自动更新有修改的文件


然后 $ git commit -m "asdf" //“asdf”是更新注释
最后 $ git push origin master 
ok完成 更新成功
3. git remote add [name] [url]



5  
$ git push -u origin master
To github.com:passliang/firstgit.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:passliang/firstgit.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.


解决方案  加一个 -f 参数 强制同步
$ git push -u -f  origin master
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (6/6), 508 bytes | 0 bytes/s, done.
Total 6 (delta 0), reused 0 (delta 0)
To github.com:passliang/firstgit.git
 + cfb6a26...de86fcb master -> master (forced update)
Branch master set up to track remote branch master from origin.

猜你喜欢

转载自blog.csdn.net/a15835774652/article/details/78123931