git 撤销和 public key

  • 今年使用git的时候遇到了问题,因为自己的疏忽,错误的提交了一个 commit,因为我只是想提交一个包的程序,我错误的将整个 project 全部提交过去了。我的第一想法就是撤销commit的提交.

    我使用 git reset head进入提交记录文档 删除掉提交记录,但是每次删除玩,重新进入文档,删除的还是会恢复。

    PS: 这种方法失败,无法实现

  • 最后没有办法,我只能将 本地的 项目里的git 删掉,然后将远程也删除,将项目重新传一遍(不得以而为之,最后不要这样操作)

    第二步操作,

           ls -a    //查看项目所有目录
           rm -rf .git    //删除项目里的git   > 这样删除玩git
    
          git init   //实例华
          git stauts //之前的 commit 记录依然存在   >  之前的删除 rm -rf 删除是错误的,应该这样
    
          find . -name .git -exec rm -rf {} \;
    
          find -name '.git*' |xargs rm -rf;
      //这两条语句都可以,删除项目里和 git项目的所有内容
    
  • 在重新传文件的时候,又遇到过一个问题 在这么还是提一下吧(为自己做个记事本)需要重新提交ssk keys

      Permission denied (publickey).
      fatal: Could not read from remote repository.
      Please make sure you have the correct access rights
      and the repository exists.   gitlab 这里又帮助文档,重新添加一下 ssh key 就行,之前的ssh key可以继续保留不用删除
    
  • 现在来说一下如何撤销 git commit的操作吧

    先使用git log 或者 git reflog 查看 commit日志

          Thu Aug 21 15:10:21 2014 +0800 d1ff364 (HEAD, origin/master,    origin/HEAD, master
          Tue Jul 15 22:41:51 2014 +0800 ae07cae update content  [黄兴]
          Tue Jul 15 22:38:43 2014 +0800 dd94452 update asp  [黄兴]
          Tue Jul 15 22:33:14 2014 +0800 145ac2f add content  [黄兴]
          Sun Jun 15 10:24:24 2014 +0800 54053be update content  [黄兴]
          Fri Jun 13 17:42:12 2014 +0800 cd5d0ef add content  [黄兴]
          Wed Jun 11 11:18:41 2014 +0800 ace8a5f uodate content  [黄兴]  <b>找到需要回退的那次commit的 哈希值,
    
           git reset --hard commit_id  /commit_id 为 d1ff364(log
           第一行为例)
    

    使用上面的命令进行回退</b>