git常用命令

—-

Alt text

图片取自 阮一峰的网络日志

  • Workspace:工作区
  • Index/Stage:暂存区
  • Repostory: 仓库区(或本地仓库)
  • Remote:远程仓库

查看git当前配置

git配置在 .git 文件夹config文件,默认隐藏文件夹,

1
2
3
4
git config -l
#设置提交代码用户信息
git config [-global] user.name "name"
git config [-global] user.email "email address"

git init

在当前目录新建git 仓库(repository)会生成 .git 文件夹

1
git init

git clone 命令

将远程源码下载/复制到本地当前目录

1
git clone [url]

git pull 命令

更新当前文件夹源码

1
git pull

git add 命令

添加文件到暂存区

1
git add

git commit 命令

提交暂存区到仓库区

1
git commit -m [message]

git 生成ssh key

1
ssh-keygen -t rsa -C "your@email.com"

运行命令后会生成.ssh 文件夹,里面会有id_rsa.pub文件里会有ssh-key