微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Git基本用法

管理修改文件

Reset

git reset //只会影响tracked的文件

Unpacked file

git clean -f -fd -xfd //删除文件文件&夹、包含.gitignore指定的
git clean -nf -nfd -nxfd //预览要删除文件

Commit

多个Commit选择性Push

  1. git log查看要提交的commit id
  2. git checkout -b 创建一个新的本地分支
  3. git cherry-pick $(commit id)
  4. git fetach, git rebase同步最新code
  5. git push

amend

合并缓冲区的修改和上一次commit,来替代上一次commit。
--no-edit //不修改commit msg

Log

Reflog

--relative-date
查看本地所有记录(切换branch、pull、commit)的ID

Log

blame

Config

Git配置有系统级配置,全局配置和本地仓库配置
同时存在,底层配置会覆盖上层

  • $Repo/.git/config
  • ~/.gitconfig //--global config
  • $(prefix)/etc/gitconfig //--system

Git config命令与修改配置文件效果相同
git config (--global/system) --edit
创建配置文件中的数据项
git config <title>.<attri> <string>
效果如:

[title]
attri = string
#title:user.name&email,alias,core.editor

Bare repo

不具有snapshot的Git repo,仅仅存储历史记录(.git)
https://stegosaurusdormant.com/bare-git-repo/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐