The authenticity of host 'gitee.com (120.55.226.**)' can't be established.
>> git clone git@gitee.com:haiseason/JavaShiXun.git
Cloning into 'JavaShiXun'...
The authenticity of host 'gitee.com (120.55.226.**)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbV**********.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added 'gitee.com,120.55.226.**' (ECDSA) to the list of known hosts.
Bad packet length 1186263935.
ssh_dispatch_run_fatal: Connection to 120.55.226.** port 22: Connection corrupted
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解决:
>> ssh -o StrictHostKeyChecking=no 120.55.226.24
PTY allocation request failed on channel 0
Hi [33;01mAnonymous[0m! You've [32msuccessfully[0m authenticated, but GITEE.COM does not provide shell access.
Note: Perhaps the current use is [33mDeployKey.[0m
Note: DeployKey only supports [33;01mpull/fetch[0m operations
Connection to 120.55.226.24 closed.
>> git clone git@gitee.com:haiseason/JavaShiXun.git
Cloning into 'JavaShiXun'...
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 11 (delta 2), reused 0 (delta 0)
Receiving objects: 100% (11/11), done.
Resolving deltas: 100% (2/2), done.
DeployKey does not support push code
>> git push origin master
Access denied: DeployKey does not support push code
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解决:
>> ssh-keygen -t rsa -C "emailxxxxx@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\admin/.ssh/id_rsa):
一直按回车
之后打开C:\Users\admin/.ssh/id_rsa.pub 复制到个人的SSH公钥内而不是项目的
git 图表显示分支状况:
git log --graph --pretty=oneline --abbrev-commit
git rebase
git 合并多个
git reset --hard commit_id
commit_id: HEAD HEAD^ HEAD~100
git reflog 查看命令历史
git log 可以查看提交历史
git diff HEAD -- readme.txt 查看工作区和版本库里面最新版本的区别
# --------------------------------------
命令git checkout -- readme.txt意思就是,把readme.txt文件在工作区的修改全部撤销,这里有两种情况:
一种是readme.txt自修改后还没有被放到暂存区,现在,撤销修改就回到和版本库一模一样的状态;
一种是readme.txt已经添加到暂存区后,又作了修改,现在,撤销修改就回到添加到暂存区后的状态。
总之,就是让这个文件回到最近一次git commit或git add时的状态。
git checkout -- file命令中的--很重要,没有--,就变成了“切换到另一个分支”的命令
git reset命令既可以回退版本,也可以把暂存区的修改回退到工作区。当我们用HEAD时,表示最新的版本。
git reset HEAD readme.txt
# git reset HEAD file_path 部分文件撤回
# git reset --hard HEAD 整个记录撤回
git push -u origin master
由于远程库是空的,我们第一次推送master分支时,
加上了-u参数,Git不但会把本地的master分支内容推送的远程新的master分支,
还会把本地的master分支和远程的master分支关联起来,在以后的推送或者拉取时就可以简化命令。
要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git;
关联后,使用命令git push -u origin master第一次推送master分支的所有内容;
通常,合并分支时,如果可能,Git会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息。
如果要强制禁用Fast forward模式,Git就会在merge时生成一个新的commit,这样,从分支历史上就可以看出分支信息。
git merge --no-ff -m "merge with no-ff" dev
工作现场还在,Git把stash内容存在某个地方了,但是需要恢复一下,有两个办法:
一是用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除;
另一种方式是用git stash pop,恢复的同时把stash内容也删了:
git branch -D feature-vulcan
销毁失败。Git友情提醒,feature-vulcan分支还没有被合并,如果删除,将丢失掉修改,如果要强行删除,需要使用大写的-D参数。
git rebase -i HEAD~3 合并最后3次的commit