GitHub入门(四)

基本命令操作

1.初始化仓库

进入指定目录$ cd E:\githome
初始化:$ git init
初始化成功提示:Initialized empty Git repository in /Users/hirocaster/github/github-book

/git-tutorial/.git/

2.查看仓库状态

查看命令:$ git status
提示处于master分支下:# On branch master 
#
# Initial commit
#

提示没有可提交的文件:nothing to commit (create/copy files and use "git add" to track)

3.向暂存区中添加文件

提交文件:$ git add test.txt

查看状态:$ git status

提示信息# On branch master

#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: test.txt

#

4.保存仓库的历史记录

    4.1保存命令其中“First commit”是描述信息:$ git commit -m "First commit ”

    4.2终止提交

如果在编辑器启动后想中止提交,请将提交信息留空并直接关闭编辑器,随后提交就会被中止。

5.查看提交日志

    5.1查看命令:$ git log

    5.2只显示提交信息的第一行 :$ git log --pretty=short

    5.3只显示指定目录、文件的日志 :$ git log test.txt

    5.4显示文件的改动 :$ git log -p test.txt

6.查看更改前后的差别

6.1查看工作树和暂存区的差别$ git diff 

6.2查看工作树和最新提交的差别 :$ git diff HEAD












猜你喜欢

转载自blog.csdn.net/ly853602/article/details/80379721
今日推荐