xwill

To be double-cool

06 Jan 2021

[tip]-- git

命令 说明
git branch -r 查看远程仓库的分支信息 -r :remote
git branch -a 查看本地和远程仓库的分支信息 -a : all
git branch -m <oldbranch> <newbranch> 重命名 -M 强制重命名
git branch 查看本地
git branch <branchname> 创建本地分支
git checkout -b <branchname> 创建新分支,并切换到该分支
git checkout <branchname> 切换分支
git branch -d <branchname> 删除分支(已参与过合并的分支) -D 强制删除
git push [远程仓库] <本地分支>: <远程分支> 推送本地分支的代码到远程仓库 <远程分支> 名不填,则推送到与本地分支名相同的分支。
如果远程仓库没有,则创建
git默认远程仓库 origin 分支 master
git push [远程仓库] : <远程分支> 删除远程仓库的分支 推送一个空到远程仓库的分支
git pull [远程仓库] <远程分支>: <本地分支> 拉取远程仓库分支到本地 本地分支不填,则默认本地分支名为远程分支名
git stash 暂存修改
git stash pop 应用最近的暂存修改
git stash list 列出当前暂存所有修改
tag
git tag -l -n 查看本地tag
git fetch 单单获取远程信息到本地,但不是pull
git diff –cached path/file 查看暂存去修改 git add后 红的变绿的
git merge –squash | 多次合并记录为一次提交记录