git 问题整理

1、上传代码/拉取代码报错:remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.

  秘钥过期,把本地git公钥配制到gitlab中

  1)生成秘钥

    ssh-keygen -t rsa -C "example@qq.com"     替换成你的邮箱

  2)拷贝公钥

    上一步生成的秘钥有两个,一个是id_rsa ,一个是id_rsa.pub ,都放在C:Usersyourname.ssh下

    打开id_rsa.pub,拷贝里面的内容

    类似于下面的这个:

            

   3)添加到gitlab中

    打开gitlab,登录后,进入项目》点击个人头像》setting》ssh and GPG key》点击new ssh key 

        

     填入标题(自己随便写一个),然后复制刚才拷贝的id_res.pub内容到下面的key中,点击添加就可以了。

      

2、运行 git pull --rebase origin master 报错:error: cannot pull with rebase: You have unstaged changes.

  这个是没有commit 代码就直接拉取了:

  先运行 git commit -m "本次修改了一个bug"

3、运行git commit -m "232"报错:Changes not staged for commit:

         (use "git add <file>..." to update what will be committed)
    (use "git restore <file>..." to discard changes in working directory)
    modified: src/main/java/com/example/。。。。

    no changes added to commit (use "git add" and/or "git commit -a")

  这个是没有add本地修改的代码

    运行 git add .       (“.”不要忘了)

原文地址:https://www.cnblogs.com/51python/p/15488121.html