Git操作手册(二)

发布时间:2022-07-05 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了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操作手册(二)

本地库连接远程库

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

文件发送到远程库上 第一次加 “@H_587_126@-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'.

到此连接就成功了

Git操作手册(二)

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

Git操作手册(二)

 在Gitee里添加公钥

Git操作手册(二)

Linux端发到远程仓库

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

#  git push -u origin master

Git操作手册(二)

@H_879_360@

脚本宝典总结

以上是脚本宝典为你收集整理的Git操作手册(二)全部内容,希望文章能够帮你解决Git操作手册(二)所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。