Git的使用

来源:互联网 发布:云南省贫困人口数据 编辑:程序博客网 时间:2024/05/19 20:47

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这里刷新一下就可以了

原创粉丝点击