Skip to content

Instantly share code, notes, and snippets.

@flaneur2020
Created January 14, 2012 11:32

Revisions

  1. flaneur2020 revised this gist Nov 26, 2012. 1 changed file with 0 additions and 63 deletions.
    63 changes: 0 additions & 63 deletions shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -28,66 +28,3 @@ crontab并没有直接向用户暴露配置文件的位置,是因为crontab这
    比如:

    + 每天凌晨1点执行:`0 1 * * * blah`

    ### svn

    svn提供了比git更为精细的权限控制,按照目录为单位。

    + checkout: `svn co http://svn.miaomiao.com/svn/trunk -r HEAD`
    + 创建自己的分支目录:`svn mkdir http://svn.foo.com/svn/branches/fleuria`
    + 创建特性分支:`svn cp http://svn.foo.com/svn/trunk http://svn.foo.com/svn/branches/fleuria/issue1`
    + 切换分支:`svn switch http://svn.foo.com/svn/branches/fleuria/issue1`
    + 不像git有暂存区,svn在提交时只能将需要提交的文件列在命令里: `svn commit -m 'commit message' file1.c file2.c`
    + 撤销当前的所有更改: `svn revert -R .`
    + merge需要先得到revision的范围: `svn log /branches/feature_233 --stop-on-copy; svn merge /branches/feature_233 -r 999:1000`
    + 获取分支的第一个revision: `svn log -v --stop-on-copy`
    + 当前修改: `svn st -q`
    + revert当前的所有修改: ``svn revert `svn st -q` ``
    + merge合并过trunk的分支时记得加上: `--reintergrate`

    Troubleshoots:

    ```
    Working copy locked
    ```

    `cd .svn; rm lock`

    ```
    svn: E160013: '/svn/shire/!svn/bc/135926/branches/miaomia/meow' path not found
    ```

    先检查下哪里拼错了。

    ```
    svn: Failed to add directory 'waymeet': an unversioned directory of the same name already exists
    ```

    `svn switch`时如有遇到如此提示,删掉这个`waymeet`文件重新执行原先的`svn switch`

    ```
    svn st -q 时列出来一坨S状态的文件
    ```

    如果`svn switch`被中断会出现这种情况。

    恢复: `svn info bad_file` 查看某个S状态的文件所在的分支,然后`svn switch`到这个分支。

    ### git-svn

    建svn分支:

    ```
    git svn branch foo
    git checkout -b foo -t remotes/foo
    git commit
    git svn dcommit
    ```

    + Q: Could not unmemoize function `lookup_svn_merge', because it was not memoized to begin with at /usr/local/Cellar/git/1.7.6/libexec/git-core/git-svn line 3226

    A: `rm -rf .git/svn/.caches`

    + Q: Multiple branch paths defined for Subversion repository. You must specify where you want to create the branch with the --destination argument.

    A: 修改.git/config,添加: `branches = branches/liyazhou/*:refs/remotes/*``[svn-remote "svn"]`下。
  2. flaneur2020 revised this gist Nov 26, 2012. 1 changed file with 14 additions and 1 deletion.
    15 changes: 14 additions & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,6 @@
    + `xxxdump | vim -`: 将stdout的输出重定向给vim

    ### 后台任务

    + 后台进程并不等于它是长期执行的进程,在用户注销时,可能照样会收到sighup。

    解决方法是使用tmux或者`nohup`
    @@ -60,6 +59,20 @@ svn: E160013: '/svn/shire/!svn/bc/135926/branches/miaomia/meow' path not found

    先检查下哪里拼错了。

    ```
    svn: Failed to add directory 'waymeet': an unversioned directory of the same name already exists
    ```

    `svn switch`时如有遇到如此提示,删掉这个`waymeet`文件重新执行原先的`svn switch`

    ```
    svn st -q 时列出来一坨S状态的文件
    ```

    如果`svn switch`被中断会出现这种情况。

    恢复: `svn info bad_file` 查看某个S状态的文件所在的分支,然后`svn switch`到这个分支。

    ### git-svn

    建svn分支:
  3. flaneur2020 revised this gist Nov 21, 2012. No changes.
  4. flaneur2020 revised this gist Nov 21, 2012. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -48,7 +48,17 @@ svn提供了比git更为精细的权限控制,按照目录为单位。

    Troubleshoots:

    + `Working copy locked`: `cd .svn; rm lock`
    ```
    Working copy locked
    ```

    `cd .svn; rm lock`

    ```
    svn: E160013: '/svn/shire/!svn/bc/135926/branches/miaomia/meow' path not found
    ```

    先检查下哪里拼错了。

    ### git-svn

  5. flaneur2020 revised this gist Nov 21, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ crontab并没有直接向用户暴露配置文件的位置,是因为crontab这

    svn提供了比git更为精细的权限控制,按照目录为单位。

    + checkout: `svn co http://svn.miaomiao.com/svn/trunk HEAD`
    + checkout: `svn co http://svn.miaomiao.com/svn/trunk -r HEAD`
    + 创建自己的分支目录:`svn mkdir http://svn.foo.com/svn/branches/fleuria`
    + 创建特性分支:`svn cp http://svn.foo.com/svn/trunk http://svn.foo.com/svn/branches/fleuria/issue1`
    + 切换分支:`svn switch http://svn.foo.com/svn/branches/fleuria/issue1`
  6. flaneur2020 revised this gist Nov 21, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -34,6 +34,7 @@ crontab并没有直接向用户暴露配置文件的位置,是因为crontab这

    svn提供了比git更为精细的权限控制,按照目录为单位。

    + checkout: `svn co http://svn.miaomiao.com/svn/trunk HEAD`
    + 创建自己的分支目录:`svn mkdir http://svn.foo.com/svn/branches/fleuria`
    + 创建特性分支:`svn cp http://svn.foo.com/svn/trunk http://svn.foo.com/svn/branches/fleuria/issue1`
    + 切换分支:`svn switch http://svn.foo.com/svn/branches/fleuria/issue1`
  7. flaneur2020 revised this gist Nov 16, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -43,6 +43,7 @@ svn提供了比git更为精细的权限控制,按照目录为单位。
    + 获取分支的第一个revision: `svn log -v --stop-on-copy`
    + 当前修改: `svn st -q`
    + revert当前的所有修改: ``svn revert `svn st -q` ``
    + merge合并过trunk的分支时记得加上: `--reintergrate`

    Troubleshoots:

  8. flaneur2020 revised this gist Nov 16, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -42,7 +42,7 @@ svn提供了比git更为精细的权限控制,按照目录为单位。
    + merge需要先得到revision的范围: `svn log /branches/feature_233 --stop-on-copy; svn merge /branches/feature_233 -r 999:1000`
    + 获取分支的第一个revision: `svn log -v --stop-on-copy`
    + 当前修改: `svn st -q`
    + revert当前的所有修改: `svn revert `svn st -q` `
    + revert当前的所有修改: ``svn revert `svn st -q` ``

    Troubleshoots:

  9. flaneur2020 revised this gist Nov 16, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -42,7 +42,7 @@ svn提供了比git更为精细的权限控制,按照目录为单位。
    + merge需要先得到revision的范围: `svn log /branches/feature_233 --stop-on-copy; svn merge /branches/feature_233 -r 999:1000`
    + 获取分支的第一个revision: `svn log -v --stop-on-copy`
    + 当前修改: `svn st -q`
    + revert当前的所有修改: `svn revert \`svn st -q\``
    + revert当前的所有修改: `svn revert `svn st -q` `

    Troubleshoots:

  10. flaneur2020 revised this gist Nov 16, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -41,6 +41,8 @@ svn提供了比git更为精细的权限控制,按照目录为单位。
    + 撤销当前的所有更改: `svn revert -R .`
    + merge需要先得到revision的范围: `svn log /branches/feature_233 --stop-on-copy; svn merge /branches/feature_233 -r 999:1000`
    + 获取分支的第一个revision: `svn log -v --stop-on-copy`
    + 当前修改: `svn st -q`
    + revert当前的所有修改: `svn revert \`svn st -q\``

    Troubleshoots:

  11. flaneur2020 revised this gist Nov 13, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -40,6 +40,7 @@ svn提供了比git更为精细的权限控制,按照目录为单位。
    + 不像git有暂存区,svn在提交时只能将需要提交的文件列在命令里: `svn commit -m 'commit message' file1.c file2.c`
    + 撤销当前的所有更改: `svn revert -R .`
    + merge需要先得到revision的范围: `svn log /branches/feature_233 --stop-on-copy; svn merge /branches/feature_233 -r 999:1000`
    + 获取分支的第一个revision: `svn log -v --stop-on-copy`

    Troubleshoots:

  12. flaneur2020 revised this gist Oct 31, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@

    + 后台进程并不等于它是长期执行的进程,在用户注销时,可能照样会收到sighup。

    解决方法是使用tmux或者nohup
    解决方法是使用tmux或者`nohup`

    + 列出后台任务:`jobs`

  13. flaneur2020 revised this gist Oct 31, 2012. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,18 @@

    + 列出后台任务:`jobs`

    ### crontab

    crontab并没有直接向用户暴露配置文件的位置,是因为crontab这种比较敏感的脚本,是不能容忍语法错误的。`crontab -e`保存之后,就相当于经过了一层语法检验。编辑crontab:

    crontab -e

    格式:`minute hour day_in_month month day_in_week program`

    比如:

    + 每天凌晨1点执行:`0 1 * * * blah`

    ### svn

    svn提供了比git更为精细的权限控制,按照目录为单位。
  14. flaneur2020 revised this gist Oct 30, 2012. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -46,4 +46,8 @@ git svn dcommit

    + Q: Could not unmemoize function `lookup_svn_merge', because it was not memoized to begin with at /usr/local/Cellar/git/1.7.6/libexec/git-core/git-svn line 3226

    A: rm -rf .git/svn/.caches
    A: `rm -rf .git/svn/.caches`

    + Q: Multiple branch paths defined for Subversion repository. You must specify where you want to create the branch with the --destination argument.

    A: 修改.git/config,添加: `branches = branches/liyazhou/*:refs/remotes/*``[svn-remote "svn"]`下。
  15. flaneur2020 revised this gist Oct 30, 2012. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -35,6 +35,15 @@ Troubleshoots:

    ### git-svn

    建svn分支:

    ```
    git svn branch foo
    git checkout -b foo -t remotes/foo
    git commit
    git svn dcommit
    ```

    + Q: Could not unmemoize function `lookup_svn_merge', because it was not memoized to begin with at /usr/local/Cellar/git/1.7.6/libexec/git-core/git-svn line 3226

    A: rm -rf .git/svn/.caches
  16. flaneur2020 revised this gist Oct 30, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,8 @@

    + `sudo -u fleuria bash`: 切换用户

    + `xxxdump | vim -`: 将stdout的输出重定向给vim

    ### 后台任务

    + 后台进程并不等于它是长期执行的进程,在用户注销时,可能照样会收到sighup。
  17. flaneur2020 revised this gist Oct 26, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -25,6 +25,7 @@ svn提供了比git更为精细的权限控制,按照目录为单位。
    + 切换分支:`svn switch http://svn.foo.com/svn/branches/fleuria/issue1`
    + 不像git有暂存区,svn在提交时只能将需要提交的文件列在命令里: `svn commit -m 'commit message' file1.c file2.c`
    + 撤销当前的所有更改: `svn revert -R .`
    + merge需要先得到revision的范围: `svn log /branches/feature_233 --stop-on-copy; svn merge /branches/feature_233 -r 999:1000`

    Troubleshoots:

  18. flaneur2020 revised this gist Oct 26, 2012. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -26,8 +26,12 @@ svn提供了比git更为精细的权限控制,按照目录为单位。
    + 不像git有暂存区,svn在提交时只能将需要提交的文件列在命令里: `svn commit -m 'commit message' file1.c file2.c`
    + 撤销当前的所有更改: `svn revert -R .`

    Troubleshoots:

    + `Working copy locked`: `cd .svn; rm lock`

    ### git-svn

    + Q: Could not unmemoize function `lookup_svn_merge', because it was not memoized to begin with at /usr/local/Cellar/git/1.7.6/libexec/git-core/git-svn line 3226

    A: rm -rf .git/svn/.caches
    A: rm -rf .git/svn/.caches
  19. flaneur2020 revised this gist Oct 25, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,8 @@

    + ``sshfs yourname@host:/path/to/your/dir ~/local`` sshfs挂载到本地

    + `sudo -u fleuria bash`: 切换用户

    ### 后台任务

    + 后台进程并不等于它是长期执行的进程,在用户注销时,可能照样会收到sighup。
  20. flaneur2020 revised this gist Oct 25, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -27,4 +27,5 @@ svn提供了比git更为精细的权限控制,按照目录为单位。
    ### git-svn

    + Q: Could not unmemoize function `lookup_svn_merge', because it was not memoized to begin with at /usr/local/Cellar/git/1.7.6/libexec/git-core/git-svn line 3226

    A: rm -rf .git/svn/.caches
  21. flaneur2020 revised this gist Oct 25, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -26,5 +26,5 @@ svn提供了比git更为精细的权限控制,按照目录为单位。

    ### git-svn

    + Q: `Could not unmemoize function `lookup_svn_merge', because it was not memoized to begin with at /usr/local/Cellar/git/1.7.6/libexec/git-core/git-svn line 3226`
    + Q: Could not unmemoize function `lookup_svn_merge', because it was not memoized to begin with at /usr/local/Cellar/git/1.7.6/libexec/git-core/git-svn line 3226
    A: rm -rf .git/svn/.caches
  22. flaneur2020 revised this gist Oct 25, 2012. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -22,4 +22,9 @@ svn提供了比git更为精细的权限控制,按照目录为单位。
    + 创建特性分支:`svn cp http://svn.foo.com/svn/trunk http://svn.foo.com/svn/branches/fleuria/issue1`
    + 切换分支:`svn switch http://svn.foo.com/svn/branches/fleuria/issue1`
    + 不像git有暂存区,svn在提交时只能将需要提交的文件列在命令里: `svn commit -m 'commit message' file1.c file2.c`
    + 撤销当前的所有更改: `svn revert -R .`
    + 撤销当前的所有更改: `svn revert -R .`

    ### git-svn

    + Q: `Could not unmemoize function `lookup_svn_merge', because it was not memoized to begin with at /usr/local/Cellar/git/1.7.6/libexec/git-core/git-svn line 3226`
    A: rm -rf .git/svn/.caches
  23. flaneur2020 revised this gist Oct 25, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -21,4 +21,5 @@ svn提供了比git更为精细的权限控制,按照目录为单位。
    + 创建自己的分支目录:`svn mkdir http://svn.foo.com/svn/branches/fleuria`
    + 创建特性分支:`svn cp http://svn.foo.com/svn/trunk http://svn.foo.com/svn/branches/fleuria/issue1`
    + 切换分支:`svn switch http://svn.foo.com/svn/branches/fleuria/issue1`
    + 不像git有暂存区,svn在提交时只能将需要提交的文件列在命令里: `svn commit -m 'commit message' file1.c file2.c`
    + 不像git有暂存区,svn在提交时只能将需要提交的文件列在命令里: `svn commit -m 'commit message' file1.c file2.c`
    + 撤销当前的所有更改: `svn revert -R .`
  24. flaneur2020 revised this gist Oct 25, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -20,4 +20,5 @@ svn提供了比git更为精细的权限控制,按照目录为单位。

    + 创建自己的分支目录:`svn mkdir http://svn.foo.com/svn/branches/fleuria`
    + 创建特性分支:`svn cp http://svn.foo.com/svn/trunk http://svn.foo.com/svn/branches/fleuria/issue1`
    + 切换分支:`svn switch http://svn.foo.com/svn/branches/fleuria/issue1`
    + 不像git有暂存区,svn在提交时只能将需要提交的文件列在命令里: `svn commit -m 'commit message' file1.c file2.c`
  25. flaneur2020 revised this gist Oct 25, 2012. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -12,4 +12,12 @@

    解决方法是使用tmux或者nohup

    + 列出后台任务:`jobs`
    + 列出后台任务:`jobs`

    ### svn

    svn提供了比git更为精细的权限控制,按照目录为单位。

    + 创建自己的分支目录:`svn mkdir http://svn.foo.com/svn/branches/fleuria`
    + 创建特性分支:`svn cp http://svn.foo.com/svn/trunk http://svn.foo.com/svn/branches/fleuria/issue1`
    + 不像git有暂存区,svn在提交时只能将需要提交的文件列在命令里: `svn commit -m 'commit message' file1.c file2.c`
  26. flaneur2020 revised this gist Oct 23, 2012. No changes.
  27. flaneur2020 revised this gist Oct 23, 2012. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -4,4 +4,12 @@

    + `` sudo shutdown -r now`` 重启机器

    + ``sshfs yourname@host:/path/to/your/dir ~/local`` sshfs挂载到本地
    + ``sshfs yourname@host:/path/to/your/dir ~/local`` sshfs挂载到本地

    ### 后台任务

    + 后台进程并不等于它是长期执行的进程,在用户注销时,可能照样会收到sighup。

    解决方法是使用tmux或者nohup

    + 列出后台任务:`jobs`
  28. flaneur2020 revised this gist Sep 21, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -4,4 +4,4 @@

    + `` sudo shutdown -r now`` 重启机器

    + ``sshfs yourname@remote-host:/path/to/your/dir ~/home-server`` sshfs挂载到本地
    + ``sshfs yourname@host:/path/to/your/dir ~/local`` sshfs挂载到本地
  29. flaneur2020 revised this gist Sep 21, 2012. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,6 @@

    + ``grep processor /proc/cpu_info`` 显示当前的CPU数目

    + `` sudo shutdown -r now`` 重启机器
    + `` sudo shutdown -r now`` 重启机器

    + ``sshfs yourname@remote-host:/path/to/your/dir ~/home-server`` sshfs挂载到本地
  30. flaneur2020 revised this gist Feb 21, 2012. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion shell_tips.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    + ``gcc -M hello.c`` 可以得到某文件依赖的头文件。

    + ``grep processor /proc/cpu_info`` 显示当前的CPU数目
    + ``grep processor /proc/cpu_info`` 显示当前的CPU数目

    + `` sudo shutdown -r now`` 重启机器