git常用命令
配置ssh 以及git config
用法
配置更改用户名/邮箱
git config --global user.name “用户名”
git config --global user.email “邮箱”\
查询用户名/邮箱
git config user.name
git config user.email
生成ssh文件
ssh-keygen -t rsa -C “邮箱地址”
文件切换目录/查询目录列表
cd c:
ls -a
查询config列表
git config --lists
更新远程仓库 git fetch
git fetch -p
commit
回退commit
git reset --soft HEAD^ ----不撤回add只撤回
commit git reset --mixed HEAD^ — 撤回add
HEAD^ 撤回1次
HEAD~1 撤回1次
HEAD~2 撤回2次commit
修改commit 注释
git commit --amend
tig
按 p 退出 tig
checkout / branch
git branch -a 插看所有分支
创建分支: $ git branch mybranch
切换分支: $ git checkout mybranch
创建并切换分支: $ git checkout -b mybranch
删除分支: $ git branch -d mybranch
强制删除分支: $ git branch -D mybranch
列出所有分支: $ git branch
查看各个分支最后一次提交: $ git branch -v
查看哪些分支合并入当前分支: $ git branch –merged
查看哪些分支未合并入当前分支: $ git branch –no-merged
重命名分支 git branch -m oldName newName
修改远程分支重命名
a. 重命名远程分支对应的本地分支
b. 删除远程分支
c. 上传新命名的本地分支
将别人分支合并到自己分支上 git cherry-pick commitid
储存 git rebase
git rebase master 将当前分支储存到master分支上
git rebase --abort 会回到rebase操作之前的状态,之前的提交的不会丢弃;git rebase --skip 则会将引起冲突的commits丢弃掉;
git rebase --continue 用于修复冲突,提示开发者,一步一步地有没有解决冲突,fix conflicts and then
run “git rebase --continue”