Mercurial 的混乱情况
我处于这种情况:
首先我刚刚开始使用 Mercurial。 我有一个服务器,里面有我的 django 项目。
我想从本地计算机服务器上的项目目录克隆存储库。
我已经这样做了:
user@host> cd myproject
user@host> hg init
user@host> hg add
user@host> hg commit -m "Added initial files."
我已经使用 hg clone ssh://user@host//path/to/project
克隆了存储库。没关系,我的计算机上有服务器上的所有文件。
现在,我想编辑 settings.py
来设置本地环境(数据库引擎和其他内容),但我不想更新服务器上的 settings.py
。编辑后,hg status
返回我M settings.py
。即使我设置了 echo 'settings.py' > .hgignore 在我的本地存储库中,它不起作用。对于工作目录中的目录 static
、media
和数据库 my_database
也是如此。如何将 Mercurial 设置为 NOT 更新并在服务器中提交?
我想在我的计算机和服务器上工作,并使所有两个存储库始终同步。
有人可以解释一下我应该做什么吗?我有点困惑。
谢谢你!
I'm in this situation:
First of all I just started to use mercurial.
I've a server where there's a my django project.
I want to clone repository from the project dir on server in my local computer.
I've done this:
user@host> cd myproject
user@host> hg init
user@host> hg add
user@host> hg commit -m "Added initial files."
I've cloned the repo with hg clone ssh://user@host//path/to/project
. And it's ok, on my computer I've all files that I've on the server.
Now, I want to edit settings.py
for setting local environment (database engine and other stuff), but I don't want to update the settings.py
on the server. And after the edit, hg status
returns me M settings.py
. Even if I set echo 'settings.py' > .hgignore
in my local repo, it doesn't work. The same for the directories static
, media
and the database my_database
in the working directory. How can I set mercurial for NOT update and commit in the server?
I want to work either on my computer and on the server and get all two repo always synchronized.
Could someone kindly explain me what should I do? I'm a bit confused.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它没有直接回答你的问题,但我发现管理本地设置的好方法是将它们放在一个单独的文件中(被你的SCM忽略)并将它们加载到settings.py中。
例如,将其放在 settings.py 的底部:
settings_local.py
中的任何内容都将覆盖settings.py
中的值。编辑:
更直接地解决您的问题,请参阅 Mercurial 忽略文件下的答案。看起来不支持忽略已经版本化的文件。我以前用 Subversion 做过这个,所以我能明白你为什么要尝试它。其他答案有一些解决方法。
It doesn't answer your question directly, but I've found a good way to manage local settings is by putting them in a separate file (ignored by your SCM) and loading them in settings.py.
For example, put this at the bottom of settings.py:
Anything in
settings_local.py
will override the values insettings.py
.EDIT:
More directly to your question, see this answer under Mercurial ignore file. It looks like ignoring an already-versioned file isn't supported. I have done it with Subversion before, so I can see why you are trying it. The other answers have some workarounds.
首先,如果
settings.py
已经提交,那么忽略它不会改变这一点。您需要首先(据我所知,仅将文件名附加到 .hgignore 不会执行任何操作,但我知道有不同的格式。无论如何,请注意这一点,因为出色地。)
First, if
settings.py
is already committed, then ignoring it won't change that. You'd need to first(Just appending the filename to
.hgignore
doesn't do anything, that I know of, but I know there are different formats for this. Anyway, be aware of that, as well.)我可以回答您问题的一部分:
如果一个文件与忽略文件 (.hgignore) 中的模式匹配,则如果该文件已被 Mercurial 跟踪,则该文件不会被忽略。这解释了为什么对 settings.py 的编辑不会被忽略;这是因为 settings.py 已经被跟踪。当您执行命令
hg add
时,会将所有文件添加到您的存储库中;也就是说,mercurial 开始跟踪所有这些(除了当时被忽略的)。I can answer one part of your question:
If a file matches a pattern in the ignore file (.hgignore), it is NOT ignored if it is already being tracked by mercurial. This explains why edits to your settings.py are NOT ignored; it's because settings.py is already being tracked. When you did the command
hg add
, that added all the files into your repository; that is, mercurial started tracking them all (except any that were being ignored at the time).