git相关

作者: koreadragon | 来源:发表于2017-07-07 10:24 被阅读75次

其实更多的是关于gerrit的内容

1.两篇很不错的git教程文章
都是由浅到深的,很适合学习。
这篇适合入门
想要提高看这篇

2.撤销已经push到远端的提交
找到你的commit id,比如3df5a456 ,然后执行git revert 3df5a456,此时就产生了一个与该id对应的提交(可以理解与之前的提交互为“反物质”,一旦提交之后两次就中和了)。
然后执行git push

2.Gerrit提交时缺失change-Id的问题
有时候会有类似报错! [remote rejected] HEAD -> refs/for/store (change https://gerrit.epbox.com.cn/5184 closed)
我出现这个错误是因为之前的commit被abandon掉了,所以提示这个change closed,解决办法就是针对已经closed的这个commit ,删除掉其中的change-Id,操作如下:git commit --amend,然后进入到编辑界面,手动删除掉change-Id,然后再:wq,保存退出后会自动生成新的change-Id,然后就可以提交了

3.不想提交Untracked files

删除 untracked files

git clean -f

连 untracked 的目录也一起删掉

git clean -fd

连 gitignore 的untrack 文件/目录也一起删掉 (慎用,一般这个是用来删掉编译出来的 .o之类的文件用的)

git clean -xfd

在用上述 git clean 前,墙裂建议加上 -n 参数来先看看会删掉哪些文件,防止重要文件被误删

git clean -nxfd
git clean -nf
git clean -nfd

4.改log显示时间

`--date= (relative|local|default|iso|rfc|short|raw):定制后边如果出现%ad或%cd时的日期格式

有几个默认选项
--date=relative:shows dates relative to the current time, e.g. "2 hours ago".

--date=local:shows timestamps in user’s local timezone.
--date=iso (or --date=iso8601):shows timestamps in ISO 8601 format.
--date=rfc (or --date=rfc2822):shows timestamps in RFC 2822 format,often found in E-mail messages.
--date=short:shows only date but not time, in YYYY-MM-DD format.这个挺好用
--date=raw:shows the date in the internal raw git format %s %z format.
--date=default:shows timestamps in the original timezone (either committer’s or author’s).
也可以自定义格式(需要git版本2.6.0以上),比如--date=format:'%Y-%m-%d %H:%M:%S' 会格式化成:2016-01-13 11:32:13,其他的格式化占位符如下:
%a:Abbreviated weekday name (Fri)
%A:Full weekday name
%b:Abbreviated month name
%B:Full month name
%c:Date and time representation appropriate for locale
%d:Day of month as decimal number (01 – 31)
%H: Hour in 24-hour format (00 – 23)
%I:Hour in 12-hour format (01 – 12)
%j:Day of year as decimal number (001 – 366)
%m:Month as decimal number (01 – 12)
%M:Minute as decimal number (00 – 59)
%p:Current locale's A.M./P.M. indicator for 12-hour clock
%S:Second as decimal number (00 – 59)
%U:Week of year as decimal number, with Sunday as first day of week (00 – 53)
%w:Weekday as decimal number (0 – 6; Sunday is 0)
%W:Week of year as decimal number, with Monday as first day of week (00 – 53)
%x:Date representation for current locale
%X:Time representation for current locale
%y:Year without century, as decimal number (00 – 99)
%Y:Year with century, as decimal number
%z, %Z:Either the time-zone name or time zone abbreviation, depending on registry settings; no characters if time zone is unknown
%%:Percent sign
如 git config --global log.date format-local:'%Y-%m-%d %H:%M:%S 星期%w'

下面是效果:

git log 显示时间的修改

相关文章

  • git基本命令

    git常用命令 git丢弃更改相关 git连接远程仓库相关 git切换分支相关 git stash相关 git标签相关

  • 前端 | Git的学习

    文章目录 Git相关命令 Git相关命令 git init :初始化本地git目录,生成 .git 文件夹 git...

  • 2019-06-26: Git 相关?

    一:Git相关 '--------------------------git pull--------------...

  • Git相关

    关联到GitHub http://www.runoob.com/git/git-remote-repo.html

  • Git相关

    更新 fork 的仓库 https://github.com/lxconan/java/blob/master/s...

  • git相关

    常见命令 git help git config --global user.name "一纸砚白" git co...

  • git 相关

    2018年3月27日15:31:29 用eclipse 用习惯了,换着思维使用一下git,服务器用的是coding...

  • git相关

    https://www.jianshu.com/p/52694939213b

  • git相关

    本地创建新分支: git checkout -b 新分支名字 或者 git branch 新分支名字 git br...

  • git 相关

    1,git clone .. 克隆远程分支到本地。 2,git checkout branchName 在本地切换...

网友评论

      本文标题:git相关

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