manywaypark's Blog
개발, 검색, 함수

gitignore

tips & tricks 2017. 3. 22. 20:56 by manywaypark

git을 사용할 때 .gitignore 파일을 제대로 만들어놓지 않으면 git repository가 지저분해진다.

REST API를 통해 간단히 만들 수 있는 방법이 있다고 알려주는 페이지가 있는데, 오늘(2017-03-22) 기준으로 응답이 제대로 오지 않았다.

https://www.lesstif.com/pages/viewpage.action?pageId=18220154

직접 접속해서 해보니 되는데, 위의 링크에서 http를 https로만 바꾸면 제대로 동작한다.

직접 여기(https://github.com/joeblau/gitignore.io)를 보았으면 한번에 잘되었겠다.

물론 전통의 https://github.com/github/gitignore 를 보는 것이 더 좋을 수도 있겠다.


간단히 mac과 linux에서의 global gitignore 설정을 해보자 (bash 환경기준. 다른 환경은 상기 링크 참조)

mac:

$ echo "function gi() { curl -L -s https://www.gitignore.io/api/\$@ ;}" >> ~/.bash_profile && source ~/.bash_profile

$ gi osx,emacs > ~/.gitignore_global

$ git config --global core.excludesfile ~/.gitignore_global


linux:

$ echo "function gi() { curl -L -s https://www.gitignore.io/api/\$@ ;}" >> ~/.bashrc && source ~/.bashrc

$ gi linux,emacs > ~/.gitignore_global 

$ git config --global core.excludesfile ~/.gitignore_global

gi list를 하면 모든 지원되는 항목을 볼 수 있다.


happy hackin'

일단 레드마인 박스에 루트 권한으로 적당한 곳에 소스를 저장할 디렉토리를 만든다.

(현재 내가 알기로 git은 간단히 remote url 입력해서 해결 되지는 않는다)

$ sudo -i

# mkdir /var/src-repos

# mkdir /var/src-repos/[redmine-prj-name]     # 여러 개의 project가 아니라면 이 단계는 생략

# cd $_

# git clone --mirror [url-of-git-repo] [local-dir-name]


이제는 redmine의 프로젝트 설정에서 (Settings > Repositories) +New repository를 선택해서 local directory를 repositiory로 추가한다.

SCM: Git

Identifier: what-ever-you-want

URL: /var/src-repos/[redmine-prj-name]/[local-dir-name]

프로젝트의 repository 에 가보면 추가된 것을 확인 할 수 있다.

여기서 끝이면 좋겠지만, 자동 업데이트 따위가 지원되지 않는다. Orz.


루트로 아래와 같은 파일을 하나 만들어서 crontab에 등록해 적당한 주기로 sync 시키면 해결된다.

#!/bin/bash


REPOS=`ls -d /var/src-repos/*/*`        # 다중 프로젝트 아니면 */* -> *


for repo in $REPOS

do

    cd $repo

    git remote update

done


내 경우 ~/bin/sync-src-repos.sh로 저장했고 crontab -e 하면 다음과 같이 나온다.
......
*/30 * * * * /root/bin/sync-src-repos.sh

......


happy hackin'


framewerk(오타 아님)는 일종의 autotools wrapper이다.

c/c++은 물론이고 javascript와 erlang도 지원하는 점이 맘에든다.

사용법은 참조링크에 쉽고 자세하게 나온다.

간단한 예제를 하나 들자면 erlang project에서 rebar 및 git을 사용할 경우 다음과 같이 한다.

$ fw-init --name myprj --template erlang-rebar --revision git

$ cd myprj

$ ./bootstrap

$ ./configure

$ make

지원되는 버전 관리 도구(revision에서 설정): git, svn, cvs

지원되는 개발 환경(template에서 설정): c, c++, erlang, erlang-rebar, java-mvn


refs: https://code.google.com/p/fwtemplates/


2014-11-11 추가: project configuration(version number 설정 등)은 fw-pkgin/config 파일을 편집한다.


2016-06-07 추가: 원래 프로젝트 페이지는 관리 안된지 좀 오래 인듯. 비교적 최근까지 관리되는 곳은 여기: https://github.com/dukesoferl/fw

또한 빌드 및 사용 법은, ./bootstrap -> ./build (--prefix=/usr/local) -> sudo make install 로 하면 좀더 간편하다.


happy hackin'

[git] gitolite admin public key 교체.

tips & tricks 2013. 12. 23. 16:51 by manywaypark

완전 똑같은 문제에 대한 참조가 있었다.

핵심은 그냥 설치된 머신에서 gitolite user(보통 git)로 변신(su)한 후에 clone한 후에 push하는 것인데 후처리가 필요하므로 gl-admin-push를 쓰는 것이다.

su git

cd /tmp && git clone /path/to/gitolite-admin.git

# keydir 내의 admin.pub key 교체

~/.gitolite/src/gl-admin-push # apt package manager를 써서 설치한 경우는 /usr/share/gitolite/gl-admin-push


ref: http://stackoverflow.com/questions/7033991/gitolite-access-repair


happy hackin'


2017-09-15 추가: gitolite 최신 버전은 여기 참조 http://gitolite.com/gitolite/emergencies/index.html

git submodule foreach

tips & tricks 2013. 11. 21. 23:29 by manywaypark

git에서 모든 submodule에대해 무언가 작업을하고 싶다면 foreach를 활용하면 간단히 해결된다.

모든 서브모듈들을 pull하고 싶다면 아래와 같이 하면 된다.

git submodule foreach git pull origin master


ref: http://stackoverflow.com/questions/1030169/easy-way-pull-latest-of-all-submodules


happy hackin'

git/gitolite - remote branch 삭제하기

tips & tricks 2013. 11. 19. 13:59 by manywaypark

gitolite 관리자 권한으로,

git branch -d -r origin/branch-name

git push origin :branch-name # =:= git push origin --delete branch-name


refs: 

http://www.markhneedham.com/blog/2011/06/28/git-deleting-a-remote-branch-on-a-gitolite-configured-repository/

http://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-both-locally-and-remote


happy hackin'

svn rep를 git의 submodule로 쓰기

tips & tricks 2013. 11. 17. 00:22 by manywaypark

git의 submodule로 svn 저장소를 쓸 수 있을까?

갑자기 궁금해져서 검색해봤다.

결론은  "쓸 수 없다"이다.


하지만 이전글에서도 잠시 언급했듯이, svn repo를 git repo로 변경후에 submodule로 지정하면 동일한 효과를 볼 수 있다.


ref: http://stackoverflow.com/questions/465042/is-it-possible-to-have-a-subversion-repository-as-a-git-submodule


happy hackin'



github 사용하기

tips & tricks 2013. 5. 11. 09:10 by manywaypark

자주 쓰지 않아서 그런지 매번 쓸 때마다 구글링하곤 했었는데, 우연히 잘 정리된 페이지를 만났다.

요지는 내 repo로 fork한 다음 clone하고, 원저자의 repo를 remote add upstream으로 추가해서 관리하는 것이다.

ref: https://github.com/ginatrapani/todo.txt-cli/wiki/developer-documentation


happy hackin'

새 윈도우 박스에 cygwin을 깔고 github에서 소스를 받으려고 했는데 에러가 났다.

인증서는 제대로 등록되어있는 상태.

문제:

$ git clone https://github.com/foo/bar.git

Cloning into 'bar'...

error: error setting certificate verify locations:

  CAfile: /usr/ssl/certs/ca-bundle.crt

  CApath: none while accessing https://github.com/namjae/rebar.git/info/refs

fatal: HTTP request failed


해결:

아래 참고 페이지에 보면 여러 해결 방법이 있으나, 그 중에 ca-certificates 패키지를 설치하는 방법이 제일 간단하다 (내경우 잘 해결되었다는 말)



ref:

http://stackoverflow.com/questions/3777075/ssl-certificate-rejected-trying-to-access-github-over-https-behind-firewall


happy hackin'

svn에서 git으로 옮겨타기

tips & tricks 2013. 4. 5. 23:44 by manywaypark

svn에서 git으로 소스트리 옮기기.

git-svn 설치 후 git remote add 후 push!

예를 들어 google code의 svn repo에서 github로 옮긴다면 다음과 같이 한다.

참고로 모든 변경 내역이 유지된다.

git svn clone http://[yourproject].googlecode.com/svn/trunk/path/to/code/

git remote add origin git@github.com:[youraccount]/[yourrepository].git

git push origin master


ref: http://bassistance.de/2009/08/20/getting-started-with-git-and-github-and-importing-from-subversion/


happy hackin'

1 2 
분류 전체보기 (306)
잡담 (20)
함수형 언어 (65)
emacs (16)
java (18)
tips & tricks (154)
사랑 (1)
가사 (0)
독서 (4)
mobile (6)
비함수형 언어 (2)

공지사항

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

04-25 13:05