git指令练习

附git菜鸟教程:
https://www.runoob.com/git/git-basic-operations.html
创建一个目录gitdemo

cd
mkdir gitdemo
cd gitdemo/
ll

在这里插入图片描述

git init 命用于在目录中创建新的 Git 仓库。

在目录中执行 git init 就可以创建一个 Git 仓库了。

 /usr/local/git-2.6.2/bin/git init

在这里插入图片描述

ll -a
ll .git/
ll

在这里插入图片描述

创建test.txt文本文件

vi test.txt

第一次编辑

this is first line

ESC

:wq

在这里插入图片描述
git status 命令用于查看在你上次提交之后是否有对文件进行再次修改。

git status

在这里插入图片描述
添加当前目录所有文件到仓库并查看在你上次提交之后是否有对文件进行再次修改

git add ./
git status

在这里插入图片描述
提交暂存区的指定文件到仓库区

git commit -m "first commit"

在这里插入图片描述
我们需要先设置提交的用户信息,包括用户名和邮箱:

git config user.name "zhangsan"
git config user.email "zhangsan@162.com"
git commit -m "first commit"

在这里插入图片描述
在这里插入图片描述
编辑test.txt文件

ll
vi test.txt

新增一行

second line

在这里插入图片描述
ESC
退出

:wq
git status

在这里插入图片描述

git commit -a -m "second commit"

在这里插入图片描述

–oneline 标记的作用是把每一个提交信息压缩为一行。默认情况下只会展示提交 ID与提交信息的首行。

git log --oneline
ll

在这里插入图片描述
在这里插入图片描述

第三次编辑

vi test.txt

在这里插入图片描述
第三次提交

git commit -a -m "third commit"
git log --oneline

在这里插入图片描述
查看历史提交记录

git log

在这里插入图片描述
使用reset回退版本

$ git reset HEAD^            # 回退所有内容到上一个版本  
$ git reset HEAD^ hello.php  # 回退 hello.php 文件的版本到上一个版本  
$ git  reset  052e           # 回退到指定版本
git reset HEAD^

在这里插入图片描述

git log --oneline
ll

在这里插入图片描述

more test.txt

在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值