軟件是對質(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 閱讀(660) 評論(0)  編輯  收藏


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


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 玉溪市| 基隆市| 子长县| 林西县| 同仁县| 合阳县| 汨罗市| 贵德县| 新竹县| 丹阳市| 灵川县| 郧西县| 广东省| 淮南市| 龙口市| 乌拉特中旗| 会同县| 萨嘎县| 乐业县| 高密市| 深州市| 永川市| 远安县| 缙云县| 定边县| 樟树市| 保山市| 大余县| 攀枝花市| 华坪县| 手游| 茶陵县| 太保市| 泰顺县| 孝感市| 南岸区| 定结县| 乌兰县| 米脂县| 沁源县| 常熟市|