私人变更的用例 [英] Use case for private changes

查看:80
本文介绍了私人变更的用例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有以下情况:我从URL X克隆了一个开源项目.现在,我有了它的本地克隆.我对本地克隆进行了一些更改以尝试操作并在本地提交.现在我想要的是:

Supposing I have following scenario: I cloned some open-source project, say from URL X. Now I have local clone of it. I made some changes to local clone to try things out and commited them locally. Now what I want is following:

我想从开源项目X中获取更新.只需获取其所有最新代码,而无需进行任何更改.但是我希望所做的更改能够保留在历史记录中的某个位置,以便以后再获取.而且我不想为此克隆单独,而希望在我的一个仓库中全部复制.

I want to get update from the open-source project X. Just get all its latest code, without my changes at all. But I want my changes to live somewhere in tag in history so I can get them later. And I don't want to separate clone for this, want it all in my one repo.

现在我做了以下事情:

  1. hg tag
  2. 标记我的更改
  3. 拉&合并来自URL X的最新代码
  4. 将存储库恢复为URL X的最新版本
  1. Tag my changes with hg tag
  2. Pull & merge latest code from URL X
  3. Revert repository to latest revision of URL X

但是我觉得这不是好方法,而是回旋处.我认为有更好的方法.你能建议吗?

But I feel this isn't good way and it's roundabout. I think there's better way. Could you please suggest?

推荐答案

我将使用书签.如果您使用Mercurial 1.8或更高版本,则您已经内置了书签功能.否则,您首先需要通过将以下内容放入您的~/.hgrc文件来启用扩展名:

Instead of tags, I would use a bookmark. If you use Mercurial 1.8 or later, you already have the bookmark functionality built-in. Otherwise, you first have enable the extension by putting the following in your ~/.hgrc file:

[extensions]
bookmarks =

[bookmarks]
track.current = True

现在获取您项目的副本:

Now get the clone of your project:

hg clone http://bitbucket.org/user/X
cd X

然后入侵:

# edit, edit, edit...
hg commit -m 'Great new feature!'

现在在此变更集上添加书签

Now put a bookmark on this changeset

hg bookmark mywork

这就像一个标签,但是书签的优点是在您进行新提交时会随之移动.这就像您在读书并随身携带书签时一样.创建书签后,您可以

This is like a tag, but the advantage of a bookmark is that is moves along when you make new commits. This is just like when you're reading a book and move the bookmark along with you. When the bookmark is created, you can do

hg update mywork

返回带书签的变更集.

在上游存储库中进行了更改后,您可以将其合并到自己的分支中:

When there has been changes made in the upstream repository, then you pull and merge them into your own branch:

hg update mywork # if necessary
hg pull
hg merge
hg commit -m 'Merged new upstream changes.'    

书签将向前移动,现在指向您刚创建的合并更改集.如果您想更新到X中的版本,那么

The bookmark will have moved forward and is now pointing to the merge changeset you just created. If you want to update to the version in X, then

hg update --rev -2

将在您添加更改后执行此操作-这将从合并之前的X的尖端更新到旧的尖端Changeset.

will do it after you pulled in changes -- this updates to the old tip changeset from before the merge, which was the tip of X.

这篇关于私人变更的用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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