'git如何创建公匙,和一些常用指令'

#本文是从别的博客上或笔记上裁剪来的

#姑且算是原创吧…

git的使用
一台新电脑首先创建公钥
rm -rf /home/fanchen/ss.sh
先删除原来的公匙
ssh-keygen -t rsa -C “github账号邮箱”
生成公匙,一直确定
cat /home/fanchen/.ssh/id_rsa.pub
打开公匙文件
点击setting然后点击ssh and keys
点击new SSH key
输入title(谁便起)
输入id_rsa.pub的内容
完成
如果输入git push -u origin master提示
sign_and_send_pubkey: signing failed: agent refused operation
Permission denied (publickey).
可以执行以下语句
ssh -T git@git.coding.net
或者
ssh -vT git@git.coding.net
我们可能看到如下语句:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to git.coding.net [124.116.152.172] port 22.
debug1: Connection established.
......
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa
SHA256:jok3FH7q5LJ6qvE7iPNehBgXRw51ErE77S0Dn+Vg/Ik
debug1: Host 'git.coding.net' is known and matches the RSA host key.
debug1: Found key in /home/chen/.ssh/known_hosts:1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/chen/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
sign_and_send_pubkey: signing failed: agent refused operation
debug1: Trying private key: /home/chen/.ssh/id_dsa
debug1: Trying private key: /home/chen/.ssh/id_ecdsa
debug1: Trying private key: /home/chen/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

解决办法是输入:
eval “$(ssh-agent -s)”
我们会看到
Agent pid xxxxx
继续输入:
ssh-add
最后显示如下即成功
ssh-add /home/chen/.ssh/bitbucket.id_rsa.pub
然后去试试推送文件吧.
详细解释:https://segmentfault.com/a/1190000008733238


fatal: remote origin already exists.
致命:起源已经存在
解决办法如下:
删除起源
git remote rm origin

如果要删除远程仓库的某个文件或目录
使用git rm -r –cached a/2.txt //删除a目录下的2.txt文件 删除a目录git rm -r –cached a
git commit -m “删除a目录下的2.txt文件”
git push

用-r参数删除目录, git rm –cached a.txt 删除的是本地仓库中的文件,且本地工作区的文件会保留且不再与
远程仓库发生跟踪关系,如果本地仓库中的文件也要删除则用git rm a.txt

2、Git命令:
git init:初始化一个Git仓库
git status:查看仓库当前状态
git diff:查看修改文件内容详情
git add . :把修改的文件提交到仓库
git commit -m “本次提交的备注信息,修改了什么或完成什么功能”:本次提交的说明
git log:显示从最近到最远的提交日志
git reset –hard commit_id:选择不同版本
git reflog:查看命令历史
git checkout – file:撤销(在准备提交前)
git reset HEAD file:撤销(git add 后,还未提交)
git rm:删除文件
git remote add origin git@server-name:path/repo-name.git:关联一个远程仓库
git push -u origin master:推送master分支内容
git push origin master:推送最新更改
git clone:克隆远程仓库

×

纯属好玩

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

文章目录
,