{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/git-tips-and-tricks/",
  "atlas": "https://www.pystone.net/?node=git-tips-and-tricks#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/git-tips-and-tricks.md",
  "context": "https://www.pystone.net/notes/git-tips-and-tricks.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:git-tips-and-tricks",
  "slug": "git-tips-and-tricks",
  "title": "Git技巧",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "Git技巧",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "0ac5400fcaad3e91e9cb8fa419452f462884c2ff9591a7a34943d976572002e1",
  "assets": [],
  "headings": [
    {
      "depth": 1,
      "text": "Git技巧",
      "anchor": "git技巧",
      "citation": "https://www.pystone.net/notes/git-tips-and-tricks/#git%E6%8A%80%E5%B7%A7"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:software-engineering-and-quality",
      "title": "软件工程与质量保障",
      "url": "https://www.pystone.net/notes/software-engineering-and-quality/",
      "atlas": "https://www.pystone.net/?node=software-engineering-and-quality#knowledge-atlas",
      "label": "软件工程与质量保障",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "CI-CD与质量保障/CI-CD工具链中的“Git技巧”导航项",
      "citation": "https://www.pystone.net/notes/software-engineering-and-quality/#ci-cd%E4%B8%8E%E8%B4%A8%E9%87%8F%E4%BF%9D%E9%9A%9Cci-cd%E5%B7%A5%E5%85%B7%E9%93%BE"
    }
  ],
  "contentMarkdown": "# Git技巧\n\n﻿# Git技巧\n\n> 创建时间：2022/3/29 11:47\n\n删除某次提交，回退到某次记录——不到万不得已不要这样做，这样会让本地和远程的相关内容都丢失。\n\ngit log // 查找要删除的前一次提交的 commit_id\n\ngit rebase -i commit_id // 将 commit_id 替换成复制的值\n\n进入 Vim 编辑模式，将要删除的 commit 前面的 `pick` 改成 `drop`\n\n$ git reset --hard HEAD^ 回退到上个版本\n\n$ git reset --hard HEAD~3 回退到前3次提交之前，以此类推，回退到n次提交之前\n\n$ git reset --hard commit_id 退到/进到 指定commit的sha码\n\n强推到远程：\n\n$ git push origin HEAD --force\n\nGit配置代理\n\n<https://zhuanlan.zhihu.com/p/390620901>\n\n<https://imciel.com/2016/06/28/git-proxy/>\n\n自动放弃本地修改并更新\n\ncd /d %WORKINGCOPY_DIR%\n\ngit reset --hard\n\ngit checkout -b main origin/main\n\ngit pull origin main:main\n\n​\n"
}
