git 配置了解这些就够了

2 篇文章 0 订阅

git 配置了解这些就够了

1. config 

Git相关的配置文件有三个

1. /etc/gitconfig:包含了适用于系统所有用户和所有项目的值。  --system

2.~/.gitconfig:只适用于当前登录用户的配置。 --global

3. 位于git项目目录中的.git/config:适用于特定git项目的配置。 --local

  git config --system -e 就可以编辑了

[core]
        excludesfile = ~/.gitignore
        legacyheaders = false # >git 1.5
        quotepath = false

[user]
#       name = your name
#       email = your@name

[mergetool]
        keepBackup = true

[push]
        default = simple # [ matching | simple ]

[color]
        ui = auto
        interactive = auto

[repack]
        usedeltabaseoffset = true # >git 1.5

[alias]
        s = status
        a = !git add . && git status
        au = !git add -u . && git status
        aa = !git add . && git add -u . && git status
        c = commit
        cm = commit -m
        ca = commit --amend # careful
        ac = !git add . && git commit
        acm = !git add . && git commit -m
        l = log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'
        ll = log --stat --abbrev-commit
        lg = log --color --graph --pretty=format:'%C(bold white)%h%Creset -%C(bold green)%d%Creset %s %C(bold green)(%cr)%Creset %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
        llg = log --color --graph --pretty=format:'%C(bold white)%H %d%Creset%n%s%n%+b%C(bold blue)%an <%ae>%Creset %C(bold green)%cr (%ci)' --abbrev-commit
        d = diff
        master = checkout master
        spull = svn rebase
        spush = svn dcommit
        alias = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\\t => \\2/' | sort  
[include]       # as of 1.7.10 https://github.com/git/git/commit/9b25a0b52e09400719366f0a33d0d0da98bbf7b0
        path = ~/.gitcinclude
        path = .githubconfig
        path = .gitcredential

#[github]
#       user =
#       token =

[diff]
        # git does copy/rename *detection*. if you want it to track copies/renames:
        # http://stackoverflow.com/questions/1043388/record-file-copy-operation-with-git
        # renames = copies

[diff "exif"]
        textconv = exif
[credential]
        helper = osxkeychain           

2. 一些git命令常用

git push new-branch 
git push tag 
git push ~

git tag publish/x.x.x
git push origin publish/x.x.x:publish/x.x.x

git push origin —delete branchName 删除branch
git push origin :<branchName>

git push origin —delete tag tagName 删除tag
git tag -d <tagname>ta
git push origin :refs/tags/<tagname> 

git rm --cached -r . 清缓存git命令

git reset [--hard|soft|mixed|merge|keep] [commit|HEAD] 回滚

git remote prune origin // 远程删除了分支,本地同步

2. 一些问题

报错 fatal: refusing to merge unrelated histories
命令后面加参数 --allow-unrelated-histories

参考链接

1、Git查看、删除、重命名远程分支和tag

2、git - 默认行为的"git push"没有指定一个分支

3、git-merge完全解析

4、Git忽略提交规则 - .gitignore配置运维总结

5、图解 Git 命令

欢迎交流~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值