How do I `hg revert

Using Mercurial's hg revert -aC , or with long option names, hg revert --all --no-backup I can reset my working copy to head.

IE, which ever branch I'm on, it'll update the working copy to be the latest commit on that branch that the local repo contains.

In particular:

  • If I have commits in my local repository, it definitely won't discard those commits.
  • It will remove untracked files that are not ignored files.
  • It will leave ignored files alone.
  • I find this to be one of the most essential basic commands for working with a repo. I'll often make some exploratory changes to a few files and then want to abandon this to do begin real work from a pristine set.

    How do I do that this git ?


    This is logged as a duplicate of How do I use 'git reset --hard HEAD' to revert to a previous commit?. That question (and questions it links to) has answers that are a useful resource to answer this question. However, this question is specifically asking how a mercurial user should achieve part of their work flow using git instead.


    To reset your working copy to head:

    git reset --hard HEAD
    

    To remove untracked files, but not ignored files:

    git clean -f
    

    WARNING: These commands will permanently revert all uncommitted changes and remove all untracked files!

    However, used in this way, they will preserve any local commits that you have not yet pushed.

    链接地址: http://www.djcxy.com/p/37818.html

    上一篇: 原点撤消后撤消git合并

    下一篇: 我如何`hg恢复