Git基础使用
文章目录
安装
初始化git
git config --global user.name 'xxxxx'
git config --global user.email 'xxx@xx.xxx'
生成秘钥
注:秘钥生成位置:~/.ssh
- windows:C:\Users\Liu\.ssh
- linux:/home/.ssh
ssh-keygen -t rsa -C 'xxx@xx.xxx'
项目维度
初始化项目
git init
克隆
git clone address
常见配置命令
## 查看全局配置
git config --global --list
IDE使用github
连接repository
- git bash:生成秘钥
ssh-keygen -t rsa -C 'xxx@xx.xxx'
- git hub:配置ssh key,将生成的id_rsa.pub公钥文件写入
https://github.com/settings/keys
- git hub:在github创建repository,并拷贝ssh连接(https连接国内可能连接不上)
- IDEA:git - manage remotes中,使用ssh连接添加远程仓库(如果没有配置秘钥或账号会添加失败)
- IDEA:选择remote及branches,Push/Pull
|
7. IDEA:创建local branches
Intellij IDE连接github
准备工作
- git bash:完成git初始化。
- git bash:生成秘钥
ssh-keygen -t rsa -C 'xxx@xx.xxx'
,并写入github - git hub:在github创建repository,并拷贝ssh连接(https连接国内可能连接不上)
IDEA使用github
连接repository(IDEA中操作)
- git - manage remotes中,使用ssh连接添加远程仓库(如果没有配置秘钥或账号会添加失败)
![]() | ![]() |
---|
- 选择remote及branches,Push/Pull
![]() | ![]() |
---|
- 创建local branches
VScode使用github
连接github
-
添加remote,第一步输ssh连接,回车后输remote name
等效于命令git remote add master ssh连接
-
点击删除远程存储库查看是否添加成功(别真删)
等效于命令git remote -v
-
创建本地分支
![]() | ![]() |
---|
- Push/Pull