git相关问题

git rebase

git rebase -i HEAD~3    //合并3个commit 
pick //第一个要pick
s     //后面的都是s
s     //后面的都是s



git rebase master   //放到master后面

 

撤销 git add

//所有
git reset HEAD -- .
//指定文件
git reset HEAD -- filename

撤销 git commit

git reset --soft HEAD^
// HEAD^的意思是上一个版本,也可以写成HEAD~1
// 如果你进行了2次commit,想都撤回,可以使用HEAD~2

其他参数解析:

  • --soft
    不删除工作空间改动代码,撤销commit,不撤销git add .

  • --mixed
    不删除工作空间改动代码,撤销commit,并且撤销git add .
    这个为默认参数, git reset --mixed HEAD^ 和 git reset HEAD^ 效果是一样的。

  • --hard
    删除工作空间改动代码,撤销commit,并且撤销git add .

补充:如果该仓库到目前为止只有commit过一次代码,则会报错:

 

 

 

Unable to negotiate with XX.XXX.XX.XX: no matching host key type found. Their offer: ssh-dss

The recent openssh version deprecated DSA keys by default. You should suggest to your GIT provider to add some reasonable host key. Relying only on DSA is not a good idea.

As a workaround, you need to tell your ssh client that you want to accept DSA host keys, as described in the official documentation for legacy usage. You have few possibilities, but I recommend to add these lines into your ~/.ssh/config file:

# HostkeyAlgorithms +ssh-dss
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa

 

Other possibility is to use environment variable GIT_SSH to specify these options:

GIT_SSH_COMMAND="ssh -oHostKeyAlgorithms=+ssh-dss" git clone ssh://user@host/path-to-repository

 

posted on 2023-04-07 09:20  heysong  阅读(4)  评论(0编辑  收藏  举报

导航