Category: Life

  • git fsck 清理 dangle objects

    经常 commit –amend,merge,rebase,reset –hard 后,会产生一些没有引用的 objects,这些有的可能会恢复你误操作后的修改,但是大部分时间是没用的。想着清理一下。

    先查看有哪些

    git fsck --full

    Dangling blob = A change that made it to the staging area/index, but never got committed. One thing that is amazing with Git is that once it gets added to the staging area, you can always get it back because these blobs behave like commits in that they have a hash too!!

    Dangling commit = A commit that isn’t directly linked to by any child commit, branch, tag or other reference. You can get these back too!

    Dangling tree

    然后查看已经没有的引用

    git reflog expire --expire=now --all

    git reflog: record when refs were update in the local repository, useful for recovering lost commits

    清理

    git gc --prune=now

    git gc: clean up and optimize the local repository

    参考:
    http://www.tekkie.ro/news/howto-remove-all-dangling-commits-from-your-git-repository/
    https://git-scm.com/docs/git-fsck
    https://git-scm.com/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery

  • centos7 图形界面和字符界面切换

    通过 systemctl 控制

    1. 字符界面

    systemctl set-default multi-user.target

    2. 图形界面

    systemctl set-default graphical.target
  • 将 bitbucket 迁移到 github

    先装 bitbucket 中的 origin 命名成 bitbucket

    git remote rename origin bitbucket

    在 github 添加 origin

    git remote add origin https://github.com/username/myproject.git

    将 master 发上去

    git push origin master

    将 bitbucket 删掉

    git remote rm bitbucket

    在这里操作可以查看 .git/config 中的变化

    http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/

  • 快速从一台机器同步目录到另一台机器

    使用 pigz nc tar 组合命令完成

    发送方( pigz -4 代表压缩等级)

    tar c 20151014 | pigz -4 | nc -l 3389

    接收方

    nc 192.168.1.55 3389 | pigz -d | tar xf -
  • 查看文件的 mtime

    直接输出

    stat -c %Y filename
  • 学习 markdown

    参考:

    https://guides.github.com/features/mastering-markdown/

    mac 下工具

    sublime + markdown preview