导言

网上关于Git相关的资料教程已经一大堆,这里也只是记录一下个人常用的一些操作

命令

# 初始化一个Git仓库(本地)
$ git init

# 推送一个本地仓库到远端
$ git remote add origin https://xx.xxx.com/test.git
$ git push --set-upstream origin --all
$ git push --set-upstream origin --tags

# 克隆一个仓库到本地
$ git clone https://xx.xxx.com/test.git

# 把当前工作区内容加入暂存区
$ git add .

# 放弃工作区的修改(添加的文件不能撤销),俩命令都行
$ git checkout .
$ git restore --worktree .

# 恢复暂存区的内容到工作区
$ git restore --staged .

# 提交内容
$ git commit -m 'feature: 本次提交的版本特性'

# 推送提交到远端
$ git push

# 更新远端仓库到本地(可能会有冲突,注意冲突问题)
$ git pull

# 查看分支
$ git branch -a

# 创建分支
$ git branch xxxxx

# 切换分支
$ git switch xxxxx_V4.0D0017

# 合并分支(先去到要合并到的分支)
$ git merge xxxx

# 查看提交日志
$ git log

# 重置版本(注意回滚后和本地工作区的冲突问题)
$ git reset 版本号

# 回滚版本(创建一个新的版本,新的版本不包含回滚的那个提交的内容)
$ git revert 版本号

参考资料

https://cloud.tencent.com/developer/article/1757064
https://blog.csdn.net/weixin_45346457/article/details/123706224
https://blog.csdn.net/lianshaohua/article/details/108336436
https://blog.csdn.net/qq_46106285/article/details/124744328

标签: none

添加新评论