GIT使用笔记
GIT笔记
随时更新
一、使用技巧
1.合并commit
git rebase -i <commit_sha>
//以 “旧、新、最新” 提交为例,要合并 新和最新 提交
git rebase -i 旧
//弹出文本,修改pick >> fixup 后保存退出
pick 新
fixup 最新
2.更改最新commit备注
git commit --amend
3.工程回到某个commit
git reset <旧commit>
git reflog
git reset <新commit>
//或者使用 vscode history功能
代码如下(示例):
4.本地暂存代码,不提交commit
git stash #暂存
git 干其他事
git stash list #查看暂存区代码
git stash pop stash@{n} #n为list内第几个暂存
5.git使用中途添加.gitignore文件
git rm -r --cached .
git add .
git commit -m 'update .gitignore'
6.已经add的文件,撤销add保留修改
git reset --mixed
//查看可操作状态 git status