我的GIT使用记录

记录平时使用到的git操作命令

git clone --recursive-submodules /path/to/repositoty.git 递归克隆

git checkout -b <local/branch/name> origin/<remote/branch/name> 新建关联远程分支的本地分支并切换到该本地分支

git submodule update --init --recursive 递归更新子仓库

git submodule sync --recursive  手动修改.gitmodule里面的URL之后执行同步,将.git/config中配置的url也同步更正

git push -d origin <remote/branch/name> 删除远程分支

git branch -D <local/branch/name> 删除本地分支

git branch -a  查看所有的分支。换成 -l 表示本地分支,换成 -r 表示远程分支

git branch -vv 查看分支的关联关系

git branch --set-upstream-to=origin/<remote/branch/name> 更改当前分支关联的远程分支

git fetch

git rebase -i <commit-id> 交互式合并提交点,注意这个提交点一般要指定到更前面的一个

git cherry-pick <commit-id[..commit-id]> 摘取指定的一个[或者指定范围内的]修改

git cherry-pick --abort 中止摘取

git cherry-pick --continue 继续摘取,一般是中间有冲突,修改之后commit,再执行continue

git reset [--hard] <commit-id> 恢复到指定的提交点,使用 --hard 会将所有的修改都回退掉,而--soft参数回退后,所有的修改点都保存在工作区。

git stash push -m <提示内容> [/path/to/be/push] 将修改点暂存

git stash list 查看已暂存的项

git stash pop [name] 弹出已暂存的修改点并将其从stash中移除

git stash apply [name] 弹出已暂存的修改点并将其保留在stash中

gitk [branch/name] [&] 通过窗口查看[指定分支]的记录,我理解符号 & 表示异步(使用&之后git窗口还能继续执行命令,否则就阻塞在哪里)

git commit --amend 修改当前分支的最后一个提交点的备注信息

 git diff [/path/of/file] [>out.diff] 查看差异

git apply [--check|--reject|--stat] <file.diff>  将差异合并,--check是尝试看有不有错,--reject是合并不冲突的保留冲突的

git remote add origin git@1.2.3.4:path/to/project.git  添加一个远程仓库地址 

git remote -v 查看远程仓库的地址信息

 

posted @ 2023-04-12 19:50  -ssdq-  阅读(14)  评论(0编辑  收藏  举报