git使用笔记

目录

  • git基本操作
    • 下载与配置
    • 基本使用
  • ubuntu ssh连接git
    • win10 ssh 连接github
  • 参考

git基本操作

下载与配置

windows中可以去官网下载git:下载地址
ubuntu中可以直接终端下载,比较方便

sudo apt-get install git

设置用户名和邮箱地址

git config --global user.name "你的github名字"
git config --global user.email "你的邮箱地址"

基本使用

我比较习惯在先在github上创建仓库,然后git clone到本地,修改之后在提交(如果是在vscode中操作会更简单),操作过程如下:

  1. clone远程仓库
git clone "在github上创建仓库的地址"
  1. add
    以添加index.py为例
git add index.py
  1. commit
git commit -m "add a new file"
  1. push将提交的信息推送到仓库
git push
  1. pull,获取并整合另外的版本库或一个本地分支
git pull
  1. checkout,检出一个分支或路径到工作区
checkout index.py

ubuntu ssh连接git

  1. 创建SSH key , 没有特殊的指定文件可以直接回车
ssh-keygen -t rsa -C "你的email地址"

git使用笔记_第1张图片

  1. 在github上添加sshkey

登陆GitHub,打开“Account settings”,“SSH Keys”页面,然后,点“Add SSH Key”,填上任意Title,在Key文本框里粘贴id_rsa.pub文件的内容。

win10 ssh 连接github

和ubuntu中操作差不多,但是执行命令要在git bash中执行

ssh-keygen -t rsa -C "[email protected]"

git使用笔记_第2张图片

参考

git和github在ubuntu上的使用

你可能感兴趣的:(git,github,git,ubuntu,windows)