美文网首页程序员
Git 常用命令

Git 常用命令

作者: 7c03aed0f01f | 来源:发表于2016-11-29 10:50 被阅读64次
# 查看Git版本
git --version

# 查看Git设置
git config

# 查看Git的配置
cat ~/.gitconfig

# 设置命令行中 Git 语法的高亮
git config --global color.ui true

# 初始化Git
git init

# 查看Git状态
git status

# 提交文件到 Git 缓存区
git add index.php

# 提交版本
git commit -m '更新'

# 查看commit记录
git log

# 查看commit记录( 以树状显示 )
git log

# 删除 Git 缓存文件
git rm -r --cached .idea/

# 使用版本的哈希值, 会退到该版本代码<br>
# --soft 是返回到该 commit的版本<br>
# --hard 同上, 但是 删除掉 该commit之后的版本
git reset --soft 00624869ac54256be3bc9ac5d55dbe9d00ce6741
git reset --hard 00624869ac54256be3bc9ac5d55dbe9d00ce6741

# 查看 commit哈希值的版本代码
git show 00624869ac54256be3bc9ac5d55dbe9d00ce6741

# 将 index.php 回滚到上一个版本
git checkout -- index.php

# 添加分支 about-feature
git branch about-feature

# 查看分支
git branch

# 切换分支
git checkout about-feature

# 添加, 并进入分支
git checkout -b about-feature

# 合并分支, 在master分支下 合并其他分支
git merge about-feature

# 删除分支
git branch -d about-feature

# 查看冲突文件
git diff index.php

# 设置 Git 快捷方式
git config --global slias.s status

# 强制更新
git fetch --all
git reset --hard origin/master
git pull

相关文章

网友评论

    本文标题:Git 常用命令

    本文链接:https://www.haomeiwen.com/subject/cquapttx.html