git-使用

记录下 git 的基本用法,便于日后查阅

1.git基本信息配置
git config --global user.name "yeran"
git config --global user.email "gao_ye@outlook.com" #只要邮箱格式正确即可
2. 生成密钥
ssh-keygen -t rsa -C "gao_ye@outlook.com"

输入上面的命令后一直按3次回车直到出现图形界面即可,不要输入任何内容直接回车到出现图形界面

3. 添加私钥到github

密钥内容在 C:UsersAdministrator.sshid_rsa.pub 打开文件后复制

在网页版 github账户 settings中找到 SSH and GPG keys 一项,进入后选择点击 new ssh keys 填写密钥即可

4. 将远程仓库同步到本地

同步方式有两种

way 1:

创建一个文件夹并初始化

  mkdir  mkdir gao-ye.github.io
  git init 

本地连接github仓库

git remote add origin https://github.com/gao-ye/gao-ye.github.io.git
同步仓库到本地

git pull origin master

way 2 :

  git clone https://github.com/gao-ye/gao-ye.github.io.git    
5. 将本地仓库推送到github
git add . #加入缓存
git commit -m "first push" #添加推送注释
git push origin master #开始上传
git 强制覆盖本地
git fetch --all
git reset --hard origin/master
git pull
修改 .gitignore文件后更新
#add .gitignore
#查看状态,是否忽略了指定的文件? 
$ git status --ignored #查看状态,包括忽略的文件
 
#让其对已经跟踪的文件也起作用
$ git rm -r --cached .  #清除缓存 -r 表示递归删除(如果有文件夹的话) . 表示所有文件
 
#查看一下具体效果
$ git status --ignored
$ git add .           #重新trace file
$ git commit -m "update .gitignore"     #提交和注释
————————————————
版权声明:本文为CSDN博主「秦时明月之君临天下」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_41287260/article/details/89787203
如果有一天我们淹没在茫茫人海中庸碌一生,那一定是我们没有努力活得丰盛
原文地址:https://www.cnblogs.com/yeran/p/10823884.html