git基本操作

git基本操作

配置好钥匙

查看用户名和邮箱地址

1
2
git config user.name
git config user.email

设置/修改用户名和邮箱地址

1
2
git config --global user.name "1134506391" //(设置用户名)
git config --global user.email "1134506391@qq.com" (//设置常用邮箱,最好与guihub用的邮箱一致)

注意git config命令的–global参数,用了这个参数,表示你这台机器上所有的Git仓库都会使用这个配置,当然也可以对某个仓库指定不同的用户名和Email地址。

推送文件夹到远程仓库

新建远程仓库

1
2
3
new respository
名字和本地仓库一样
test7

2.得到https

1
https://github.com/1134506391/test7.git

本地git仓库

1
2
3
mkdir test7
cd test7
git init

复制文件过来,推送文件夹到远程

1
2
3
4
git add . //缓存区
git commit -m "推送文件夹到远程" "工作区 -m为注释"
git remote add origin https://github.com/1134506391/test7.git //关联远程仓库
git push -u origin master //推送到远程仓库 //第一次用-u 以后不用

文件夹内要有文件才会推送
远程仓库修改,本地下拉更新

1
git pull

clone

1
git clone https://github.com/1134506391/test7.git