Let's say you do hg status and you have three files modified. I know how to check in all three files (hg commit). But how can you check in (and then hg push) just one of the modified files?
Asked
Active
Viewed 1.5k times
29
Martin Geisler
- 72,968
- 25
- 171
- 229
Marcus Leon
- 55,199
- 118
- 297
- 429
-
2possible duplicate of [Using mercurial, what's the easiest way to commit and push a single file while leaving other modifications alone?](http://stackoverflow.com/questions/125272/using-mercurial-whats-the-easiest-way-to-commit-and-push-a-single-file-while-le) – Milen A. Radev May 25 '10 at 20:29
3 Answers
44
Please check the output of hg help commit which reveals that you can do
hg commit foo.c
if you just want to commit a single file. This is just like Subversion and many other systems — no hocus-pocus :-)
Martin Geisler
- 72,968
- 25
- 171
- 229
-
I receive a message "abort ... file not tracked!". My local repository is already tracked by Mercurial. What could be wrong? – WindRider Mar 24 '14 at 19:16
-
1@WindRider: it means that you need to tell Mercurial that you want to track the file first. Use [`hg add` for that](http://www.selenic.com/mercurial/hg.1.html#add). See also [a Mercurial guide](http://mercurial.aragost.com/kick-start/en/basic/#creating-a-changeset) – Martin Geisler Mar 26 '14 at 08:21
7
Just do:
hg ci -I path/to/file -m "commited only one file"
That commits only one file, and you can push it, and none of the uncommitted changes will be affected.
Ry4an Brase
- 78,112
- 7
- 148
- 169
-
2you should also be able to do it just like you would in svn: hg commit -m "here is my message" path/to/file – RyanWilcox May 25 '10 at 23:28
2
On the off chance you're running on Windows, TortoiseHG (a graphical Mercurial interface) lets you select which files to commit every time.
Vadim Kotov
- 8,084
- 8
- 48
- 62
dimo414
- 47,227
- 18
- 148
- 244