이클립스와 Git 연동하여 사용하기
http://itmir.tistory.com/461
nodejs 시작하기-이클립스
http://ourcstory.tistory.com/36
2015년 11월 18일 수요일
[git] GitHub Remote(원격) 저장소에 브랜치 생성/삭제하기
원격저장소로 GitHub을 이용하고 있고, Branch를 만들고 삭제하는 방법에 대해서 알아보자.
1) 브랜치 생성, 삭제 순서
- local 저장소에 branch를 만든다
- remote 저장소로 branch를 push 하여 추적(tracking) 한다
- 사용하지 않는 branch는 삭제한다
////////////////////////////////////////////////
// 새로운 브랜치를 생성하고 checkout 한다
$ git checkout -b shopping_cart
Switched to a new branch 'shopping_cart'
////////////////////////////////////////////////
// 원격 저장소로 브랜치를 push 한다
$ git push origin shopping_cart
Username for 'https://github.com':
Password for 'https://ysyun@yuwin.co.kr@github.com':
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/ysyun/pro_git.git
* [new branch] shopping_cart -> shopping_cart
// github에 새로운 브랜치가 추가 되었다.
///////////////////////////////////////////////
// 새로운 파일을 추가하고 원격으로 push 한다
$ touch cart.js
$ git add cart.js
$ git commit -m "add cart javascript file"
[shopping_cart 4856f8d] add cart javascript file
0 files changed
create mode 100644 cart.js
$ git push
Username for 'https://github.com':
Password for 'https://ysyun@yuwin.co.kr@github.com':
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 245 bytes, done.
Total 2 (delta 1), reused 0 (delta 0)
To https://github.com/ysyun/pro_git.git
f42a865..4856f8d shopping_cart -> shopping_cart
///////////////////////////////////////////////
// 로컬 브랜치 내역 과 원격 브랜치 내역을 본다
$ git branch
master
* shopping_cart
$ git branch -r
origin/HEAD -> origin/master
origin/master
origin/shopping_cart
////////////////////////////////////////////////////
// 로컬의 새로 추가한 shopping_cart 브랜치를 삭제한다
$ git checkout master
Switched to branch 'master'
$ git branch -d shopping_cart
error: The branch 'shopping_cart' is not fully merged.
If you are sure you want to delete it, run 'git branch -D shopping_cart'.
$ git branch -D shopping_cart
Deleted branch shopping_cart (was 4856f8d).
$ git branch
* master
///////////////////////////////////////////////
// 로컬에 이제 shopping_cart 브랜치가 없다 다시 복구 하고 싶다면
// 원격 저장소를 통하여 checkout 하면 된다
$ git checkout shopping_cart
Branch shopping_cart set up to track remote branch shopping_cart from origin.
Switched to a new branch 'shopping_cart'
$ git branch
master
* shopping_cart
///////////////////////////////////////////////
// 원격의 브랜치 내역을 보자
// 어떤 브랜치들이 존재하는지 한눈에 알 수 있다
$ git remote show origin
* remote origin
Fetch URL: https://github.com/ysyun/pro_git.git
Push URL: https://github.com/ysyun/pro_git.git
HEAD branch: master
Remote branches:
master tracked
shopping_cart tracked
Local branches configured for 'git pull':
master merges with remote master
shopping_cart merges with remote shopping_cart
Local refs configured for 'git push':
master pushes to master (up to date)
shopping_cart pushes to shopping_cart (up to date)
///////////////////////////////////////////////
// 원격에 있는 브랜치를 삭제 하자
$ git push origin :shopping_cart
Username for 'https://github.com':
Password for 'https://ysyun@yuwin.co.kr@github.com':
To https://github.com/ysyun/pro_git.git
- [deleted] shopping_cart
// shopping_cart 브랜치가 삭제되었음을 알 수 있다
$ git remote show origin
* remote origin
Fetch URL: https://github.com/ysyun/pro_git.git
Push URL: https://github.com/ysyun/pro_git.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
///////////////////////////////////////////////
// remote 브랜치 clean up 하기
$ git remote prune origin
UserXP@NUKNALEA /d/Git_repositories/pro_git (master)
$ git remote show origin
* remote origin
Fetch URL: https://github.com/ysyun/pro_git.git
Push URL: https://github.com/ysyun/pro_git.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
2) master가 아닌 local 브랜치를 remote 저장소의 master 브랜치에 push 하기
- 조건 : local 저장소의 브랜치가 master가 아닌 다른 브랜치로 checkout 되어 있을 경우 예) shopping_cart
- 명령 : git push [원격저장소 주소 alias] [로컬저장소명칭]:master
- 예 : git push origin shopping_cart:master
- 의미 : origin 원격 주소의 master 브랜치에 local저장소의 shopping_cart 브랜치를 push 한다
[git]이미 리모트로 push된 마지막 커밋을 삭제하고싶을경우
수정해서 푸시한 커밋에 문제가 있을경우 이를 돌려놓고 싶을 경우가 있다. 단, 푸시된 커밋을 다른 유저가 이미 받아갔을경우에는 소스가 꼬이게되므로 리모트 저장소에있는 마지막 커밋을 아무도 받아가지 않은 경우에만 가능하다.
로컬에서 먼저 마지막 커밋을 리셋한 후에
git reset --hard HEAD^
force push 옵션을 줘서 강제로 리모트저장소로 푸시해버리면 된다.
git push -f
2015년 11월 16일 월요일
GIT push: permission denied (public key) 해결
Git 서버들은 SSH public key 방식으로 인증을 합니다.
이 SSH public key 를 생성하는 방법에 대해 알아보겠습니다.
- public key 위치
$ cd ~/.ssh/ $ ls id_rsa id_rsa.pub known_hosts $
이중 id_rsa 와 id_rsa.pub 이 key 파일들인데, id_rsa 는 개인 키 파일이고, id_rsa.pub 가 공개키 파일입니다.
만약 없다면 생성할 수 있습니다.
- public key 생성
$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/woong/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/woong/.ssh/id_rsa. Your public key has been saved in /home/woong/.ssh/id_rsa.pub. The key fingerprint is: 7c:44:b1:25:4c:94:b4:31:6c:63:3d:a2:cf:d6:b1:6c woong@idea The key's randomart image is: +--[ RSA 2048]----+ | *X+. | | .OBo | | ++o . | | ... . | | So.o o | | .+ E | | . . | | | | | +-----------------+ $ ls id_rsa id_rsa.pub known_hosts $
중간에 물어보는 부분은 그냥 Enter 로 넘어가도 괜찮습니다.
그리고 key 파일들이 생성된 것을 볼 수 있습니다.
이제 git 서버에 public key 를 넣어야 할 경우 id_rsa.pub 의 내용을 넣어주면 됩니다.
$ cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDV8QpLgV/fZu/D1IxgE/0vDcZjdAta6Jg0497u3FC2fX3aIntoUMB3hfNsJJ6VvR8m9s0ottjTifUmRP0nu7udDwuKoyjTiy98/F5L5AN8EFpIGsW8sTWBu3stTJG7wsOhv56XuhuY32eSjDCKr8nLP3T0ZVFAvkS3DGIhHuwNpDIIRxwUR6MlIwBPUBXGd1eeawIvW+RSLUX5rltf7+HxM9Jeq0d9bX9YyRemQyg4alC9vsM+FooLVcfL5dYRTn2yuJ9S1gyL7qwjMKW+W+p3wDpci/qt8upk99F7qG08nvnr18KJ1kZ6WTdWhOdyA+zv9x4gOADBr2JE+AM6qLSb woong@idea $
2015년 9월 21일 월요일
새 프로젝트 생성 및 git 등록
rails와 ruby의 설치가 이미 완료되어 있다는 가정하에
새로운 프로젝트를 다음과 같이 생성한다.
$ rails new 프로젝트명
프로젝트 생성 확인
$ rails s -b 0.0.0.0 -p3000
git 초기화 및 저장소 등록
$ git init
$ git config --global user.email "email계정"
$ git config --global user.name "홍길동"
$ git remote add origin https://계정명@git 패스
$ touch readme
$ git add .
$ git commit -m "최초 커밋"
$ git push -u origin master
$ git pull -u origin master
[참고]
$ git push -u origin --all # pushes up the repo and its refs for the first time
$ git push -u origin --tags # pushes up any tags
http://noritersand.tistory.com/189
jquery 자바스크립트 라이브러리 디폴트로 설정
$ rails new myproject -j prototype
mysql 디비글 사용하기
$ rails new myproject -d mysql -j prototype
새로운 프로젝트를 다음과 같이 생성한다.
$ rails new 프로젝트명
프로젝트 생성 확인
$ rails s -b 0.0.0.0 -p3000
git 초기화 및 저장소 등록
$ git init
$ git config --global user.email "email계정"
$ git config --global user.name "홍길동"
$ git remote add origin https://계정명@git 패스
$ touch readme
$ git add .
$ git push -u origin master
$ git pull -u origin master
[참고]
$ git push -u origin --all # pushes up the repo and its refs for the first time
$ git push -u origin --tags # pushes up any tags
http://noritersand.tistory.com/189
jquery 자바스크립트 라이브러리 디폴트로 설정
$ rails new myproject -j prototype
mysql 디비글 사용하기
$ rails new myproject -d mysql -j prototype
피드 구독하기:
글 (Atom)