git学习笔记-7 git checkout 切换分支

来源:互联网 发布:lvmh招聘 知乎 编辑:程序博客网 时间:2024/06/05 19:20

1 分离的头指针
涉及到命令
cat .git/head //LINUX命令
查看分支指向的地方

git checkout 35e2f0d(切换到某次提交(某个commit的id))
head 处于游离的状态

git branch -v 或者 git status 查看当前所处的分支状态
会发现当前没有分支,也就是游离的状态

git reflog -1 查看第一条记录(最近的) moving from master to xxxxx

2 挽救分离头指针

git branch new_branch_name xxxxxxxxxx(commit id)
通过创建新分支把这次提交保存到分支上

git merge xxxxxxxxxx(commit id) 改变历史
log中会多了一次提交

git cat -file -p HEAD 会有两个parent

再add commit push 这样就回到历史的版本了

——checkout常用命令
git checkout 目录 ———– 回退

0 0
原创粉丝点击