从当前工作树创建分支并重置为HEAD [英] Create branch from current working tree and reset to HEAD

查看:60
本文介绍了从当前工作树创建分支并重置为HEAD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一项功能,该功能实际上比预期的要大,因此最好创建一个分支来处理该功能。因此,我需要从当前工作目录中创建一个新分支,并将master分支重置为当前HEAD,以便可以对生产环境进行一些修复。

I currently work on a feature that turns out to be bigger than expected, so it's propably the best to create a branch to work on it. So I need to create a new branch from my current working directory and reset the master branch to the current HEAD so that some fixes to the production environment can be done.

这听起来很容易,但我还不太清楚。可能是由于我缺乏睡眠。

Somehow this sounds like an easy task, yet I can't quite figure it out. Possibly due to my lack of sleep.

推荐答案

因此,创建一个工作分支:

So, create a working branch:

git checkout -b working_branch

提交或存储更改

git add <files>
git commit -m "message"

OR

git stash

回到主目录

git checkout master
git reset HEAD

这篇关于从当前工作树创建分支并重置为HEAD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆