配置git
1、添加全局git个人信息
1 2
| git config --global user.name "name" git config --global user.email [email protected]
|
不添加全局可去掉--global,配置文件在当前项目的.git/config文件内。
2、ssh key
本地创建sshkey
之后会要求确认路径和输入密码,我们这使用默认的一路回车就行。成功的话会在~/下生成.ssh文件夹,进去,打开id_rsa.pub,复制里面的key。回到github上,进入Account Settings(账户配置),左边选择SSH Keys,Add SSH Key,title随便填,粘贴在你电脑上生成的key。
为了验证是否成功,在git bash下输入:
3、添加远程仓库地址
git 命令
1、创建本地仓库
1 2 3 4
| mkdir project cd project
git init
|
2、远程仓库
1 2 3 4 5
| git clone https://githun.com/username/repo.git cd repo
git remote git remote -v
|
3、分支
1 2 3 4 5 6 7
| git checkout -b new-feature git checkout main git branch git branch -r git branch -a git branch testing git branch -d testing
|
4、暂存文件
1 2 3 4
| git add filename
git add .
|
5、提交更改
1
| git commite -m "add new"
|
6、拉取最新更改
7、推送更改
8、查看状态