git_v3.txt

3 篇文章 0 订阅

Git配置
-------------------
$>git config --system i18n.logoutputencoding gbk
$>git config --system i18n.commitencoding gbk
$>git config --system color.ui true
$>git config --system user.name "HY"
$>git config --system user.email "HY@example.org"
$>git config --system core.logallrefupdates true
$>git config --system alias.s "status -s"
$>git config --system alias.tg "tag --sort=taggerdate --format '%(refname:short) %(taggerdate:short) %(subject)'"
$>git config --system alias.ca "commit --amend --allow-empty --reset-author -aF"
$>git config --system alias.cm "commit -aF"
$>git config --system log.date iso
$>git config -e --system                                                #编辑配置文件.

Git强制切换某个分支
-------------------
$>git checkout -fb <branch name> <tag name>

Git丢弃本地修改
-------------------
$>git reset --hard [commit]               #返回到某个节点,不保留修改.
 >git reset --hard HEAD                   #丢弃最近的修改.
$>git reset --soft [commit]               #返回到某个节点,保留修改.
$>git clean -df                           #删除本地工作目录中未跟踪的文件,删除文件和目录.

Git日志
-------------------
$>git log -ps -n [x]                                 #查看最近[x]次提交的修改.
$>git log --since=[x].day                            #列出最近[x]天的修改.
 >git log --since=[x].weeks                          #列出最近[x]周的修改.
 >git log --since=[x].years                          #列出最近[x]年的修改.
$>git log -s --since=[y].day --committer [x]         #列出提交者([x])最近[y]天的修改.
$>git shortlog -n                                    #显示简短的日志信息.
$>git log --graph --pretty=oneline --abbrev-commit   #查看分支历史.
$>git reflog                                         #显示本地库HEAD的更改日志.

Git注释格式
-------------------
Added            #新加入的需求.
Fixed            #修复bug.
Changed          #完成的任务.
Updated          #完成的任务或者由于第三方模块变化而做的更改.
Issue#[issue number]

Git提交日志
-------------------
步骤1,编辑<commit log>提交日志文件.
$>vi <commit log>
------
title

<Added/Fixed/Changed/Updated>
<desc>(描述):
...

<git status -s>

步骤2,根据<commit log>进行提交.
$>git commit -aF <commit log>

Git从仓库中删除某个目录或文件
-------------------
$>git rm -rf --cached [File/Dir Name]
$>git commit -aF <commit log>

Git注意事项
-------------------
1.Git仓库移动建议使用命令<tar -cvzf name.tar.gz name/>压缩后传输到其他主机然后再解压并使用.

Git清理
-------------------
$>git clean -fdx

Git修改上一次的提交信息
-------------------
$>git commit --amend --allow-empty --reset-author -aF <commit log>      #改正上一次的提交记录,此条命令执行后不会新增新的[commit-id]信息;[--amend]是对刚刚的提交进行修补,[--allow-empty]使得空白提交被允许,[--reset-author]是将作者[Author]的ID同步修改,否则只能影响(commit)的ID.
or 
$>git ca <commit log>
$>git cm <commit log>

Git创建tag
-------------------
$>git tag -a <tag name> -fF <commit log>

Git对tag输出进行排序
-------------------
$>git tag --sort=taggerdate --format '%(refname:short) %(taggerdate:short) %(subject)'
or
$>git tg

Git显示TAG名字
-------------------
$>git describe
$>git describe <commit id>
$>git name-rev --tags <commit id>
$>git log --oneline --decorate
$>git log <branch name or tag name> --pretty=oneline | git name-rev --tags --stdin
$>git log --oneline -<number> --stat                    #显示<number>条日志的状态信息.
$>git log -<number>                                     #显示<number>条日志.

Git操作上游TAG
-------------------
$>git remote -v
$>git remote rename <old name> <new name>
$>git remote update                                        #远程版本库的更新.
$>git config remote.<remote name>.skipdefaultupdate true   #跳过<remote name>的自动更新.
$>git remote rm <remote name>                              #删除远程版本库.
$>git ls-remote <origin name>                              #查看上游tag.
$>git push <origin name> :<tagname>                        #删除远程版本库中的里程碑.
$>git push <origin name> <tagname>                         #推送tag到远程版本库.

Git分支
-------------------
$>git branch
$>git branch <branch name>
$>git branch <branch name> <branch name or commit id>
$>git branch -d <branch name>
$>git branch -m <old branch name> <new branch name>     
$>git checkout -b <branch name> <branch name or commit id>

Git基于TAG创建分支
-------------------
$>git checkout -b <branch name> <tag name> 

Git查看两个分支的提交记录
--------------------
$>git log v4.19.133...v4.19.134

查看代码修改记录
-------------------
文件标注
--------
$>git blame -C -L <起始行,终止行> <文件>

二分查找
--------
$>git bisect start
$>git bisect bad 
$>git bisect good <标记名称/TAG>
$>git bisect reset

参考:progit_v2.1.53.pdf <使用 Git 调试>

子模块
--------
参考:progit_v2.1.53.pdf <使用 Git 调试-子模块>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

胡致云

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值