有用的 snippet
ansible all -l 'web' -m user -a "name=www shell=/bin/bash createhome=yes"
有用的 snippet
ansible all -l 'web' -m user -a "name=www shell=/bin/bash createhome=yes"
虚拟机:192.168.1.111
安装 pptp-setup
yum install pptp-setup
创建 pptp
pptpsetup --create p1_jp1 --server p1.jp1.jpuyy.com --username user --password pass --start
这之后会有文件 /etc/ppp/peers/p1_jp1
# written by pptpsetup pty "pptp p1.jp1.jpuyy.com --nolaunchpppd" lock noauth nobsdcomp nodeflate name user remotename p1_jp1 ipparam p1_jp1 require-mppe
对应的密码文件记录在 /etc/ppp/chap-secrets
之后要想连接或断开 pptp,可以使用,做两个软链
ln -s /usr/share/doc/ppp-2.4.5/scripts/pon /usr/local/bin/ ln -s /usr/share/doc/ppp-2.4.5/scripts/poff /usr/local/bin/
之后运行
pon p1_jp1
如果发现连不上,还需要启用 ip_gre 模块。参见这里。
打开 ip 转发
更改 /etc/sysctl.conf
net.ipv4.ip_forward = 1
sysctl -p 生效
设置 nat
-A POSTROUTING -o ppp0 -j MASQUERADE
替换默认网关
ip route replace default dev ppp0
至此,局域网中的其他机器可以设置把 192.168.1.111 做为网关了。
平时 git diff 都是以行级别的
如果以单词级别的可以这样
git diff --color-words
git diff --word-diff
在 git 里,每一个 commit 都带有一个 sha1 的标识,在任何分支,任何状态下,如果你知道这次提交的相关情况,可以将一次 commit merge 过来。
git cherry-pick 2379df
分支里多次提交合并成一个提交
示例
将最近几个(number_of_commits) 提交合并成一个提交
git rebase -i HEAD~[number_of_commits]
然后进入交互式选择
# # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # These lines can be re-ordered; they are executed from top to bottom. # # If you remove a line here THAT COMMIT WILL BE LOST. # # However, if you remove everything, the rebase will be aborted. # # Note that empty commits are commented out
这里先进行 commit 方面的选择,把除去第一行的都改为 squash
pick f7f3f6d changed my name a bit squash 310154e updated README formatting and added blame squash a5f4a0d added cat-file
然后进行 commit msg 的界面,自己写一下合并后的 commit。
分支的 push 强制提交会将本地操作生效
参考:
pro git
经常 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