如何将主人移到HEAD? [英] How to move master to HEAD?

查看:85
本文介绍了如何将主人移到HEAD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  * [971f835](HEAD,original_idea)现在在这里工作。一些评论9 
* [692b673]一些评论8
* [3ebff62]恢复到最初的想法。一些评论7
| * [72ea01d](主)决定这是不值得的努力。一些评论6
| * [985c1ad]一些评论5
| * [4d7d491]一些评论4
| * [0c697bb]分支来尝试一个想法。一些评论3
| /
* [7280b1f]一些评论2
* [5c2c6d0]一些评论1
* [bc7aac6]初始提交

因此, master 被留下了。不知道这是怎么发生的。一旦我确定我已经完成了没有工作的分支,我就签出了 [7280b1f] ,并从那里继续。



我如何解决这个问题?我这个臭名昭着的分离头问题?



master 必须与 HEAD 以获得回购的最佳状态?



我的工作流程非常简单。这只是管理一个文本文件。在绝大多数情况下,它是:

  git add。 
git commit -am一些评论

就是这样。



我决定尝试一个想法并创建一个分支。当它没有成功时,我检出了该分支的根目录并返回到 git add / commit 例程。

解决方案


这是臭名昭着的独立头问题吗?

否,HEAD指向分支 original_idea


master是否必须与HEAD保持一致才能达到
回购的最佳状态?

否, master 只是一个传统的名字,通常被认为是一个可以随时建立的分支,并且希望有一个工作快照。


我解决了这个问题?


如果您将 master 推送到另一个存储库,则需要合并您的更改 original_idea 转换为 master

  git checkout master 
git合并original_idea

请注意,如果有任何冲突的更改,您需要解决它们。 p>

如果您还没有将 master 推送到另一个re您可以删除 master 并从 original_idea 重新创建它。 警告:每个正在处理 master 的人都必须重置他们的 master 分支。

  $ git checkout master 
切换到分支'master'

$ git checkout -b experiment_1
切换到新分支'experiment_1 '

#这里我们要删除主人。应该是安全的,因为experiment_1
#是从上述命令的这一点创建的

$ git branch -d master
已删除的分支主机(是72ea01d)。

$ git checkout original_idea
转换到分支'original_idea'

#现在我们签出了HEAD指向的分支,我们可以重新创建master

$ git checkout -b master
转换到新分支'master'


* [971f835] (HEAD, original_idea) Now working here. Some comment 9
* [692b673] Some comment 8
* [3ebff62] Reverted to original idea. Some comment 7
| * [72ea01d] (master) Decided it wasn't worth the effort. Some comment 6
| * [985c1ad] Some comment 5
| * [4d7d491] Some comment 4
| * [0c697bb] Branched to try an idea. Some comment 3
|/
* [7280b1f] Some comment 2
* [5c2c6d0] Some comment 1
* [bc7aac6] Initial commit

So, master got left behind. Not sure how that happened. Once I decided I was done with the branch that didn't work out I checked out [7280b1f] and continued from there.

How do I fix this? I this the infamous "detached head" issue?

Does master have to be aligned with HEAD for optimal health of the repo?

My workflow is super-simple. This is just managing a single text file. In the vast majority of cases it's:

git add .
git commit -am "Some comment"

And that's it.

I decided to try an idea and created a branch. When it didn't work out I checked out the root of that branch and went back to the git add/commit routine.

解决方案

Is this the infamous "detached head" issue?

No, HEAD is pointing at branch original_idea

Does master have to be aligned with HEAD for optimal health of the repo?

No, master is just a conventional name, usually taken to be a branch which is readily buildable and hopefully a working snapshot.

How do I fix this?

If you have pushed master to another repository, you need to merge you changes from original_idea into master:

git checkout master
git merge original_idea

Be aware that if there are any conflicting changes you'll need to resolve them.

If you have not yet pushed master to another repository, you could delete master and recreate it from original_idea. WARNING: Everyone who was working on master will have to reset their master branch.

$ git checkout master
Switched to branch 'master'

$ git checkout -b experiment_1
Switched to a new branch 'experiment_1'

# Here we are going to delete master.  Should be safe, since experiment_1
# was created from this point on the previous command

$ git branch -d master
Deleted branch master (was 72ea01d).

$ git checkout original_idea 
Switched to branch 'original_idea'

# Now that we checked out the branch HEAD is pointing to, we can recreate master

$ git checkout -b master
Switched to a new branch 'master'

这篇关于如何将主人移到HEAD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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