git
差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版 | ||
git [2017/01/07 18:09] – Add git clean command memory | git [2023/12/03 10:24] (当前版本) – 外部编辑 127.0.0.1 | ||
---|---|---|---|
行 4: | 行 4: | ||
===== Common command ===== | ===== Common command ===== | ||
+ | |||
+ | ==== add ==== | ||
+ | |||
+ | 按节暂存(stage)/ | ||
+ | |||
+ | <code bash> | ||
+ | git add -p < | ||
+ | </ | ||
+ | |||
+ | ==== commit ==== | ||
+ | |||
+ | 指定 commit 时间: | ||
+ | |||
+ | <code bash> | ||
+ | d=' | ||
+ | GIT_AUTHOR_DATE=" | ||
+ | |||
+ | # or | ||
+ | GIT_AUTHOR_DATE=" | ||
+ | </ | ||
+ | |||
+ | ==== tag ==== | ||
+ | |||
+ | 删除标签: | ||
+ | |||
+ | <code bash> | ||
+ | git tag -d <tag> | ||
+ | </ | ||
+ | |||
+ | 删除远程 origin 中的标签: | ||
+ | |||
+ | <code bash> | ||
+ | git push --delete origin <tag> | ||
+ | </ | ||
===== Useful command ===== | ===== Useful command ===== | ||
行 38: | 行 72: | ||
<code bash> | <code bash> | ||
git bisect good # 将输出引入bug的commit | git bisect good # 将输出引入bug的commit | ||
+ | </ | ||
+ | |||
+ | ==== patch ==== | ||
+ | |||
+ | 生成 '' | ||
+ | |||
+ | <code bash> | ||
+ | git format-patch -1 <sha> | ||
+ | git format-patch -1 HEAD # or | ||
+ | |||
+ | git format-patch <sha> # format patch from <sha> to HEAD | ||
+ | </ | ||
+ | |||
+ | 应用 '' | ||
+ | |||
+ | <code bash> | ||
+ | git am ./ | ||
</ | </ | ||
===== Trick ===== | ===== Trick ===== | ||
+ | |||
[[https:// | [[https:// | ||
行 47: | 行 99: | ||
git read-tree --reset HEAD | git read-tree --reset HEAD | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | Ignore some tracked files | ||
+ | |||
+ | <code bash> | ||
+ | git update-index --assume-unchanged < | ||
+ | |||
+ | # retrack | ||
+ | git update-index --no-assume-unchanged < | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | **Change commited username/ | ||
+ | |||
+ | <code bash> | ||
+ | git filter-branch -f --env-filter \ | ||
+ | " | ||
+ | GIT_COMMITTER_NAME=' | ||
+ | |||
+ | # need to push force | ||
+ | git push --force | ||
+ | </ | ||
+ | |||
+ | ==== 管理多个ssh密钥 ==== | ||
+ | |||
+ | Linux是通过.ssh/ | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | < | ||
+ | Host my-user-name.github.com | ||
+ | | ||
+ | User git | ||
+ | | ||
+ | | ||
+ | |||
+ | Host company.github.com | ||
+ | | ||
+ | User git | ||
+ | | ||
+ | | ||
+ | </ |
git.1483783753.txt.gz · 最后更改: 2023/12/03 10:24 (外部编辑)