Git的使用

1.打开Git Bash
2.配置
$ git config查看所有操作

$ git config –global user.name “joyceshenhui”

$ git config –global user.name “joyceshenhui@qq.com”

$ git config -l
可以看到刚才输入的用户名和邮箱

$ cd \d
到D盘下

$ mkdir work
创建work文件夹

$ cd /d/work/
到当前目录下

$ pwd
显示当前路径
3.创建本地仓库
$ git init git30 初始化空的仓库

$ cd git30

$ ls -a会出现./ ../ .git/

$ touch hello.txt创建hello.txt文件

$ git status查看状态会显示有个未提交

$ ls -a会出现./ ../ .git/ hello.txt但是未提交到版本去只出现在工作区

$ git add hello.txt添加到暂存区

$ git commit -m “创建了一个hello.txt” 表示提交

$ git log查看日志

$ echo “this is a ” >> hello.txt修改文件内容

$ git add .

$ git commit -m “添加了一行数据”

$ cat hello.txt查看文本内容

$ git reset –hard 68976ef0d表示会滚到那个地方

$ git rm “hello.txt”删除文件

4.创建仓库https://github.com/new
这里写图片描述
复制框框里面的内容,要使用SSH的
这里写图片描述
$ cd ..到/d/work目录下

$ git clone 后面是刚才复制的内容粘贴

$ cd StudyRemote/ 刚才创建的仓库

$ git remote

$ git remote -v

然后按照上面创建文件测试有没有远程连接仓库成功

$ git push报错因为没有权限

$ cd ~返回到最外面

$ ssh-keygen -t rsa -P “” -C “joyceshenhui”

$ cd .ssh

$ cat id_rsa.pub
复制这里的内容

https://github.com/settings/keys
创建一个SSH key title自己取,key粘贴刚才复制的

$ ssh -T git@github.com
再去https://github.com/settings/keys这里刷新一下就可以了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值