Git - 从旧提交中创建一个新的远程分支

标签 git branch commit

我正在使用以下 Git 命令来创建一个新的远程分支:

git push origin origin:refs/heads/new_branch_name

我希望新分支将从旧的提交开始,

我该怎么做? (我试过一些不同的方法,虽然失败了)

谢谢。

最佳答案

git checkout -b new_branch_name
git reset --hard <old_commit_id>
git push origin new_branch_name

关于Git - 从旧提交中创建一个新的远程分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24833198/

相关文章:

git - 有没有办法以 git log 漂亮的格式执行 shell 脚本?

git - 推送到 Bitbucket : ssh: Could not resolve hostname bitbucket. org:用户名: 没有这样的文件或目录

git - 每次提交将分支拆分为一个分支

git - 在git中标记多个分支?

ios - Git获取源差异提交

git 克隆 git@myserver :gitolite-admin fails

git - 锁定 Git 分支

git - 恢复损坏的分支/解决分离的 HEAD 状态?

python - Python 如何查看另一个客户端对 MariaDB 所做的更改?

ruby - 如何使用 webhooks 从 Gitlab 推送到 Github