{"id":50917860,"url":"https://github.com/echore/learngit","last_synced_at":"2026-06-16T17:02:34.411Z","repository":{"id":184095371,"uuid":"562448816","full_name":"echore/learngit","owner":"echore","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-20T13:13:57.000Z","size":948,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-07-27T03:34:43.695Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/echore.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-11-06T11:57:04.000Z","updated_at":"2023-07-27T03:34:48.501Z","dependencies_parsed_at":"2023-07-27T03:44:57.914Z","dependency_job_id":null,"html_url":"https://github.com/echore/learngit","commit_stats":null,"previous_names":["echore/learngit"],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/echore/learngit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echore%2Flearngit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echore%2Flearngit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echore%2Flearngit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echore%2Flearngit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/echore","download_url":"https://codeload.github.com/echore/learngit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echore%2Flearngit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34415248,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-16T17:02:33.746Z","updated_at":"2026-06-16T17:02:34.404Z","avatar_url":"https://github.com/echore.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 《progit》相关笔记\n## git 基础\n\u003e 获取Git仓库\n1. 在已存在目录中初始化仓库  \n   `git init`  \n2. 克隆现有仓库  \n   `git clone \u003curl\u003e`  \n\u003e  记录每次更新到仓库  \n1. 检查当前文件状态  \n`git status`  \n2. 跟踪新文件  \n`git add xxx`\n3. 状态简览  \n   新添加的未跟踪文件前面有 **??** 标记，新添加到暂存区中的文件前面有 **A** 标记，修改过的文件前面有 **M** 标记。\n4. 忽略文件  \n   需要创建一个名为 **.gitignore** 的文件\n5. 提交更新  \n   `git commit`  \n   commit命令后添加-m选项，将提交信息与命令放在同一行  \n   `git commit -m \"first commit\"`  \n6. 跳过使用暂存区域  \n   在提交时，给git commit加上-a选项，Git就会自动把所有已经跟踪过的文件暂存起来一并提交，从而跳过git add步骤。但有时这个选项会将不需要的文件添加到提交中。  \n7. 移除文件   \n   `git rm`  \n   如果要删除之前修改过或已经放到暂存区的文件，必须使用强制删除-f选项。  \n   让文件保留在磁盘，又不想让Git继续跟踪。（尤其是忘记添加.gitignore文件时）。使用--cached选项  \n   `git rm --cached README`  \n8. 移动文件  \n   在Git中对文件改名  \n   `git mv file_from file_to`  \n\u003e 查看提交历史  \n1. 回顾提交历史  \n   `git log`  \n   \u003ccenter\u003e git log 的常用选项  \n\n   | 选项 | 说明 |\n   |------|------|\n   | -p | 按补丁格式显示每个提交引入的差异。 |\n   | --stat | 显示每次提交的文件修改统计信息。 |\n   | --shortstat | 只显示 --stat 中最后的行数修改添加移除统计。 |\n   | --name-only | 仅在提交信息后显示已修改的文件清单。 |\n   | --name-status | 显示新增、修改、删除的文件清单。 |\n   | --abbrev-commit | 仅显示 SHA-1 校验和所有 40 个字符中的前几个字符。 |\n   | --relative-date | 使用较短的相对时间而不是完整格式显示日期（比如“2 weeks ago”）。 |\n   | --graph | 在日志旁以 ASCII 图形显示分支与合并历史。 |\n   | --pretty | 使用其他格式显示历史提交信息。可用的选项包括 oneline、short、full、fuller 和 format（用来定义自己的格式）。 |\n   | --oneline | --pretty=oneline --abbrev-commit 合用的简写。 |\n2. 限制输出长度  \n   \u003ccenter\u003e 限制git log 输出的选项  \n\n   选项|说明\n   ---|---\n   -n|仅显示最近的 n 条提交。\n   --since, --after|仅显示指定时间之后的提交。\n   --until, --before|仅显示指定时间之前的提交。\n   --author|仅显示作者匹配指定字符串的提交。\n   --committer|仅显示提交者匹配指定字符串的提交。\n   --grep|仅显示提交说明中包含指定字符串的提交。\n   -S|仅显示添加或删除内容匹配指定字符串的提交。\n\n\u003e 撤销操作    \n1. 注意：有些操作是不可逆的，使用撤销操作前最好再查一下  \n2. 新的提交替换旧的提交 例子如下：  \n   `git commit -m 'inital commit' `        \n   `git add forgotten_file   `  \n   `git commit --amend`    \n\n\u003e 远程仓库的使用  \n1. 查看远程仓库  \n   `git remote`\n2. 添加远程仓库  \n   `git remote add \u003cshortname\u003e \u003curl\u003e`\n3. 从远程仓库中抓取与拉取\n   `git fetech \u003cremote\u003e`\n4. 推送到远程仓库  \n   `git push \u003cremote\u003e \u003cbranch\u003e`  \n5. 远程仓库的重命名与移除  \n   `git remote rename`  \n\u003e 打标签  \n1. 列出标签  \n   `git tag`  \n2. 创建标签  \n   创建附注标签：  \n   `git tag -a v1.0 \"my version 1.0\" `  \n   创建轻量标签，只需要提供标签名字：  \n   `git tag v1.0.0`  \n3. 共享标签  \n   `git push origin \u003ctagname\u003e`  \n   一次性推送很多标签：  \n   `git push origin --tags`  \n4. 删除标签  \n   `git tag -d \u003ctagname\u003e`  \n\u003e Git别名  \n1. 一些例子：  \n   `git config --global alias.co checkout`  \n   `git config --global alias.ct commit`  \n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fechore%2Flearngit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fechore%2Flearngit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fechore%2Flearngit/lists"}