<meta charset="utf-8">
删除文件的方法
-
git rm 文件名
同时删除文件夹和文档库中文件。 -
删除文件夹中文件,执行
git add - A
,git commit
3. git rm --cached 文件名
将文件转变成为追踪状态但不会删除文件
4. git reset HEAD 文件名
将文件内容从git索引中删除
显示各种信息的命令
-
git status
-
```git diff````对比版本差异
3. git ls - files -s
查看暂存区中状态
4. git ls -tree 分支名称
查看commit 文件
5.ll
显示当前分支的历史版本
自定义命令
1.git config alias.指令别名
设置指令别名
2. git tag 自定义标签名称 commit 节点标识符或标签
commit自定义标签
git tag -d commit 节点标签
删除自定义节点标签
3. git mv 原来的文件名 新文件名
更改文件夹中文件名,并将其加入git 索引。
返回历史文本命令
1. git reset 选项 commit 节点标识符或标签
选项:“ --soft ”只改变文档库中数据
“--mixed”恢复到指定节点中的状态,但文件夹中文件不受影响。
“--hard”文档库,git索引,文件夹中文件都恢复到指定节点状态。
2. git reset chash --(. or filename )
commit 内容覆盖暂存区
3. git commit --amend m'提交说明'
修改提交说明
比较文件差异命令
![](https://img.haomeiwen.com/i14288156/72f13358754b840f.png)
无分支情况下从git文档库中取出文件
git checkout commit 节点标识符或标签 文件1 文件2
git checkout 文件1 文件2...
依次查找文件
git grep '要找的字符串'commit 节点
![](https://img.haomeiwen.com/i14288156/0e4baea00056aa92.png)
清理git 文档库
![](https://img.haomeiwen.com/i14288156/ee2ece03fa0d7858.png)
程序项目的分支
1. git branch 分支名称 commit 节点标识符或标签
创建一个新分支
2. git check out -f分支名称
转换分支时,强制覆盖修改文件
3. git branch -d 要删除的分支名称
将 -d 换成 -D 强制删除未合并分支
4. git branch -m 分支名称
改变分支名称
5. ``git checkout HEAD标识符``` 变成detached HEAD 状态
6. git mergee --abort
合并冲突时放弃合并
7. git rebase --onto newbase start head
运用变基合并分支
8. git cherry-pick commit chash
commit 一个历史的版本(运用指定的 commit 节点版本)
revert 的使用
1.git revert chash
undo 一个commit
2. git revert -m 1(2) chash
撤销一个merge并选择主线
网友评论