zhuangjinxin / study

每日学习笔记
0 stars 0 forks source link

git command #28

Open zhuangjinxin opened 3 years ago

zhuangjinxin commented 3 years ago

git add .添加变更到暂存区 git commit -m''提交变更到当前分支 git push origin <branch>推送变更到远程仓库

git status查看变更状态 git diff查看变更内容 git log 查看提交记录 git log --graph --pretty=oneline --abbrev-commit 查看分支合并图 git reflog 查看历史命令

git reset --hard head^ (head~n) 往前回退 git reset --hard <commit_id> 指定版本 git reset HEAD <file> 指定版本

git checkout -- <file> 撤销修改文件 git checkout -b'BRANCH' origin/master 新建分支 git checkout <branch> 切换分支

远程仓库: git remote add origin <ssh_url> 添加远程仓库 git push -u origin master 第一次推送,关联本地master与远程master git push origin master 推送本地内容到远程 git clone <ssh_url> 克隆远程仓库

分支管理: git branch 查看分支 git branch <branch> 新建分支 git branch -d <branch> 删除分支 git branch -D <branch> 强制删除分支 git checkout <branch> 切换分支 git checkout -b'<branch>' 新建并切换分支 git merge <branch> 合并某分支到当前分支 git switch -c <branch> 新建并切换分支 git switch <branch> 切换分支