Git在Githib和Github上的使用

时间:2023-03-09 04:26:55
Git在Githib和Github上的使用

本文使用的环境是linux里

一、git的常用命令解释:

1、基础命令:
git init #创建版本库
git add <file> #将文件修改添加到暂存区
git commit -m #把暂存区的所有内容提交到当前分支
git status #查看状态
git logs #查看提交日志 2、版本回退:
git reset --hard 1094a 3、版本库拉取:
git clone <存储库地址> 4、存储推送远端存储库:
git push -u origin master 5、git add详细介绍:
git add -u <==> git add –update #提交所有被删除和修改的文件到数据暂存区
git add . #提交所有修改的和新建的数据暂存
git add -A <==>git add –all #提交所有被删除、被替换、被修改和新增的文件到数据暂存区

二、在gitlib上使用:

1、讲秘钥加入到列表(先生成秘钥,已经有就不用)

ssh-keygen -t rsa -C ”mail”

2、将公钥复制到gitlib里面:

cat /root/.ssh/id_rsa.pub

点击 Profile Settings --> SSH Keys

三、在github上使用:

cat /root/.ssh/id_rsa.pub

点击 settings --> SSH keys

四、初始化新的版本库:

echo “新的存储库" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin 存储库地址
git push -u origin master

详细使用见:

  https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

相关文章