軟件是對質量的不懈追求

          'git revert' Is Not Equivalent To 'svn revert'

          I just learned that if you have some changes in your working tree that you want to get rid of, you don't type 'git revert' like you might guess. No, that's what cvs, subversion, mercurial, and bazaar (to name a few) use revert to mean, but not git. With git, revert is used to undo actual commits. Thankfully, you can undo your revert with another 'git revert', I just learned. So let me repeat to be clear, if you have changes to your working files that you want to abandon, DO NOT do this:

          git revert HEAD

          That will undo your last commit. Do this instead:

          git reset --hard HEAD

          I'm glad I have that straightened out now. I'm wondering if /etc was really a good place for me to start out playing with git.

          UPDATE: Nearly two years later and I'm still getting comments on this. I'm glad I've been able to help people out this way. The discussion in the comments is good, and one thing I'd like to point out is that I now always use and recommend:

          git checkout filename

          (as recommended by Anonymous and others below) instead of git reset. I think the git stash trick from Nicolas is pretty cool too.

          posted on 2010-01-06 14:48 BlakeSu 閱讀(665) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 启东市| 托里县| 夏津县| 长白| 宽城| 汤阴县| 台安县| 岳阳市| 乌鲁木齐市| 芒康县| 长兴县| 岳阳县| 岳普湖县| 广丰县| 安西县| 修水县| 怀集县| 东莞市| 黔江区| 宾阳县| 商水县| 塔河县| 布尔津县| 英吉沙县| 荔波县| 长宁县| 获嘉县| 繁峙县| 泸州市| 禹州市| 常山县| 宁强县| 嘉祥县| 玉树县| 永州市| 旅游| 哈尔滨市| 西林县| 桐梓县| 安西县| 伊通|