添加文件从工作区到暂存区,采用 git add +(文件名),
git status 查看修改的状态(暂存区,工作区)
添加所有文件到暂存区
git add .
将暂存区文件放入仓库 git commit -m "文件代号"
git commit -m "文件代号"
?
?查看操作的历史记录 git log
clear以后也可查找历史记录 git reflog
git log
编辑仓库文件? vi (文件名) 进入后修改内容 再按ESC键 再写 :wq? 回车,修改文件完成
?查看git状态 ,可以看到什么文件在暂存区,未放进仓库
$ git status
94946@LAPTOP-81SAERCH MINGW64 /d/GIT/repositorys/repo1 (master)
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: fff.txt
?git为命令设置别名,首先?touch ~/.bashrc
再设置自己想要的别名?alias git-log='git log --pretty=oneline --all --graph --abbrev-commit'
94946@LAPTOP-81SAERCH MINGW64 /d/GIT/repositorys/repo1 (master)
$ touch ~/.bashrc
94946@LAPTOP-81SAERCH MINGW64 /d/GIT/repositorys/repo1 (master)
$ alias git-log='git log --pretty=oneline --all --graph --abbrev-commit'
94946@LAPTOP-81SAERCH MINGW64 /d/GIT/repositorys/repo1 (master)
$ git-log
* ccd3700 (HEAD -> master) 123
* 6da137a fff
* da0dd0d add hello
?git版本回退以及前进 git reset --hard (版本id)
94946@LAPTOP-81SAERCH MINGW64 /d/GIT/repositorys/repo1 (master)
$ git-log
* ccd3700 (HEAD -> master) 123
* 6da137a fff
* da0dd0d add hello
94946@LAPTOP-81SAERCH MINGW64 /d/GIT/repositorys/repo1 (master)
$ git reset --hard da0dd0d
HEAD is now at da0dd0d add hello
94946@LAPTOP-81SAERCH MINGW64 /d/GIT/repositorys/repo1 (master)
$ git-log
* da0dd0d (HEAD -> master) add hello
94946@LAPTOP-81SAERCH MINGW64 /d/GIT/repositorys/repo1 (master)
$ git reset --hard 6da137a
HEAD is now at 6da137a fff
94946@LAPTOP-81SAERCH MINGW64 /d/GIT/repositorys/repo1 (master)
$ git-log
* 6da137a (HEAD -> master) fff
* da0dd0d add hello
|