{"id":24710,"date":"2022-11-28T13:11:04","date_gmt":"2022-11-28T05:11:04","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=24710"},"modified":"2022-11-28T13:11:30","modified_gmt":"2022-11-28T05:11:30","slug":"some-git-tips","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/some-git-tips.html","title":{"rendered":"\u5e38\u7528\u7684Git Tips"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nGit\u88ab\u8d8a\u6765\u8d8a\u591a\u7684\u516c\u53f8\u4f7f\u7528\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u4e86\u89e3Git\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u7684\u4e00\u4e9b\u6280\u5de7\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\u5e38\u7528\u7684\u6570\u5341\u4e2a<\/a><\/p>\n

\u4e00\u3001Configuration:\u914d\u7f6e<\/strong><\/div>\n

\u00a0<\/span>\u5217\u4e3e\u6240\u6709\u7684\u522b\u540d\u4e0e\u914d\u7f6e<\/p>\n

git\u00a0config\u00a0--list<\/pre>\n

Git \u522b\u540d\u914d\u7f6e<\/p>\n

git\u00a0config\u00a0--global\u00a0alias.\u00a0\u00a0git\u00a0config\u00a0--global\u00a0alias.st\u00a0status<\/pre>\n

\u8bbe\u7f6egit\u4e3a\u5927\u5c0f\u5199\u654f\u611f<\/p>\n

git config --global core.ignorecase false<\/pre>\n
\u4e8c\u3001Help:\u5e38\u7528\u7684\u8f85\u52a9\u67e5\u8be2\u547d\u4ee4<\/strong><\/div>\n

\u5728git \u547d\u4ee4\u884c\u91cc\u67e5\u770beveryday git<\/p>\n

git help everyday<\/pre>\n

\u663e\u793agit\u5e38\u7528\u7684\u5e2e\u52a9\u547d\u4ee4<\/p>\n

git help -g<\/pre>\n

\u83b7\u53d6Git Bash\u7684\u81ea\u52a8\u8865\u5168<\/p>\n

~\/.git-completion.bash\u00a0&&\u00a0echo\u00a0'[\u00a0-f\u00a0~\/.git-completion.bash\u00a0]\u00a0&&\u00a0.\u00a0~\/.git-completion.bash'\u00a0>>\u00a0~\/.bashrc<\/pre>\n

\u8bbe\u7f6e\u81ea\u52a8\u66f4\u6b63<\/p>\n

git\u00a0config\u00a0--global\u00a0help.autocorrect\u00a01<\/pre>\n
\u4e09\u3001Remote:\u8fdc\u7aef\u4ed3\u5e93\u914d\u7f6e<\/strong><\/div>\n

\u83b7\u53d6\u6240\u6709\u8fdc\u7aef\u5f15\u7528\u914d\u7f6e<\/p>\n

git\u00a0remote<\/pre>\n

\u6216\u8005<\/p>\n

git\u00a0remote\u00a0show<\/pre>\n

\u4fee\u6539\u67d0\u4e2a\u8fdc\u7aef\u7684\u5730\u5740<\/p>\n

git\u00a0remote\u00a0set-url\u00a0origin\u00a0URL<\/pre>\n

Repo<\/strong><\/p>\n

\u67e5\u770b\u5f53\u524d\u4ed3\u5e93\u4e2d\u7684\u6240\u6709\u672a\u6253\u5305\u7684objects\u548c\u78c1\u76d8\u5360\u7528<\/p>\n

git\u00a0count-objects\u00a0--human-readable<\/pre>\n

\u4eceobject\u6570\u636e\u5e93\u4e2d\u5220\u9664\u6240\u6709\u4e0d\u53ef\u8fbe\u7684object<\/p>\n

git\u00a0gc\u00a0--prune=now\u00a0--aggressive<\/pre>\n
\u56db\u3001\u6587\u4ef6\u7c7b\u64cd\u4f5c \uff0cCache:\u7f13\u5b58\uff0cTrack:\u6587\u4ef6\u8ffd\u8e2a\uff0c<\/strong><\/div>\n

\u5c55\u793a\u6240\u6709\u88ab\u8ffd\u8e2a\u7684\u6587\u4ef6<\/p>\n

git\u00a0ls-files\u00a0-t<\/pre>\n

\u5c55\u793a\u6240\u6709\u672a\u88ab\u8ffd\u8e2a\u7684\u5206\u652f<\/p>\n

git\u00a0ls-files\u00a0--others<\/pre>\n

\u5c55\u793a\u6240\u6709\u88ab\u5ffd\u7565\u7684\u6587\u4ef6<\/p>\n

git\u00a0ls-files\u00a0--others\u00a0-i\u00a0--exclude-standard\r\ngit\u00a0check-ignore*\r\ngit\u00a0status\u00a0--ignored<\/pre>\n

Manipulation:\u64cd\u4f5c<\/strong><\/p>\n

\u505c\u6b62\u8ffd\u8e2a\u67d0\u4e2a\u6587\u4ef6\u4f46\u662f\u4e0d\u5220\u9664\u5b83<\/p>\n

git\u00a0rm\u00a0--cached\u00a0<file_path<\/pre>\n

\u6216\u8005<\/p>\n

git\u00a0rm\u00a0--cached\u00a0-r\u00a0<directory_path<\/pre>\n

\u5f3a\u5236\u5220\u9664\u672a\u88ab\u8ffd\u8e2a\u7684\u6587\u4ef6\u6216\u8005\u76ee\u5f55<\/p>\n

git\u00a0clean\u00a0-f\r\n\r\ngit\u00a0clean\u00a0-f\u00a0-d\r\ngit\u00a0clean\u00a0-df<\/pre>\n

\u6e05\u7a7a.gitignore<\/p>\n

git\u00a0clean\u00a0-X\u00a0-f<\/pre>\n

Changes:\u4fee\u6539<\/strong><\/p>\n

Info:\u4fe1\u606f\u67e5\u770b<\/strong><\/p>\n

\u67e5\u770b\u4e0a\u6b21\u63d0\u4ea4\u4e4b\u540e\u7684\u672a\u6682\u5b58\u6587\u4ef6<\/p>\n

git\u00a0diff<\/pre>\n

\u67e5\u770b\u51c6\u5907\u7528\u4e8e\u63d0\u4ea4\u7684\u6682\u5b58\u4e86\u7684\u4fee\u6539\u7684\u6587\u4ef6<\/p>\n

git\u00a0diff\u00a0--cached<\/pre>\n

\u663e\u793a\u6240\u6709\u6682\u5b58\u4e0e\u672a\u6682\u5b58\u7684\u6587\u4ef6<\/p>\n

git\u00a0diff\u00a0HEAD<\/pre>\n

\u67e5\u770b\u6700\u65b0\u7684\u6587\u4ef6\u7248\u672c\u4e0eStage\u4e2d\u533a\u522b<\/p>\n

git\u00a0diff\u00a0--staged<\/pre>\n

dd:\u8ffd\u8e2a\u67d0\u4e2a\u4fee\u6539\uff0c\u51c6\u5907\u63d0\u4ea4<\/strong><\/p>\n

Stage\u67d0\u4e2a\u6587\u4ef6\u7684\u90e8\u5206\u4fee\u6539\u800c\u4e0d\u662f\u5168\u90e8<\/p>\n

git\u00a0add\u00a0-p<\/pre>\n

Reset:\u4fee\u6539\u91cd\u7f6e<\/strong><\/p>\n

\u4ee5HEAD\u4e2d\u7684\u6700\u65b0\u7684\u5185\u5bb9\u8986\u76d6\u67d0\u4e2a\u672c\u5730\u6587\u4ef6\u7684\u4fee\u6539<\/p>\n

git\u00a0checkout\u00a0--\u00a0<file_name><\/pre>\n

Stash:\u8d2e\u5b58<\/strong><\/p>\n

Info:\u4fe1\u606f\u67e5\u770b<\/strong><\/p>\n

\u5c55\u793a\u6240\u6709\u4fdd\u5b58\u7684Stashes<\/p>\n

git\u00a0stash\u00a0list<\/pre>\n

Manipulation:\u64cd\u4f5c<\/strong><\/p>\n

Save:\u4fdd\u5b58<\/strong><\/p>\n

\u4fdd\u5b58\u5f53\u524d\u8ffd\u8e2a\u7684\u6587\u4ef6\u4fee\u6539\u72b6\u6001\u800c\u4e0d\u63d0\u4ea4\uff0c\u5e76\u4f7f\u5f97\u5de5\u4f5c\u7a7a\u95f4\u6062\u590d\u5e72\u51c0<\/p>\n

git\u00a0stash<\/pre>\n

\u6216\u8005<\/p>\n

git\u00a0stash\u00a0save<\/pre>\n

\u4fdd\u5b58\u6240\u6709\u6587\u4ef6\u4fee\u6539\uff0c\u5305\u62ec\u672a\u8ffd\u8e2a\u7684\u6587\u4ef6<\/p>\n

git\u00a0stash\u00a0save\u00a0-u<\/pre>\n

\u6216\u8005<\/p>\n

git\u00a0stash\u00a0save\u00a0--include-untracked<\/pre>\n
Apply:\u5e94\u7528<\/strong><\/div>\n

\u5e94\u7528\u4efb\u4f55\u7684Stash\u800c\u4e0d\u4eceStash\u5217\u8868\u4e2d\u5220\u9664<\/p>\n

git\u00a0stash\u00a0apply\u00a0<stash@{n}><\/pre>\n

\u5e94\u7528\u5e76\u4e14\u5220\u9664Stash\u5217\u8868\u4e2d\u7684\u6700\u540e\u4e00\u4e2a<\/p>\n

git\u00a0stash\u00a0pop<\/pre>\n

\u6216\u8005<\/p>\n

git\u00a0stash\u00a0apply\u00a0stash@{0}\u00a0&&\u00a0git\u00a0stash\u00a0drop\u00a0stash@{0}<\/pre>\n

\u5220\u9664\u5168\u90e8\u5b58\u50a8\u7684Stashes<\/p>\n

git\u00a0stash\u00a0clear<\/pre>\n

\u6216\u8005<\/p>\n

git\u00a0stash\u00a0drop\u00a0<stash@{n}><\/pre>\n

\u4ece\u67d0\u4e2aStash\u4e2d\u5e94\u7528\u5355\u4e2a\u6587\u4ef6<\/p>\n

git\u00a0checkout\u00a0<stash@{n}>\u00a0--\u00a0<file_path><\/pre>\n

\u6216\u8005<\/p>\n

git\u00a0checkout\u00a0stash@{0}\u00a0--\u00a0<file_path><\/pre>\n

Commit:\u63d0\u4ea4<\/strong><\/p>\n

\u68c0\u7d22\u67d0\u4e2a\u63d0\u4ea4\u7684Hash\u503c<\/p>\n

git\u00a0rev-list\u00a0--reverse\u00a0HEAD\u00a0|\u00a0head\u00a0-1<\/pre>\n

Info:\u4fe1\u606f\u67e5\u770b<\/strong><\/p>\n

List:Commit\u5217\u8868<\/strong><\/p>\n

\u67e5\u770b\u81eaFork Master\u4ee5\u6765\u7684\u5168\u90e8\u63d0\u4ea4<\/p>\n

git\u00a0log\u00a0--no-merges\u00a0--stat\u00a0--reverse\u00a0master..<\/pre>\n

\u5c55\u793a\u5f53\u524d\u5206\u652f\u4e2d\u6240\u6709\u5c1a\u672a\u5408\u5e76\u5230Master\u4e2d\u7684\u63d0\u4ea4<\/p>\n

git\u00a0cherry\u00a0-v\u00a0master<\/pre>\n

\u6216\u8005<\/p>\n

git\u00a0cherry\u00a0-v\u00a0master\u00a0<branch-to-be-merged><\/pre>\n

\u53ef\u89c6\u5316\u5730\u67e5\u770b\u6574\u4e2aVersion\u6811<\/p>\n

git\u00a0log\u00a0--pretty=oneline\u00a0--graph\u00a0--decorate\u00a0--all<\/pre>\n

\u6216\u8005<\/p>\n

gitk\u00a0-all<\/pre>\n

\u67e5\u770b\u6240\u6709\u5728\u5206\u652f1\u800c\u4e0d\u5728\u5206\u652f2\u4e2d\u7684\u63d0\u4ea4<\/p>\n

git\u00a0log\u00a0Branch1\u00a0^Branch2<\/pre>\n
Files:\u6587\u4ef6\u4fe1\u606f<\/strong><\/div>\n

\u5c55\u793a\u76f4\u5230\u67d0\u6b21\u63d0\u4ea4\u7684\u5168\u90e8\u6587\u4ef6\u5217\u8868<\/p>\n

git\u00a0ls-tree\u00a0--name-only\u00a0-r\u00a0<commit-ish><\/pre>\n

\u5c55\u793a\u6240\u6709\u5728\u67d0\u6b21\u63d0\u4ea4\u4e2d\u4fee\u6539\u7684\u6587\u4ef6<\/p>\n

git\u00a0diff-tree\u00a0--no-commit-id\u00a0--name-only\u00a0-r\u00a0<commit-ish><\/pre>\n

\u5c55\u793a\u6240\u6709\u5bf9\u4e8e\u67d0\u4e2a\u6587\u4ef6\u7684\u63d0\u4ea4\u4fee\u6539<\/p>\n

git\u00a0log\u00a0--follow\u00a0-p\u00a0--\u00a0<file_path><\/pre>\n

Manipulation:\u5173\u4e8e\u63d0\u4ea4\u7684\u64cd\u4f5c<\/strong><\/p>\n

Apply:Commit\u786e\u8ba4\u6216\u8005\u5e94\u7528<\/strong><\/p>\n

\u5229\u7528cherry-pick\u5c06\u67d0\u4e2a\u5206\u652f\u7684\u67d0\u4e2a\u63d0\u4ea4\u8de8\u5206\u652f\u7684\u5e94\u7528\u5230\u5176\u4ed6\u5206\u652f<\/p>\n

git\u00a0checkout\u00a0<branch-name>\u00a0&&\u00a0git\u00a0cherry-pick\u00a0<commit-ish><\/pre>\n

\u63d0\u4ea4\u65f6\u5019\u5ffd\u7565Staging\u533a\u57df<\/p>\n

git\u00a0commit\u00a0-am\u00a0<commit\u00a0message><\/pre>\n

\u63d0\u4ea4\u65f6\u5019\u5ffd\u7565\u67d0\u4e2a\u6587\u4ef6<\/p>\n

git\u00a0update-index\u00a0--assume-unchanged\u00a0Changelog;\r\n\r\ngit\u00a0commit\u00a0-a;\r\n\r\ngit\u00a0update-index\u00a0--no-assume-unchanged\u00a0Changelog<\/pre>\n

\u64a4\u9500\u67d0\u4e2a\u6545\u610f\u5ffd\u7565<\/p>\n

git\u00a0update-index\u00a0--no-assume-unchanged\u00a0<file_name><\/pre>\n

\u5c06\u67d0\u4e2a\u63d0\u4ea4\u6807\u8bb0\u4e3a\u5bf9\u4e4b\u524d\u67d0\u4e2a\u63d0\u4ea4\u7684Fixup<\/p>\n

git\u00a0commit\u00a0--fixup\u00a0<SHA-1><\/pre>\n

Reset:\u5c06\u5f53\u524d\u5206\u652f\u7684HEAD\u91cd\u7f6e\u5230\u67d0\u4e2a\u63d0\u4ea4\u65f6\u5019\u7684\u72b6\u6001<\/strong><\/p>\n

\u91cd\u7f6eHEAD\u5230\u7b2c\u4e00\u6b21\u63d0\u4ea4<\/p>\n

git\u00a0update-ref\u00a0-d\u00a0HEAD<\/pre>\n

\u4e22\u5f03\u81ea\u67d0\u4e2aCommit\u4e4b\u540e\u7684\u63d0\u4ea4\uff0c\u5efa\u8bae\u53ea\u5728\u79c1\u6709\u5206\u652f\u4e0a\u8fdb\u884c\u64cd\u4f5c\u3002\u6ce8\u610f\uff0c\u548c\u4e0a\u4e00\u4e2a\u64cd\u4f5c\u4e00\u6837\uff0c\u91cd\u7f6e\u4e0d\u4f1a\u4fee\u6539\u5f53\u524d\u7684\u6587\u4ef6\u72b6\u6001\uff0cGit\u4f1a\u81ea\u52a8\u5c06\u5f53\u524d\u6587\u4ef6\u4e0e\u8be5Commit\u65f6\u5019\u7684\u6539\u53d8\u4f5c\u4e3aChanges\u5217\u4e3e\u51fa\u6765<\/p>\n

git\u00a0reset\u00a0<commit-ish><\/pre>\n

Undo&Revert:\u64a4\u9500\u4e0e\u6062\u590d\u67d0\u4e2aCommit<\/p>\n

\u4ee5\u521b\u5efa\u4e00\u4e2a\u65b0\u63d0\u4ea4\u7684\u65b9\u5f0f\u64a4\u9500\u67d0\u4e2a\u63d0\u4ea4\u7684\u64cd\u4f5c<\/p>\n

git\u00a0revert\u00a0<commit-ish><\/pre>\n

\u6062\u590d\u67d0\u4e2a\u6587\u4ef6\u5230\u67d0\u4e2aCommit\u65f6\u5019\u7684\u72b6\u6001<\/p>\n

git\u00a0checkout\u00a0<commit-ish>\u00a0--\u00a0<file_path><\/pre>\n

Update:\u4fee\u6539\u67d0\u4e2aCommit<\/strong><\/p>\n

\u4fee\u6539\u4e0a\u4e00\u4e2a\u63d0\u4ea4\u7684\u4fe1\u606f<\/p>\n

git\u00a0commit\u00a0-v\u00a0--amend<\/pre>\n

\u4fee\u6539\u63d0\u4ea4\u7684\u4f5c\u8005\u4fe1\u606f<\/p>\n

git\u00a0commit\u00a0--amend\u00a0--author='Author\u00a0Name\u00a0<email@address.com>'<\/pre>\n

\u5728\u5168\u5c40\u7684\u914d\u7f6e\u6539\u53d8\u4e86\u4e4b\u540e\uff0c\u4fee\u6539\u67d0\u4e2a\u4f5c\u8005\u4fe1\u606f<\/p>\n

git\u00a0commit\u00a0--amend\u00a0--reset-author\u00a0--no-edit<\/pre>\n

\u4fee\u6539\u524d\u4e00\u4e2aCommit\u7684\u63d0\u4ea4\u5185\u5bb9\u4f46\u662f\u4e0d\u4fee\u6539\u63d0\u4ea4\u4fe1\u606f<\/p>\n

git\u00a0add\u00a0--all\u00a0&&\u00a0git\u00a0commit\u00a0--amend\u00a0--no-edit<\/pre>\n

Branch:\u5206\u652f<\/strong><\/p>\n

Info:\u4fe1\u606f\u67e5\u770b<\/strong><\/p>\n

\u83b7\u53d6\u5f53\u524d\u5206\u652f\u540d<\/p>\n

git\u00a0rev-parse\u00a0--abbrev-ref\u00a0HEAD<\/pre>\n

Tag<\/strong><\/p>\n

\u5217\u4e3e\u5f53\u524d\u5206\u652f\u4e0a\u6700\u5e38\u7528\u7684\u6807\u7b7e<\/p>\n

git\u00a0describe\u00a0--tags\u00a0--abbrev=0<\/pre>\n

List:\u5206\u652f\u679a\u4e3e<\/strong><\/p>\n

\u83b7\u53d6\u6240\u6709\u672c\u5730\u4e0e\u8fdc\u7a0b\u7684\u5206\u652f<\/p>\n

git\u00a0branch\u00a0-a<\/pre>\n

\u53ea\u5c55\u793a\u8fdc\u7a0b\u5206\u652f<\/p>\n

git\u00a0branch\u00a0-r<\/pre>\n

\u6839\u636e\u67d0\u4e2aCommit\u7684Hash\u6765\u67e5\u627e\u6240\u6709\u5173\u8054\u5206\u652f<\/p>\n

git\u00a0branch\u00a0-a\u00a0--contains\u00a0<commit-ish>\r\n\r\n\u6216\u8005\r\n\r\ngit\u00a0branch\u00a0--contains\u00a0<commit-ish><\/pre>\n

Changes:\u67d0\u4e2a\u5206\u652f\u4e0a\u7684\u4fee\u6539\u60c5\u51b5\u67e5\u770b<\/strong><\/p>\n

\u67e5\u770b\u4e24\u5468\u4ee5\u6765\u7684\u6240\u6709\u4fee\u6539<\/p>\n

git\u00a0log\u00a0--no-merges\u00a0--raw\u00a0--since='2\u00a0weeks\u00a0ago'\r\n\r\n\u6216\u8005\r\n\r\ngit\u00a0whatchanged\u00a0--since='2\u00a0weeks\u00a0ago'<\/pre>\n

Merger:\u5408\u5e76\u60c5\u51b5\u67e5\u770b<\/strong><\/p>\n

\u8ffd\u8e2a\u67d0\u4e2a\u5206\u652f\u7684\u4e0a\u6e38\u5206\u652f<\/p>\n

git\u00a0branch\u00a0-u\u00a0origin\/mybranch<\/pre>\n

\u5217\u4e3e\u51fa\u6240\u6709\u7684\u5206\u652f\u4ee5\u53ca\u5b83\u4eec\u7684\u4e0a\u6e38\u548c\u6700\u540e\u4e00\u6b21\u63d0\u4ea4<\/p>\n

git\u00a0branch\u00a0-vv<\/pre>\n

\u5217\u4e3e\u51fa\u6240\u6709\u5df2\u7ecf\u5408\u5e76\u8fdb\u5165Master\u7684\u5206\u652f<\/p>\n

git\u00a0branch\u00a0--merged\u00a0master<\/pre>\n

Manipulation:\u64cd\u4f5c<\/strong><\/p>\n

Checkout:\u68c0\u51fa\u4e0e\u5206\u652f\u5207\u6362<\/p>\n

\u5feb\u901f\u5207\u6362\u5230\u4e0a\u4e00\u4e2a\u5206\u652f<\/p>\n

git\u00a0checkout\u00a0-<\/pre>\n

\u4e0d\u5e26\u5386\u53f2\u8bb0\u5f55\u7684\u68c0\u51fa\u67d0\u4e2a\u5206\u652f<\/p>\n

git\u00a0checkout\u00a0--orphan\u00a0<branch_name><\/pre>\n

Remove:\u5206\u652f\u79fb\u9664<\/strong><\/p>\n

\u5220\u9664\u672c\u5730\u5206\u652f<\/p>\n

git\u00a0branch\u00a0-d\u00a0<local_branchname><\/pre>\n

\u5220\u9664\u8fdc\u7a0b\u5206\u652f<\/p>\n

git\u00a0push\u00a0origin\u00a0--delete\u00a0<remote_branchname>\r\n\r\n\u6216\u8005\r\n\r\ngit\u00a0push\u00a0origin\u00a0:<remote_branchname><\/pre>\n

\u79fb\u9664\u6240\u6709\u5df2\u7ecf\u5408\u5e76\u8fdb\u5165Master\u7684\u5206\u652f<\/p>\n

git\u00a0branch\u00a0--merged\u00a0master\u00a0|\u00a0grep\u00a0-v\u00a0'^\/*'\u00a0|\u00a0xargs\u00a0-n\u00a01\u00a0git\u00a0branch\u00a0-d<\/pre>\n

\u79fb\u9664\u6240\u6709\u5728\u8fdc\u7aef\u5df2\u7ecf\u88ab\u5220\u9664\u7684\u8fdc\u7a0b\u5206\u652f<\/p>\n

git\u00a0fetch\u00a0-p\r\n\r\n\u6216\u8005\r\n\r\ngit\u00a0remote\u00a0prune\u00a0origin<\/pre>\n

Update:\u4fe1\u606f\u66f4\u65b0<\/strong><\/p>\n

\u4fee\u6539\u5f53\u524d\u5206\u652f\u540d<\/p>\n

git\u00a0branch\u00a0-m\u00a0<new-branch-name>\r\n\r\n\u6216\u8005\r\n\r\ngit\u00a0branch\u00a0-m\u00a0[<old-branch-name>]\u00a0<new-branch-name><\/pre>\n

rchive:\u6253\u5305<\/strong><\/p>\n

\u5c06Master\u5206\u652f\u6253\u5305<\/p>\n

git\u00a0archive\u00a0master\u00a0--format=zip\u00a0--output=master.zip<\/pre>\n

\u5c06\u5386\u53f2\u8bb0\u5f55\u5305\u62ec\u5206\u652f\u5185\u5bb9\u6253\u5305\u5230\u4e00\u4e2a\u6587\u4ef6\u4e2d<\/p>\n

git\u00a0bundle\u00a0create\u00a0<file>\u00a0<branch-name><\/pre>\n

\u4ece\u67d0\u4e2aBundle\u4e2d\u5bfc\u5165<\/p>\n

git\u00a0clone\u00a0repo.bundle\u00a0<repo-dir>\u00a0-b\u00a0<branch-name><\/pre>\n

Merge:\u5408\u5e76<\/strong><\/p>\n

Pull&Push:\u8fdc\u7a0b\u5206\u652f\u5408\u5e76\u64cd\u4f5c<\/p>\n

\u7528pull\u8986\u76d6\u672c\u5730\u5185\u5bb9<\/p>\n

git\u00a0fetch\u00a0--all\u00a0&&\u00a0git\u00a0reset\u00a0--hard\u00a0origin\/master<\/pre>\n

\u6839\u636ePull\u7684ID\u62c9\u53d6\u67d0\u4e2aPull\u8bf7\u6c42\u5230\u672c\u5730\u5206\u652f<\/p>\n

git\u00a0fetch\u00a0origin\u00a0pull\/<id>\/head:<branch-name><\/pre>\n

\u6216\u8005<\/p>\n

git\u00a0pull\u00a0origin\u00a0pull\/<id>\/head:<branch-name><\/pre>\n

Rebase:\u53d8\u57fa<\/strong><\/p>\n

\u5728Pull\u65f6\u5019\u5f3a\u5236\u7528\u53d8\u57fa\u8fdb\u884c\u64cd\u4f5c<\/p>\n

git\u00a0config\u00a0--global\u00a0branch.autosetuprebase\u00a0always<\/pre>\n

\u5c06\u67d0\u4e2afeature\u5206\u652f\u53d8\u57fa\u5230master\uff0c\u7136\u540e\u5408\u5e76\u8fdbmaster<\/p>\n

git\u00a0checkout\u00a0feature\u00a0&&\u00a0git\u00a0rebase\u00a0@{-1}\u00a0&&\u00a0git\u00a0checkout\u00a0@{-2}\u00a0&&\u00a0git\u00a0merge\u00a0@{-1}<\/pre>\n

\u53d8\u57fa\u4e4b\u524d\u81ea\u52a8Stash\u6240\u6709\u6539\u53d8<\/p>\n

git\u00a0rebase\u00a0--autostash<\/pre>\n

\u5229\u7528\u53d8\u57fa\u81ea\u52a8\u5c06fixup\u63d0\u4ea4\u4e0e\u6b63\u5e38\u63d0\u4ea4\u5408\u5e76<\/p>\n

git\u00a0rebase\u00a0-i\u00a0--autosquash<\/pre>\n

\u5229\u7528ReBase\u5c06\u524d\u4e24\u4e2a\u63d0\u4ea4\u5408\u5e76<\/p>\n

git\u00a0rebase\u00a0--interactive\u00a0HEAD~2<\/pre>\n

Diff&Conflict:\u5dee\u5f02\u4e0e\u51b2\u7a81<\/p>\n

Info:\u4fe1\u606f\u67e5\u770b<\/strong><\/p>\n

\u5217\u4e3e\u5168\u90e8\u7684\u51b2\u7a81\u6587\u4ef6<\/p>\n

git\u00a0diff\u00a0--name-only\u00a0--diff-filter=U<\/pre>\n

\u5728\u7f16\u8f91\u5668\u4e2d\u6253\u5f00\u6240\u6709\u51b2\u7a81\u6587\u4ef6<\/p>\n

git\u00a0diff\u00a0--name-only\u00a0|\u00a0uniq\u00a0|\u00a0xargs\u00a0$EDITOR<\/pre>\n

Workflow:\u5de5\u4f5c\u6d41<\/strong><\/p>\n

SubModules:\u5b50\u6a21\u5757<\/strong><\/p>\n

Info:\u4fe1\u606f\u67e5\u770b<\/strong><\/p>\n

Manipulation:\u64cd\u4f5c<\/strong><\/p>\n

\u5229\u7528SubTree\u65b9\u5f0f\u5c06\u67d0\u4e2aProject\u6dfb\u52a0\u5230Repo\u4e2d<\/p>\n

git\u00a0subtree\u00a0add\u00a0--prefix=<directory_name>\/<project_name>\u00a0--squash\u00a0git@github.com:<username>\/<project_name>.git\u00a0master<\/pre>\n

\u66f4\u65b0\u6240\u6709\u7684\u5b50\u6a21\u5757<\/p>\n

git\u00a0submodule\u00a0foreach\u00a0git\u00a0pull<\/pre>\n

Work Tree<\/strong><\/p>\n

Manipulation:\u64cd\u4f5c<\/strong><\/p>\n

\u4ece\u67d0\u4e2a\u4ed3\u5e93\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Working Tree<\/p>\n

git\u00a0worktree\u00a0add\u00a0-b\u00a0<branch-name>\u00a0<path>\u00a0<start-point><\/pre>\n

\u4eceHEAD\u72b6\u6001\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Working Tree<\/p>\n

git\u00a0worktree\u00a0add\u00a0--detach\u00a0<path>\u00a0HEAD<\/pre>\n

 <\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/os.51cto.com\/art\/201608\/515536.htm<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttp:\/\/lrxjmw.cn\/some-git-tips.html<\/a>\u7f16\u8f91\u5458\uff1a\u9676\u6b66\u6770\uff0c\u5ba1\u6838\u5458\uff1a\u738b\u8f89<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u3010\u5f15\u81ea xjtuhit \u7684\u535a\u5ba2\u3011 Configuration:\u914d\u7f6e  \u5217\u4e3e\u6240\u6709\u7684\u522b\u540d\u4e0e\u914d\u7f6eGit \u522b\u540d\u914d\u7f6e<\/p>\n","protected":false},"author":63,"featured_media":28125,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-24710","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/24710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=24710"}],"version-history":[{"count":16,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/24710\/revisions"}],"predecessor-version":[{"id":258481,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/24710\/revisions\/258481"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/28125"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=24710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=24710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=24710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}