1. Git 常用命令
192:Desktop futantan$ git config --global user.name dandan_claire
192:Desktop futantan$ git config --global user.email [email protected]
192:Downloads futantan$ cd git-demo/
git add 文件名 (到暂存区)
192:git-demo futantan$ git init ###初始化git Initialized empty Git repository in /Users/futantan/Downloads/git-demo/.git/ 192:git-demo futantan$ ls -a . .. .git 192:git-demo futantan$ touch hello.txt ###在git 文件下创建一个文件试试看 192:git-demo futantan$ vim hello.txt 192:git-demo futantan$ tail -n 2 hello.txt im fine too 192:git-demo futantan$ tail -n 1 hello.txt 192:git-demo futantan$ git status On branch master No commits yet Untracked files: (use "git add <file>..." to include in what will be committed) hello.txt nothing added to commit but untracked files present (use "git add" to track) 192:git-demo futantan$ git add hello.txt 192:git-demo futantan$ git status On branch master No commits yet Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: hello.txt 192:git-demo futantan$ git --version git version 2.20.1 (Apple Git-117) 192:git-demo futantan$
时这个hello.txt 在暂存区了
下面的命令就是把文件从暂存区删除,但是文件还存在于工作区
192:git-demo futantan$ git rm --cached hello.txt
rm 'hello.txt'
192:git-demo futantan$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
hello.txt
nothing added to commit but untracked files present (use "git add" to track)
192:git-demo futantan$ ls
hello.txt
将暂存区的文件提交到本地库
基本语法,git commit -m "日志信息" 文件名
提交后用git log 或者git reflog
修改文件(hello.txt)(以下红色的hello.txt 说明文件hello.txt还没有添加到暂存区)
git add hello.txt
git commit -m "xxxx" hello.txt
然后就可以查到两个版本了
标签:demo,git,futantan,常用命令,192,Git,使用,txt,hello From: https://www.cnblogs.com/clairedandan/p/18048532