起步
Git 保存的不是文件的变化或者差异,而是一系列不同时刻的 快照
在进行提交操作时,Git 会保存一个提交对象(commit object), 知道了 Git 保存数据的方式,我们可以很自然的想到——该提交对象会包含一个指向暂存内容快照的指针。但不仅仅是这样,该提交对象还包含了作者的姓名和邮箱、提交时输入的信息以及指向它的父对象的指针
首次提交产生的提交对象没有父对象,普通提交操作产生的提交对象有一个父对象, 而由多个分支合并产生的提交对象有多个父对象
基础操作
- 提交完了才发现漏掉了几个文件没有添加,或者提交信息写错了 ```git git add . git commit -m ‘1.MD’
git add . git commit —amend -m ‘3.md’
2. 取消暂存区文件
```git
git add .
git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: 2.MD
modified: 3.MD
git reset HEAD 1.MD
撤销对工作区文件的修改
撤销提交
git reset --hard f6ff02007a2b10661b56b0a0873e8fb1ff55c005
5.切换分支 ```bash $ git branch
在checkout命令指定 -b选项执行,可以创建分支并进行切换。
$ git checkout -b
<a name="YjKBw"></a>
#### git subtree
```dockerfile
git remote -v
git remote rm destination
git subtree add --prefix=musee-business/src/components components master
git subtree add --prefix=components http://gitlab.musee.com.cn/musee-front/musee-bs/components.git master --squash
git subtree push --prefix=b-platform/src/components http://gitlab.musee.com.cn/musee-front/musee-bs/components.git master --squash
git remote add components http://gitlab.musee.com.cn/musee-front/musee-bs/components
git subtree pull --prefix=b-admin/src/components components master
git subtree push --prefix=b-platform/src/components components master --squash
git远程回滚
revert
# 回退到该版本
git revert 3b758f45cacdcdb6d932e115a34cd81d28f5f845
# 正常提交