git常用命令、冲突解决

  1. 查看当前分支: git branch
  2. 切换分支:git checkout 分支名字
  3. 新建分支:git branch 分支名字
  4. 删除本地分支:git branch -d 分支名字(-D 强制删除)
  5. 提交创建的分支到远程:git push origin 分支名字
  6. 删除远程分支:git push -d origin 分支名字
  7. 提交到暂存区: git add .
  8. 提交到本地仓库:git commit -m "注释"
  9. 提交到远程服务器:git push origin 分支名字
  10. 拉取远程服务器的代码到本地:git pull origin 分支名字
  11. 本地修改暂存:git stash 或 git stash save "暂存的名字"
  12. 查看暂存列表:git stash list
  13. 切换到某个暂存:git stash pop stash@{index} 此操作会删除对应暂存
  14. 放弃本地修改,未提交和暂存:git checkout -- filepathname
  15. 查看状态:git status
  16. git restore --staged <file>命令,把文件从暂存区撤回到工作区,保留文件最后一次修改的内容
  17. git restore <file>命令,会撤销文件的修改,使文件恢复到暂存区或本地代码库(取决于文件在修改前的状态)
posted @ 2021-12-14 17:46  陈娟  阅读(614)  评论(0)    收藏  举报