当前位置:   article > 正文

如何在Linux上安装git?Linux上git如何配置gitee仓库?_linux配置git仓库

linux配置git仓库

如何在Linux上安装git?

下载(Ubuntu)

sudo apt update
sudo apt install git
  • 1
  • 2

验证下载

git --version
  • 1

Linux上git如何配置gitee仓库?

配置

git config --global user.name "Your Name"
git config --global user.email "email@domain.com"
  • 1
  • 2

验证配置

git config --list	#正常则会打印出你的用户名和邮箱
  • 1

生成密钥

ssh-keygen -t rsa -C "email@domain.com"
  • 1

如果回车后打印如下:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa):
  • 1
  • 2

这里是在设置存储地址,直接按回车,会出现以下两种情况

  1. Enter passphrase (empty for no passphrase):
    
    • 1

    按回车

    Enter same passphrase again:
    
    • 1

    继续按回车,打印出密钥的随机图像则表示成功

  2. /home/username/.ssh/id_rsa already exists.
    Overwrite (y/n)?
    
    • 1
    • 2

    这说明已经设置了存储地址,输入“y”覆盖

    Enter same passphrase again:
    
    • 1

    继续按回车,打印出密钥的随机图像则表示成功

查看公钥

cat ~/.ssh/id_rsa.pub
  • 1

复制公钥到gitee

复制公钥到gitee

测试是否和gitee连通

ssh -T git@gitee.com
  • 1

打印如下表示成功

The authenticity of host 'gitee.com (212.64.63.190)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'gitee.com,212.64.63.190' (ECDSA) to the list of known hosts.
Hi username! You've successfully authenticated, but GITEE.COM does not provide shell access.
  • 1
  • 2
  • 3
  • 4
  • 5

代码推送到远端仓库

  • 初始化一个仓库

    mkdir test_git/  && cd test_git/
    git init
    
    • 1
    • 2
  • 添加代码

    touch main.cpp
    git add .
    
    • 1
    • 2
  • 提交代码到仓库

    git commit -m "Add a file which names main.cpp"
    
    • 1
  • 先在gitee上创建仓库:test_git

  • 添加远程仓库地址(已经被添加过了则不用执行这一步)

    git remote add origin https://gitee.com/username/test_git.git
    
    • 1
  • 推送到远程仓库的master分支

    git push origin master
    
    • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/930556
推荐阅读
相关标签
  

闽ICP备14008679号