軟件是對(duì)質(zhì)量的不懈追求

          '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) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 荔波县| 上栗县| 荥经县| 五大连池市| 济源市| 绍兴县| 清河县| 广水市| 徐水县| 广昌县| 轮台县| 樟树市| 广元市| 灵丘县| 万载县| 青田县| 梁山县| 县级市| 保亭| 灵丘县| 旬阳县| 仪征市| 湘乡市| 南雄市| 宝清县| 鄂尔多斯市| 广德县| 瑞丽市| 康定县| 瑞昌市| 蒲城县| 新闻| 镇江市| 灵川县| 扶余县| 诏安县| 鹤庆县| 玛纳斯县| 那坡县| 久治县| 本溪市|