軟件是對質量的不懈追求

          '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)  編輯  收藏


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


          網站導航:
           
          主站蜘蛛池模板: 江阴市| 许昌市| 黑山县| 全椒县| 七台河市| 微博| 中山市| 澄城县| 清水县| 寿光市| 泗洪县| 红安县| 浏阳市| 吴堡县| 昭觉县| 上林县| 博爱县| 梁平县| 宜丰县| 洪泽县| 霸州市| 石泉县| 南澳县| 新蔡县| 潞城市| 福海县| 剑河县| 安丘市| 双鸭山市| 安塞县| 曲麻莱县| 布拖县| 化德县| 平果县| 城固县| 肃北| 鹤峰县| 古浪县| 西乡县| 绿春县| 黑水县|