This question already has an answer here:
Are my changes gone after "hg revert"?
(1 answer)
Closed 8 years ago.
After I had accidentally added several files with
hg add
I wanted to revert that with
hg revert --all
Unfortunatelly I hadn't committed my intended changes so they were reverted as well. Can I get that content back?
You did not specify the --no-backup, so there should be backup files right next to the actual file.
Documentation to support this
Modified files are saved with a .orig suffix before reverting. To disable these backups, use --no-backup.
Related
This question already has answers here:
Mercurial Remove History
(2 answers)
Closed 2 years ago.
I want to ask a question about Hg.
You can see the picture that there is a branch from 196 to 199, and now I want to remove the branch in the server version and use the 195 as the newest version, could you please tell me how to do that?
Thank you so much!
If 196:199 was already pushed to remote, you can't delete this branch (check hg out or phases of these revisions)
If 196:199 are pure local, you can just simply hg strip not needed anymore anonymous branch
Anyway, you can:
Dummy merge r199 into r195 and continue work
Forget about branch, and continue your work from 195 (first push with new child-commit of 195 will require -f due to new head in branch)
This question already has answers here:
How to change the default branch to push in mercurial?
(3 answers)
Closed 6 years ago.
I would like to configure Mercurial to push the commits on the current branch only, instead of all draft commits - much like Git does when the push.default is set to simple. I scanned the hgrc manual page, but couldn't locate the option which enforces this. How is it called?
Although deprecated, you can set defaults for commands in hgrc:
[defaults]
push = -r .
The recommended alternative is aliases:
[alias]
pushcurrent = push -r .
I've made unwanted changes to several files recently. Is it possible to revert them based on the time (for example revert all changes made in last 10 minutes)
Option 1: Rollback or strip
In case you already commit (and not pushed) some of the unwanted changes, it is easy:
$ hg strip <firts-unwanted-revision>
This requires the mqstrip extension to be enabled.
Alternatively check if the rollback command is sufficient for your case.
Option 2: Revert selected files only
Otherwise you can only revert files to the state of the last commit. Mercurial (as Git, SVN, and most other version control systems) only tracks changes when you commit. Everything in between is out of Mercurial's control. That's why it is generally best to commit early and often.
However, you could make use of the modification time of your files and only revert those that have been touched in the last 10 minutes. Be aware that this reverts all changes per file, i.e. also changes made in these files more than 10 minutes ago. It only safes your correctly edited files where the last change has been more than 10 minutes ago.
$ hg revert <files-touched-within-last-10-minutes>
On Unix systems, you get the list of all files modified within the last 10 minutes using the find command:
$ find -mmin -10
Option 3: Commit good changes, discard bad ones
Finally there is a 3rd option which works good when your bad changes did not overwrite good changes but exist next to them. Here a good strategy is to
only commit the good changes (using the record or crecord command), and then
revert all remaining changes (e.g. with hg up -r . -C)
The HG-Book has more hints on dealing with unwanted changes.
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
How to deal with committer name change in Mercurial
On a new install, I forgot to set my username reasonably in my hg client. As a result, the last few commits have me listed as "Billy", rather than the "Billy O'Neal <billy.oneal#example.com>" like I have been using.
Is there a way I can change these to make them consistent?
It is possible to edit history with extensions like mq and convert, but if you have pushed the commits, you'd have to edit every clone of your repository as well. If you are a small group of users that may be possible, but otherwise it is too late.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Generating a list of which files changed between hg versions
hg diff -r 5 -r 10 will give the differences between revisions 5 and 10. But I want to see specifically just a list of files that are different - I don't want to see the full diffs. Is there a quick way to do this?
hg status can do this.
The main purpose of hg status is showing modified files in the working directory (in comparison to the last commit).
But you can use the --rev parameter to let it compare two specific revisions instead, like this:
hg status --rev 5 --rev 10