git基本操作
下载与配置
windows中可以去官网下载git:下载地址
ubuntu中可以直接终端下载,比较方便
sudo apt-get install git
设置用户名和邮箱地址
git config --global user.name "你的github名字"
git config --global user.email "你的邮箱地址"
基本使用
我比较习惯在先在github上创建仓库,然后git clone到本地,修改之后在提交(如果是在vscode中操作会更简单),操作过程如下:
- clone远程仓库
git clone "在github上创建仓库的地址"
- add
以添加index.py为例
git add index.py
- commit
git commit -m "add a new file"
- push将提交的信息推送到仓库
git push
- pull,获取并整合另外的版本库或一个本地分支
git pull
- checkout,检出一个分支或路径到工作区
checkout index.py
ubuntu ssh连接git
- 创建SSH key , 没有特殊的指定文件可以直接回车
ssh-keygen -t rsa -C "你的email地址"
- 在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 "1812752073@qq.com"