Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I unadd a not yet committed file I have added?

Tags:

mercurial

I typed in hg add and I am brand new to mercurial and the result of this was a bunch of dll's exe's pdb's etc all got added Nothing's been committed yet and I basically want to undo the add. the documentation for hg forget is not very clear not sure if that is want I want How do I undo the add before the next commit

I do have some real files that need adding so after I can undo the add I will use add with the exclude flag
Thanks

like image 272
Rahul Avatar asked Apr 18 '10 08:04

Rahul


People also ask

How do you remove file from commit after add?

Remove File From Commit using Git Restore To install newer versions of Git, you can check this tutorial. To remove files from commits, use the “git restore” command, specify the source using the “–source” option and the file to be removed from the repository.

How do you remove a file from git add before commit?

To undo git add before a commit, run git reset <file> or git reset to unstage all changes.

How do I remove committed changes?

To remove the last commit from git, you can simply run git reset --hard HEAD^ If you are removing multiple commits from the top, you can run git reset --hard HEAD~2 to remove the last two commits. You can increase the number to remove even more commits.

How do I exclude one file from a commit?

Set “–assume-unchanged” to a path to exclude to check on git commit and it will exclude your file from git commit. You will need to use the git update-index and –assume-unchanged to exclude files from git commit.


1 Answers

Check out this mercurial tip. To cite the link - if you have accidentally added a file, the way to undo that (changing its status from A back to ?, or unknown) is hg revert. For example, if you just ran hg add and realized that you do not want files foo or bar to be tracked by Mercurial:

hg revert foo bar 
like image 163
Bozhidar Batsov Avatar answered Sep 28 '22 04:09

Bozhidar Batsov