Mac终端实用git命令行

90 阅读1分钟

gitTest

1. 远程分支关联

默认关联

2. add 撤回

git reset HEAD .

git reset HEAD file //撤销单个文件

3.commit撤回

git reset --soft fbe82f4b1cb14f024025472a0985920ca74a07ae //保留到暂存区域

commit b233e61e5fe26a1db2c2e24d696e7c0ac1775a9f (HEAD -> test)
Author: gongchengshilifa <15554104745@163.com>
Date:   Wed Dec 13 15:45:35 2023 +0800
​
    commit 撤回
​
commit fbe82f4b1cb14f024025472a0985920ca74a07ae (origin/test)
Author: gongchengshilifa <15554104745@163.com>
Date:   Wed Dec 13 15:43:48 2023 +0800
​
    update addInfo

git reset --hard fbe82f4b1cb14f024025472a0985920ca74a07ae //b233e61e5fe26a1db2c2e24d696e7c0ac1775a9f提交消失

4. 查看远程分支

git branch -r

5. stash

git stash save 'stsh1' //会将当前分支的工作区、暂存区中的代码剪贴到stash区域

git stash pop stash@{0} //检出全部

git stash pop //检出所有

git stash list //查看stash

6.git checkout

git checkout fileName 清除fileName文件的

git checkout . //慎用,会把工作区的所有新代码都清除

7. git diff

git diff fileName 查看本次修改和上次修改的区别