记录一些平时常用的Git命令
clone
git clone URL -b BRANCH path--depth 1 日志中只有最近1次提交--bare 以镜像的形式拉取代码--mirror 以镜像的形式拉取代码,与--bare相比,--mirror不仅将源的本地分支映射到目标的本地分支,还映射所有引用
remote
git remote, 显示所有远端库别名origin
git remote -v, 显示所有远端库别名 + url,每个别名都有与之对应的fetch(下载)和push(上传)地址origin https://gitee.com/zhangguangxuan/Documents.git (fetch)origin https://gitee.com/zhangguangxuan/Documents.git (push)
git remote show origin* remote originFetch URL: https://gitee.com/zhangguangxuan/Documents.gitPush URL: https://gitee.com/zhangguangxuan/Documents.gitHEAD branch: masterRemote branch: 远端分支master tracked(已跟踪)...Local branch configured for 'git pull': 本地可直接git pull的分支master merges with remote master...Local ref configured for 'git push': 本地可直接git push的分支master pushes to master (up to date)...
git remote add alias url
git remote prune alias, 删除远端库中不存在的分支
git remote rename old_alias new_alias
git remote update
git remote get-url alias
stash
git stash [save]
pop `<ID>` 弹出ID号暂存修改作用于当前分支,默认最新
apply `<ID>` 提取ID号暂存修改作用于当前分支,默认最新
create 创建暂存
store `<ID>` 将暂存存到栈中
branch `<ID>` 弹出ID号暂存创建分支,默认罪行
clear 删除所有暂存
drop `<ID>` 删除ID号暂存
list 显示所有暂存,ID号暂存,在某分支上,路径信息stash@{0}: On sanjuan/master: systemtest/configs/
show `<ID>` 显示ID号暂存修改,默认最新
diff
git diff 按行显示修改--word-diff 按单词显示修改
git diff --name-only FETCH_HEAD..FETCH_HEAD^
git show commitId, 查看修改的详情# 显示大量的文件mode被修改
git config --global core.filemode false
submodule
# 添加子模块
git submodule add git@ssh:xxx.git pod-librarygit submodule update --init --recursivegit submodule foreach git pull