I am very new to Hg so please excuse my ignorance here...
I am using Mercurial and TortoiseHg in Windows 7. I have a repository created that has the following folder structure:
-- My repo dir
|
|--- .hg
|--- .hgignore
|--- File 1
|--- File 2
|--- ...
My database data files live in the repo directory but I do not want them to be included as part of the repository. I've tried all kinds of things in the .hgignore file, but regardless when I right-click on the repo folder in the Windows Shell and go to Hg Commit..., it includes the two database data files in the list of files to be committed. Yes, I can uncheck them manually, but my thought was that by being in .hgignore they wouldn't be included in the list of files to commit.
Here's my current incarnation of .hgignore, although I've tried a handful of others with no luck:
MyDatabase\.mdf
MyDatabase\_log\.ldf
Am I being daft here, or is it that TortoiseHg does not respect/inspect the .hgignore file when committing?
UPDATE:
Finally got this to work. I had to instruct Mercurial to forget the files, as #Diego suggested. Interestingly, though, when I followed #Diego's suggestions and tried to forget them via the command-line it did not work. I had to go to Windows Explorer, right-click on the files, and from the context menu I chose TortoiseHg --> Forget Files...
Thanks for the suggestions, everyone.
Maybe mercurial is already tracking those files. If files are already tracked then .hgignore does not have any effect. Try:
hg forget MyDatabase\.mdf MyDatabase\_log\.ldf
Then edit .hgignore to exclude those files and commit.
That should solve it.
You need to add this line at the beginning of your .hgignore file:
syntax: glob
MyDatabase\.mdf
MyDatabase\_log\.ldf
Scott,
Do you have any other mdf/ldf files that you want to add to the repository? If not, could you just try the following in your .hgignore file?
syntax: glob
*.mdf
*.ldf
Related
I have often used this approach to dot file management in git, where I create a bare git repo "~/.dotfiles" and us $HOME as a work tree. With the shell alias config I can then add dot files from the home dir quickly (as in config add, config commit
alias config='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
I wonder if a similar setup is possible in mercurial.
You can use a regular repository for that[^bare] and clone it with the share extension. Creating a new home dir as one-liner:
hg --config extensions.share= share $HOME/.dotfiles $HOME
For more information see hg help share. For information how to ignore changes to untracked files, see hg help hgignore.
[^bare]: If it is important for you to have no files in the .dotfiles, just hg update null in ~/.dotfiles. That’s the root of the repository (before anything got added). Mercurial needs no special bare state.
I am using BitBucket with SourceTree on my home computer and on my laptop.
When I commit on one computer, the bin and obj folders are ignored.
When I commit on the other computer, changes to files in the bin and obj folders display.
The .hgignore file is under source control so I don't understand why it does not behave the same on both computers.
Both computers run VS2015 Update 1 and SourceTree 1.7.32059
The repositories do have different folder names.
The .hgignore file on my home computer is (trimmed down)
syntax: glob
MyAppDocuments
SBD.MyApp.Web\MyAppdocs
*.nupkg
Why does this not work the same way on my laptop?
Apparently Sourcetree supports both the usual .hgignore file in the Mercurial repository and a global .hgignore which is stored in C:\users\<username>\.hgignore_global.
It sounds like you've got the bin and obj folders added to the global ignore on one computer, but not on the other.
Really the bin and obj entries should be in the .hgignore in your repository. If you can locate the global ignore file you might be able to copy the required entries from there into your repository .hgignore file.
Information taken from this question on Atlassian support.
i am using Mercurial for version controlling. I am trying to ignore zip files in the repository, my hgignore file is in the root directory of project
i got the codes below from http://www.selenic.com/mercurial/hg.1.html#patterns.
syntax: glob
**.zip
syntax: regexp
re:.*\.zip$
But these doesnt work for me.
i also tried
hg addremove
and
hg forget -I '*'
but it didnt help. Can you tell me how can properly ignore zip files from the repository?
Thanks for help.
EDIT
My problem was the zip files were already added to repository. I first forgot them and committed. Now it ignores
Simply writing *.zip inside .hgignore will do this. The patterns inside .hgignore are not rooted, so *.zip would match a zip archive no matter where it appears.
I currently have a project versioned using Mercurial. On my computer, there is a .hg folder in the root of my local repository.
I want to change from Mercurial to Git, so I'm wondering if removing the .hg folder is enough to remove Mercurial versioning from this folder?
If not, what can I do? (I don't want to move the existing sources on my computer).
Yes, all the bits that make it a Mercurial repository are in the .hg folder so you can delete that to remove the Mercurial versioning.
Note though that doing this will obviously lose all your source control history as well.
Looks like there are some options to convert the repository if you want to keep that history, first hit on google:
http://arr.gr/blog/2011/10/bitbucket-converting-hg-repositories-to-git/
yes that should work.
mercurial stores chancesets and so on in the .hg folder, but you will lose all your projects history if you just delete the .hg folder and use git instead then.
I've created my very first Mercurial repo on my machine. I used the hg init command on the directory.
Now I'm trying to use this ignore file, before uploading to BitBucket:
Mercurial .hgignore for Visual Studio 2008 projects
Where would I post Even Mien's configuration file? I can't find an hgignore file anywhere.
Thanks
Just make one in the top-level directory of the repository (the same place where the .hg folder is).
Just create a new text file named .hgignore at the root folder of your project and paste the content into it.