美文网首页
Git基本操作

Git基本操作

作者: 马川敉 | 来源:发表于2020-07-22 16:25 被阅读0次

    安装/配置

    一般情况下,Linux系统一般都已经自带,无需安装,如需安装,请使用以下命令

    sudo apt install -y git-all ssh
    

    配置git用户名和邮箱

    这里配置的用户名和邮箱都不作为验证用,不必跟gitee上一致,但建议最好保持一致

    git config --global user.email "张三的邮箱地址"
    git config --global user.name "张三"
    

    Configuration(SSH and GPG keys)

    个人设置中设置个人ssh公钥,之后使用ssh方式clone代码后再提交代码时不需重复输入用户名和密码。

    1. 生成生成ssh公钥及私钥

      ssh-keygen -t rsa
      

      一路回车即可,如果遇到文件已经存在的提示,可以选择覆盖原有文件,如下

      Generating public/private rsa key pair.
      Enter file in which to save the key (/home/feidao/.ssh/id_rsa):
      /home/feidao/.ssh/id_rsa already exists.
      Overwrite (y/n)?
      

      输入y并回车

    2. 将生成的文件

      • windows c:/用户/个人用户名/.ssh/id_rsa.pub
      • linux ~/.ssh/id_rsa.pub

      中的内容全部复制到个人设置即可

      提示:

      可以通过cat命令输出这个文件的内容(windows请在Git Bash中执行该命令)

      cat ~/.ssh/id_rsa.pub
      

      注意:如果是通过文本编辑器打开的该文件,请注意一定不要误修改这个文件,如果你修改过,请按上面的步骤重新再次生成一次。

    相关文章

      网友评论

          本文标题:Git基本操作

          本文链接:https://www.haomeiwen.com/subject/avltlktx.html