기록에서 삭제하지 않고 변경 사항 포기
작동하지 않는 커밋이 있으므로 history에서 삭제하지 않고 버리고 싶습니다 .
이전 개정판에서 업데이트하여 커밋하여 새로운 헤드를 만들었습니다.
나는 가지가없고, 가지를 원하지 않습니다. 단지 새 머리를 그대로 그대로, 공상, 합병, 걱정하지 않고 그냥 이전 머리를 잊어 버리고 싶습니다.
나는 그것을하는 방법을 찾지 못하는 것 같아서 할 수 없다는 것을 믿기 시작했습니다. 내가 찾은 것은 가지에 관한 것, 또는 병합에 관한 것입니다.
잊고 자하는 개정으로 리포지토리를 헤드로 업데이트 한 다음 hg commit --close-branch
(익명) 브랜치를 닫힌 것으로 표시하는 데 사용하십시오 . 그런 다음 그 지점의 머리로 업데이트 할 원하고 작업을 계속합니다.
-c
옵션을 사용하면 닫힌 분기를 계속 볼 수 hg heads
있지만 기본적으로 표시 hg merge
되지 않으며 닫힌 헤드와 병합을 시도하지 않습니다.
당신은 사용해야합니다 hg push --force
당신이 누를 때 당신이 실제로 원격 저장소에 추가 머리를 만들 수 있기 때문에 다른 저장소에이 폐쇄 머리를 밀어 처음. 따라서 Mercurial에게 이것이 괜찮다고 말하십시오 --force
. 닫힌 머리를 당기는 사람들은 경고로 귀찮게하지 않습니다.
이 단계에서 브랜치로 작업 하고 싶지 않다는 것을 알고 있지만 이것이 바로 당신이 한 일입니다. 이전 버전으로 돌아가서 작동하는 무언가를 커밋하면 이름이없는 브랜치 인 브랜치를 만들었지 만 모두 같은 브랜치를 만들었습니다.
머리를 여러 개 가지고있는 것에 대해 걱정하지 않고 그대로 유지하는 데 아무런 문제가 없지만, 물건을 정리하고 싶을 때 실수로 잘못된 머리를 한 번 선택하지 않으면 이전 지점을 죽일 수 있습니다.
Mercurial 문서에는 가지 치기 데드 브랜치 (Pruning Dead Branches) 와 관련된 여러 옵션을 안내하는 좋은 섹션이 있습니다 .
가장 좋은 방법은 오래된 지점을 "닫은"것으로 표시하는 것입니다. 이전 헤드가 "123"개정판 인 경우 :
hg update -r 123
hg commit --close-branch -m 'Closing old branch'
hg update -C default
먼저 다음을 입력하십시오.
hg heads
세 개의 머리가 나열되어 있다고 상상해보십시오.
changeset: 223:d1c3deae6297
user: Your name <your@email.com>
date: Mon Jun 09 02:24:23 2014 +0200
summary: commit description #3
changeset: 123:91c5402959z3
user: Your name <your@email.com>
date: Sat Dec 23 16:05:38 2013 +0200
summary: commit description #2
changeset: 59:81b9804156a8
user: Your name <your@email.com>
date: Sat Sep 14 13:14:40 2013 +0200
summary: commit description #1
마지막 머리를 활성 상태로 유지하고 (223) 나머지를 닫으려고합니다.
그런 다음 다음과 같이하십시오.
클로즈 헤드 # 59
hg up -r 59
hg ci --close-branch -m "clean up heads; approach abandoned"
클로즈 헤드 # 123
hg up -r 123
hg ci --close-branch -m "clean up heads; approach abandoned"
변경 사항을 커밋
hg push
마지막에 오른쪽 머리로 전환하는 것을 잊지 마십시오
hg up -r 223
그리고 당신은 끝났습니다.
사용하고 싶습니다 hg backout
. 이렇게하면 변경 세트에서 변경 한 사항이 모든 하위 변경 세트에서 제거됩니다.
좋은 설명을 위해 이것을 확인하십시오. 머큐리얼 백 아웃
Niall과 Nick의 대답은 모두 직설적입니다. 매달린 머리를 많이 만들었으므로 머리를 더 쉽게 닫을 수 있도록 별칭을 작성했습니다. 이것을 당신의 .hgrc
:
[alias]
behead = !REV=$($HG id -i); $HG update $@ -q && $HG ci --close-branch -m "Closing dead head" && $HG update $REV -q
(이미 [alias]
섹션이 있다면 대신 추가 할 수 있습니다)
You can now close a head in one single-command (and without having to update to a different changeset manually) like this:
$ hg behead 123
Note: the alias takes advantage of the fact that Mercurial aliases can be shell commands. This means that this will probably only work on UNIX, not on Windows.
This is a use case for the Evolve extension. It's currently not bundled with Mercurial, so it is technically a third party extension. But it's being used quite heavily by a bunch of people, including Mercurial developers, is being very actively developed, and isn't going anywhere.
With the Evolve extension, you simply do
hg prune -r revname
and get on with your life. The cset will still be there, but obsoleted. It won't be visible unless you pass the --hidden
option to Mercurial commands, and by default won't be pushed to remote repositories. Though I think you can force it if you really want to.
If the cset you are pruning has ancestors you want to keep, then you'll have to run hg evolve
to rebase those changesets. hg evolve
will do so automatically. Otherwise, you don't have to do anything.
You may clone your corrupted repo to a new one without cloning that unwanted head. Then remove old repository, move newly created clone to the original place and continue working with it. This will take some time, but you'll get a perfectly clean repository without a sign of that unwanted revision.
hg clone --rev myGoodResition myDirtyRepo myCleanRepo
An alternative to closing or stripping the unwanted branch would be to merge it in a way that totally discards its effects, but leaves it in history. This approach will allow those unwanted changes to propagate in a push - so only use this if that is the intended effect.
Let's say the changeset history looks like this:
1-2-3-4-5-6
\
7-8-*
and it is 5
and 6
which are no longer wanted.
You can do this:
hg up 8
hg merge -r 6 -t :local
hg commit ...
which will create this:
1-2-3-4-5-6
\ \
7-8-9-*
The update to 8
ensures you are working at the desired head in history, which you want to keep.
The -t :local
instructs hg to use the merge "tool" called local which tells it to ignore changes from the other branch, i.e., the one NOT represented by the current working folder state. More info.
Thus the unwanted changes in 5
and 6
are preserved in history but do not affect anything more recent.
I have run into this issue many times when I want to behead a head that was created in error. I always want to see it disappear off the face of the Earth.
On your local copy, get the latest and then:
Find the beginning of a head you want to strip (where a new neck starts to branch off), get the revision number
Strip it.
Source: TipsAndTricks.
Source: PruningDeadBranches#Using_strip.
hg --config extensions.hgext.mq= strip -n <rev>
- Make a trivial file update (add a whitespace to a file), commit and push.
Your repo should now have the head stripped. The last step is important as stripping doesn't create any changes you can push to your central repository. Without the last step you only have stripped the head locally.
참고URL : https://stackoverflow.com/questions/3688263/abandoning-changes-without-deleting-from-history
'IT' 카테고리의 다른 글
X-SourceFiles 헤더는 무엇을합니까? (0) | 2020.05.20 |
---|---|
부트 스트랩 그리드 시스템이있는 중첩 된 행? (0) | 2020.05.20 |
mongoimport를 사용하여 CSV를 가져 오는 방법 (0) | 2020.05.20 |
WPF 차트 컨트롤 (0) | 2020.05.20 |
HTML-줄임표가 활성화 된 경우에만 툴팁을 표시하는 방법 (0) | 2020.05.20 |