Git操作笔记

1、git push报错error: failed to push some refs to 'git@github.com:

$ git push -u origin masterTo git@github.com:xxx/xxx.git 
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:xxx/xxx.git'hint:
 Updates were rejected because the remote contains work that you dohint: not have locally. 
This is usually caused by another repository pushinghint: to the same ref.
 You may want to first integrate the remote changeshint: (e.g., 'git pull ...')
 before pushing again.hint:
 See the 'Note about fast-forwards' in 'git push --help' for details.

原因: GitHub远程仓库中的README.md文件不在本地仓库中。 解决方案:

 
$ git pull --rebase origin master
$ git push -u origin master

 

 

 

2、git输错账号密码的处理方式

1.打开控制面板(快捷打开win+R,输入control);

2.点击打开用户账户;

3.点击打开凭证管理(windows凭证管理栏);

4.普通凭证下拉打开有你已存在的git账号密码,删除即可。

 

 

 

3、fatal: HttpRequestException encountered解决方法

 

 

 

无论是push前先将远程仓库pull到本地仓库,还是强制push都会弹出这个问题。

网上查了一下发现是Github 禁用了TLS v1.0 and v1.1,必须更新Windows的git凭证管理器,才行。

https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/tag/v1.14.0

 

 

 

4、问题:git add 遇到 warning: LF will be replaced by CRLF in 警告

执行下面代码在命令行中执行:

git config --global core.autocrlf false

 

再次提交文件就不会再自动转换。

5、Git -- 删除本地仓库

 

1、$ git branch  #显示所有本地分支
2、$ git init  #初始化本地版本库
3、$ ls -a   #找到目录下.git
4、$ rm -rf  .git  #删除

5、可以看到master分支已经删除(隐藏的.git文件夹已经删除)

6、删除git之后 再去删除本地的库文件夹即可 rm -rf XXXX

简而言之,就是删除仓库文件夹下隐藏的.git文件夹即可

 

6、Git安装教程

https://blog.csdn.net/sanxd/article/details/82624127

 

7、使用Git上传文件到GitHub

https://blog.csdn.net/m0_37725003/article/details/80904824

 1.git init (将当前目录生成本地git管理)

 2.git add . (将当前目录下的所有文件('.'表示所有文件)添加到暂存区仓库)

 3.git commit -m "first commit" (将暂存区的文件添加到git仓库)

 4.git remote add origin https://自己的仓库url地址( 将本地的仓库与Github仓库关联)

 5.git push -u origin master (将本地仓库的代码上传到GitHub仓库上)

 

8、在本地仓库修改文件内容或者添加了文件,上传到GitHub仓库方法


git status  //看看有哪些文件改动了
git add 你修改后要提交的文件
git commit -m '提交注释'
git push -u origin 你远程分支或者master

  

 


 

 


 


9、Git常用操作


1.查看用户名和邮箱地址


$ git config user.name
$ git config user.email

  


 


2.修改全局用户名和邮箱地址:

$ git config --global user.name  "username"     
$ git config --global user.email "email"

  

       

3.修改局部用户名和邮箱地址:

$ cd ~/you project                       
$ git config user.name  "username"      
$ git config user.email "email"   

  


 


4.克隆:


git clone https://github.com/JDLiao/sprincloud-config.git

  


 


10、ssh: connect to host github.com port 22: Connection timed out

  1. 首先我们先查看是否创建SSH KEY,如果没有,请先创建。

  https://blog.csdn.net/lqlqlq007/article/details/78983879


ssh-keygen -t rsa -C "1454xxxx88@qq.com"

  秘钥:

  


  1. 使用命令测试git是否成功连接github


ssh -T git@github.com

  

如果出现:ssh: connect to host github.com port 22: Connection timed out,很遗憾连接超时


https://jingyan.baidu.com/article/ca00d56c4861b0e99febcf6e.html


首先找到git的安装目录,找到/etc/ssh/ssh_config文件



把如下内容复制到ssh_config文件的末尾处:并记得保存


Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443

  

 


再次测试:



  1. 最后使用以下命名,clone完成,使用https不能clone。


git clone git@github.com:JDLiao/sprincloud-config.git

 

11、码云配置


https://www.cnblogs.com/yiven/p/8465054.html


 


 


 


posted @ 2020-05-10 13:38  JDLiao  阅读(246)  评论(0编辑  收藏  举报