Windows平台Sublime Text编辑远程Linux平台上的文件


Sublime Text是个跨平台的强大的代码编辑工具,不多说。
想使用Sublime Text完成linux平台下django站点的代码编辑工作以提高效率(原来使用linux下的vim效率较低,适合编辑一些小脚本)。

下载linux平台下的Sublime_Text_2.0.2_x64.tar.bz2(http://www.sublimetext.com/)

解压使用:
tar -xjvf Sublime_Text_2.0.2_x64.tar.bz2
cd Sublime\ Text\ 2/

执行
./sublime_text

报错
./sublime_text: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by ./sublime_text)
./sublime_text: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by ./sublime_text)
./sublime_text: /lib64/libc.so.6: version `GLIBC_2.11' not found (required by ./sublime_text)

原因是所使用的系统为CentOS5,版本过低,c/c++库版本过低。
公司的电脑不能随便升级库或者升级系统,只能另想办法。

 

中文输入的问题是参考的这篇文章:

Ubuntu 12.10 安装破解Sublime Text 2

Ubuntu 13.04安装Sublime Text 2

编码神器——Sublime Text 包管理工具及扩展大全

如何开发 Sublime Text 2 的插件

Windows Mac Linux下安装以及破解Sublime Text 2编辑器

文本编辑器Sublime Text 使用体验


设想一:
linux服务器上的代码拉下来存放在windows机器上,使用windows平台上的sublime对其进行编辑,之后重新上传到linux服务器中。

问题:代码编辑后通常需要实际运行调试,尤其是站点类型的代码,常常需要编辑好后立刻验证一下显示结果。而我们的整个运行环境是搭建在linux平台下的,如此一来,便需要先将代码从linux服务器拉倒windows平台,改动一个地方后重新传回linux服务器,测试运行,若有问题则重新拉下来编辑,重新上传、测试,如此下去,非常繁琐耗时。有没有一种更好的办法?

设想二:
在linux服务器上使用git为代码建立仓库,在windows上clone该仓库,使用sublime对clone下来的仓库中的代码进行编辑,编辑完成后一条push命令将所有提交的更新内容推到远程的代码仓库中进行测试。过程与设想一类似,改进之处在于使用git命令来向远程linux服务器推更新,而不是手工逐个将更新的文件上传到远程服务器。

不知道有没有问题,先试试看:
之前已经在linux服务器上创建了代码仓库,位置为
/var/www/site/mycitsm
直接使用 /var/www/site/mycitsm目录下的.git目录创建供其他机器clone的代码仓库
sudo git remote add origin ssh://username@IP:PORT/var/www/site/mycitsm/.git

之后远程机器就可以使用
git clone ssh://username@IP:PORT/var/www/site/mycitsm/.git d:/www/mycitsm
该命令将远程服务器上的代码仓库拉倒本地d:/www/mycits目录中

我们在windows平台上下载安装Git-1.9.2(http://git-scm.com/download/win)或者第三方的gitHub等等
clone仓库:
进入git bash(安装Git后创建的命令行工具)
$git clone ssh://username@IP:PORT/var/www/site/mycitsm/.git d:/www/mycitsm
可能提示让输入远程服务器上op1的密码,(如果将本地服务器的公钥写进了远程服务器的authorized_keys文件则无需密码即可。具体可参考如何设置无密码SSH至远程主机,Windows系统与linux系统之间与linux系统与linux系统之间的设置方法是相同的。)
也可能提示找不到git-upload-pack,这是因为远程服务器中git安装的位置不是标准的默认位置,只需要将这些工具复制到标准的位置,或在标准位置设置软连接连接至这些工具即可,也可以在clone命令中指定工具的位置如: --upload-pack /home/op1/bin/git-upload-pack。

此后远程仓库中的目录结构和内容被clone到了本地windows服务器的d:/www/mycitsm目录中了,可以使用sublime直接打开该目录对内部的文件进行编辑。

在git bash中进入本地仓库
$cd d://www/mycitsm

查看git状态
$git status

提交变化
$git add filename
$git commit -m "some text"

将本地仓库推到远程仓库
$git push (origin master)

报错:
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To ssh://op1@192.168.83.36:1022/var/www/site/mycitsm/.git
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'ssh://op1@192.168.83.36:1022/var/www/site/my
citsm/.git'

意思为:默认情况下不允许在非裸仓库中更新当前分支,因为推送的内容会导致索引和工作目录树不一致。
尽管可以通过通过将git配置文件中'receive.denyCurrentBranch'变量值设置为ignore或warn来允许推送至当前分支,但非常不推荐这么做,除非你安排更新工作目录树来匹配你推送的内容。

既然如此,那我们设置一个罗仓库会怎么样呢?
来到linux服务器的/var/www/site/目录
创建裸仓库(具体参考http://git-scm.com/book/zh):
$ git clone --bare mycitsm mycitsm.git
该命令实际上相当于
$ cp -Rf mycitsm/.git mycitsm.git

之后把该罗仓库移动至你期望的位置即可。
$sudo git remote add origin ssh://username@IP:PORT/var/www/site/mycitsm.git
$git clone ssh://username@IP:PORT/var/www/site/mycitsm.git d:/www/mycitsm

用sublime编辑,本地提交,推送至远程仓库。没有看到异常。
那,是否意味着我们可以在远程的仓库中测试了呢?

连到linux服务器进入/var/www/site/mycitsm/目录发现里边的文件并没有发生任何变化。哦对,我们是将更新推送到了linux服务器上的裸仓库mycitsm.git中。
进入mycitsm.git,恩并没有工作目录树(这也是罗仓库之所以叫裸仓库的原因),它只记录了提交历史信息。

费了好大劲,也就是说我们并不能通过这种方式来将本地最新内容同步到linux原始仓库中,只能将变化信息同步到相关的裸仓库中,而我们又不能在裸仓库中获取到可以进行测试的目录文件。

且上述两种方案都有一个问题,那就是linux服务器中的文件变化不能主动直接的反馈到windows端,我们必须重新拉回最新的文件才能看到这种变化。

更多详情见请继续阅读下一页的精彩内容:

  • 1
  • 2
  • 下一页

相关内容