赞
踩
附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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。