如果我有N个提交,我如何从N-3个提交分支?
当前回答
我可以这样做:
git branch new_branch_name `git log -n 1 --skip 3 --format=%H`
必须在其中输入跳过值。0是最新的,1是先前的,2是之前的提交,等等。
其他回答
这是我所做的:
C:\Users\[path]\build>git checkout -b responsivenavigation 8a75b001096536b3216022484af3026aa9c7bb5b
Switched to a new branch 'responsivenavigation'
C:\Users\jaimemontoya\[path]\app>git branch
master
* responsivenavigation
在本例中,8a75b001096536b3216022484af3026aa9c7bb5b是属于主分支的旧提交。
使用提交哈希创建分支:
git branch branch_name <commit-hash>
或使用符号引用:
git branch branch_name HEAD~3
要在创建分支时签出分支,请使用:
git checkout -b branch_name <commit-hash or HEAD~3>
还没人提到git开关?
您可以执行以下操作:
git checkout<commit hash>
或使用符号引用:
git结帐头~3
然后:
git开关-c我的新功能分支
使用Sourcetree|最简单的方法。
首先,签出要进行特定提交以创建新分支的分支。然后查看工具栏,选择Repository>Branch。。。快捷方式是Command+Shift+B。然后选择要执行的特定提交。并给出一个新的分支名称,然后创建一个分支!
我可以这样做:
git branch new_branch_name `git log -n 1 --skip 3 --format=%H`
必须在其中输入跳过值。0是最新的,1是先前的,2是之前的提交,等等。
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- 在GitHub上有一个公共回购的私人分支?
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式