Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close head without committing any change

Tags:

mercurial

I'm working on a project which is using mercurial and it's gotten into a bit of a mess with a number of heads which for all intensive purposes are dead.

I want to kill off these heads and bring the commit graph back to a single line.

I've been told there's a way to merge branches but at the same time ignore any file changes, so essentially just merging the tree, but I can't seem to work out the command set.

Is there a way to do this, kill off branches by doing merges and ignoring the file changes? Or alternatively is there a way to bring in the graph again without the changes (which are not massively irrelevant in the project)?

like image 947
Aaron Powell Avatar asked Dec 16 '10 13:12

Aaron Powell


People also ask

How do you get rid of changes before committing?

Try Git checkout --<file> to discard uncommitted changes to a file. Git reset --hard is for when you want to discard all uncommitted changes. Use Git reset --hard <commit id> to point the repo to a previous commit.

What does it mean when head is detached?

In Git, HEAD refers to the currently checked-out branch's latest commit. However, in a detached HEAD state, the HEAD does not point to any branch, but a specific commit or the remote repository.

How do you fix a detached head problem?

If you want to keep changes made with a detached HEAD, just create a new branch and switch to it. You can create it right after arriving at a detached HEAD or after creating one or more commits. The result is the same. The only restriction is that you should do it before returning to your normal branch.

How do you exit a detached head?

to get out of detached HEAD state. Generally speaking: git checkout <branchname> will get you out of that. This also tries to check out your last checked out branch.


1 Answers

If you are using TortoiseHg and named branches, you can select the branch option in the commit dialog to close a branch and it will allow you to commit without having an actual file change.

It will still leave you with a head, but it will be marked inactive.

like image 63
Binary Phile Avatar answered Sep 18 '22 01:09

Binary Phile