Am having problems removing a file from Tortoise.
I make the clone, and there are a few test files which I want out. What is the proceedure for removing a file from the repository,
thanks in advance,
Right-click on the file(s) and click the TortoiseHg --> Remove Files... and then confirm the dialog. Commit to save the change to your local repository. Note that this will delete the file from disk and from Mercurial.
If you'd like to remove a file from Mercurial but keep the file on disk, you can click TortoiseHg --> Forget Files.... Then you may want to add the file to your .hgignore list (you can do this graphically through the Commit or View File Status dialogs) so that you don't add it accidentally in the future. Then commit.
Related
I've got a configuration file ("config") that we originally committed to our repository. (first mistake)
We then deleted that file using hg rm, and left a sample configuration file in the repository.
When developing, we just copy the "config.sample" file to "config". However, whenever I update to a different branch and back to the branch with the delete, the untracked config file is deleted.
I've already added the config file to .hgignore.
Is there a way to make mercurial allow the existence of this untracked file going forward?
It looks like the branch you go to before coming back contains a config file too. When updating back, the file was deleted, so mercurial removes it.
Try deleting the config file in your other branch, too, and adding the file in the .hgignore of that same branch.
How to move files (to subfolder) without losing their history?
In my Mercurial repository (I mean the folder with the .hg in it) I have MyProject/ folder with all project files. Now I need to create src/ folder inside and move all files to it (from MyProject/ to MyProject/src/). How can I do it without losing all history?
Since you have a "tortoisehg" tag, I figured I'd explain the way I do this using the GUI.
Usually, I just rename/move files in my IDE, or from windows explorer, then when I go to commit, THG will show a bunch of (?) unknown files and (R) removed files. Just right click on any of the files and choose "Detect Renames...", then click the "Find Renames" button.
You might have to adjust the "Min Similarity" slider until you get all the files you want and only the files you want, but it's usually very straightforward.
hg mv
does do the right thing, but hg log does not list entries past the move unless you
give it the -f option. See this question for more info
Why 'hg mv' (mercurial) doesn't move a file's history by default?
After you do this, you likely want to add the -f option to hg log
to the hgrc file for the repo.
.hg/hgrc
[defaults]
log = -f
In Windows with Tortoise HG installed, there is a windows shell extension that handles this very nicely.
In Windows Explorer, simply right-click and drag the file(s) you wish to move into the destination folder. You are then presented with a pop-up that give you these choices:
HG Move versioned item(s) here
HG Copy versioned item(s) here
Use hg mv to move your files and then use hg log -f (follow) to see history including renames.
When trying to export a patch for a commit, the resulting patch file doesn't include empty files that were added in the commit.
Steps to reproduce:
Create a new folder and initialize it as an Hg repository.
Add some zero-byte file to that folder, and create an initial commit for that file.
Create a second zero-byte file, and create a second commit for that file.
In Hg Workbench, right-click on either of those commits, and choose Export >> Export Patch.
Open the resultant patch file in Notepad / any text viewer.
Observe that the patch file does not contain any information about the new files that were added.
It seems like the newly added files should be included. If I exported that patch and someone else applied it, they wouldn't really be getting the full changeset, since the new files aren't included.
Can someone tell me what I'm doing wrong, or why it behaves this way? This is not the behavior I expected.
I'm using TortoiseHg 2.7.1, which includes Mercurial 2.5.2.
I have a file named A/B/SomeFile.dll that gets generated by visual studio on each compile.
In my .hgignore file I have included:
SomeFile.dll
A/B/SomeFile.dll
*SomeFile.dll
and yet, every recompile makes mercurial think the file has been modified. (this is not a local hgignore file, but what it is the latest committed file)
I have triple verified it is spelled correctly and the cases are the exact same. Now I am lost.
Make sure you didn't add the file to the repo before you added it to .ignore file. If you did, you will need to "hg remove" it from the repository, then commit.
Hope it helps.
You need to stop tracking the file in mercurial; .hgignore is ignored for files already tracked in the repository.
So I accidentally included a config file (different for each machine) into our mercurial repositories.
How can I get Mercurial to not include it in version control? I don't want to delete the file since I still want it. And I don't want to cause the file to get deleted on other developer's working directories either.
And how do I do this in TortoiseHG?
Right click on the file -> TortoiseHG -> Forget Files. Click Forget. Commit and Sync.
Edit:
You'll also want to add the path to your .hgignore to keep it from getting added again. You can right click on the file in the HG Commit dialog and choose to ignore it.
Here's the manual way of doing it through the command line:
Copy the config file somewhere outside of the repository.
Run hg rm path/to/config/file
Add the config file path to your .hgignore.
Commit the repository.
Move the config file back to where you had it.
Do an hg stat on your repository to double check you did everything right. (It shouldn't show up in the list of modified/added files).
Edit:
hg forget is the best way to do this.
Run hg forget path/to/config/file
Edit your .hgignore and add the path to the config file.
hg ci to save your changes.
Run hg stat to ensure everything worked according to plan.
See nates answer for how to do it TortoiseHG.
hg remove or hg remove -f?
I think hg forget also removes it from the branch.
In both cases, files are retained in your directory.
For those using SourceTree, there is an option Stop Tracking when you right click a file, it basically does the same thing as hg forget or git rm --cache, removing the file from repo but not from hard disk.
add it to your ignore list.
See the .hgignore file.
TortoiseHG gives you access to this config file via the "Edit Ignore Filter" menu option.