Git操作手册(二)

1.学习要求

1.1可以将Gitee连接到本地

1.2可以将Gitee连接到Linux

2.配置安装

2.1 git安装

Windows端安装地址: Git for Windows

Linux端 安装: yum install git -y

3.开始操作

3.1 本地连接Gitee

在git bash 中进入H:/www/githome

$ git init

输入用户信息

$ git config --global user.name "name"

$ git config --global user.email "yourmail@qq.com"

创建一个新文件

$ echo "hello world" > 1.txt  

添加本地文件

$ git add 1.txt

提交到本地库

$ git commit -m "add new file 1.txt"

在Gitee中加入公钥(将本地C:/用户/user/.ssh/id_rsa_pub里的公钥提交到Gitee中)

本地库连接远程库

$ git remote add origin git@gitee.com:your/githome.git

文件发送到远程库上 第一次加 “-u

$ git push -u origin master

提示以下

The authenticity of host 'gitee.com (180.97.125.228)' can't be established.

ED25519 key fingerprint is SHA256:+ULzij2u99B9eWYFTw1Q4ErYG/aepHLbu96PAUCoV88.

This key is not known by any other names

下面选项填yes

Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

Warning: Permanently added 'gitee.com' (ED25519) to the list of known hosts.

Enumerating objects: 3, done.

Counting objects: 100% (3/3), done.

Writing objects: 100% (3/3), 223 bytes | 223.00 KiB/s, done.

Total 3 (delta 0), reused 0 (delta 0), pack-reused 0

remote: Powered by GITEE.COM [GNK-6.1]

To gitee.com:your/githome.git

 * [new branch]      master -> master

Branch 'master' set up to track remote branch 'master' from 'origin'.

到此连接就成功了

3.2 linux 连接Gitee

在linux中安装git

# yum install git -y

# git version

git version 1.8.3.1

配置基本信息

# git config --global user.name "name"

# git config --global user.email "yourmail@qq.com"

建立git仓库

# mkdir /data/gitroot

# cd /data/gitroot

初始化仓库

# git init

# Initialized empty Git repository in /data/gitroot/.git/

创建一个新的文件

# echo "hello world">2.txt

把2.txt添加到仓库

# git add 2.txt

# git commit -m "add new file 2.txt"

在Linux里查看你设置的SSH公钥

# cd .ssh/

# cat id_rsa.pub

 在Gitee里添加公钥

Linux端发到远程仓库

#  git remote add origin git@gitee.com:shuaihewen/gitroot.git

#  git push -u origin master

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

闻仔睡不醒

你的鼓励将是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值