{"id":40707130,"url":"https://github.com/leafduo/live-with-git","last_synced_at":"2026-01-21T12:34:12.617Z","repository":{"id":10484347,"uuid":"12663547","full_name":"leafduo/live-with-git","owner":"leafduo","description":"A talk about git","archived":false,"fork":false,"pushed_at":"2013-09-11T07:25:37.000Z","size":1952,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"gh-pages","last_synced_at":"2024-04-14T09:38:36.673Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://leafduo.github.io/live-with-git/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"keyphact/pgoapi","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leafduo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-07T10:58:49.000Z","updated_at":"2014-03-19T06:39:59.000Z","dependencies_parsed_at":"2022-07-30T18:38:09.959Z","dependency_job_id":null,"html_url":"https://github.com/leafduo/live-with-git","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leafduo/live-with-git","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafduo%2Flive-with-git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafduo%2Flive-with-git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafduo%2Flive-with-git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafduo%2Flive-with-git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leafduo","download_url":"https://codeload.github.com/leafduo/live-with-git/tar.gz/refs/heads/gh-pages","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafduo%2Flive-with-git/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28632818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-01-21T12:34:11.957Z","updated_at":"2026-01-21T12:34:12.605Z","avatar_url":"https://github.com/leafduo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Live with Git\n\n## What's Git\n\nGit is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.\n\nNO.\n\nGit is a filesystem which is often used as DVCS.\n\n## TL; DR\n\n1. Commit early, commit often\n2. Don't change published history\n\n第一条出事了不慌，第二条避免挨骂。\n\n## Why Git?\n\n- Inner peace\n- Flexible\n- Fast\n- Popularity\n- GitHub\n\n## 3 Sections\n\n![3 sections in git project](assets/3 sections.png)\n\n1. working directory 就是每天修改的那些文件\n2. staging area 是 add 过后还没 commit 的那部分，也叫 index，有些命令用 --cached 表示 staging area\n3. repository 已经提交过的代码\n\n## Moving files\n\n- git add, working directory -\u003e staging area\n- git commit, staging area -\u003e repo\n- git checkout, repo -\u003e working directory\n- git reset\n\n### git reset\n\n- soft, changes HEAD\n- mixed, changes HEAD and index\n- hard, changes HEAD, index and working directory\n\n## Revision Selection\n\n- 734713bc047d87bf7eac9674765ae793478c50d3, SHA-1\n- HEAD\n- HEAD@{0}, reflog\n- master@{yesterday}, time\n- HEAD^, parent commit\n- HEAD^^, parent's parent\n- HEAD^2, second parent\n- HEAD~, same as HEAD^\n- HEAD~2, same as HEAD^^\n- master..experiment\n- master...experiment\n\n## Rewriting History\n\n- git rebase\n- git rebase -i\n- git commit --amend\n- git revert\n- git cherry-pick\n- git filter-branch\n\n## I have an upstream project!\n\n### Submodule\n\n- perfect for project you won't touch\n- git submodule add\n- git submodule init\n- git submodule update\n- git submodule update --init --recursive\n- git submodule foreach git pull\n\n### Subtree\n\n- git subtree add\n- git subtree merge\n- git subtree pull\n- git subtree push\n- git subtree split\n\n## Internal\n\n### object\n\n- blob\n- commit\n- tree\n- tag\n\n### reference\n\n- branch\n- remote\n- HEAD\n\n## Don't Panic when Code is Missing\n\n- Git doesn't lose code you already committed\n- Except that `.git` has been deleted :-(\n- Use `git reflog` and `git fsck`\n\n### git-reflog\n\n- shows what have been done recently\n- alias for `git log -g --abbrev-commit --pretty=oneline`\n- customizable\n\n### git-fsck\n\n- find dangling objects\n- dangling blob, commit…\n- git grep \u003cregex\u003e `git fsck | grep \"dangling commit\" | cut -d \" \" -f 3-`\n\n## Don't Panic when Regression is Found\n\n- Use `git bisect`\n- Binary search which commit introduces the bug\n\n## Find who is responsible\n\n- `git blame`\n- Ask how the code works\n- Xcode integration\n\n![git-blame-xcode-integration](assets/git-blame-xcode-integration.png)\n\n## PM is Coming!\n\n- git stash\n\n## Configuration\n\n- .gitignore\n- .gitattributes\n- .gitconfig\n- git config\n\n## Alias\n\n### git-alias\n\n- git co\n- git config --global alias.co checkout\n\n### shell alias\n\n- alias g=git\n- alias gs=git status\n- alias gl=git log\n\n## Clean up\n\n- git clean\n- git clean -fd\n\n## Working with Gerrit\n\n- git-review\n- Change-Ids\n- .gitreview\n\n## Reference\n\nPro git\n\nhttp://sethrobertson.github.io/GitBestPractices/\n\nRTFM\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafduo%2Flive-with-git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleafduo%2Flive-with-git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafduo%2Flive-with-git/lists"}