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/

posted @ 2022-08-21 11:12  牧之原翔子  阅读(102)  评论(0编辑  收藏  举报