2016년 1월 5일 화요일

sublimetext에서 git 연동하기

Sublime text에서 git 을 연동하기 위해서는 아래 사항들이 준비되어 있어야 한다.


  • git repository 준비
  • sublime text 설치
  • sublime text: Package control 설치
  • sublime text: git plug-in 설치


1. git repository 준비

Sublime text와 연동을 하기 위해서, 당연히 git 저장소가 필요하다. 다양한 방법이 있겠지만, 크게 외부 서비스를 활용하는 방법과 자체 저장소를 유지하는 방법이 있다. 외부 서비스를 사용할 때는 github이나 bitbucket, gitlab 등의 서비스가 있고, 자체 git저장소를 구성하기 위한 방법으로는 gitolite를 통해 설치하는 방법이 있다.

  • github이나 bitbucket, gitlab 비교: http://www.slant.co/topics/153/compare/~github_vs_bitbucket_vs_gitlab
  • gitolite 설치: http://gitolite.com/gitolite/index.html

2. sublime text 설치

http://www.sublimetext.com/ 에서 다운로드 받아서 설치를 하도록 한다.
sublime text는 2와 3이 있는데, 성능이나 안정성, 한글 인코딩 문제 등에 차이가 있으니 확인 후 잘 선택해야 한다.

3. sublime text: Package control 설치

sublime text에 plug-in을 설치하는 방법은 여러가지가 있지만 package control을 설치하고 이를 통하는 것이 가장 편하다.
먼저 단축키 ctrl+` 을 입력하거나 메뉴에서 View > Show Console 을 선택해 console창을 띄운다.

다음으로 브라우저 창에 https://packagecontrol.io/installation를 입력해 package control 설치 가이드 사이트로 이동한다.
여기서 sublime text 3 와 sublime text 2 가 설치하는 방법이 갈리는데,
sublime text 3 의 경우, 아래와 같은 명령을 복사해 console 창에 입력하고
import urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

아래와 같이 하단 console바에 위 명령을 입력하면 아래와 같다.

엔터를 입력해 명령을 수행하면 package control이 설치된다.



sublime text 2는 아래와 같은 명령을 복사해 console 창에 입력한다.
import urllib2,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else None; print('Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'Please restart Sublime Text to finish installation')

4. sublime text: git plug-in 설치

Package Control을 설치하고 나면 Control-Shift-P(맥에서는 Command-Shoft-P)를 눌러 Command Pallette를 수행한 뒤 install을 입력하면 나오는 하단 메뉴 중 Package Control: Install Package를 클릭하면 아래와 같이 plug-in을 설치할 수 있는 창이 뜬다.

git 를 입력하면 나오는 plug-in들 중에서 Git 을 선택해 plug-in을 설치한다.

Control-Shift-P(맥에서는 Command-Shoft-P)를 눌러 Command Pallette를 수행한 뒤 git 를 입력하면 아래와 같이 git 관련 명령들이 추가된 것을 확인할 수 있다.




댓글 없음:

댓글 쓰기