> 文章列表 > 一些常用的git命令

一些常用的git命令

一些常用的git命令

git checkout -b [branch-name] 新建并切换分支
git branch -d [branch-name] 删除分支
git switch [branch-name] 切换分支
git merge [branch] 合并指定分支到当前分支
git branch -D [branch-name] 强制删除一个没有合并的分支

git log -3 查看最新3条commit日志
git reflog 显示操作本地版本库的命令,包括commit和reset等,在回退版本以后又后悔找不到commit id了可以使用此命令查看历史

git add . 工作区添加进暂存区
git reset [file] 暂存区的指定文件到工作区-撤销add

git commit -m [message] 暂存区提交到仓库
git commit --amend 改写上一次commit的提交信息
git reset --soft HEAD~ 撤销一次commit

git status 显示有变更的文件

git pull [remote] [branch] 取远程仓库的变化,并与本地分支合并
git push [remote] [branch] 上传本地指定分支到远程仓库
git remote show [remote] 显示某个远程仓库的信息

git stash (save “message”) 隐藏当前工作的修改(并添加备注)
git stash list 查看隐藏版本列表
git stash pop 恢复隐藏版本,并删除
git stash apply stash@{0} 恢复隐藏版本,不删除
git stash drop tab 删除(指定)隐藏版本