在Linux上管理Git分支

git   Linux  

1、把远程仓库克隆到本地

  1. root@virtualbox:/home/wwwroot# git clone https://gitee.com/liu21st/thinkphp.git
  2. root@virtualbox:/home/wwwroot# git clone https://gitee.com/liu21st/thinkphp.git thinkphp6
  3. root@virtualbox:/home/wwwroot# ll
  4. 总用量 16
  5. drwxr-xr-x 4 root root 4096 11 27 17:22 ./
  6. drwxr-xr-x 6 root root 4096 11 20 16:34 ../
  7. drwxr-xr-x 11 root root 4096 11 27 17:21 thinkphp/
  8. drwxr-xr-x 11 root root 4096 11 27 17:22 thinkphp6/
  9. root@virtualbox:/home/wwwroot# cd thinkphp

2、Git分支管理命令

  • 查看当前分支:git branch
  • 切换Git分支:git checkout branchname
  • 删除Git分支:git branch -D branchname

3、管理Git分支上的文件

  • 拉取最新版本:git pull
  • 舍弃当前目录所有的更改:git checkout .
  • 舍弃当前目录某个文件的更改:git checkout filename

4、Git回滚代码

  • 查看Git日志:git log
  1. root@virtualbox:/home/zhenkai/thinkphp# git log
  2. commit 40551b4ba735fea11f0699764041c1d32c7656c7 (HEAD -> master, tag: v5.0.24, origin/master)
  3. Author: thinkphp <thinkphp@qq.com>
  4. Date: Fri Jan 11 16:11:23 2019 +0800
  5. 更新日志
  6. commit 9cff9762112eaf74bfb06e9fa1521d6c512c7094 (tag: v5.0.23)
  7. Author: thinkphp <thinkphp@qq.com>
  8. Date: Mon Dec 10 14:54:30 2018 +0800
  9. 添加更新日志
  10. commit 2b9f858978b4ebe0fa8406094e429cad3cf0fe4c (tag: v5.0.22)
  11. Author: thinkphp <thinkphp@qq.com>
  12. Date: Fri Sep 7 16:33:13 2018 +0800
  13. 增加配置
  14. commit bad4beef4c100ad60f4d8bd019954e78c21a1a62 (tag: v5.0.20)
  15. Author: thinkphp <thinkphp@qq.com>
  16. Date: Fri May 11 16:12:00 2018 +0800
  17. 调整
  18. commit fcdf196a7275e6da765675d0b00b18af059bab04 (tag: v5.0.19)
  19. Author: thinkphp <thinkphp@qq.com>
  20. Date: Wed Apr 25 18:31:45 2018 +0800
  21. 配置调整
  22. commit 6089b6dac0b01de95b33e4064a9317626904720b (tag: v5.0.18)
  23. Author: thinkphp <thinkphp@qq.com>
  24. :
  • 回滚到指定的版本:git reset --hard bad4beef4c100ad60f4d8bd019954e78c21a1a62
  • 回滚后再次拉去最新的版本:git pull


评论 0

发表评论

Top