GIT使用指南

本地git与远程仓库关联

现象

git push -u origin master
Warning: Permanently added the RSA host key for IP address '127.0.0.1' to the list of known hosts.
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

将本地的公钥拷贝出来

  1. cd ~
  2. cd .ssh
  3. id_rsa.pub里的内容拷贝出来

粘贴到远程仓库

GIT使用指南_第1张图片

本地创建工程与远程仓库进行关联

本地创建工程

  1. 随意的本地创建一个工程 LeetCode
  2. 使用git init初始化为git仓库
  3. 使用git add增加一次改动
  4. 使用git commit -m update提交一次改动

远程创建仓库

  1. 在github上新建仓库GIT使用指南_第2张图片
  2. 工程名和本地一致
    GIT使用指南_第3张图片

本地工程与远程仓库进行关联

  1. 关联远程
    git remote add origin [email protected]:your name/LeetCode.git
  2. 提交代码至远程
    git push -u origin master

常用操作

  1. 查看基本设置
    cat ~/.gitconfig
  2. 回滚到某一版本
    git reset --hard b498237e6dc1fc4861c79d3314d07285995b
  3. 强制提交到远程分支
    git push -f origin master

.gitignore文件配置规则

  1. 忽略venv文件夹下的所有内容
    /venv/*

你可能感兴趣的:(GIT,git)